Changeset 89652 in webkit


Ignore:
Timestamp:
Jun 23, 2011 10:42:25 PM (13 years ago)
Author:
yurys@chromium.org
Message:

2011-06-23 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

[Chromium] Web Inspector: provide context menu item for enabling native worker inspection
https://bugs.webkit.org/show_bug.cgi?id=63258

Added context menu checkbox item that allows to enable inspection of
native workers. The value will be persisted as other inspector settings
and will be restored after frontend/breowser reopening.

  • inspector/Inspector.json:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::restoreInspectorStateFromCookie):
  • inspector/InspectorInstrumentation.h: (WebCore::InspectorInstrumentation::didStartWorkerContext):
  • inspector/InspectorWorkerAgent.cpp: (WebCore::InspectorWorkerAgent::setFrontend): (WebCore::InspectorWorkerAgent::restore): (WebCore::InspectorWorkerAgent::setWorkerInspectionEnabled):
  • inspector/InspectorWorkerAgent.h:
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel): (WebInspector.ScriptsPanel.prototype.reset): (WebInspector.ScriptsPanel.prototype._toggleFormatSourceFiles): (WebInspector.ScriptsPanel.prototype._contextMenu.enableWorkerInspection): (WebInspector.ScriptsPanel.prototype._contextMenu):
  • inspector/front-end/Settings.js: (WebInspector.Settings):
  • inspector/front-end/inspector.js: (WebInspector.didCreateWorker): (WebInspector.didDestroyWorker):
  • workers/Worker.cpp: (WebCore::Worker::notifyFinished):

2011-06-23 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

[Chromium] Web Inspector: provide context menu item for enabling native worker inspection
https://bugs.webkit.org/show_bug.cgi?id=63258

  • src/js/DevTools.js: ():
