incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmue...@apache.org
Subject [17/51] [partial] Apache-ization, port to node.js
Date Wed, 15 Feb 2012 17:42:37 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/InjectedFakeWorker.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/InjectedFakeWorker.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InjectedFakeWorker.js
new file mode 100644
index 0000000..7176844
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InjectedFakeWorker.js
@@ -0,0 +1,345 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+var InjectedFakeWorker = function(InjectedScriptHost, inspectedWindow, injectedScriptId)
+{
+
+Worker = function(url)
+{
+    var impl = new FakeWorker(this, url);
+    if (impl === null)
+        return null;
+
+    this.isFake = true;
+    this.postMessage = bind(impl.postMessage, impl);
+    this.terminate = bind(impl.terminate, impl);
+
+    function onmessageGetter()
+    {
+        return impl.channel.port1.onmessage;
+    }
+    function onmessageSetter(callback)
+    {
+        impl.channel.port1.onmessage = callback;
+    }
+    this.__defineGetter__("onmessage", onmessageGetter);
+    this.__defineSetter__("onmessage", onmessageSetter);
+    this.addEventListener = bind(impl.channel.port1.addEventListener, impl.channel.port1);
+    this.removeEventListener = bind(impl.channel.port1.removeEventListener, impl.channel.port1);
+    this.dispatchEvent = bind(impl.channel.port1.dispatchEvent, impl.channel.port1);
+}
+
+function FakeWorker(worker, url)
+{
+    var scriptURL = this._expandURLAndCheckOrigin(document.baseURI, location.href, url);
+
+    this._worker = worker;
+    this._id = InjectedScriptHost.nextWorkerId();
+    this.channel = new MessageChannel();
+    this._listeners = [];
+    this._buildWorker(scriptURL);
+
+    InjectedScriptHost.didCreateWorker(this._id, scriptURL.url, false);
+}
+
+FakeWorker.prototype = {
+    postMessage: function(msg, opt_ports)
+    {
+        if (this._frame != null)
+            this.channel.port1.postMessage.apply(this.channel.port1, arguments);
+        else if (this._pendingMessages)
+            this._pendingMessages.push(arguments)
+        else
+            this._pendingMessages = [ arguments ];
+    },
+
+    terminate: function()
+    {
+        InjectedScriptHost.didDestroyWorker(this._id);
+
+        this.channel.port1.close();
+        this.channel.port2.close();
+        if (this._frame != null)
+            this._frame.frameElement.parentNode.removeChild(this._frame.frameElement);
+        this._frame = null;
+        this._worker = null; // Break reference loop.
+    },
+
+    _buildWorker: function(url)
+    {
+        var code = this._loadScript(url.url);
+        var iframeElement = document.createElement("iframe");
+        iframeElement.style.display = "none";
+
+        this._document = document;
+        iframeElement.onload = bind(this._onWorkerFrameLoaded, this, iframeElement, url, code);
+
+        if (document.body)
+            this._attachWorkerFrameToDocument(iframeElement, url, code);
+        else
+            window.addEventListener("load", bind(this._attachWorkerFrameToDocument, this, iframeElement), false);
+    },
+
+    _attachWorkerFrameToDocument: function(iframeElement)
+    {
+        document.body.appendChild(iframeElement);
+    },
+
+    _onWorkerFrameLoaded: function(iframeElement, url, code)
+    {
+        var frame = iframeElement.contentWindow;
+        this._frame = frame;
+        this._setupWorkerContext(frame, url);
+
+        var frameContents = '(function() { var location = __devtools.location; var window; ' + code + '})();\n' + '//@ sourceURL=' + url.url;
+
+        frame.eval(frameContents);
+        if (this._pendingMessages) {
+            for (var msg = 0; msg < this._pendingMessages.length; ++msg)
+                this.postMessage.apply(this, this._pendingMessages[msg]);
+            delete this._pendingMessages;
+        }
+    },
+
+    _setupWorkerContext: function(workerFrame, url)
+    {
+        workerFrame.__devtools = {
+            handleException: bind(this._handleException, this),
+            location: url.mockLocation()
+        };
+
+        var self = this;
+
+        function onmessageGetter()
+        {
+            return self.channel.port2.onmessage ? self.channel.port2.onmessage.originalCallback : null;
+        }
+
+        function onmessageSetter(callback)
+        {
+            var wrappedCallback = bind(self._callbackWrapper, self, callback);
+            wrappedCallback.originalCallback = callback;
+            self.channel.port2.onmessage = wrappedCallback;
+        }
+
+        workerFrame.__defineGetter__("onmessage", onmessageGetter);
+        workerFrame.__defineSetter__("onmessage", onmessageSetter);
+        workerFrame.addEventListener = bind(this._addEventListener, this);
+        workerFrame.removeEventListener = bind(this._removeEventListener, this);
+        workerFrame.dispatchEvent = bind(this.channel.port2.dispatchEvent, this.channel.port2);
+        workerFrame.postMessage = bind(this.channel.port2.postMessage, this.channel.port2);
+        workerFrame.importScripts = bind(this._importScripts, this, workerFrame);
+        workerFrame.close = bind(this.terminate, this);
+    },
+
+    _addEventListener: function(type, callback, useCapture)
+    {
+        var wrappedCallback = bind(this._callbackWrapper, this, callback);
+        wrappedCallback.originalCallback = callback;
+        wrappedCallback.type = type;
+        wrappedCallback.useCapture = Boolean(useCapture);
+
+        this.channel.port2.addEventListener(type, wrappedCallback, useCapture);
+        this._listeners.push(wrappedCallback);
+    },
+
+    _removeEventListener: function(type, callback, useCapture)
+    {
+        var listeners = this._listeners;
+        for (var i = 0; i < listeners.length; ++i) {
+            if (listeners[i].originalCallback === callback &&
+                listeners[i].type === type && 
+                listeners[i].useCapture === Boolean(useCapture)) {
+                this.channel.port2.removeEventListener(type, listeners[i], useCapture);
+                listeners[i] = listeners[listeners.length - 1];
+                listeners.pop();
+                break;
+            }
+        }
+    },
+
+    _callbackWrapper: function(callback, msg)
+    {
+        // Shortcut -- if no exception handlers installed, avoid try/catch so as not to obscure line number.
+        if (!this._frame.onerror && !this._worker.onerror) {
+            callback(msg);
+            return;
+        }
+
+        try {
+            callback(msg);
+        } catch (e) {
+            this._handleException(e, this._frame.onerror, this._worker.onerror);
+        }
+    },
+
+    _handleException: function(e)
+    {
+        // NB: it should be an ErrorEvent, but creating it from script is not
+        // currently supported, so emulate it on top of plain vanilla Event.
+        var errorEvent = this._document.createEvent("Event");
+        errorEvent.initEvent("Event", false, false);
+        errorEvent.message = "Uncaught exception";
+
+        for (var i = 1; i < arguments.length; ++i) {
+            if (arguments[i] && arguments[i](errorEvent))
+                return;
+        }
+
+        throw e;
+    },
+
+    _importScripts: function(targetFrame)
+    {
+        for (var i = 1; i < arguments.length; ++i) {
+            var workerOrigin = targetFrame.__devtools.location.href;
+            var url = this._expandURLAndCheckOrigin(workerOrigin, workerOrigin, arguments[i]);
+            targetFrame.eval(this._loadScript(url.url) + "\n//@ sourceURL= " + url.url);
+        }
+    },
+
+    _loadScript: function(url)
+    {
+        var xhr = new XMLHttpRequest();
+        xhr.open("GET", url, false);
+        xhr.send(null);
+
+        var text = xhr.responseText;
+        if (xhr.status != 0 && xhr.status/100 !== 2) { // We're getting status === 0 when using file://.
+            console.error("Failed to load worker: " + url + "[" + xhr.status + "]");
+            text = ""; // We've got error message, not worker code.
+        }
+        return text;
+    },
+
+    _expandURLAndCheckOrigin: function(baseURL, origin, url)
+    {
+        var scriptURL = new URL(baseURL).completeWith(url);
+
+        if (!scriptURL.sameOrigin(origin))
+            throw new DOMCoreException("SECURITY_ERR",18);
+        return scriptURL;
+    }
+};
+
+function URL(url)
+{
+    this.url = url;
+    this.split();
+}
+
+URL.prototype = {
+    urlRegEx: (/^(http[s]?|file):\/\/([^\/:]*)(:[\d]+)?(?:(\/[^#?]*)(\?[^#]*)?(?:#(.*))?)?$/i),
+
+    split: function()
+    {
+        function emptyIfNull(str)
+        {
+            return str == null ? "" : str;
+        }
+        var parts = this.urlRegEx.exec(this.url);
+
+        this.schema = parts[1];
+        this.host = parts[2];
+        this.port = emptyIfNull(parts[3]);
+        this.path = emptyIfNull(parts[4]);
+        this.query = emptyIfNull(parts[5]);
+        this.fragment = emptyIfNull(parts[6]);
+    },
+
+    mockLocation: function()
+    {
+        var host = this.host.replace(/^[^@]*@/, "");
+
+        return {
+            href:     this.url,
+            protocol: this.schema + ":",
+            host:     host,
+            hostname: host,
+            port:     this.port,
+            pathname: this.path,
+            search:   this.query,
+            hash:     this.fragment
+        };
+    },
+
+    completeWith: function(url)
+    {
+        if (url === "" || /^[^/]*:/.exec(url)) // If given absolute url, return as is now.
+            return new URL(url);
+
+        var relParts = /^([^#?]*)(.*)$/.exec(url); // => [ url, path, query-andor-fragment ]
+
+        var path = (relParts[1].slice(0, 1) === "/" ? "" : this.path.replace(/[^/]*$/, "")) + relParts[1];
+        path = path.replace(/(\/\.)+(\/|$)/g, "/").replace(/[^/]*\/\.\.(\/|$)/g, "");
+
+        return new URL(this.schema + "://" + this.host + this.port + path + relParts[2]);
+    },
+
+    sameOrigin: function(url)
+    {
+        function normalizePort(schema, port)
+        {
+            var portNo = port.slice(1);
+            return (schema === "https" && portNo == 443 || schema === "http" && portNo == 80) ? "" : port;
+        }
+
+        var other = new URL(url);
+
+        return this.schema === other.schema &&
+            this.host === other.host &&
+            normalizePort(this.schema, this.port) === normalizePort(other.schema, other.port);
+    }
+};
+
+function DOMCoreException(name, code)
+{
+    function formatError()
+    {
+        return "Error: " + this.message;
+    }
+
+    this.name = name;
+    this.message = name + ": DOM Exception " + code;
+    this.code = code;
+    this.toString = bind(formatError, this);
+}
+
+function bind(func, thisObject)
+{
+    var args = Array.prototype.slice.call(arguments, 2);
+    return function() { return func.apply(thisObject, args.concat(Array.prototype.slice.call(arguments, 0))); };
+}
+
+function noop()
+{
+}
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorBackendStub.qrc
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorBackendStub.qrc b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorBackendStub.qrc
new file mode 100644
index 0000000..30f6d75
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorBackendStub.qrc
@@ -0,0 +1,6 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource prefix="/webkit/inspector">
+    <file>InspectorBackendStub.js</file>
+</qresource>
+</RCC>
+

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorFrontendHostStub.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorFrontendHostStub.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorFrontendHostStub.js
new file mode 100644
index 0000000..07f392d
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/InspectorFrontendHostStub.js
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+if (!window.InspectorFrontendHost) {
+
+WebInspector.InspectorFrontendHostStub = function()
+{
+    this._attachedWindowHeight = 0;
+}
+
+WebInspector._platformFlavor = WebInspector.PlatformFlavor.MacLeopard;
+
+WebInspector.InspectorFrontendHostStub.prototype = {
+    platform: function()
+    {
+        var match = navigator.userAgent.match(/Windows NT/);
+        if (match)
+            return "windows";
+        match = navigator.userAgent.match(/Mac OS X/);
+        if (match)
+            return "mac";
+        return "linux";
+    },
+
+    port: function()
+    {
+        return "unknown";
+    },
+
+    bringToFront: function()
+    {
+        this._windowVisible = true;
+    },
+
+    closeWindow: function()
+    {
+        this._windowVisible = false;
+    },
+
+    disconnectFromBackend: function()
+    {
+        this._windowVisible = false;
+    },
+
+    attach: function()
+    {
+    },
+
+    detach: function()
+    {
+    },
+
+    search: function(sourceRow, query)
+    {
+    },
+
+    setAttachedWindowHeight: function(height)
+    {
+    },
+
+    moveWindowBy: function(x, y)
+    {
+    },
+
+    setExtensionAPI: function(script)
+    {
+    },
+
+    loaded: function()
+    {
+    },
+
+    localizedStringsURL: function()
+    {
+        return undefined;
+    },
+
+    hiddenPanels: function()
+    {
+        return "";
+    },
+
+    inspectedURLChanged: function(url)
+    {
+    },
+
+    copyText: function()
+    {
+    },
+
+    canAttachWindow: function()
+    {
+        return false;
+    },
+
+    sendMessageToBackend: function(message)
+    {
+    }
+}
+
+InspectorFrontendHost = new WebInspector.InspectorFrontendHostStub();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/KeyboardShortcut.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/KeyboardShortcut.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/KeyboardShortcut.js
new file mode 100644
index 0000000..2bcf3d1
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/KeyboardShortcut.js
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2009 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.KeyboardShortcut = function()
+{
+};
+
+/**
+ * Constants for encoding modifier key set as a bit mask.
+ * @see #_makeKeyFromCodeAndModifiers
+ */
+WebInspector.KeyboardShortcut.Modifiers = {
+    None: 0,   // Constant for empty modifiers set.
+    Shift: 1,
+    Ctrl: 2,
+    Alt: 4,
+    Meta: 8,   // Command key on Mac, Win key on other platforms.
+    get CtrlOrMeta()
+    {
+        // "default" command/ctrl key for platform, Command on Mac, Ctrl on other platforms
+        return WebInspector.isMac() ? this.Meta : this.Ctrl;
+    }
+};
+
+WebInspector.KeyboardShortcut.Keys = {
+    Backspace: { code: 8, name: "\u21a4" },
+    Tab: { code: 9, name: { mac: "\u21e5", other: "<Tab>" } },
+    Enter: { code: 13, name: { mac: "\u21a9", other: "<Enter>" } },
+    Esc: { code: 27, name: { mac: "\u238b", other: "<Esc>" } },
+    Space: { code: 32, name: "<Space>" },
+    PageUp: { code: 33,  name: { mac: "\u21de", other: "<PageUp>" } },      // also NUM_NORTH_EAST
+    PageDown: { code: 34, name: { mac: "\u21df", other: "<PageDown>" } },   // also NUM_SOUTH_EAST
+    End: { code: 35, name: { mac: "\u2197", other: "<End>" } },             // also NUM_SOUTH_WEST
+    Home: { code: 36, name: { mac: "\u2196", other: "<Home>" } },           // also NUM_NORTH_WEST
+    Left: { code: 37, name: "\u2190" },           // also NUM_WEST
+    Up: { code: 38, name: "\u2191" },             // also NUM_NORTH
+    Right: { code: 39, name: "\u2192" },          // also NUM_EAST
+    Down: { code: 40, name: "\u2193" },           // also NUM_SOUTH
+    Delete: { code: 46, name: "<Del>" },
+    Zero: { code: 48, name: "0" },
+    F1: { code: 112, name: "F1" },
+    F2: { code: 113, name: "F2" },
+    F3: { code: 114, name: "F3" },
+    F4: { code: 115, name: "F4" },
+    F5: { code: 116, name: "F5" },
+    F6: { code: 117, name: "F6" },
+    F7: { code: 118, name: "F7" },
+    F8: { code: 119, name: "F8" },
+    F9: { code: 120, name: "F9" },
+    F10: { code: 121, name: "F10" },
+    F11: { code: 122, name: "F11" },
+    F12: { code: 123, name: "F12" },
+    Semicolon: { code: 186, name: ";" },
+    Plus: { code: 187, name: "+" },
+    Comma: { code: 188, name: "," },
+    Minus: { code: 189, name: "-" },
+    Period: { code: 190, name: "." },
+    Slash: { code: 191, name: "/" },
+    Apostrophe: { code: 192, name: "`" },
+    SingleQuote: { code: 222, name: "\'" }
+};
+
+/**
+ * Creates a number encoding keyCode in the lower 8 bits and modifiers mask in the higher 8 bits.
+ * It is useful for matching pressed keys.
+ * keyCode is the Code of the key, or a character "a-z" which is converted to a keyCode value.
+ * optModifiers is an Optional list of modifiers passed as additional paramerters.
+ */
+WebInspector.KeyboardShortcut.makeKey = function(keyCode, optModifiers)
+{
+    if (typeof keyCode === "string")
+        keyCode = keyCode.charCodeAt(0) - 32;
+    var modifiers = WebInspector.KeyboardShortcut.Modifiers.None;
+    for (var i = 1; i < arguments.length; i++)
+        modifiers |= arguments[i];
+    return WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers(keyCode, modifiers);
+};
+
+WebInspector.KeyboardShortcut.makeKeyFromEvent = function(keyboardEvent)
+{
+    var modifiers = WebInspector.KeyboardShortcut.Modifiers.None;
+    if (keyboardEvent.shiftKey)
+        modifiers |= WebInspector.KeyboardShortcut.Modifiers.Shift;
+    if (keyboardEvent.ctrlKey)
+        modifiers |= WebInspector.KeyboardShortcut.Modifiers.Ctrl;
+    if (keyboardEvent.altKey)
+        modifiers |= WebInspector.KeyboardShortcut.Modifiers.Alt;
+    if (keyboardEvent.metaKey)
+        modifiers |= WebInspector.KeyboardShortcut.Modifiers.Meta;
+    return WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers(keyboardEvent.keyCode, modifiers);
+};
+
+WebInspector.KeyboardShortcut.makeDescriptor = function(key, optModifiers)
+{
+    var modifiers = 0;
+    for (var i = 1; i < arguments.length; i++)
+        modifiers |= arguments[i];
+
+    return {
+        key: WebInspector.KeyboardShortcut.makeKey(typeof key === "string" ? key : key.code, modifiers),
+        name: WebInspector.KeyboardShortcut.shortcutToString(key, modifiers)
+    };
+}
+
+WebInspector.KeyboardShortcut.shortcutToString = function(key, modifiers)
+{
+    return WebInspector.KeyboardShortcut._modifiersToString(modifiers) + WebInspector.KeyboardShortcut._keyName(key);
+}
+
+WebInspector.KeyboardShortcut._keyName = function(key)
+{
+    if (typeof key === "string")
+        return key.toUpperCase();
+    if (typeof key.name === "string")
+        return key.name;
+    return key.name[WebInspector.platform] || key.name.other;
+}
+
+WebInspector.KeyboardShortcut._makeKeyFromCodeAndModifiers = function(keyCode, modifiers)
+{
+    return (keyCode & 255) | (modifiers << 8);
+};
+
+WebInspector.KeyboardShortcut._modifiersToString = function(modifiers)
+{
+    const cmdKey = "\u2318";
+    const optKey = "\u2325";
+    const shiftKey = "\u21e7";
+    const ctrlKey = "\u2303";
+
+    var isMac = WebInspector.isMac();
+    var res = "";
+    if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Ctrl)
+        res += isMac ? ctrlKey : "<Ctrl> + ";
+    if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Alt)
+        res += isMac ? optKey : "<Alt> + ";
+    if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Shift)
+        res += isMac ? shiftKey : "<Shift> + ";
+    if (modifiers & WebInspector.KeyboardShortcut.Modifiers.Meta)
+        res += isMac ? cmdKey : "<Win> + ";
+
+    return res;
+};

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/MetricsSidebarPane.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/MetricsSidebarPane.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/MetricsSidebarPane.js
new file mode 100644
index 0000000..3c0f315
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/MetricsSidebarPane.js
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.MetricsSidebarPane = function()
+{
+    WebInspector.SidebarPane.call(this, WebInspector.UIString("Metrics"));
+    this._inlineStyleId = null;
+}
+
+WebInspector.MetricsSidebarPane.prototype = {
+    update: function(node)
+    {
+        if (node)
+            this.node = node;
+        else
+            node = this.node;
+
+        if (!node || !node.ownerDocument.defaultView || node.nodeType !== Node.ELEMENT_NODE) {
+            this.bodyElement.removeChildren();
+            return;
+        }
+
+        var self = this;
+        var callback = function(style) {
+            if (!style)
+                return;
+            self._update(style);
+        };
+        WebInspector.cssModel.getComputedStyleAsync(node.id, callback);
+
+        var inlineStyleCallback = function(style) {
+            if (!style)
+                return;
+            self.inlineStyle = style;
+        };
+        WebInspector.cssModel.getInlineStyleAsync(node.id, inlineStyleCallback);
+    },
+
+    _update: function(style)
+    {
+        // Updating with computed style.
+        var metricsElement = document.createElement("div");
+        metricsElement.className = "metrics";
+
+        function createBoxPartElement(style, name, side, suffix)
+        {
+            var propertyName = (name !== "position" ? name + "-" : "") + side + suffix;
+            var value = style.getPropertyValue(propertyName);
+            if (value === "" || (name !== "position" && value === "0px"))
+                value = "\u2012";
+            else if (name === "position" && value === "auto")
+                value = "\u2012";
+            value = value.replace(/px$/, "");
+
+            var element = document.createElement("div");
+            element.className = side;
+            element.textContent = value;
+            element.addEventListener("dblclick", this.startEditing.bind(this, element, name, propertyName), false);
+            return element;
+        }
+
+        // Display types for which margin is ignored.
+        var noMarginDisplayType = {
+            "table-cell": true,
+            "table-column": true,
+            "table-column-group": true,
+            "table-footer-group": true,
+            "table-header-group": true,
+            "table-row": true,
+            "table-row-group": true
+        };
+
+        // Display types for which padding is ignored.
+        var noPaddingDisplayType = {
+            "table-column": true,
+            "table-column-group": true,
+            "table-footer-group": true,
+            "table-header-group": true,
+            "table-row": true,
+            "table-row-group": true
+        };
+
+        // Position types for which top, left, bottom and right are ignored.
+        var noPositionType = {
+            "static": true
+        };
+
+        var boxes = ["content", "padding", "border", "margin", "position"];
+        var boxLabels = [WebInspector.UIString("content"), WebInspector.UIString("padding"), WebInspector.UIString("border"), WebInspector.UIString("margin"), WebInspector.UIString("position")];
+        var previousBox;
+        for (var i = 0; i < boxes.length; ++i) {
+            var name = boxes[i];
+
+            if (name === "margin" && noMarginDisplayType[style.getPropertyValue("display")])
+                continue;
+            if (name === "padding" && noPaddingDisplayType[style.getPropertyValue("display")])
+                continue;
+            if (name === "position" && noPositionType[style.getPropertyValue("position")])
+                continue;
+
+            var boxElement = document.createElement("div");
+            boxElement.className = name;
+
+            if (name === "content") {
+                var width = style.getPropertyValue("width").replace(/px$/, "");
+                var widthElement = document.createElement("span");
+                widthElement.textContent = width;
+                widthElement.addEventListener("dblclick", this.startEditing.bind(this, widthElement, "width", "width"), false);
+
+                var height = style.getPropertyValue("height").replace(/px$/, "");
+                var heightElement = document.createElement("span");
+                heightElement.textContent = height;
+                heightElement.addEventListener("dblclick", this.startEditing.bind(this, heightElement, "height", "height"), false);
+
+                boxElement.appendChild(widthElement);
+                boxElement.appendChild(document.createTextNode(" \u00D7 "));
+                boxElement.appendChild(heightElement);
+            } else {
+                var suffix = (name === "border" ? "-width" : "");
+
+                var labelElement = document.createElement("div");
+                labelElement.className = "label";
+                labelElement.textContent = boxLabels[i];
+                boxElement.appendChild(labelElement);
+
+                boxElement.appendChild(createBoxPartElement.call(this, style, name, "top", suffix));
+                boxElement.appendChild(document.createElement("br"));
+                boxElement.appendChild(createBoxPartElement.call(this, style, name, "left", suffix));
+
+                if (previousBox)
+                    boxElement.appendChild(previousBox);
+
+                boxElement.appendChild(createBoxPartElement.call(this, style, name, "right", suffix));
+                boxElement.appendChild(document.createElement("br"));
+                boxElement.appendChild(createBoxPartElement.call(this, style, name, "bottom", suffix));
+            }
+
+            previousBox = boxElement;
+        }
+
+        metricsElement.appendChild(previousBox);
+        this.bodyElement.removeChildren();
+        this.bodyElement.appendChild(metricsElement);
+    },
+
+    startEditing: function(targetElement, box, styleProperty)
+    {
+        if (WebInspector.isBeingEdited(targetElement))
+            return;
+
+        var context = { box: box, styleProperty: styleProperty };
+
+        WebInspector.startEditing(targetElement, {
+            context: context,
+            commitHandler: this.editingCommitted.bind(this),
+            cancelHandler: this.editingCancelled.bind(this)
+        });
+    },
+
+    editingCancelled: function(element, context)
+    {
+        this.update();
+    },
+
+    editingCommitted: function(element, userInput, previousContent, context)
+    {
+        if (!this.inlineStyle) {
+            // Element has no renderer.
+            return this.editingCancelled(element, context); // nothing changed, so cancel
+        }
+
+        if (userInput === previousContent)
+            return this.editingCancelled(element, context); // nothing changed, so cancel
+
+        if (context.box !== "position" && (!userInput || userInput === "\u2012"))
+            userInput = "0px";
+        else if (context.box === "position" && (!userInput || userInput === "\u2012"))
+            userInput = "auto";
+
+        // Append a "px" unit if the user input was just a number.
+        if (/^\d+$/.test(userInput))
+            userInput += "px";
+
+        var self = this;
+        var callback = function(style) {
+            if (!style)
+                return;
+            self.inlineStyle = style;
+            self.dispatchEventToListeners("metrics edited");
+            self.update();
+        };
+
+        function setEnabledValueCallback(context, style)
+        {
+            var property = style.getLiveProperty(context.styleProperty);
+            if (!property)
+                style.appendProperty(context.styleProperty, userInput, callback);
+             else
+                property.setValue(userInput, callback);
+        }
+
+        var allProperties = this.inlineStyle.allProperties;
+        for (var i = 0; i < allProperties.length; ++i) {
+            var property = allProperties[i];
+            if (property.name !== context.styleProperty || property.inactive)
+                continue;
+            if (property.disabled)
+                property.setDisabled(false, setEnabledValueCallback.bind(null, context));
+            else
+                property.setValue(userInput, callback);
+            return;
+        }
+
+        this.inlineStyle.appendProperty(context.styleProperty, userInput, callback);
+    }
+}
+
+WebInspector.MetricsSidebarPane.prototype.__proto__ = WebInspector.SidebarPane.prototype;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkItemView.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkItemView.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkItemView.js
new file mode 100644
index 0000000..418f559
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkItemView.js
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.NetworkItemView = function(resource)
+{
+    WebInspector.View.call(this);
+
+    this.element.addStyleClass("network-item-view");
+
+    this._headersView = new WebInspector.ResourceHeadersView(resource);
+    // Do not store reference to content view - it can be recreated.
+    var contentView = WebInspector.ResourceView.resourceViewForResource(resource);
+
+    this._tabbedPane = new WebInspector.TabbedPane(this.element);
+    this._tabbedPane.appendTab("headers", WebInspector.UIString("Headers"), this._headersView);
+    if (contentView.hasContent()) {
+        // Reusing this view, so hide it at first.
+        contentView.visible = false;
+        this._tabbedPane.appendTab("content", WebInspector.UIString("Content"), contentView);
+    }
+    if (Preferences.showCookiesTab) {
+        this._cookiesView = new WebInspector.ResourceCookiesView(resource);
+        this._tabbedPane.appendTab("cookies", WebInspector.UIString("Cookies"), this._cookiesView);
+    }
+    if (Preferences.showTimingTab) {
+        var timingView = new WebInspector.ResourceTimingView(resource);
+        this._tabbedPane.appendTab("timing", WebInspector.UIString("Timing"), timingView);
+    }
+
+    this._tabbedPane.addEventListener("tab-selected", this._tabSelected, this);
+}
+
+WebInspector.NetworkItemView.prototype = {
+    show: function(parentElement)
+    {
+        WebInspector.View.prototype.show.call(this, parentElement);
+        this._selectTab();
+    },
+
+    _selectTab: function(tabId)
+    {
+        if (!tabId)
+            tabId = WebInspector.settings.resourceViewTab;
+
+        if (!this._tabbedPane.selectTab(tabId)) {
+            this._isInFallbackSelection = true;
+            this._tabbedPane.selectTab("headers");
+            delete this._isInFallbackSelection;
+        }
+    },
+
+    _tabSelected: function(event)
+    {
+        WebInspector.settings.resourceViewTab = event.data.tabId;
+    },
+
+    resize: function()
+    {
+        if (this._cookiesView && this._cookiesView.visible)
+            this._cookiesView.resize();
+    }
+}
+
+WebInspector.NetworkItemView.prototype.__proto__ = WebInspector.View.prototype;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-weinre/blob/c4fbd3d0/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkManager.js
----------------------------------------------------------------------
diff --git a/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkManager.js b/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkManager.js
new file mode 100644
index 0000000..da043fe
--- /dev/null
+++ b/weinre.build/vendor/webkit/WebCore/inspector/front-end/NetworkManager.js
@@ -0,0 +1,378 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+WebInspector.NetworkManager = function(resourceTreeModel)
+{
+    WebInspector.Object.call(this);
+    this._resourceTreeModel = resourceTreeModel;
+    this._dispatcher = new WebInspector.NetworkDispatcher(resourceTreeModel, this);
+    InspectorBackend.cachedResources(this._processCachedResources.bind(this));
+}
+
+WebInspector.NetworkManager.EventTypes = {
+    ResourceStarted: "ResourceStarted",
+    ResourceUpdated: "ResourceUpdated",
+    ResourceFinished: "ResourceFinished",
+    MainResourceCommitLoad: "MainResourceCommitLoad"
+}
+
+WebInspector.NetworkManager.prototype = {
+    reset: function()
+    {
+        WebInspector.panels.network.clear();
+        this._resourceTreeModel.reset();
+        InspectorBackend.cachedResources(this._processCachedResources.bind(this));
+    },
+
+    requestContent: function(resource, base64Encode, callback)
+    {
+        function callbackWrapper(success, content)
+        {
+            callback(success ? content : null);
+        }
+        InspectorBackend.resourceContent(resource.loader.frameId, resource.url, base64Encode, callbackWrapper);
+    },
+
+    _processCachedResources: function(mainFramePayload)
+    {
+        var mainResource = this._dispatcher._addFramesRecursively(mainFramePayload);
+        WebInspector.mainResource = mainResource;
+        mainResource.isMainResource = true;
+    },
+
+    inflightResourceForURL: function(url)
+    {
+        return this._dispatcher._inflightResourcesByURL[url];
+    }
+}
+
+WebInspector.NetworkManager.prototype.__proto__ = WebInspector.Object.prototype;
+
+WebInspector.NetworkDispatcher = function(resourceTreeModel, manager)
+{
+    this._manager = manager;
+    this._inflightResourcesById = {};
+    this._inflightResourcesByURL = {};
+    this._resourceTreeModel = resourceTreeModel;
+    this._lastIdentifierForCachedResource = 0;
+    InspectorBackend.registerDomainDispatcher("Network", this);
+}
+
+WebInspector.NetworkDispatcher.prototype = {
+    _updateResourceWithRequest: function(resource, request)
+    {
+        resource.requestMethod = request.httpMethod;
+        resource.requestHeaders = request.httpHeaderFields;
+        resource.requestFormData = request.requestFormData;
+    },
+
+    _updateResourceWithResponse: function(resource, response)
+    {
+        if (resource.isNull)
+            return;
+
+        resource.mimeType = response.mimeType;
+        resource.expectedContentLength = response.expectedContentLength;
+        resource.textEncodingName = response.textEncodingName;
+        resource.suggestedFilename = response.suggestedFilename;
+        resource.statusCode = response.httpStatusCode;
+        resource.statusText = response.httpStatusText;
+
+        resource.responseHeaders = response.httpHeaderFields;
+        resource.connectionReused = response.connectionReused;
+        resource.connectionID = response.connectionID;
+
+        if (response.wasCached)
+            resource.cached = true;
+        else
+            resource.timing = response.timing;
+
+        if (response.loadInfo) {
+            if (response.loadInfo.httpStatusCode)
+                resource.statusCode = response.loadInfo.httpStatusCode;
+            if (response.loadInfo.httpStatusText)
+                resource.statusText = response.loadInfo.httpStatusText;
+            resource.requestHeaders = response.loadInfo.requestHeaders;
+            resource.responseHeaders = response.loadInfo.responseHeaders;
+        }
+    },
+
+    _updateResourceWithCachedResource: function(resource, cachedResource)
+    {
+        resource.type = WebInspector.Resource.Type[cachedResource.type];
+        resource.resourceSize = cachedResource.encodedSize;
+        this._updateResourceWithResponse(resource, cachedResource.response);
+    },
+
+    identifierForInitialRequest: function(identifier, url, loader, callStack)
+    {
+        this._startResource(this._createResource(identifier, url, loader, callStack));
+    },
+
+    willSendRequest: function(identifier, time, request, redirectResponse)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        // Redirect may have empty URL and we'd like to not crash with invalid HashMap entry.
+        // See http/tests/misc/will-send-request-returns-null-on-redirect.html
+        var isRedirect = !redirectResponse.isNull && request.url.length;
+        if (isRedirect) {
+            this.didReceiveResponse(identifier, time, "Other", redirectResponse);
+            resource = this._appendRedirect(resource.identifier, time, request.url);
+        }
+
+        this._updateResourceWithRequest(resource, request);
+        resource.startTime = time;
+
+        if (isRedirect)
+            this._startResource(resource);
+        else
+            this._updateResource(resource);
+    },
+
+    markResourceAsCached: function(identifier)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.cached = true;
+        this._updateResource(resource);
+    },
+
+    didReceiveResponse: function(identifier, time, resourceType, response)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.responseReceivedTime = time;
+        resource.type = WebInspector.Resource.Type[resourceType];
+
+        this._updateResourceWithResponse(resource, response);
+
+        this._updateResource(resource);
+        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
+    },
+
+    didReceiveContentLength: function(identifier, time, lengthReceived)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.resourceSize += lengthReceived;
+        resource.endTime = time;
+
+        this._updateResource(resource);
+    },
+
+    didFinishLoading: function(identifier, finishTime)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        this._finishResource(resource, finishTime);
+    },
+
+    didFailLoading: function(identifier, time, localizedDescription)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.failed = true;
+        resource.localizedFailDescription = localizedDescription;
+        this._finishResource(resource, time);
+    },
+
+    didLoadResourceFromMemoryCache: function(time, cachedResource)
+    {
+        var resource = this._createResource("cached:" + ++this._lastIdentifierForCachedResource, cachedResource.url, cachedResource.loader);
+        this._updateResourceWithCachedResource(resource, cachedResource);
+        resource.cached = true;
+        resource.requestMethod = "GET";
+        this._startResource(resource);
+        resource.startTime = resource.responseReceivedTime = time;
+        this._finishResource(resource, time);
+        this._resourceTreeModel.addResourceToFrame(resource.loader.frameId, resource);
+    },
+
+    frameDetachedFromParent: function(frameId)
+    {
+        this._resourceTreeModel.frameDetachedFromParent(frameId);
+    },
+
+    setInitialContent: function(identifier, sourceString, type)
+    {
+        var resource = WebInspector.networkResourceById(identifier);
+        if (!resource)
+            return;
+
+        resource.type = WebInspector.Resource.Type[type];
+        resource.setInitialContent(sourceString);
+        this._updateResource(resource);
+    },
+
+    didCommitLoadForFrame: function(frame, loader)
+    {
+        this._resourceTreeModel.didCommitLoadForFrame(frame, loader);
+        if (!frame.parentId) {
+            var mainResource = this._resourceTreeModel.resourceForURL(frame.url);
+            if (mainResource) {
+                WebInspector.mainResource = mainResource;
+                mainResource.isMainResource = true;
+                this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.MainResourceCommitLoad, mainResource);
+            }
+        }
+    },
+
+    didCreateWebSocket: function(identifier, requestURL)
+    {
+        var resource = this._createResource(identifier, requestURL);
+        resource.type = WebInspector.Resource.Type.WebSocket;
+        this._startResource(resource);
+    },
+
+    willSendWebSocketHandshakeRequest: function(identifier, time, request)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.requestMethod = "GET";
+        resource.requestHeaders = request.webSocketHeaderFields;
+        resource.webSocketRequestKey3 = request.webSocketRequestKey3;
+        resource.startTime = time;
+
+        this._updateResource(resource);
+    },
+
+    didReceiveWebSocketHandshakeResponse: function(identifier, time, response)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+
+        resource.statusCode = response.statusCode;
+        resource.statusText = response.statusText;
+        resource.responseHeaders = response.webSocketHeaderFields;
+        resource.webSocketChallengeResponse = response.webSocketChallengeResponse;
+        resource.responseReceivedTime = time;
+
+        this._updateResource(resource);
+    },
+
+    didCloseWebSocket: function(identifier, time)
+    {
+        var resource = this._inflightResourcesById[identifier];
+        if (!resource)
+            return;
+        this._finishResource(resource, time);
+    },
+
+    _appendRedirect: function(identifier, time, redirectURL)
+    {
+        var originalResource = this._inflightResourcesById[identifier];
+        var previousRedirects = originalResource.redirects || [];
+        originalResource.identifier = "redirected:" + identifier + "." + previousRedirects.length;
+        delete originalResource.redirects;
+        this._finishResource(originalResource, time);
+        var newResource = this._createResource(identifier, redirectURL, originalResource.loader, originalResource.stackTrace);
+        newResource.redirects = previousRedirects.concat(originalResource);
+        return newResource;
+    },
+
+    _startResource: function(resource)
+    {
+        this._inflightResourcesById[resource.identifier] = resource;
+        this._inflightResourcesByURL[resource.url] = resource;
+        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceStarted, resource);
+    },
+
+    _updateResource: function(resource)
+    {
+        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceUpdated, resource);
+    },
+
+    _finishResource: function(resource, finishTime)
+    {
+        resource.endTime = finishTime;
+        resource.finished = true;
+        this._dispatchEventToListeners(WebInspector.NetworkManager.EventTypes.ResourceFinished, resource);
+        delete this._inflightResourcesById[resource.identifier];
+        delete this._inflightResourcesByURL[resource.url];
+    },
+
+    _addFramesRecursively: function(framePayload)
+    {
+        var frameResource = this._createResource(null, framePayload.resource.url, framePayload.resource.loader);
+        this._updateResourceWithRequest(frameResource, framePayload.resource.request);
+        this._updateResourceWithResponse(frameResource, framePayload.resource.response);
+        frameResource.type = WebInspector.Resource.Type["Document"];
+        frameResource.finished = true;
+
+        this._resourceTreeModel.addOrUpdateFrame(framePayload);
+        this._resourceTreeModel.addResourceToFrame(framePayload.id, frameResource);
+
+        for (var i = 0; framePayload.children && i < framePayload.children.length; ++i)
+            this._addFramesRecursively(framePayload.children[i]);
+
+        if (!framePayload.subresources)
+            return;
+
+        for (var i = 0; i < framePayload.subresources.length; ++i) {
+            var cachedResource = framePayload.subresources[i];
+            var resource = this._createResource(null, cachedResource.url, cachedResource.loader);
+            this._updateResourceWithCachedResource(resource, cachedResource);
+            resource.finished = true;
+            this._resourceTreeModel.addResourceToFrame(framePayload.id, resource);
+        }
+        return frameResource;
+    },
+
+    _dispatchEventToListeners: function(eventType, resource)
+    {
+        this._manager.dispatchEventToListeners(eventType, resource);
+    },
+
+    _createResource: function(identifier, url, loader, stackTrace)
+    {
+        var resource = new WebInspector.Resource(identifier, url);
+        resource.loader = loader;
+        if (loader)
+            resource.documentURL = loader.url;
+        resource.stackTrace = stackTrace;
+        return resource;
+    }
+}


Mime
View raw message