Changeset 182039 in webkit


Ignore:
Timestamp:
Mar 26, 2015 4:37:30 PM (9 years ago)
Author:
timothy@apple.com
Message:

Web Inspector: Convert Base and Protocol files to ES6 classes
https://bugs.webkit.org/show_bug.cgi?id=143106

Reviewed by Joseph Pecoraro.

  • UserInterface/Base/EventListener.js:
  • UserInterface/Base/EventListenerSet.js:
  • UserInterface/Protocol/ApplicationCacheObserver.js:
  • UserInterface/Protocol/CSSObserver.js:
  • UserInterface/Protocol/ConsoleObserver.js:
  • UserInterface/Protocol/DOMObserver.js:
  • UserInterface/Protocol/DOMStorageObserver.js:
  • UserInterface/Protocol/DatabaseObserver.js:
  • UserInterface/Protocol/DebuggerObserver.js:
  • UserInterface/Protocol/InspectorBackend.js:
  • UserInterface/Protocol/InspectorObserver.js:
  • UserInterface/Protocol/LayerTreeObserver.js:
  • UserInterface/Protocol/MessageDispatcher.js:
  • UserInterface/Protocol/NetworkObserver.js:
  • UserInterface/Protocol/PageObserver.js:
  • UserInterface/Protocol/RemoteObject.js:
  • UserInterface/Protocol/ReplayObserver.js:
  • UserInterface/Protocol/RuntimeObserver.js:
  • UserInterface/Protocol/TimelineObserver.js:

Converted to ES6 classes where possible.