Location:
trunk/Source
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89651 r89652  
     12011-06-23  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        [Chromium] Web Inspector: provide context menu item for enabling native worker inspection
     6        https://bugs.webkit.org/show_bug.cgi?id=63258
     7
     8        Added context menu checkbox item that allows to enable inspection of
     9        native workers. The value will be persisted as other inspector settings
     10        and will be restored after frontend/breowser reopening.
     11
     12        * inspector/Inspector.json:
     13        * inspector/InspectorController.cpp:
     14        (WebCore::InspectorController::restoreInspectorStateFromCookie):
     15        * inspector/InspectorInstrumentation.h:
     16        (WebCore::InspectorInstrumentation::didStartWorkerContext):
     17        * inspector/InspectorWorkerAgent.cpp:
     18        (WebCore::InspectorWorkerAgent::setFrontend):
     19        (WebCore::InspectorWorkerAgent::restore):
     20        (WebCore::InspectorWorkerAgent::setWorkerInspectionEnabled):
     21        * inspector/InspectorWorkerAgent.h:
     22        * inspector/front-end/ScriptsPanel.js:
     23        (WebInspector.ScriptsPanel):
     24        (WebInspector.ScriptsPanel.prototype.reset):
     25        (WebInspector.ScriptsPanel.prototype._toggleFormatSourceFiles):
     26        (WebInspector.ScriptsPanel.prototype._contextMenu.enableWorkerInspection):
     27        (WebInspector.ScriptsPanel.prototype._contextMenu):
     28        * inspector/front-end/Settings.js:
     29        (WebInspector.Settings):
     30        * inspector/front-end/inspector.js:
     31        (WebInspector.didCreateWorker):
     32        (WebInspector.didDestroyWorker):
     33        * workers/Worker.cpp:
     34        (WebCore::Worker::notifyFinished):
     35
    1362011-06-23  Simon Fraser  <simon.fraser@apple.com>
    237
  • trunk/Source/WebCore/inspector/Inspector.json

    r89449 r89652  
    17581758        "commands": [
    17591759            {
     1760                "name": "setWorkerInspectionEnabled",
     1761                "parameters": [
     1762                    { "name": "value", "type": "boolean" }
     1763                ]
     1764            },
     1765            {
    17601766                "name": "sendMessageToWorker",
    17611767                "parameters": [
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r89456 r89652  
    340340    m_domStorageAgent->restore();
    341341#endif
     342#if ENABLE(WORKERS)
     343    m_workerAgent->restore();
     344#endif
    342345#if ENABLE(JAVASCRIPT_DEBUGGER)
    343346    m_debuggerAgent->restore();
  • trunk/Source/WebCore/inspector/InspectorInstrumentation.h

    r89345 r89652  
    167167
    168168#if ENABLE(WORKERS)
    169     static bool willStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*);
    170     static void didStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*, bool paused, const KURL&);
     169    static void didStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*, const KURL&);
    171170    static void didCreateWorker(ScriptExecutionContext*, intptr_t id, const String& url, bool isSharedWorker);
    172171    static void didDestroyWorker(ScriptExecutionContext*, intptr_t id);
     
    908907
    909908#if ENABLE(WORKERS)
    910 inline bool InspectorInstrumentation::willStartWorkerContext(ScriptExecutionContext*, WorkerContextProxy*)
    911 {
    912     return false;
    913 }
    914 
    915 inline void InspectorInstrumentation::didStartWorkerContext(ScriptExecutionContext* context, WorkerContextProxy* proxy, bool paused, const KURL& url)
    916 {
    917 #if ENABLE(INSPECTOR)
    918     if (!paused)
    919         return;
     909inline void InspectorInstrumentation::didStartWorkerContext(ScriptExecutionContext* context, WorkerContextProxy* proxy, const KURL& url)
     910{
     911#if ENABLE(INSPECTOR)
    920912    FAST_RETURN_IF_NO_FRONTENDS(void());
    921913    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForContext(context))
  • trunk/Source/WebCore/inspector/InspectorWorkerAgent.cpp

    r88547 r89652  
    4848
    4949namespace WorkerAgentState {
     50static const char workerInspectionEnabled[] = "workerInspectionEnabled";
    5051static const char autoconnectToWorkers[] = "autoconnectToWorkers";
    5152};
     
    124125{
    125126    m_inspectorFrontend = frontend;
    126     // Disabled for now.
    127     // m_instrumentingAgents->setInspectorWorkerAgent(this);
     127    restore();
     128}
     129
     130void InspectorWorkerAgent::restore()
     131{
     132    if (m_inspectorState->getBoolean(WorkerAgentState::workerInspectionEnabled))
     133        m_instrumentingAgents->setInspectorWorkerAgent(this);
    128134}
    129135
     
    140146}
    141147
     148void InspectorWorkerAgent::setWorkerInspectionEnabled(ErrorString*, bool value)
     149{
     150    m_inspectorState->setBoolean(WorkerAgentState::workerInspectionEnabled, value);
     151    if (!m_inspectorFrontend)
     152        return;
     153    if (value)
     154        m_instrumentingAgents->setInspectorWorkerAgent(this);
     155    else
     156        m_instrumentingAgents->setInspectorWorkerAgent(0);
     157}
     158
    142159void InspectorWorkerAgent::connectToWorker(ErrorString* error, int workerId)
    143160{
  • trunk/Source/WebCore/inspector/InspectorWorkerAgent.h

    r87992 r89652  
    5353
    5454    void setFrontend(InspectorFrontend*);
     55    void restore();
    5556    void clearFrontend();
    5657
     
    6061
    6162    // Called from InspectorBackendDispatcher
     63    void setWorkerInspectionEnabled(ErrorString*, bool value);
    6264    void connectToWorker(ErrorString*, int workerId);
    6365    void disconnectFromWorker(ErrorString*, int workerId);
  • trunk/Source/WebCore/inspector/front-end/ScriptsPanel.js

    r89428 r89652  
    107107    }
    108108
    109     this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane();
    110109    if (Preferences.canInspectWorkers && WebInspector.workerManager)
     110        this.sidebarElement.addEventListener("contextmenu", this._contextMenu.bind(this), true);
     111    if (Preferences.canInspectWorkers && WebInspector.workerManager && WebInspector.settings.workerInspectionEnabled) {
     112        WorkerAgent.setWorkerInspectionEnabled(true);
    111113        this.sidebarPanes.workerList = new WebInspector.WorkerListSidebarPane(WebInspector.workerManager);
    112 
     114    } else
     115        this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane();
    113116
    114117    for (var pane in this.sidebarPanes)
     
    498501        this.sidebarPanes.jsBreakpoints.reset();
    499502        this.sidebarPanes.watchExpressions.refreshExpressions();
    500         if (!preserveItems)
     503        if (!preserveItems && this.sidebarPanes.workers)
    501504            this.sidebarPanes.workers.reset();
    502505    },
     
    10671070        this._toggleFormatSourceFilesButton.toggled = !this._toggleFormatSourceFilesButton.toggled;
    10681071        this._presentationModel.setFormatSourceFiles(this._toggleFormatSourceFilesButton.toggled);
     1072    },
     1073
     1074    _contextMenu: function(event)
     1075    {
     1076        var contextMenu = new WebInspector.ContextMenu();
     1077
     1078        function enableWorkerInspection()
     1079        {
     1080            var newValue = !WebInspector.settings.workerInspectionEnabled;
     1081            WebInspector.settings.workerInspectionEnabled = newValue;
     1082            WorkerAgent.setWorkerInspectionEnabled(newValue);
     1083            if (newValue) {
     1084                var element = this.sidebarPanes.workers.element;
     1085                delete this.sidebarPanes.workers;
     1086                this.sidebarPanes.workerList = new WebInspector.WorkerListSidebarPane(WebInspector.workerManager);
     1087                element.parentNode.replaceChild(this.sidebarPanes.workerList.element, element);
     1088            } else {
     1089                var element = this.sidebarPanes.workerList.element;
     1090                delete this.sidebarPanes.workerList;
     1091                this.sidebarPanes.workers = new WebInspector.WorkersSidebarPane();
     1092                element.parentNode.replaceChild(this.sidebarPanes.workers.element, element);
     1093            }
     1094        }
     1095        contextMenu.appendCheckboxItem(WebInspector.UIString("Enable worker inspection"), enableWorkerInspection.bind(this), WebInspector.settings.workerInspectionEnabled);
     1096
     1097        contextMenu.show(event);
    10691098    }
    10701099}
  • trunk/Source/WebCore/inspector/front-end/Settings.js

    r89135 r89652  
    7979    this.installApplicationSetting("domBreakpoints", []);
    8080    this.installApplicationSetting("xhrBreakpoints", []);
     81    this.installApplicationSetting("workerInspectionEnabled", []);
    8182
    8283    // If there are too many breakpoints in a storage, it is likely due to a recent bug that caused
  • trunk/Source/WebCore/inspector/front-end/inspector.js

    r89556 r89652  
    10051005{
    10061006    var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
    1007     workersPane.addWorker.apply(workersPane, arguments);
     1007    if (workersPane)
     1008        workersPane.addWorker.apply(workersPane, arguments);
    10081009}
    10091010
     
    10111012{
    10121013    var workersPane = WebInspector.panels.scripts.sidebarPanes.workers;
    1013     workersPane.removeWorker.apply(workersPane, arguments);
     1014    if (workersPane)
     1015        workersPane.removeWorker.apply(workersPane, arguments);
    10141016}
    10151017
  • trunk/Source/WebCore/workers/Worker.cpp

    r88578 r89652  
    132132        dispatchEvent(Event::create(eventNames().errorEvent, false, true));
    133133    else {
    134         bool shouldStartPaused = InspectorInstrumentation::willStartWorkerContext(scriptExecutionContext(), m_contextProxy);
    135134        m_contextProxy->startWorkerContext(m_scriptLoader->url(), scriptExecutionContext()->userAgent(m_scriptLoader->url()), m_scriptLoader->script());
    136         InspectorInstrumentation::didStartWorkerContext(scriptExecutionContext(), m_contextProxy, shouldStartPaused, m_scriptLoader->url());
     135        InspectorInstrumentation::didStartWorkerContext(scriptExecutionContext(), m_contextProxy, m_scriptLoader->url());
    137136        InspectorInstrumentation::scriptImported(scriptExecutionContext(), m_scriptLoader->identifier(), m_scriptLoader->script());
    138137    }
  • trunk/Source/WebKit/chromium/ChangeLog

    r89635 r89652  
     12011-06-23  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        [Chromium] Web Inspector: provide context menu item for enabling native worker inspection
     6        https://bugs.webkit.org/show_bug.cgi?id=63258
     7
     8        * src/js/DevTools.js:
     9        ():
     10
    1112011-06-23  John Bates  <jbates@google.com>
    212
  • trunk/Source/WebKit/chromium/src/js/DevTools.js

    r86746 r89652  
    5353    Preferences.saveAsAvailable = true;
    5454    Preferences.useLowerCaseMenuTitlesOnWindows = true;
     55    Preferences.canInspectWorkers = true;
    5556})();
    5657
Note: See TracChangeset for help on using the changeset viewer.