Location:
trunk/Source/WebInspectorUI
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebInspectorUI/ChangeLog

    r181987 r182039  
     12015-03-26  Timothy Hatcher  <timothy@apple.com>
     2
     3        Web Inspector: Convert Base and Protocol files to ES6 classes
     4        https://bugs.webkit.org/show_bug.cgi?id=143106
     5
     6        Reviewed by Joseph Pecoraro.
     7
     8        * UserInterface/Base/EventListener.js:
     9        * UserInterface/Base/EventListenerSet.js:
     10        * UserInterface/Protocol/ApplicationCacheObserver.js:
     11        * UserInterface/Protocol/CSSObserver.js:
     12        * UserInterface/Protocol/ConsoleObserver.js:
     13        * UserInterface/Protocol/DOMObserver.js:
     14        * UserInterface/Protocol/DOMStorageObserver.js:
     15        * UserInterface/Protocol/DatabaseObserver.js:
     16        * UserInterface/Protocol/DebuggerObserver.js:
     17        * UserInterface/Protocol/InspectorBackend.js:
     18        * UserInterface/Protocol/InspectorObserver.js:
     19        * UserInterface/Protocol/LayerTreeObserver.js:
     20        * UserInterface/Protocol/MessageDispatcher.js:
     21        * UserInterface/Protocol/NetworkObserver.js:
     22        * UserInterface/Protocol/PageObserver.js:
     23        * UserInterface/Protocol/RemoteObject.js:
     24        * UserInterface/Protocol/ReplayObserver.js:
     25        * UserInterface/Protocol/RuntimeObserver.js:
     26        * UserInterface/Protocol/TimelineObserver.js:
     27        Converted to ES6 classes where possible.
     28
    1292015-03-25  Tobias Reiss  <tobi+webkit@basecode.de>
    230
  • trunk/Source/WebInspectorUI/UserInterface/Base/EventListener.js

    r173431 r182039  
    11/*
     2 * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
    23 * Copyright (C) 2013, 2014 University of Washington. All rights reserved.
    3  * Copyright (C) 2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2525 */
    2626
    27 WebInspector.EventListener = function(thisObject, fireOnce)
     27WebInspector.EventListener = class EventListener
    2828{
    29     this._thisObject = thisObject;
    30     this._emitter = null;
    31     this._callback = null;
    32     this._fireOnce = fireOnce;
    33 };
     29    constructor(thisObject, fireOnce)
     30    {
     31        this._thisObject = thisObject;
     32        this._emitter = null;
     33        this._callback = null;
     34        this._fireOnce = fireOnce;
     35    }
    3436
    35 WebInspector.EventListener.prototype = {
    36     connect: function(emitter, type, callback, usesCapture)
     37    // Public
     38
     39    connect(emitter, type, callback, usesCapture)
    3740    {
    3841        console.assert(!this._emitter && !this._callback, "EventListener already bound to a callback.", this);
     
    6568        else
    6669            this._emitter.addEventListener(this._type, this._callback, this._thisObject);
    67     },
     70    }
    6871
    69     disconnect: function()
     72    disconnect()
    7073    {
    7174        console.assert(this._emitter && this._callback, "EventListener is not bound to a callback.", this);
  • trunk/Source/WebInspectorUI/UserInterface/Base/EventListenerSet.js

    r181185 r182039  
    11/*
     2 * Copyright (C) 2014, 2015 Apple Inc. All rights reserved.
    23 * Copyright (C) 2013, 2014 University of Washington. All rights reserved.
    3  * Copyright (C) 2014 Apple Inc. All rights reserved.
    44 *
    55 * Redistribution and use in source and binary forms, with or without
     
    2929// Use `install()` and `uninstall()` to enable or disable all listeners
    3030// in the set at once.
    31 WebInspector.EventListenerSet = function(defaultThisObject, name)
     31
     32WebInspector.EventListenerSet = class EventListenerSet
    3233{
    33     this.name = name;
    34     this._defaultThisObject = defaultThisObject;
     34    constructor(defaultThisObject, name)
     35    {
     36        this.name = name;
     37        this._defaultThisObject = defaultThisObject;
    3538
    36     this._listeners = [];
    37     this._installed = false;
    38 }
     39        this._listeners = [];
     40        this._installed = false;
     41    }
    3942
    40 WebInspector.EventListenerSet.prototype = {
    41     register: function(emitter, type, callback, thisObject, usesCapture)
     43    // Public
     44
     45    register(emitter, type, callback, thisObject, usesCapture)
    4246    {
    4347        console.assert(callback, "Missing callback for event: " + type);
     
    5054
    5155        this._listeners.push({listener: new WebInspector.EventListener(thisObject || this._defaultThisObject), emitter, type, callback, usesCapture});
    52     },
     56    }
    5357
    54     unregister: function()
     58    unregister()
    5559    {
    5660        if (this._installed)
    5761            this.uninstall();
    5862        this._listeners = [];
    59     },
     63    }
    6064
    61     install: function()
     65    install()
    6266    {
    6367        console.assert(!this._installed, "Already installed listener group: " + this.name);
     
    6973        for (var data of this._listeners)
    7074            data.listener.connect(data.emitter, data.type, data.callback, data.usesCapture);
    71     },
     75    }
    7276
    73     uninstall: function(unregisterListeners)
     77    uninstall(unregisterListeners)
    7478    {
    7579        console.assert(this._installed, "Trying to uninstall listener group " + this.name + ", but it isn't installed.");
     
    8488        if (unregisterListeners)
    8589            this._listeners = [];
    86     },
    87 }
     90    }
     91};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/ApplicationCacheObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.ApplicationCacheObserver = function()
     26WebInspector.ApplicationCacheObserver = class ApplicationCacheObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.ApplicationCacheObserver.prototype = {
    33     constructor: WebInspector.ApplicationCacheObserver,
    34 
    3528    // Events defined by the "ApplicationCache" domain.
    3629
    37     applicationCacheStatusUpdated: function(frameId, manifestURL, status)
     30    applicationCacheStatusUpdated(frameId, manifestURL, status)
    3831    {
    3932        WebInspector.applicationCacheManager.applicationCacheStatusUpdated(frameId, manifestURL, status);
    40     },
     33    }
    4134
    42     networkStateUpdated: function(isNowOnline)
     35    networkStateUpdated(isNowOnline)
    4336    {
    4437        WebInspector.applicationCacheManager.networkStateUpdated(isNowOnline);
    4538    }
    4639};
    47 
    48 WebInspector.ApplicationCacheObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/CSSObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.CSSObserver = function()
     26WebInspector.CSSObserver = class CSSObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.CSSObserver.prototype = {
    33     constructor: WebInspector.CSSObserver,
    34 
    3528    // Events defined by the "CSS" domain.
    3629
    37     mediaQueryResultChanged: function()
     30    mediaQueryResultChanged()
    3831    {
    3932        WebInspector.cssStyleManager.mediaQueryResultChanged();
    40     },
     33    }
    4134
    42     styleSheetChanged: function(styleSheetId)
     35    styleSheetChanged(styleSheetId)
    4336    {
    4437        WebInspector.cssStyleManager.styleSheetChanged(styleSheetId);
    45     },
     38    }
    4639
    47     styleSheetAdded: function(header)
     40    styleSheetAdded(header)
    4841    {
    4942        // FIXME: Not implemented. <rdar://problem/13213680>
    50     },
     43    }
    5144
    52     styleSheetRemoved: function(header)
     45    styleSheetRemoved(header)
    5346    {
    5447        // FIXME: Not implemented. <rdar://problem/13213680>
    55     },
     48    }
    5649
    57     namedFlowCreated: function(namedFlow)
     50    namedFlowCreated(namedFlow)
    5851    {
    5952        WebInspector.domTreeManager.namedFlowCreated(namedFlow);
    60     },
     53    }
    6154
    62     namedFlowRemoved: function(documentNodeId, flowName)
     55    namedFlowRemoved(documentNodeId, flowName)
    6356    {
    6457        WebInspector.domTreeManager.namedFlowRemoved(documentNodeId, flowName);
    65     },
     58    }
    6659
    6760    // COMPATIBILITY (iOS 7): regionLayoutUpdated was removed and replaced by regionOversetChanged.
    68     regionLayoutUpdated: function(namedFlow)
     61    regionLayoutUpdated(namedFlow)
    6962    {
    7063        WebInspector.domTreeManager.regionLayoutUpdated(namedFlow);
    71     },
     64    }
    7265
    73     regionOversetChanged: function(namedFlow)
     66    regionOversetChanged(namedFlow)
    7467    {
    7568        WebInspector.domTreeManager.regionOversetChanged(namedFlow);
    76     },
     69    }
    7770
    78     registeredNamedFlowContentElement: function(documentNodeId, flowName, contentNodeId, nextContentElementNodeId)
     71    registeredNamedFlowContentElement(documentNodeId, flowName, contentNodeId, nextContentElementNodeId)
    7972    {
    8073        WebInspector.domTreeManager.registeredNamedFlowContentElement(documentNodeId, flowName, contentNodeId, nextContentElementNodeId);
    81     },
     74    }
    8275
    83     unregisteredNamedFlowContentElement: function(documentNodeId, flowName, contentNodeId)
     76    unregisteredNamedFlowContentElement(documentNodeId, flowName, contentNodeId)
    8477    {
    8578        WebInspector.domTreeManager.unregisteredNamedFlowContentElement(documentNodeId, flowName, contentNodeId);
    8679    }
    8780};
    88 
    89 WebInspector.CSSObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.ConsoleObserver = function()
     26WebInspector.ConsoleObserver = class ConsoleObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.ConsoleObserver.prototype = {
    33     constructor: WebInspector.ConsoleObserver,
    34 
    3528    // Events defined by the "Console" domain.
    3629
    37     messageAdded: function(message)
     30    messageAdded(message)
    3831    {
    3932        if (message.type === "assert" && !message.text)
     
    4942
    5043        WebInspector.logManager.messageWasAdded(message.source, message.level, message.text, message.type, message.url, message.line, message.column || 0, message.repeatCount, message.parameters, message.stackTrace, message.networkRequestId);
    51     },
     44    }
    5245
    53     messageRepeatCountUpdated: function(count)
     46    messageRepeatCountUpdated(count)
    5447    {
    5548        WebInspector.logManager.messageRepeatCountUpdated(count);
    56     },
     49    }
    5750
    58     messagesCleared: function()
     51    messagesCleared()
    5952    {
    6053        WebInspector.logManager.messagesCleared();
    6154    }
    6255};
    63 
    64 WebInspector.ConsoleObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/DOMObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.DOMObserver = function()
     26WebInspector.DOMObserver = class DOMObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.DOMObserver.prototype = {
    33     constructor: WebInspector.DOMObserver,
    34 
    3528    // Events defined by the "DOM" domain.
    3629
    37     documentUpdated: function()
     30    documentUpdated()
    3831    {
    3932        WebInspector.domTreeManager._documentUpdated();
    40     },
     33    }
    4134
    42     setChildNodes: function(parentId, payloads)
     35    setChildNodes(parentId, payloads)
    4336    {
    4437        WebInspector.domTreeManager._setChildNodes(parentId, payloads);
    45     },
     38    }
    4639
    47     attributeModified: function(nodeId, name, value)
     40    attributeModified(nodeId, name, value)
    4841    {
    4942        WebInspector.domTreeManager._attributeModified(nodeId, name, value);
    50     },
     43    }
    5144
    52     attributeRemoved: function(nodeId, name)
     45    attributeRemoved(nodeId, name)
    5346    {
    5447        WebInspector.domTreeManager._attributeRemoved(nodeId, name);
    55     },
     48    }
    5649
    57     inlineStyleInvalidated: function(nodeIds)
     50    inlineStyleInvalidated(nodeIds)
    5851    {
    5952        WebInspector.domTreeManager._inlineStyleInvalidated(nodeIds);
    60     },
     53    }
    6154
    62     characterDataModified: function(nodeId, characterData)
     55    characterDataModified(nodeId, characterData)
    6356    {
    6457        WebInspector.domTreeManager._characterDataModified(nodeId, characterData);
    65     },
     58    }
    6659
    67     childNodeCountUpdated: function(nodeId, childNodeCount)
     60    childNodeCountUpdated(nodeId, childNodeCount)
    6861    {
    6962        WebInspector.domTreeManager._childNodeCountUpdated(nodeId, childNodeCount);
    70     },
     63    }
    7164
    72     childNodeInserted: function(parentNodeId, previousNodeId, payload)
     65    childNodeInserted(parentNodeId, previousNodeId, payload)
    7366    {
    7467        WebInspector.domTreeManager._childNodeInserted(parentNodeId, previousNodeId, payload);
    75     },
     68    }
    7669
    77     childNodeRemoved: function(parentNodeId, nodeId)
     70    childNodeRemoved(parentNodeId, nodeId)
    7871    {
    7972        WebInspector.domTreeManager._childNodeRemoved(parentNodeId, nodeId);
    80     },
     73    }
    8174
    82     shadowRootPushed: function(parentNodeId, nodeId)
     75    shadowRootPushed(parentNodeId, nodeId)
    8376    {
    8477        WebInspector.domTreeManager._childNodeInserted(parentNodeId, 0, nodeId);
    85     },
     78    }
    8679
    87     shadowRootPopped: function(parentNodeId, nodeId)
     80    shadowRootPopped(parentNodeId, nodeId)
    8881    {
    8982        WebInspector.domTreeManager._childNodeRemoved(parentNodeId, nodeId);
    9083    }
    9184};
    92 
    93 WebInspector.DOMObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/DOMStorageObserver.js

    r181769 r182039  
    2525 */
    2626
    27 WebInspector.DOMStorageObserver = function()
     27WebInspector.DOMStorageObserver = class DOMStorageObserver
    2828{
    29     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    30     // WebInspector.Object.call(this);
    31 };
    32 
    33 WebInspector.DOMStorageObserver.prototype = {
    34     constructor: WebInspector.DOMStorageObserver,
    35     __proto__: WebInspector.Object.prototype,
    36 
    3729    // Events defined by the "DOMStorage" domain.
    3830
    3931    // COMPATIBILITY (iOS 6): This event no longer exists. It is still needed and called on iOS 6.
    40     addDOMStorage: function(storage)
     32    addDOMStorage(storage)
    4133    {
    4234        WebInspector.storageManager.domStorageWasAdded(storage.id, storage.host, storage.isLocalStorage);
    43     },
     35    }
    4436
    4537    // COMPATIBILITY (iOS 6): This event was split into the granular events below.
    46     updateDOMStorage: function(storageId)
     38    updateDOMStorage(storageId)
    4739    {
    4840        WebInspector.storageManager.domStorageWasUpdated(storageId);
    49     },
     41    }
    5042
    51     domStorageItemsCleared: function(storageId)
     43    domStorageItemsCleared(storageId)
    5244    {
    5345        WebInspector.storageManager.itemsCleared(storageId);
    54     },
     46    }
    5547
    56     domStorageItemRemoved: function(storageId, key)
     48    domStorageItemRemoved(storageId, key)
    5749    {
    5850        WebInspector.storageManager.itemRemoved(storageId, key);
    59     },
     51    }
    6052
    61     domStorageItemAdded: function(storageId, key, value)
     53    domStorageItemAdded(storageId, key, value)
    6254    {
    6355        WebInspector.storageManager.itemAdded(storageId, key, value);
    64     },
     56    }
    6557
    66     domStorageItemUpdated: function(storageId, key, oldValue, value)
     58    domStorageItemUpdated(storageId, key, oldValue, value)
    6759    {
    6860        WebInspector.storageManager.itemUpdated(storageId, key, oldValue, value);
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/DatabaseObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.DatabaseObserver = function()
     26WebInspector.DatabaseObserver = class DatabaseObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.DatabaseObserver._callbacks = {};
    33 
    34 WebInspector.DatabaseObserver.prototype = {
    35     constructor: WebInspector.DatabaseObserver,
    36 
    3728    // Events defined by the "Database" domain.
    3829
    39     addDatabase: function(database)
     30    addDatabase(database)
    4031    {
    4132        WebInspector.storageManager.databaseWasAdded(database.id, database.domain, database.name, database.version);
    42     },
     33    }
    4334
    4435    // COMPATIBILITY (iOS 6): This event was removed in favor of a more async DatabaseAgent.executeSQL.
    45     sqlTransactionSucceeded: function(transactionId, columnNames, values)
     36    sqlTransactionSucceeded(transactionId, columnNames, values)
    4637    {
    4738        if (!WebInspector.DatabaseObserver._callbacks[transactionId])
     
    5344        if (callback)
    5445            callback(columnNames, values, null);
    55     },
     46    }
    5647
    5748    // COMPATIBILITY (iOS 6): This event was removed in favor of a more async DatabaseAgent.executeSQL.
    58     sqlTransactionFailed: function(transactionId, sqlError)
     49    sqlTransactionFailed(transactionId, sqlError)
    5950    {
    6051        if (!WebInspector.DatabaseObserver._callbacks[transactionId])
     
    6960};
    7061
    71 WebInspector.DatabaseObserver.prototype.__proto__ = WebInspector.Object.prototype;
     62WebInspector.DatabaseObserver._callbacks = {};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/DebuggerObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.DebuggerObserver = function()
     26WebInspector.DebuggerObserver = class DebuggerObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.DebuggerObserver.prototype = {
    33     constructor: WebInspector.DebuggerObserver,
    34 
    3528    // Events defined by the "Debugger" domain.
    3629
    37     globalObjectCleared: function()
     30    globalObjectCleared()
    3831    {
    3932        WebInspector.debuggerManager.reset();
    40     },
     33    }
    4134
    42     scriptParsed: function(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
     35    scriptParsed(scriptId, url, startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL)
    4336    {
    4437        WebInspector.debuggerManager.scriptDidParse(scriptId, url, isContentScript, startLine, startColumn, endLine, endColumn, sourceMapURL);
    45     },
     38    }
    4639
    47     scriptFailedToParse: function(url, scriptSource, startLine, errorLine, errorMessage)
     40    scriptFailedToParse(url, scriptSource, startLine, errorLine, errorMessage)
    4841    {
    4942        // FIXME: Not implemented.
    50     },
     43    }
    5144
    52     breakpointResolved: function(breakpointId, location)
     45    breakpointResolved(breakpointId, location)
    5346    {
    5447        WebInspector.debuggerManager.breakpointResolved(breakpointId, location);
    55     },
     48    }
    5649
    57     paused: function(callFrames, reason, data)
     50    paused(callFrames, reason, data)
    5851    {
    5952        WebInspector.debuggerManager.debuggerDidPause(callFrames, reason, data);
    60     },
     53    }
    6154
    62     resumed: function()
     55    resumed()
    6356    {
    6457        WebInspector.debuggerManager.debuggerDidResume();
    65     },
     58    }
    6659
    67     playBreakpointActionSound: function(breakpointActionIdentifier)
     60    playBreakpointActionSound(breakpointActionIdentifier)
    6861    {
    6962        WebInspector.debuggerManager.playBreakpointActionSound(breakpointActionIdentifier);
    70     },
     63    }
    7164
    72     didSampleProbe: function(sample)
     65    didSampleProbe(sample)
    7366    {
    7467        WebInspector.probeManager.didSampleProbe(sample);
    7568    }
    7669};
    77 
    78 WebInspector.DebuggerObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js

    r180384 r182039  
    3131 */
    3232
    33 function InspectorBackendClass()
     33InspectorBackendClass = class InspectorBackendClass
    3434{
    35     this._lastSequenceId = 1;
    36     this._pendingResponsesCount = 0;
    37     this._callbackData = new Map;
    38     this._agents = {};
    39     this._deferredScripts = [];
    40 
    41     this.dumpInspectorTimeStats = false;
    42     this.dumpInspectorProtocolMessages = false;
    43     this.warnForLongMessageHandling = false;
    44     this.longMessageHandlingThreshold = 10; // milliseconds.
    45 }
    46 
    47 InspectorBackendClass.prototype = {
     35    constructor()
     36    {
     37        this._lastSequenceId = 1;
     38        this._pendingResponsesCount = 0;
     39        this._callbackData = new Map;
     40        this._agents = {};
     41        this._deferredScripts = [];
     42
     43        this.dumpInspectorTimeStats = false;
     44        this.dumpInspectorProtocolMessages = false;
     45        this.warnForLongMessageHandling = false;
     46        this.longMessageHandlingThreshold = 10; // milliseconds.
     47    }
    4848
    4949    // Public
    5050
    51     registerCommand: function(qualifiedName, callSignature, replySignature)
     51    registerCommand(qualifiedName, callSignature, replySignature)
    5252    {
    5353        var [domainName, commandName] = qualifiedName.split(".");
    5454        var agent = this._agentForDomain(domainName);
    5555        agent.addCommand(InspectorBackend.Command.create(this, qualifiedName, callSignature, replySignature));
    56     },
    57 
    58     registerEnum: function(qualifiedName, enumValues)
     56    }
     57
     58    registerEnum(qualifiedName, enumValues)
    5959    {
    6060        var [domainName, enumName] = qualifiedName.split(".");
    6161        var agent = this._agentForDomain(domainName);
    6262        agent.addEnum(enumName, enumValues);
    63     },
    64 
    65     registerEvent: function(qualifiedName, signature)
     63    }
     64
     65    registerEvent(qualifiedName, signature)
    6666    {
    6767        var [domainName, eventName] = qualifiedName.split(".");
    6868        var agent = this._agentForDomain(domainName);
    6969        agent.addEvent(new InspectorBackend.Event(eventName, signature));
    70     },
    71 
    72     registerDomainDispatcher: function(domainName, dispatcher)
     70    }
     71
     72    registerDomainDispatcher(domainName, dispatcher)
    7373    {
    7474        var agent = this._agentForDomain(domainName);
    7575        agent.dispatcher = dispatcher;
    76     },
    77 
    78     dispatch: function(message)
     76    }
     77
     78    dispatch(message)
    7979    {
    8080        if (this.dumpInspectorProtocolMessages)
     
    8787        else
    8888            this._dispatchEvent(messageObject);
    89     },
    90 
    91     runAfterPendingDispatches: function(script)
     89    }
     90
     91    runAfterPendingDispatches(script)
    9292    {
    9393        console.assert(script);
     
    9898        else
    9999            this._deferredScripts.push(script);
    100     },
    101 
    102     activateDomain: function(domainName, activationDebuggableType)
     100    }
     101
     102    activateDomain(domainName, activationDebuggableType)
    103103    {
    104104        if (!activationDebuggableType || InspectorFrontendHost.debuggableType() === activationDebuggableType) {
     
    109109
    110110        return null;
    111     },
     111    }
    112112
    113113    // Private
    114114
    115     _agentForDomain: function(domainName)
     115    _agentForDomain(domainName)
    116116    {
    117117        if (this._agents[domainName])
     
    121121        this._agents[domainName] = agent;
    122122        return agent;
    123     },
    124 
    125     _willSendMessageToBackend: function(command, callback)
     123    }
     124
     125    _willSendMessageToBackend(command, callback)
    126126    {
    127127        ++this._pendingResponsesCount;
     
    141141
    142142        return sequenceId;
    143     },
    144 
    145     _dispatchCallback: function(messageObject)
     143    }
     144
     145    _dispatchCallback(messageObject)
    146146    {
    147147        --this._pendingResponsesCount;
     
    196196        if (this._deferredScripts.length && !this._pendingResponsesCount)
    197197            this._flushPendingScripts();
    198     },
    199 
    200     _dispatchEvent: function(messageObject)
     198    }
     199
     200    _dispatchEvent(messageObject)
    201201    {
    202202        var qualifiedName = messageObject["method"];
     
    242242        if (this.dumpInspectorTimeStats)
    243243            console.log("time-stats: Handling: " + processingDuration + "ms (event " + messageObject["method"] + ")");
    244     },
    245 
    246     _invokeCommand: function(command, parameters, callback)
     244    }
     245
     246    _invokeCommand(command, parameters, callback)
    247247    {
    248248        var messageObject = {};
     
    261261
    262262        InspectorFrontendHost.sendMessageToBackend(stringifiedMessage);
    263     },
    264 
    265     _reportProtocolError: function(messageObject)
     263    }
     264
     265    _reportProtocolError(messageObject)
    266266    {
    267267        console.error("Request with id = " + messageObject["id"] + " failed. " + JSON.stringify(messageObject["error"]));
    268     },
    269 
    270     _flushPendingScripts: function()
     268    }
     269
     270    _flushPendingScripts()
    271271    {
    272272        console.assert(!this._pendingResponsesCount);
     
    277277            script.call(this);
    278278    }
    279 }
    280 
    281 InspectorBackend = new InspectorBackendClass();
    282 
    283 InspectorBackend.Agent = function(domainName)
     279};
     280
     281InspectorBackend = new InspectorBackendClass;
     282
     283InspectorBackend.Agent = class InspectorBackendAgent
    284284{
    285     this._domainName = domainName;
    286 
    287     // Agents are always created, but are only useable after they are activated.
    288     this._active = false;
    289 
    290     // Commands are stored directly on the Agent instance using their unqualified
    291     // method name as the property. Thus, callers can write: FooAgent.methodName().
    292     // Enums are stored similarly based on the unqualified type name.
    293     this._events = {};
    294 }
    295 
    296 InspectorBackend.Agent.prototype = {
     285    constructor(domainName)
     286    {
     287        this._domainName = domainName;
     288
     289        // Agents are always created, but are only useable after they are activated.
     290        this._active = false;
     291
     292        // Commands are stored directly on the Agent instance using their unqualified
     293        // method name as the property. Thus, callers can write: FooAgent.methodName().
     294        // Enums are stored similarly based on the unqualified type name.
     295        this._events = {};
     296    }
     297
     298    // Public
     299
    297300    get domainName()
    298301    {
    299302        return this._domainName;
    300     },
     303    }
    301304
    302305    get active()
    303306    {
    304307        return this._active;
    305     },
     308    }
    306309
    307310    set dispatcher(value)
    308311    {
    309312        this._dispatcher = value;
    310     },
    311 
    312     addEnum: function(enumName, enumValues)
     313    }
     314
     315    addEnum(enumName, enumValues)
    313316    {
    314317        this[enumName] = enumValues;
    315     },
    316 
    317     addCommand: function(command)
     318    }
     319
     320    addCommand(command)
    318321    {
    319322        this[command.commandName] = command;
    320     },
    321 
    322     addEvent: function(event)
     323    }
     324
     325    addEvent(event)
    323326    {
    324327        this._events[event.eventName] = event;
    325     },
    326 
    327     getEvent: function(eventName)
     328    }
     329
     330    getEvent(eventName)
    328331    {
    329332        return this._events[eventName];
    330     },
    331 
    332     hasEvent: function(eventName)
     333    }
     334
     335    hasEvent(eventName)
    333336    {
    334337        return eventName in this._events;
    335     },
    336 
    337     activate: function()
     338    }
     339
     340    activate()
    338341    {
    339342        this._active = true;
    340343        window[this._domainName + "Agent"] = this;
    341     },
    342 
    343     dispatchEvent: function(eventName, eventArguments)
     344    }
     345
     346    dispatchEvent(eventName, eventArguments)
    344347    {
    345348        if (!(eventName in this._dispatcher)) {
     
    351354        return true;
    352355    }
    353 }
    354 
     356};
     357
     358// InspectorBackend.Command can't use ES6 classes because of its trampoline nature.
     359// But we can use strict mode to get stricter handling of the code inside its functions.
    355360InspectorBackend.Command = function(backend, qualifiedName, callSignature, replySignature)
    356361{
     362    'use strict';
     363
    357364    this._backend = backend;
    358365    this._instance = this;
     
    363370    this._callSignature = callSignature || [];
    364371    this._replySignature = replySignature || [];
    365 }
     372};
    366373
    367374InspectorBackend.Command.create = function(backend, commandName, callSignature, replySignature)
    368375{
     376    'use strict';
     377
    369378    var instance = new InspectorBackend.Command(backend, commandName, callSignature, replySignature);
    370379
     
    373382        if (!arguments.length || typeof arguments[arguments.length - 1] !== "function")
    374383            return instance.promise.apply(instance, arguments);
    375 
    376384        return instance._invokeWithArguments.apply(instance, arguments);
    377385    }
     386
    378387    callable._instance = instance;
    379388    callable.__proto__ = InspectorBackend.Command.prototype;
     389
    380390    return callable;
    381 }
     391};
    382392
    383393// As part of the workaround to make commands callable, these functions use |this._instance|.
     
    410420    invoke: function(commandArguments, callback)
    411421    {
     422        'use strict';
     423
    412424        var instance = this._instance;
    413425        instance._backend._invokeCommand(instance, commandArguments, callback);
     
    416428    promise: function()
    417429    {
     430        'use strict';
     431
    418432        var instance = this._instance;
    419433        var promiseArguments = Array.from(arguments);
     
    422436                return error ? reject(error) : resolve(payload);
    423437            }
     438
    424439            // FIXME: this should be indicated by invoking the command differently, rather
    425440            // than by setting a magical property on the callback. <webkit.org/b/132386>
     
    433448    supports: function(parameterName)
    434449    {
     450        'use strict';
     451
    435452        var instance = this._instance;
    436453        return instance.callSignature.some(function(parameter) {
     
    443460    _invokeWithArguments: function()
    444461    {
     462        'use strict';
     463
    445464        var instance = this._instance;
    446465        var commandArguments = Array.from(arguments);
     
    479498
    480499        instance._backend._invokeCommand(instance, Object.keys(parameters).length ? parameters : null, callback);
    481     },
    482 }
    483 
    484 InspectorBackend.Event = function(eventName, parameterNames)
     500    }
     501};
     502
     503InspectorBackend.Event = class Event
    485504{
    486     this.eventName = eventName;
    487     this.parameterNames = parameterNames;
    488 }
     505    constructor(eventName, parameterNames)
     506    {
     507        this.eventName = eventName;
     508        this.parameterNames = parameterNames;
     509    }
     510};
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/InspectorObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013, 2014 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013-2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.InspectorObserver = function()
     26WebInspector.InspectorObserver = class InspectorObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.InspectorObserver.prototype = {
    33     constructor: WebInspector.InspectorObserver,
    34 
    3528    // Events defined by the "Inspector" domain.
    3629
    37     evaluateForTestInFrontend: function(script)
     30    evaluateForTestInFrontend(script)
    3831    {
    3932        if (!InspectorFrontendHost.isUnderTest())
     
    4336            window.eval(script);
    4437        });
    45     },
     38    }
    4639
    47     inspect: function(payload, hints)
     40    inspect(payload, hints)
    4841    {
    4942        var remoteObject = WebInspector.RemoteObject.fromPayload(payload);
     
    6255
    6356        remoteObject.release();
    64     },
     57    }
    6558
    66     detached: function(reason)
     59    detached(reason)
    6760    {
    6861        // FIXME: Not implemented.
    69     },
     62    }
    7063
    71     activateExtraDomains: function(domains)
     64    activateExtraDomains(domains)
    7265    {
    7366        WebInspector.activateExtraDomains(domains);
    7467    }
    7568};
    76 
    77 WebInspector.InspectorObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/LayerTreeObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    1818 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    1919 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OdF LIABILITY, WHETHER IN
    2121 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    2222 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
     
    2424 */
    2525
    26 WebInspector.LayerTreeObserver = function()
     26WebInspector.LayerTreeObserver = class LayerTreeObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.LayerTreeObserver.prototype = {
    33     constructor: WebInspector.LayerTreeObserver,
    34 
    3528    // Events defined by the "LayerTree" domain.
    3629
    37     layerTreeDidChange: function()
     30    layerTreeDidChange()
    3831    {
    3932        if (WebInspector.layerTreeManager.supported)
     
    4134    }
    4235};
    43 
    44 WebInspector.LayerTreeObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/MessageDispatcher.js

    r173431 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 * Copyright (C) 2014 University of Washington
    44 *
     
    2525 */
    2626
    27 WebInspector.messagesToDispatch = [];
     27WebInspector._messagesToDispatch = [];
    2828
    2929WebInspector.dispatchNextQueuedMessageFromBackend = function()
    3030{
    31     var startCount = WebInspector.messagesToDispatch.length;
     31    var startCount = WebInspector._messagesToDispatch.length;
    3232    var startTime = Date.now();
    3333    var timeLimitPerRunLoop = 10; // milliseconds
    3434
    3535    var i = 0;
    36     for (; i < WebInspector.messagesToDispatch.length; ++i) {
     36    for (; i < WebInspector._messagesToDispatch.length; ++i) {
    3737        // Defer remaining messages if we have taken too long. In practice, single
    3838        // messages like Page.getResourceContent blow through the time budget.
     
    4040            break;
    4141
    42         InspectorBackend.dispatch(WebInspector.messagesToDispatch[i]);
     42        InspectorBackend.dispatch(WebInspector._messagesToDispatch[i]);
    4343    }
    4444
    45     if (i === WebInspector.messagesToDispatch.length) {
    46         WebInspector.messagesToDispatch = [];
     45    if (i === WebInspector._messagesToDispatch.length) {
     46        WebInspector._messagesToDispatch = [];
    4747        WebInspector._dispatchTimeout = null;
    4848    } else {
    49         WebInspector.messagesToDispatch = WebInspector.messagesToDispatch.slice(i);
     49        WebInspector._messagesToDispatch = WebInspector._messagesToDispatch.slice(i);
    5050        WebInspector._dispatchTimeout = setTimeout(WebInspector.dispatchNextQueuedMessageFromBackend, 0);
    5151    }
    5252
    5353    if (InspectorBackend.dumpInspectorTimeStats)
    54         console.log("time-stats: --- RunLoop duration: " + (Date.now() - startTime) + "ms; dispatched: " + (startCount - WebInspector.messagesToDispatch.length) + "; remaining: " + WebInspector.messagesToDispatch.length);
     54        console.log("time-stats: --- RunLoop duration: " + (Date.now() - startTime) + "ms; dispatched: " + (startCount - WebInspector._messagesToDispatch.length) + "; remaining: " + WebInspector._messagesToDispatch.length);
    5555};
    5656
     
    6060    // The messages are dequeued on a zero delay timeout.
    6161
    62     this.messagesToDispatch.push(message);
     62    WebInspector._messagesToDispatch.push(message);
    6363
    6464    if (this._dispatchTimeout)
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/NetworkObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.NetworkObserver = function()
     26WebInspector.NetworkObserver = class NetworkObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.NetworkObserver.prototype = {
    33     constructor: WebInspector.NetworkObserver,
    34 
    3528    // Events defined by the "Network" domain.
    3629
    37     requestWillBeSent: function(requestId, frameId, loaderId, documentURL, request, timestamp, initiator, redirectResponse, type)
     30    requestWillBeSent(requestId, frameId, loaderId, documentURL, request, timestamp, initiator, redirectResponse, type)
    3831    {
    3932        WebInspector.frameResourceManager.resourceRequestWillBeSent(requestId, frameId, loaderId, request, type, redirectResponse, timestamp, initiator);
    40     },
     33    }
    4134
    42     requestServedFromCache: function(requestId)
     35    requestServedFromCache(requestId)
    4336    {
    4437        WebInspector.frameResourceManager.markResourceRequestAsServedFromMemoryCache(requestId);
    45     },
     38    }
    4639
    47     responseReceived: function(requestId, frameId, loaderId, timestamp, type, response)
     40    responseReceived(requestId, frameId, loaderId, timestamp, type, response)
    4841    {
    4942        WebInspector.frameResourceManager.resourceRequestDidReceiveResponse(requestId, frameId, loaderId, type, response, timestamp);
    50     },
     43    }
    5144
    52     dataReceived: function(requestId, timestamp, dataLength, encodedDataLength)
     45    dataReceived(requestId, timestamp, dataLength, encodedDataLength)
    5346    {
    5447        WebInspector.frameResourceManager.resourceRequestDidReceiveData(requestId, dataLength, encodedDataLength, timestamp);
    55     },
     48    }
    5649
    57     loadingFinished: function(requestId, timestamp, sourceMapURL)
     50    loadingFinished(requestId, timestamp, sourceMapURL)
    5851    {
    5952        WebInspector.frameResourceManager.resourceRequestDidFinishLoading(requestId, timestamp, sourceMapURL);
    60     },
     53    }
    6154
    62     loadingFailed: function(requestId, timestamp, errorText, canceled)
     55    loadingFailed(requestId, timestamp, errorText, canceled)
    6356    {
    6457        WebInspector.frameResourceManager.resourceRequestDidFailLoading(requestId, canceled, timestamp);
    65     },
     58    }
    6659
    67     requestServedFromMemoryCache: function(requestId, frameId, loaderId, documentURL, timestamp, initiator, resource)
     60    requestServedFromMemoryCache(requestId, frameId, loaderId, documentURL, timestamp, initiator, resource)
    6861    {
    6962        WebInspector.frameResourceManager.resourceRequestWasServedFromMemoryCache(requestId, frameId, loaderId, resource, timestamp, initiator);
    70     },
     63    }
    7164
    72     webSocketWillSendHandshakeRequest: function(requestId, timestamp, request)
     65    webSocketWillSendHandshakeRequest(requestId, timestamp, request)
    7366    {
    7467        // FIXME: Not implemented.
    75     },
     68    }
    7669
    77     webSocketHandshakeResponseReceived: function(requestId, timestamp, response)
     70    webSocketHandshakeResponseReceived(requestId, timestamp, response)
    7871    {
    7972        // FIXME: Not implemented.
    80     },
     73    }
    8174
    82     webSocketCreated: function(requestId, url)
     75    webSocketCreated(requestId, url)
    8376    {
    8477        // FIXME: Not implemented.
    85     },
     78    }
    8679
    87     webSocketClosed: function(requestId, timestamp)
     80    webSocketClosed(requestId, timestamp)
    8881    {
    8982        // FIXME: Not implemented.
    90     },
     83    }
    9184
    92     webSocketFrameReceived: function(requestId, timestamp, response)
     85    webSocketFrameReceived(requestId, timestamp, response)
    9386    {
    9487        // FIXME: Not implemented.
    95     },
     88    }
    9689
    97     webSocketFrameError: function(requestId, timestamp, errorMessage)
     90    webSocketFrameError(requestId, timestamp, errorMessage)
    9891    {
    9992        // FIXME: Not implemented.
    100     },
     93    }
    10194
    102     webSocketFrameSent: function(requestId, timestamp, response)
     95    webSocketFrameSent(requestId, timestamp, response)
    10396    {
    10497        // FIXME: Not implemented.
    10598    }
    10699};
    107 
    108 WebInspector.NetworkObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/PageObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.PageObserver = function()
     26WebInspector.PageObserver = class PageObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.PageObserver.prototype = {
    33     constructor: WebInspector.PageObserver,
    34 
    3528    // Events defined by the "Page" domain.
    3629
    37     domContentEventFired: function(timestamp)
     30    domContentEventFired(timestamp)
    3831    {
    3932        // Covered by Timeline "MarkDOMContent" record.
    40     },
     33    }
    4134
    42     loadEventFired: function(timestamp)
     35    loadEventFired(timestamp)
    4336    {
    4437        WebInspector.timelineManager.pageDidLoad(timestamp);
    45     },
     38    }
    4639
    47     frameNavigated: function(frame, loaderId)
     40    frameNavigated(frame, loaderId)
    4841    {
    4942        WebInspector.frameResourceManager.frameDidNavigate(frame, loaderId);
    50     },
     43    }
    5144
    52     frameDetached: function(frameId)
     45    frameDetached(frameId)
    5346    {
    5447        WebInspector.frameResourceManager.frameDidDetach(frameId);
    55     },
     48    }
    5649
    57     frameStartedLoading: function(frameId)
     50    frameStartedLoading(frameId)
    5851    {
    5952        // Not handled yet.
    60     },
     53    }
    6154
    62     frameStoppedLoading: function(frameId)
     55    frameStoppedLoading(frameId)
    6356    {
    6457        // Not handled yet.
    65     },
     58    }
    6659
    67     frameScheduledNavigation: function(frameId, delay)
     60    frameScheduledNavigation(frameId, delay)
    6861    {
    6962        // Not handled yet.
    70     },
     63    }
    7164
    72     frameClearedScheduledNavigation: function(frameId)
     65    frameClearedScheduledNavigation(frameId)
    7366    {
    7467        // Not handled yet.
    75     },
     68    }
    7669
    77     javascriptDialogOpening: function(message)
     70    javascriptDialogOpening(message)
    7871    {
    7972        // Not handled yet.
    80     },
     73    }
    8174
    82     javascriptDialogClosed: function()
     75    javascriptDialogClosed()
    8376    {
    8477        // Not handled yet.
    85     },
     78    }
    8679
    87     scriptsEnabled: function(enabled)
     80    scriptsEnabled(enabled)
    8881    {
    8982        // Not handled yet.
    9083    }
    9184};
    92 
    93 WebInspector.PageObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

    r181930 r182039  
    11/*
    22 * Copyright (C) 2009 Google Inc. All rights reserved.
     3 * Copyright (C) 2015 Apple Inc. All rights reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    2930 */
    3031
    31 WebInspector.RemoteObject = function(objectId, type, subtype, value, description, size, preview)
     32WebInspector.RemoteObject = class RemoteObject
    3233{
    33     // No superclass.
    34 
    35     console.assert(type);
    36     console.assert(!preview || preview instanceof WebInspector.ObjectPreview);
    37 
    38     this._type = type;
    39     this._subtype = subtype;
    40 
    41     if (objectId) {
    42         // Object or Symbol.
    43         console.assert(!subtype || typeof subtype === "string");
    44         console.assert(!description || typeof description === "string");
    45         console.assert(!value);
    46 
    47         this._objectId = objectId;
    48         this._description = description;
    49         this._hasChildren = type !== "symbol";
    50         this._size = size;
    51         this._preview = preview;
    52     } else {
    53         // Primitive or null.
    54         console.assert(type !== "object" || value === null);
    55         console.assert(!preview);
    56 
    57         this._description = description || (value + "");
    58         this._hasChildren = false;
    59         this._value = value;
    60     }
    61 };
    62 
    63 WebInspector.RemoteObject.fromPrimitiveValue = function(value)
    64 {
    65     return new WebInspector.RemoteObject(undefined, typeof value, undefined, undefined, value);
    66 };
    67 
    68 WebInspector.RemoteObject.fromPayload = function(payload)
    69 {
    70     console.assert(typeof payload === "object", "Remote object payload should only be an object");
    71 
    72     if (payload.subtype === "array") {
    73         // COMPATIBILITY (iOS 8): Runtime.RemoteObject did not have size property,
    74         // instead it was tacked onto the end of the description, like "Array[#]".
    75         var match = payload.description.match(/\[(\d+)\]$/);
    76         if (match) {
    77             payload.size = parseInt(match[1]);
    78             payload.description = payload.description.replace(/\[\d+\]$/, "");
    79         }
    80     }
    81 
    82     if (payload.preview) {
    83         // COMPATIBILITY (iOS 8): iOS 7 and 8 did not have type/subtype/description on
    84         // Runtime.ObjectPreview. Copy them over from the RemoteObject.
    85         if (!payload.preview.type) {
    86             payload.preview.type = payload.type;
    87             payload.preview.subtype = payload.subtype;
    88             payload.preview.description = payload.description;
    89             payload.preview.size = payload.size;
    90         }
    91         payload.preview = WebInspector.ObjectPreview.fromPayload(payload.preview);
    92     }
    93 
    94     return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.size, payload.preview);
    95 };
    96 
    97 WebInspector.RemoteObject.createCallArgument = function(valueOrObject)
    98 {
    99     if (valueOrObject instanceof WebInspector.RemoteObject) {
    100         if (valueOrObject.objectId)
    101             return {objectId: valueOrObject.objectId};
    102         return {value: valueOrObject.value};
    103     }
    104 
    105     return {value: valueOrObject};
    106 };
    107 
    108 WebInspector.RemoteObject.resolveNode = function(node, objectGroup, callback)
    109 {
    110     DOMAgent.resolveNode(node.id, objectGroup, function(error, object) {
    111         if (!callback)
    112             return;
    113 
    114         if (error || !object)
    115             callback(null);
    116         else
    117             callback(WebInspector.RemoteObject.fromPayload(object));
    118     });
    119 };
    120 
    121 WebInspector.RemoteObject.type = function(remoteObject)
    122 {
    123     if (remoteObject === null)
    124         return "null";
    125 
    126     var type = typeof remoteObject;
    127     if (type !== "object" && type !== "function")
    128         return type;
    129 
    130     return remoteObject.type;
    131 };
    132 
    133 WebInspector.RemoteObject.prototype = {
    134     constructor: WebInspector.RemoteObject,
     34    constructor(objectId, type, subtype, value, description, size, preview)
     35    {
     36        console.assert(type);
     37        console.assert(!preview || preview instanceof WebInspector.ObjectPreview);
     38
     39        this._type = type;
     40        this._subtype = subtype;
     41
     42        if (objectId) {
     43            // Object or Symbol.
     44            console.assert(!subtype || typeof subtype === "string");
     45            console.assert(!description || typeof description === "string");
     46            console.assert(!value);
     47
     48            this._objectId = objectId;
     49            this._description = description;
     50            this._hasChildren = type !== "symbol";
     51            this._size = size;
     52            this._preview = preview;
     53        } else {
     54            // Primitive or null.
     55            console.assert(type !== "object" || value === null);
     56            console.assert(!preview);
     57
     58            this._description = description || (value + "");
     59            this._hasChildren = false;
     60            this._value = value;
     61        }
     62    }
     63
     64    // Static
     65
     66    static fromPrimitiveValue(value)
     67    {
     68        return new WebInspector.RemoteObject(undefined, typeof value, undefined, undefined, value);
     69    }
     70
     71    static fromPayload(payload)
     72    {
     73        console.assert(typeof payload === "object", "Remote object payload should only be an object");
     74
     75        if (payload.subtype === "array") {
     76            // COMPATIBILITY (iOS 8): Runtime.RemoteObject did not have size property,
     77            // instead it was tacked onto the end of the description, like "Array[#]".
     78            var match = payload.description.match(/\[(\d+)\]$/);
     79            if (match) {
     80                payload.size = parseInt(match[1]);
     81                payload.description = payload.description.replace(/\[\d+\]$/, "");
     82            }
     83        }
     84
     85        if (payload.preview) {
     86            // COMPATIBILITY (iOS 8): iOS 7 and 8 did not have type/subtype/description on
     87            // Runtime.ObjectPreview. Copy them over from the RemoteObject.
     88            if (!payload.preview.type) {
     89                payload.preview.type = payload.type;
     90                payload.preview.subtype = payload.subtype;
     91                payload.preview.description = payload.description;
     92                payload.preview.size = payload.size;
     93            }
     94
     95            payload.preview = WebInspector.ObjectPreview.fromPayload(payload.preview);
     96        }
     97
     98        return new WebInspector.RemoteObject(payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.size, payload.preview);
     99    }
     100
     101    static createCallArgument(valueOrObject)
     102    {
     103        if (valueOrObject instanceof WebInspector.RemoteObject) {
     104            if (valueOrObject.objectId)
     105                return {objectId: valueOrObject.objectId};
     106            return {value: valueOrObject.value};
     107        }
     108
     109        return {value: valueOrObject};
     110    }
     111
     112    static resolveNode(node, objectGroup, callback)
     113    {
     114        DOMAgent.resolveNode(node.id, objectGroup, function(error, object) {
     115            if (!callback)
     116                return;
     117
     118            if (error || !object)
     119                callback(null);
     120            else
     121                callback(WebInspector.RemoteObject.fromPayload(object));
     122        });
     123    }
     124
     125    static type(remoteObject)
     126    {
     127        if (remoteObject === null)
     128            return "null";
     129
     130        var type = typeof remoteObject;
     131        if (type !== "object" && type !== "function")
     132            return type;
     133
     134        return remoteObject.type;
     135    }
     136
     137    // Public
    135138
    136139    get objectId()
    137140    {
    138141        return this._objectId;
    139     },
     142    }
    140143
    141144    get type()
    142145    {
    143146        return this._type;
    144     },
     147    }
    145148
    146149    get subtype()
    147150    {
    148151        return this._subtype;
    149     },
     152    }
    150153
    151154    get description()
    152155    {
    153156        return this._description;
    154     },
     157    }
    155158
    156159    get hasChildren()
    157160    {
    158161        return this._hasChildren;
    159     },
     162    }
    160163
    161164    get value()
    162165    {
    163166        return this._value;
    164     },
     167    }
    165168
    166169    get size()
    167170    {
    168171        return this._size || 0;
    169     },
     172    }
    170173
    171174    get preview()
    172175    {
    173176        return this._preview;
    174     },
    175 
    176     hasSize: function()
     177    }
     178
     179    hasSize()
    177180    {
    178181        return this.isArray() || this.isCollectionType();
    179     },
    180 
    181     hasValue: function()
     182    }
     183
     184    hasValue()
    182185    {
    183186        return "_value" in this;
    184     },
    185 
    186     getOwnPropertyDescriptors: function(callback)
     187    }
     188
     189    getOwnPropertyDescriptors(callback)
    187190    {
    188191        this._getPropertyDescriptors(true, callback);
    189     },
    190 
    191     getAllPropertyDescriptors: function(callback)
     192    }
     193
     194    getAllPropertyDescriptors(callback)
    192195    {
    193196        this._getPropertyDescriptors(false, callback);
    194     },
    195 
    196     getDisplayablePropertyDescriptors: function(callback)
     197    }
     198
     199    getDisplayablePropertyDescriptors(callback)
    197200    {
    198201        if (!this._objectId || this._isSymbol()) {
     
    221224                    }
    222225                }
     226
    223227                this._getPropertyDescriptorsResolver(callback, error, ownOrGetterPropertiesList);
    224228            }.bind(this));
     
    227231
    228232        RuntimeAgent.getDisplayableProperties(this._objectId, true, this._getPropertyDescriptorsResolver.bind(this, callback));
    229     },
    230 
    231     _getPropertyDescriptors: function(ownProperties, callback)
    232     {
    233         if (!this._objectId || this._isSymbol()) {
    234             callback([]);
    235             return;
    236         }
    237 
    238 
    239         RuntimeAgent.getProperties(this._objectId, ownProperties, true, this._getPropertyDescriptorsResolver.bind(this, callback));
    240     },
    241 
    242     _getPropertyDescriptorsResolver: function(callback, error, properties, internalProperties)
    243     {
    244         if (error) {
    245             callback(null);
    246             return;
    247         }
    248 
    249         var descriptors = properties.map(function(payload) {
    250             return WebInspector.PropertyDescriptor.fromPayload(payload);
    251         });
    252 
    253         if (internalProperties) {
    254             descriptors = descriptors.concat(internalProperties.map(function(payload) {
    255                 return WebInspector.PropertyDescriptor.fromPayload(payload, true);
    256             }));
    257         }
    258 
    259         callback(descriptors);
    260     },
    261 
    262     // FIXME: Phase out these functions. They return RemoteObjectProperty instead of PropertyDescriptors.
    263 
    264     deprecatedGetOwnProperties: function(callback)
     233    }
     234
     235    // FIXME: Phase out these deprecated functions. They return DeprecatedRemoteObjectProperty instead of PropertyDescriptors.
     236    deprecatedGetOwnProperties(callback)
    265237    {
    266238        this._deprecatedGetProperties(true, callback);
    267     },
    268 
    269     deprecatedGetAllProperties: function(callback)
     239    }
     240
     241    deprecatedGetAllProperties(callback)
    270242    {
    271243        this._deprecatedGetProperties(false, callback);
    272     },
    273 
    274     _deprecatedGetProperties: function(ownProperties, callback)
    275     {
    276         if (!this._objectId || this._isSymbol()) {
    277             callback([]);
    278             return;
    279         }
    280 
    281         RuntimeAgent.getProperties(this._objectId, ownProperties, this._deprecatedGetPropertiesResolver.bind(this, callback));
    282     },
    283 
    284     deprecatedGetDisplayableProperties: function(callback)
     244    }
     245
     246    deprecatedGetDisplayableProperties(callback)
    285247    {
    286248        if (!this._objectId || this._isSymbol()) {
     
    308270                    }
    309271                }
     272
    310273                this._deprecatedGetPropertiesResolver(callback, error, ownOrGetterPropertiesList);
    311274            }.bind(this));
     
    314277
    315278        RuntimeAgent.getDisplayableProperties(this._objectId, this._deprecatedGetPropertiesResolver.bind(this, callback));
    316     },
    317 
    318     _deprecatedGetPropertiesResolver: function(callback, error, properties, internalProperties)
     279    }
     280
     281    setPropertyValue(name, value, callback)
     282    {
     283        if (!this._objectId || this._isSymbol()) {
     284            callback("Can't set a property of non-object.");
     285            return;
     286        }
     287
     288        RuntimeAgent.evaluate.invoke({expression:value, doNotPauseOnExceptionsAndMuteConsole:true}, evaluatedCallback.bind(this));
     289
     290        function evaluatedCallback(error, result, wasThrown)
     291        {
     292            if (error || wasThrown) {
     293                callback(error || result.description);
     294                return;
     295            }
     296
     297            function setPropertyValue(propertyName, propertyValue)
     298            {
     299                this[propertyName] = propertyValue;
     300            }
     301
     302            delete result.description; // Optimize on traffic.
     303
     304            RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [{value:name}, result], true, undefined, propertySetCallback.bind(this));
     305
     306            if (result._objectId)
     307                RuntimeAgent.releaseObject(result._objectId);
     308        }
     309
     310        function propertySetCallback(error, result, wasThrown)
     311        {
     312            if (error || wasThrown) {
     313                callback(error || result.description);
     314                return;
     315            }
     316
     317            callback();
     318        }
     319    }
     320
     321    isArray()
     322    {
     323        return this._subtype === "array";
     324    }
     325
     326    isCollectionType()
     327    {
     328        return this._subtype === "map" || this._subtype === "set" || this._subtype === "weakmap";
     329    }
     330
     331    isWeakCollection()
     332    {
     333        return this._subtype === "weakmap";
     334    }
     335
     336    getCollectionEntries(start, numberToFetch, callback)
     337    {
     338        start = typeof start === "number" ? start : 0;
     339        numberToFetch = typeof numberToFetch === "number" ? numberToFetch : 100;
     340
     341        console.assert(start >= 0);
     342        console.assert(numberToFetch >= 0);
     343        console.assert(this.isCollectionType());
     344
     345        // WeakMaps are not ordered. We should never send a non-zero start.
     346        console.assert((this._subtype === "weakmap" && start === 0) || this._subtype !== "weakmap");
     347
     348        var objectGroup = this.isWeakCollection() ? this._weakCollectionObjectGroup() : "";
     349
     350        RuntimeAgent.getCollectionEntries(this._objectId, objectGroup, start, numberToFetch, function(error, entries) {
     351            entries = entries.map(function(entry) { return WebInspector.CollectionEntry.fromPayload(entry); });
     352            callback(entries);
     353        });
     354    }
     355
     356    releaseWeakCollectionEntries()
     357    {
     358        console.assert(this.isWeakCollection());
     359
     360        RuntimeAgent.releaseObjectGroup(this._weakCollectionObjectGroup());
     361    }
     362
     363    pushNodeToFrontend(callback)
     364    {
     365        if (this._objectId)
     366            WebInspector.domTreeManager.pushNodeToFrontend(this._objectId, callback);
     367        else
     368            callback(0);
     369    }
     370
     371    callFunction(functionDeclaration, args, generatePreview, callback)
     372    {
     373        function mycallback(error, result, wasThrown)
     374        {
     375            result = result ? WebInspector.RemoteObject.fromPayload(result) : null;
     376            callback(error, result, wasThrown);
     377        }
     378
     379        if (args)
     380            args = args.map(WebInspector.RemoteObject.createCallArgument);
     381
     382        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, generatePreview, mycallback);
     383    }
     384
     385    callFunctionJSON(functionDeclaration, args, callback)
     386    {
     387        function mycallback(error, result, wasThrown)
     388        {
     389            callback((error || wasThrown) ? null : result.value);
     390        }
     391
     392        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, true, mycallback);
     393    }
     394   
     395    invokeGetter(getterRemoteObject, callback)
     396    {
     397        console.assert(getterRemoteObject instanceof WebInspector.RemoteObject);
     398
     399        function backendInvokeGetter(getter)
     400        {
     401            return getter ? getter.call(this) : undefined;
     402        }
     403
     404        this.callFunction(backendInvokeGetter, [getterRemoteObject], true, callback);
     405    }
     406
     407    getOwnPropertyDescriptor(propertyName, callback)
     408    {
     409        function backendGetOwnPropertyDescriptor(propertyName)
     410        {
     411            return this[propertyName];
     412        }
     413
     414        function wrappedCallback(error, result, wasThrown)
     415        {
     416            if (error || wasThrown || !(result instanceof WebInspector.RemoteObject)) {
     417                callback(null);
     418                return;
     419            }
     420
     421            var fakeDescriptor = {name: propertyName, value: result, writable: true, configurable: true, enumerable: false};
     422            var fakePropertyDescriptor = new WebInspector.PropertyDescriptor(fakeDescriptor, true, false, false, false);
     423            callback(fakePropertyDescriptor);
     424        }
     425
     426        // FIXME: Implement a real RuntimeAgent.getOwnPropertyDescriptor?
     427        this.callFunction(backendGetOwnPropertyDescriptor, [propertyName], false, wrappedCallback);
     428    }
     429
     430    release()
     431    {
     432        if (this._objectId)
     433            RuntimeAgent.releaseObject(this._objectId);
     434    }
     435
     436    arrayLength()
     437    {
     438        if (this._subtype !== "array")
     439            return 0;
     440
     441        var matches = this._description.match(/\[([0-9]+)\]/);
     442        if (!matches)
     443            return 0;
     444
     445        return parseInt(matches[1], 10);
     446    }
     447
     448    asCallArgument()
     449    {
     450        return WebInspector.RemoteObject.createCallArgument(this);
     451    }
     452
     453    // Private
     454
     455    _isSymbol()
     456    {
     457        return this._type === "symbol";
     458    }
     459
     460    _weakCollectionObjectGroup()
     461    {
     462        return JSON.stringify(this._objectId) + "-WeakMap";
     463    }
     464
     465    _getPropertyDescriptors(ownProperties, callback)
     466    {
     467        if (!this._objectId || this._isSymbol()) {
     468            callback([]);
     469            return;
     470        }
     471
     472        RuntimeAgent.getProperties(this._objectId, ownProperties, true, this._getPropertyDescriptorsResolver.bind(this, callback));
     473    }
     474
     475    _getPropertyDescriptorsResolver(callback, error, properties, internalProperties)
     476    {
     477        if (error) {
     478            callback(null);
     479            return;
     480        }
     481
     482        var descriptors = properties.map(function(payload) {
     483            return WebInspector.PropertyDescriptor.fromPayload(payload);
     484        });
     485
     486        if (internalProperties) {
     487            descriptors = descriptors.concat(internalProperties.map(function(payload) {
     488                return WebInspector.PropertyDescriptor.fromPayload(payload, true);
     489            }));
     490        }
     491
     492        callback(descriptors);
     493    }
     494
     495    // FIXME: Phase out these deprecated functions. They return DeprecatedRemoteObjectProperty instead of PropertyDescriptors.
     496    _deprecatedGetProperties(ownProperties, callback)
     497    {
     498        if (!this._objectId || this._isSymbol()) {
     499            callback([]);
     500            return;
     501        }
     502
     503        RuntimeAgent.getProperties(this._objectId, ownProperties, this._deprecatedGetPropertiesResolver.bind(this, callback));
     504    }
     505
     506    _deprecatedGetPropertiesResolver(callback, error, properties, internalProperties)
    319507    {
    320508        if (error) {
     
    338526            if (property.get || property.set) {
    339527                if (property.get)
    340                     result.push(new WebInspector.RemoteObjectProperty("get " + property.name, WebInspector.RemoteObject.fromPayload(property.get), property));
     528                    result.push(new WebInspector.DeprecatedRemoteObjectProperty("get " + property.name, WebInspector.RemoteObject.fromPayload(property.get), property));
    341529                if (property.set)
    342                     result.push(new WebInspector.RemoteObjectProperty("set " + property.name, WebInspector.RemoteObject.fromPayload(property.set), property));
     530                    result.push(new WebInspector.DeprecatedRemoteObjectProperty("set " + property.name, WebInspector.RemoteObject.fromPayload(property.set), property));
    343531            } else
    344                 result.push(new WebInspector.RemoteObjectProperty(property.name, WebInspector.RemoteObject.fromPayload(property.value), property));
    345         }
     532                result.push(new WebInspector.DeprecatedRemoteObjectProperty(property.name, WebInspector.RemoteObject.fromPayload(property.value), property));
     533        }
     534
    346535        callback(result);
    347     },
    348 
    349     setPropertyValue: function(name, value, callback)
    350     {
    351         if (!this._objectId || this._isSymbol()) {
    352             callback("Can't set a property of non-object.");
    353             return;
    354         }
    355 
    356         RuntimeAgent.evaluate.invoke({expression:value, doNotPauseOnExceptionsAndMuteConsole:true}, evaluatedCallback.bind(this));
    357 
    358         function evaluatedCallback(error, result, wasThrown)
    359         {
    360             if (error || wasThrown) {
    361                 callback(error || result.description);
    362                 return;
    363             }
    364 
    365             function setPropertyValue(propertyName, propertyValue)
    366             {
    367                 this[propertyName] = propertyValue;
    368             }
    369 
    370             delete result.description; // Optimize on traffic.
    371             RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [{ value:name }, result], true, undefined, propertySetCallback.bind(this));
    372             if (result._objectId)
    373                 RuntimeAgent.releaseObject(result._objectId);
    374         }
    375 
    376         function propertySetCallback(error, result, wasThrown)
    377         {
    378             if (error || wasThrown) {
    379                 callback(error || result.description);
    380                 return;
    381             }
    382             callback();
    383         }
    384     },
    385 
    386     _isSymbol: function()
    387     {
    388         return this._type === "symbol";
    389     },
    390 
    391     isArray: function()
    392     {
    393         return this._subtype === "array";
    394     },
    395 
    396     isCollectionType: function()
    397     {
    398         return this._subtype === "map" || this._subtype === "set" || this._subtype === "weakmap";
    399     },
    400 
    401     isWeakCollection: function()
    402     {
    403         return this._subtype === "weakmap";
    404     },
    405 
    406     getCollectionEntries: function(start, numberToFetch, callback)
    407     {
    408         start = typeof start === "number" ? start : 0;
    409         numberToFetch = typeof numberToFetch === "number" ? numberToFetch : 100;
    410 
    411         console.assert(start >= 0);
    412         console.assert(numberToFetch >= 0);
    413         console.assert(this.isCollectionType());
    414 
    415         // WeakMaps are not ordered. We should never send a non-zero start.
    416         console.assert((this._subtype === "weakmap" && start === 0) || this._subtype !== "weakmap");
    417 
    418         var objectGroup = this.isWeakCollection() ? this._weakCollectionObjectGroup() : "";
    419 
    420         RuntimeAgent.getCollectionEntries(this._objectId, objectGroup, start, numberToFetch, function(error, entries) {
    421             entries = entries.map(function(entry) { return WebInspector.CollectionEntry.fromPayload(entry); });
    422             callback(entries);
    423         });
    424     },
    425 
    426     releaseWeakCollectionEntries: function()
    427     {
    428         console.assert(this.isWeakCollection());
    429 
    430         RuntimeAgent.releaseObjectGroup(this._weakCollectionObjectGroup());
    431     },
    432 
    433     pushNodeToFrontend: function(callback)
    434     {
    435         if (this._objectId)
    436             WebInspector.domTreeManager.pushNodeToFrontend(this._objectId, callback);
    437         else
    438             callback(0);
    439     },
    440 
    441     callFunction: function(functionDeclaration, args, generatePreview, callback)
    442     {
    443         function mycallback(error, result, wasThrown)
    444         {
    445             result = result ? WebInspector.RemoteObject.fromPayload(result) : null;
    446             callback(error, result, wasThrown);
    447         }
    448 
    449         if (args)
    450             args = args.map(WebInspector.RemoteObject.createCallArgument);
    451 
    452         RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, generatePreview, mycallback);
    453     },
    454 
    455     callFunctionJSON: function(functionDeclaration, args, callback)
    456     {
    457         function mycallback(error, result, wasThrown)
    458         {
    459             callback((error || wasThrown) ? null : result.value);
    460         }
    461 
    462         RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, true, mycallback);
    463     },
    464    
    465     invokeGetter: function(getterRemoteObject, callback)
    466     {
    467         console.assert(getterRemoteObject instanceof WebInspector.RemoteObject);
    468 
    469         function backendInvokeGetter(getter)
    470         {
    471             return getter ? getter.call(this) : undefined;
    472         }
    473 
    474         this.callFunction(backendInvokeGetter, [getterRemoteObject], true, callback);
    475     },
    476 
    477     getOwnPropertyDescriptor: function(propertyName, callback)
    478     {
    479         if (!RuntimeAgent.getOwnPropertyDescriptor) {
    480             function backendGetOwnPropertyDescriptor(propertyName)
    481             {
    482                 return this[propertyName];
    483             }
    484 
    485             function wrappedCallback(error, result, wasThrown)
    486             {
    487                 if (error || wasThrown || !(result instanceof WebInspector.RemoteObject)) {
    488                     callback(null);
    489                     return;
    490                 }
    491 
    492                 var fakeDescriptor = {name: propertyName, value: result, writable: true, configurable: true, enumerable: false};
    493                 var fakePropertyDescriptor = new WebInspector.PropertyDescriptor(fakeDescriptor, true, false, false, false);
    494                 callback(fakePropertyDescriptor);
    495             }
    496 
    497             this.callFunction(backendGetOwnPropertyDescriptor, [propertyName], false, wrappedCallback);
    498         }
    499 
    500         // FIXME: Implement a real getOwnPropertyDescriptor?
    501     },
    502 
    503     release: function()
    504     {
    505         if (this._objectId)
    506             RuntimeAgent.releaseObject(this._objectId);
    507     },
    508 
    509     arrayLength: function()
    510     {
    511         if (this._subtype !== "array")
    512             return 0;
    513 
    514         var matches = this._description.match(/\[([0-9]+)\]/);
    515         if (!matches)
    516             return 0;
    517 
    518         return parseInt(matches[1], 10);
    519     },
    520 
    521     asCallArgument: function()
    522     {
    523         return WebInspector.RemoteObject.createCallArgument(this);
    524     },
    525 
    526     // Private
    527 
    528     _weakCollectionObjectGroup: function()
    529     {
    530         return JSON.stringify(this._objectId) + "-WeakMap";
    531536    }
    532537};
    533538
    534 WebInspector.RemoteObjectProperty = function(name, value, descriptor)
     539// FIXME: Phase out this deprecated class.
     540WebInspector.DeprecatedRemoteObjectProperty = class DeprecatedRemoteObjectProperty
    535541{
    536     this.name = name;
    537     this.value = value;
    538     this.enumerable = descriptor ? !!descriptor.enumerable : true;
    539     this.writable = descriptor ? !!descriptor.writable : true;
    540     if (descriptor && descriptor.wasThrown)
    541         this.wasThrown = true;
     542    constructor(name, value, descriptor)
     543    {
     544        this.name = name;
     545        this.value = value;
     546        this.enumerable = descriptor ? !!descriptor.enumerable : true;
     547        this.writable = descriptor ? !!descriptor.writable : true;
     548        if (descriptor && descriptor.wasThrown)
     549            this.wasThrown = true;
     550    }
     551
     552    // Static
     553
     554    fromPrimitiveValue(name, value)
     555    {
     556        return new WebInspector.DeprecatedRemoteObjectProperty(name, WebInspector.RemoteObject.fromPrimitiveValue(value));
     557    }
    542558};
    543 
    544 WebInspector.RemoteObjectProperty.fromPrimitiveValue = function(name, value)
    545 {
    546     return new WebInspector.RemoteObjectProperty(name, WebInspector.RemoteObject.fromPrimitiveValue(value));
    547 };
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/ReplayObserver.js

    r181769 r182039  
    2525 */
    2626
    27 WebInspector.ReplayPosition = function(segmentOffset, inputOffset)
     27// FIXME: This ReplayPosition class shouldn't be here, no matter how simple it is.
     28WebInspector.ReplayPosition = class ReplayPosition
    2829{
    29     this.segmentOffset = segmentOffset;
    30     this.inputOffset = inputOffset;
     30    constructor(segmentOffset, inputOffset)
     31    {
     32        this.segmentOffset = segmentOffset;
     33        this.inputOffset = inputOffset;
     34    }
    3135};
    3236
    33 WebInspector.ReplayPosition.fromProtocol = function(payload)
     37WebInspector.ReplayObserver = class ReplayObserver
    3438{
    35     return new WebInspector.ReplayPosition(payload.segmentOffset, payload.inputOffset);
    36 };
     39    // Events defined by the "Replay" domain.
    3740
    38 WebInspector.ReplayObserver = function()
    39 {
    40     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    41     // WebInspector.Object.call(this);
    42 };
    43 
    44 WebInspector.ReplayObserver.prototype = {
    45     constructor: WebInspector.ReplayObserver,
    46     __proto__: WebInspector.Object.prototype,
    47 
    48     captureStarted: function()
     41    captureStarted()
    4942    {
    5043        WebInspector.replayManager.captureStarted();
    51     },
     44    }
    5245
    53     captureStopped: function()
     46    captureStopped()
    5447    {
    5548        WebInspector.replayManager.captureStopped();
    56     },
     49    }
    5750
    58     playbackStarted: function()
     51    playbackStarted()
    5952    {
    6053        WebInspector.replayManager.playbackStarted();
    61     },
     54    }
    6255
    63     playbackHitPosition: function(replayPosition, timestamp)
     56    playbackHitPosition(replayPosition, timestamp)
    6457    {
    65         WebInspector.replayManager.playbackHitPosition(WebInspector.ReplayPosition.fromProtocol(replayPosition), timestamp);
    66     },
     58        WebInspector.replayManager.playbackHitPosition(new WebInspector.ReplayPosition(replayPosition.segmentOffset, replayPosition.inputOffset), timestamp);
     59    }
    6760
    68     playbackPaused: function(replayPosition)
     61    playbackPaused(replayPosition)
    6962    {
    70         WebInspector.replayManager.playbackPaused(WebInspector.ReplayPosition.fromProtocol(replayPosition));
    71     },
     63        WebInspector.replayManager.playbackPaused(new WebInspector.ReplayPosition(replayPosition.segmentOffset, replayPosition.inputOffset));
     64    }
    7265
    73     playbackFinished: function()
     66    playbackFinished()
    7467    {
    7568        WebInspector.replayManager.playbackFinished();
    76     },
     69    }
    7770
    78     inputSuppressionChanged: function(willSuppress)
     71    inputSuppressionChanged(willSuppress)
    7972    {
    8073        // Not handled yet.
    81     },
     74    }
    8275
    83     sessionCreated: function(sessionId)
     76    sessionCreated(sessionId)
    8477    {
    8578        WebInspector.replayManager.sessionCreated(sessionId);
    86     },
     79    }
    8780
    88     sessionModified: function(sessionId)
     81    sessionModified(sessionId)
    8982    {
    9083        WebInspector.replayManager.sessionModified(sessionId);
    91     },
     84    }
    9285
    93     sessionRemoved: function(sessionId)
     86    sessionRemoved(sessionId)
    9487    {
    9588        WebInspector.replayManager.sessionRemoved(sessionId);
    96     },
     89    }
    9790
    98     sessionLoaded: function(sessionId)
     91    sessionLoaded(sessionId)
    9992    {
    10093        WebInspector.replayManager.sessionLoaded(sessionId);
    101     },
     94    }
    10295
    103     segmentCreated: function(segmentId)
     96    segmentCreated(segmentId)
    10497    {
    10598        WebInspector.replayManager.segmentCreated(segmentId);
    106     },
     99    }
    107100
    108     segmentRemoved: function(segmentId)
     101    segmentRemoved(segmentId)
    109102    {
    110103        WebInspector.replayManager.segmentRemoved(segmentId);
    111     },
     104    }
    112105
    113     segmentCompleted: function(segmentId)
     106    segmentCompleted(segmentId)
    114107    {
    115108        WebInspector.replayManager.segmentCompleted(segmentId);
    116     },
     109    }
    117110
    118     segmentLoaded: function(segmentId)
     111    segmentLoaded(segmentId)
    119112    {
    120113        WebInspector.replayManager.segmentLoaded(segmentId);
    121     },
     114    }
    122115
    123     segmentUnloaded: function()
     116    segmentUnloaded()
    124117    {
    125118        WebInspector.replayManager.segmentUnloaded();
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/RuntimeObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.RuntimeObserver = function()
     26WebInspector.RuntimeObserver = class RuntimeObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.RuntimeObserver.prototype = {
    33     constructor: WebInspector.RuntimeObserver,
    34 
    3528    // Events defined by the "Runtime" domain.
    3629
    37     executionContextCreated: function(contextPayload)
     30    executionContextCreated(contextPayload)
    3831    {
    3932        WebInspector.frameResourceManager.executionContextCreated(contextPayload);
    4033    }
    4134};
    42 
    43 WebInspector.RuntimeObserver.prototype.__proto__ = WebInspector.Object.prototype;
  • trunk/Source/WebInspectorUI/UserInterface/Protocol/TimelineObserver.js

    r181769 r182039  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2013, 2015 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 WebInspector.TimelineObserver = function()
     26WebInspector.TimelineObserver = class TimelineObserver
    2727{
    28     // FIXME: Convert this to a WebInspector.Object subclass, and call super().
    29     // WebInspector.Object.call(this);
    30 };
    31 
    32 WebInspector.TimelineObserver.prototype = {
    33     constructor: WebInspector.TimelineObserver,
    34 
    3528    // Events defined by the "Timeline" domain.
    3629
    37     eventRecorded: function(record)
     30    eventRecorded(record)
    3831    {
    3932        WebInspector.timelineManager.eventRecorded(record);
    40     },
     33    }
    4134
    42     recordingStarted: function()
     35    recordingStarted()
    4336    {
    4437        WebInspector.timelineManager.capturingStarted();
    45     },
     38    }
    4639
    47     recordingStopped: function()
     40    recordingStopped()
    4841    {
    4942        WebInspector.timelineManager.capturingStopped();
    5043    }
    5144};
    52 
    53 WebInspector.TimelineObserver.prototype.__proto__ = WebInspector.Object.prototype;
Note: See TracChangeset for help on using the changeset viewer.