Changeset 74103 in webkit


Ignore:
Timestamp:
Dec 15, 2010 2:39:17 AM (13 years ago)
Author:
podivilov@chromium.org
Message:

2010-12-13 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: push persistent breakpoints into backend state cookie so they hit on navigation.
https://bugs.webkit.org/show_bug.cgi?id=48858

BreakpointManager pushes all persistent breakpoints to backend when loaded.
InspectorController restores sticky breakpoints from cookie on navigation.

  • inspector/Inspector.idl:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::InspectorController): (WebCore::InspectorController::disconnectFrontend): (WebCore::InspectorController::didCommitLoad): (WebCore::InspectorController::setStickyBreakpoints): (WebCore::InspectorController::restoreStickyBreakpoints): (WebCore::InspectorController::restoreStickyBreakpoint):
  • inspector/InspectorController.h:
  • inspector/InspectorState.cpp: (WebCore::InspectorState::InspectorState): (WebCore::InspectorState::getObject): (WebCore::InspectorState::setObject): (WebCore::InspectorState::registerObject):
  • inspector/InspectorState.h:
  • inspector/front-end/BreakpointManager.js: (WebInspector.BreakpointManager):
  • inspector/front-end/BreakpointsSidebarPane.js: (WebInspector.BreakpointsSidebarPane): (WebInspector.BreakpointsSidebarPane.prototype._removeListElement): (WebInspector.BreakpointsSidebarPane.prototype._projectChanged): (WebInspector.EventListenerBreakpointsSidebarPane): (WebInspector.EventListenerBreakpointsSidebarPane.prototype._createCategory): (WebInspector.EventListenerBreakpointsSidebarPane.prototype._breakpointAdded): (WebInspector.EventListenerBreakpointsSidebarPane.prototype._projectChanged):
  • inspector/front-end/CallStackSidebarPane.js: (WebInspector.CallStackSidebarPane):
  • inspector/front-end/ElementsPanel.js: (WebInspector.ElementsPanel.prototype.reset):
  • inspector/front-end/ScriptsPanel.js: (WebInspector.ScriptsPanel.prototype.reset):
  • inspector/front-end/Settings.js: (WebInspector.Settings.prototype.inspectedURLChanged): (WebInspector.Settings.prototype.get projectId): (WebInspector.Settings.prototype.findSettingForAllProjects): (WebInspector.Settings.prototype._formatProjectKey):
  • inspector/front-end/inspector.js: (WebInspector.createDOMBreakpointsSidebarPane): (WebInspector.createXHRBreakpointsSidebarPane): (WebInspector.reset): (WebInspector.inspectedURLChanged):
Location:
trunk/WebCore
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r74102 r74103  
     12010-12-13  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: push persistent breakpoints into backend state cookie so they hit on navigation.
     6        https://bugs.webkit.org/show_bug.cgi?id=48858
     7
     8        BreakpointManager pushes all persistent breakpoints to backend when loaded.
     9        InspectorController restores sticky breakpoints from cookie on navigation.
     10
     11        * inspector/Inspector.idl:
     12        * inspector/InspectorController.cpp:
     13        (WebCore::InspectorController::InspectorController):
     14        (WebCore::InspectorController::disconnectFrontend):
     15        (WebCore::InspectorController::didCommitLoad):
     16        (WebCore::InspectorController::setStickyBreakpoints):
     17        (WebCore::InspectorController::restoreStickyBreakpoints):
     18        (WebCore::InspectorController::restoreStickyBreakpoint):
     19        * inspector/InspectorController.h:
     20        * inspector/InspectorState.cpp:
     21        (WebCore::InspectorState::InspectorState):
     22        (WebCore::InspectorState::getObject):
     23        (WebCore::InspectorState::setObject):
     24        (WebCore::InspectorState::registerObject):
     25        * inspector/InspectorState.h:
     26        * inspector/front-end/BreakpointManager.js:
     27        (WebInspector.BreakpointManager):
     28        * inspector/front-end/BreakpointsSidebarPane.js:
     29        (WebInspector.BreakpointsSidebarPane):
     30        (WebInspector.BreakpointsSidebarPane.prototype._removeListElement):
     31        (WebInspector.BreakpointsSidebarPane.prototype._projectChanged):
     32        (WebInspector.EventListenerBreakpointsSidebarPane):
     33        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._createCategory):
     34        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._breakpointAdded):
     35        (WebInspector.EventListenerBreakpointsSidebarPane.prototype._projectChanged):
     36        * inspector/front-end/CallStackSidebarPane.js:
     37        (WebInspector.CallStackSidebarPane):
     38        * inspector/front-end/ElementsPanel.js:
     39        (WebInspector.ElementsPanel.prototype.reset):
     40        * inspector/front-end/ScriptsPanel.js:
     41        (WebInspector.ScriptsPanel.prototype.reset):
     42        * inspector/front-end/Settings.js:
     43        (WebInspector.Settings.prototype.inspectedURLChanged):
     44        (WebInspector.Settings.prototype.get projectId):
     45        (WebInspector.Settings.prototype.findSettingForAllProjects):
     46        (WebInspector.Settings.prototype._formatProjectKey):
     47        * inspector/front-end/inspector.js:
     48        (WebInspector.createDOMBreakpointsSidebarPane):
     49        (WebInspector.createXHRBreakpointsSidebarPane):
     50        (WebInspector.reset):
     51        (WebInspector.inspectedURLChanged):
     52
    1532010-12-15  Mario Sanchez Prada  <msanchez@igalia.com>
    254
  • trunk/WebCore/inspector/Inspector.idl

    r74022 r74103  
    220220        [domain=Debugger] void removeBreakpoint(in String sourceID, in unsigned long lineNumber);
    221221
     222        [domain=Inspector] void setStickyBreakpoints(in Object breakpoints); // FIXME: Move to newly introduced BrowserDebugger.
     223
    222224        [domain=DOM] void setDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger.
    223225        [domain=DOM] void removeDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger.
  • trunk/WebCore/inspector/InspectorController.cpp

    r73726 r74103  
    150150    , m_attachDebuggerWhenShown(false)
    151151    , m_hasXHRBreakpointWithEmptyURL(false)
     152    , m_stickyBreakpointsRestored(false)
    152153    , m_profilerAgent(InspectorProfilerAgent::create(this))
    153154#endif
     
    561562    disableDebugger();
    562563    m_attachDebuggerWhenShown = debuggerWasEnabled;
    563     clearNativeBreakpoints();
    564564#endif
    565565    setSearchingForNode(false);
     
    718718
    719719#if ENABLE(JAVASCRIPT_DEBUGGER)
    720         if (m_debuggerAgent)
     720        if (m_debuggerAgent) {
    721721            m_debuggerAgent->clearForPageNavigation();
    722 
    723         clearNativeBreakpoints();
     722            restoreStickyBreakpoints();
     723        }
    724724#endif
    725725
     
    13831383}
    13841384
     1385void InspectorController::setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints)
     1386{
     1387    m_state->setObject(InspectorState::stickyBreakpoints, breakpoints);
     1388    if (!m_stickyBreakpointsRestored) {
     1389        restoreStickyBreakpoints();
     1390        m_stickyBreakpointsRestored = true;
     1391    }
     1392}
     1393
     1394void InspectorController::restoreStickyBreakpoints()
     1395{
     1396    m_eventListenerBreakpoints.clear();
     1397    m_XHRBreakpoints.clear();
     1398    m_hasXHRBreakpointWithEmptyURL = false;
     1399
     1400    RefPtr<InspectorObject> allBreakpoints = m_state->getObject(InspectorState::stickyBreakpoints);
     1401    KURL url = m_inspectedPage->mainFrame()->loader()->url();
     1402    url.removeFragmentIdentifier();
     1403    RefPtr<InspectorArray> breakpoints = allBreakpoints->getArray(url);
     1404    if (!breakpoints)
     1405        return;
     1406    for (unsigned i = 0; i < breakpoints->length(); ++i)
     1407        restoreStickyBreakpoint(breakpoints->get(i)->asObject());
     1408}
     1409
     1410void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint)
     1411{
     1412    DEFINE_STATIC_LOCAL(String, eventListenerNativeBreakpointType, ("EventListener"));
     1413    DEFINE_STATIC_LOCAL(String, xhrNativeBreakpointType, ("XHR"));
     1414
     1415    if (!breakpoint)
     1416        return;
     1417    String type;
     1418    if (!breakpoint->getString("type", &type))
     1419        return;
     1420    bool enabled;
     1421    if (!breakpoint->getBoolean("enabled", &enabled) || !enabled)
     1422        return;
     1423    RefPtr<InspectorObject> condition = breakpoint->getObject("condition");
     1424    if (!condition)
     1425        return;
     1426
     1427    if (type == eventListenerNativeBreakpointType) {
     1428        String eventName;
     1429        if (condition->getString("eventName", &eventName))
     1430            setEventListenerBreakpoint(eventName);
     1431    } else if (type == xhrNativeBreakpointType) {
     1432        String url;
     1433        if (condition->getString("url", &url))
     1434            setXHRBreakpoint(url);
     1435    }
     1436}
     1437
    13851438void InspectorController::setEventListenerBreakpoint(const String& eventName)
    13861439{
     
    14291482}
    14301483
    1431 void InspectorController::clearNativeBreakpoints()
    1432 {
    1433     m_eventListenerBreakpoints.clear();
    1434     m_XHRBreakpoints.clear();
    1435     m_hasXHRBreakpointWithEmptyURL = false;
    1436 }
    14371484#endif
    14381485
  • trunk/WebCore/inspector/InspectorController.h

    r73726 r74103  
    256256    void resume();
    257257
     258    void setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints);
    258259    void setEventListenerBreakpoint(const String& eventName);
    259260    void removeEventListenerBreakpoint(const String& eventName);
     
    310311    void toggleRecordButton(bool);
    311312    void enableDebuggerFromFrontend(bool always);
    312 
    313     void clearNativeBreakpoints();
     313    void restoreStickyBreakpoints();
     314    void restoreStickyBreakpoint(PassRefPtr<InspectorObject> breakpoint);
    314315#endif
    315316#if ENABLE(DATABASE)
     
    392393    HashSet<String> m_XHRBreakpoints;
    393394    bool m_hasXHRBreakpointWithEmptyURL;
     395    bool m_stickyBreakpointsRestored;
    394396
    395397    OwnPtr<InspectorProfilerAgent> m_profilerAgent;
  • trunk/WebCore/inspector/InspectorState.cpp

    r71981 r74103  
    4141{
    4242    registerBoolean(monitoringXHR, false, "monitoringXHREnabled", "xhrMonitor");
    43     registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", (const char*)0);
    44     registerBoolean(searchingForNode, false, "searchingForNodeEnabled", (const char*)0);
    45     registerBoolean(profilerAlwaysEnabled, false, (const char*)0, "profilerEnabled");
    46     registerBoolean(debuggerAlwaysEnabled, false, (const char*)0, "debuggerEnabled");
    47     registerBoolean(inspectorStartsAttached, true, (const char*)0, "InspectorStartsAttached");
    48     registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, (const char*)0, "inspectorAttachedHeight");
    49     registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", (const char*)0);
    50     registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", (const char*)0);
    51     registerBoolean(userInitiatedProfiling, false, "userInitiatedProfiling", (const char*)0);
     43    registerBoolean(timelineProfilerEnabled, false, "timelineProfilerEnabled", String());
     44    registerBoolean(searchingForNode, false, "searchingForNodeEnabled", String());
     45    registerBoolean(profilerAlwaysEnabled, false, String(), "profilerEnabled");
     46    registerBoolean(debuggerAlwaysEnabled, false, String(), "debuggerEnabled");
     47    registerBoolean(inspectorStartsAttached, true, String(), "InspectorStartsAttached");
     48    registerLong(inspectorAttachedHeight, InspectorController::defaultAttachedHeight, String(), "inspectorAttachedHeight");
     49    registerLong(pauseOnExceptionsState, 0, "pauseOnExceptionsState", String());
     50    registerBoolean(consoleMessagesEnabled, false, "consoleMessagesEnabled", String());
     51    registerBoolean(userInitiatedProfiling, false, "userInitiatedProfiling", String());
     52    registerObject(stickyBreakpoints, String(), String());
    5253}
    5354
     
    153154}
    154155
     156PassRefPtr<InspectorObject> InspectorState::getObject(InspectorPropertyId id)
     157{
     158    PropertyMap::iterator i = m_properties.find(id);
     159    ASSERT(i != m_properties.end());
     160    return i->second.m_value->asObject();
     161}
     162
     163void InspectorState::setObject(InspectorPropertyId id, PassRefPtr<InspectorObject> value)
     164{
     165    PropertyMap::iterator i = m_properties.find(id);
     166    ASSERT(i != m_properties.end());
     167    Property& property = i->second;
     168    property.m_value = value;
     169    if (property.m_preferenceName.length())
     170        m_client->storeSetting(property.m_preferenceName, value->toJSONString());
     171    updateCookie();
     172}
     173
    155174void InspectorState::registerBoolean(InspectorPropertyId propertyId, bool value, const String& frontendAlias, const String& preferenceName)
    156175{
     
    166185{
    167186    m_properties.set(propertyId, Property::create(InspectorBasicValue::create((double)value), frontendAlias, preferenceName));
     187}
     188
     189void InspectorState::registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName)
     190{
     191    m_properties.set(propertyId, Property::create(InspectorObject::create(), frontendAlias, preferenceName));
    168192}
    169193
  • trunk/WebCore/inspector/InspectorState.h

    r71511 r74103  
    5656        consoleMessagesEnabled,
    5757        userInitiatedProfiling,
     58        stickyBreakpoints,
    5859        lastPropertyId
    5960    };
     
    6970    String getString(InspectorPropertyId propertyId);
    7071    long getLong(InspectorPropertyId propertyId);
     72    PassRefPtr<InspectorObject> getObject(InspectorPropertyId id);
    7173
    7274    void setBoolean(InspectorPropertyId propertyId, bool value) { setValue(propertyId, InspectorBasicValue::create(value), value ? "true" : "false"); }
    7375    void setString(InspectorPropertyId propertyId, const String& value) { setValue(propertyId, InspectorString::create(value), value); }
    7476    void setLong(InspectorPropertyId propertyId, long value) { setValue(propertyId, InspectorBasicValue::create((double)value), String::number(value)); }
     77    void setObject(InspectorPropertyId propertyId, PassRefPtr<InspectorObject> value);
    7578
    7679private:
     
    9093    void registerString(InspectorPropertyId propertyId, const String& value, const String& frontendAlias, const String& preferenceName);
    9194    void registerLong(InspectorPropertyId propertyId, long value, const String& frontendAlias, const String& preferenceName);
     95    void registerObject(InspectorPropertyId propertyId, const String& frontendAlias, const String& preferenceName);
    9296
    9397    InspectorClient* m_client;
  • trunk/WebCore/inspector/front-end/BreakpointManager.js

    r73726 r74103  
    3131WebInspector.BreakpointManager = function()
    3232{
     33    this._stickyBreakpoints = {};
     34    var breakpoints = WebInspector.settings.findSettingForAllProjects("nativeBreakpoints");
     35    for (var projectId in breakpoints)
     36        this._stickyBreakpoints[projectId] = this._validateBreakpoints(breakpoints[projectId]);
     37    InspectorBackend.setStickyBreakpoints(this._stickyBreakpoints);
     38
    3339    this._nativeBreakpoints = {};
    34 
     40    this._domBreakpointsRestored = false;
     41
     42    WebInspector.settings.addEventListener(WebInspector.Settings.Events.ProjectChanged, this._projectChanged, this);
    3543    WebInspector.debuggerModel.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this);
    3644    WebInspector.debuggerModel.addEventListener("debugger-resumed", this._debuggerResumed, this);
     
    4351}
    4452
     53WebInspector.BreakpointManager.Events = {
     54    DOMBreakpointAdded: "dom-breakpoint-added",
     55    EventListenerBreakpointAdded: "event-listener-breakpoint-added",
     56    XHRBreakpointAdded: "xhr-breakpoint-added",
     57    NativeBreakpointHit: "native-breakpoint-hit",
     58    ProjectChanged: "project-changed"
     59}
     60
    4561WebInspector.BreakpointManager.prototype = {
    46     createDOMBreakpoint: function(nodeId, type, disabled)
     62    createDOMBreakpoint: function(nodeId, type)
     63    {
     64        this._createDOMBreakpoint(nodeId, type, true, false);
     65    },
     66
     67    _createDOMBreakpoint: function(nodeId, type, enabled, restored)
    4768    {
    4869        var node = WebInspector.domAgent.nodeForId(nodeId);
     
    5475            return;
    5576
    56         var breakpoint = new WebInspector.DOMBreakpoint(this, breakpointId, !disabled, node, type);
    57         this._nativeBreakpoints[breakpointId] = breakpoint;
    58         this._updateNativeBreakpointsInSettings();
    59         this.dispatchEventToListeners("dom-breakpoint-added", breakpoint);
    60         return breakpoint;
     77        var breakpoint = new WebInspector.DOMBreakpoint(node, type);
     78        this._setNativeBreakpoint(breakpointId, breakpoint, enabled, restored);
     79        if (enabled && restored)
     80            breakpoint._enable();
     81
     82        breakpoint.view = new WebInspector.DOMBreakpointView(this, breakpointId, enabled, node, type);
     83        this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.DOMBreakpointAdded, breakpoint.view);
    6184    },
    6285
    6386    createEventListenerBreakpoint: function(eventName)
     87    {
     88        this._createEventListenerBreakpoint(eventName, true, false);
     89    },
     90
     91    _createEventListenerBreakpoint: function(eventName, enabled, restored)
    6492    {
    6593        var breakpointId = this._createEventListenerBreakpointId(eventName);
     
    6795            return;
    6896
    69         var breakpoint = new WebInspector.EventListenerBreakpoint(this, breakpointId, true, eventName);
    70         this._nativeBreakpoints[breakpointId] = breakpoint;
    71         this._updateNativeBreakpointsInSettings();
    72         this.dispatchEventToListeners("event-listener-breakpoint-added", { breakpoint: breakpoint, eventName: eventName });
    73         return breakpoint;
    74     },
    75 
    76     createXHRBreakpoint: function(url, disabled)
     97        var breakpoint = new WebInspector.EventListenerBreakpoint(eventName);
     98        this._setNativeBreakpoint(breakpointId, breakpoint, enabled, restored);
     99
     100        breakpoint.view = new WebInspector.EventListenerBreakpointView(this, breakpointId, enabled, eventName);
     101        this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, breakpoint.view);
     102    },
     103
     104    createXHRBreakpoint: function(url)
     105    {
     106        this._createXHRBreakpoint(url, true, false);
     107    },
     108
     109    _createXHRBreakpoint: function(url, enabled, restored)
    77110    {
    78111        var breakpointId = this._createXHRBreakpointId(url);
     
    80113            return;
    81114
    82         var breakpoint = new WebInspector.XHRBreakpoint(this, breakpointId, !disabled, url);
     115        var breakpoint = new WebInspector.XHRBreakpoint(url);
     116        this._setNativeBreakpoint(breakpointId, breakpoint, enabled, restored);
     117
     118        breakpoint.view = new WebInspector.XHRBreakpointView(this, breakpointId, enabled, url);
     119        this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.XHRBreakpointAdded, breakpoint.view);
     120    },
     121
     122    _setNativeBreakpoint: function(breakpointId, breakpoint, enabled, restored)
     123    {
    83124        this._nativeBreakpoints[breakpointId] = breakpoint;
    84         this._updateNativeBreakpointsInSettings();
    85         this.dispatchEventToListeners("xhr-breakpoint-added", breakpoint);
    86         return breakpoint;
     125        breakpoint.enabled = enabled;
     126        if (restored)
     127            return;
     128        if (enabled)
     129            breakpoint._enable();
     130        this._saveBreakpoints();
    87131    },
    88132
     
    90134    {
    91135        var breakpoint = this._nativeBreakpoints[breakpointId];
    92 
     136        if (breakpoint.enabled === enabled)
     137            return;
    93138        if (enabled)
    94139            breakpoint._enable();
    95140        else
    96141            breakpoint._disable();
    97 
    98         breakpoint._enabled = enabled;
    99         this._updateNativeBreakpointsInSettings();
    100         breakpoint.dispatchEventToListeners("enable-changed");
     142        breakpoint.enabled = enabled;
     143        this._saveBreakpoints();
    101144    },
    102145
     
    104147    {
    105148        var breakpoint = this._nativeBreakpoints[breakpointId];
    106 
    107149        if (breakpoint.enabled)
    108150            breakpoint._disable();
    109 
    110151        delete this._nativeBreakpoints[breakpointId];
    111         this._updateNativeBreakpointsInSettings();
    112         breakpoint.dispatchEventToListeners("removed");
    113     },
    114 
    115     _updateNativeBreakpointsInSettings: function()
    116     {
    117         var breakpoints = [];
    118         for (var id in this._nativeBreakpoints) {
    119             var breakpoint = this._nativeBreakpoints[id];
    120             breakpoints.push(breakpoint._serializeToJSON());
    121         }
    122         WebInspector.settings.nativeBreakpoints = breakpoints;
     152        this._saveBreakpoints();
    123153    },
    124154
     
    139169            return;
    140170
    141         breakpoint.hit = true;
     171        breakpoint.view.hit = true;
    142172        this._lastHitBreakpoint = breakpoint;
    143         this.dispatchEventToListeners("native-breakpoint-hit", { breakpoint: breakpoint, eventData: eventData });
     173        this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.NativeBreakpointHit, { breakpoint: breakpoint.view, eventData: eventData });
    144174    },
    145175
     
    148178        if (!this._lastHitBreakpoint)
    149179            return;
    150         this._lastHitBreakpoint.hit = false;
     180        this._lastHitBreakpoint.view.hit = false;
    151181        delete this._lastHitBreakpoint;
    152182    },
    153183
    154     restoreBreakpoints: function()
    155     {
    156         var breakpoints = this._persistentBreakpoints();
    157         this._domBreakpoints = [];
     184    _projectChanged: function(event)
     185    {
     186        this._nativeBreakpoints = {};
     187        this._domBreakpointsRestored = false;
     188        this.dispatchEventToListeners(WebInspector.BreakpointManager.Events.ProjectChanged);
     189
     190        var breakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
    158191        for (var i = 0; i < breakpoints.length; ++i) {
    159             if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.DOM)
    160                 this._domBreakpoints.push(breakpoints[i]);
    161             else if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener)
    162                 this.createEventListenerBreakpoint(breakpoints[i].condition.eventName);
    163             else if (breakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.XHR)
    164                 this.createXHRBreakpoint(breakpoints[i].condition.url, !breakpoints[i].enabled);
     192            var breakpoint = breakpoints[i];
     193            if (breakpoint.type === WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener)
     194                this._createEventListenerBreakpoint(breakpoint.condition.eventName, breakpoint.enabled, true);
     195            else if (breakpoint.type === WebInspector.BreakpointManager.NativeBreakpointTypes.XHR)
     196                this._createXHRBreakpoint(breakpoint.condition.url, breakpoint.enabled, true);
    165197        }
    166198    },
     
    175207                return;
    176208            for (var i = 0; i < breakpoints.length; ++i) {
    177                 if (breakpoints[i].type !== WebInspector.BreakpointManager.NativeBreakpointTypes.DOM)
     209                var breakpoint = breakpoints[i];
     210                if (breakpoint.type !== WebInspector.BreakpointManager.NativeBreakpointTypes.DOM)
    178211                    continue;
    179                 var breakpoint = breakpoints[i];
    180212                var nodeId = pathToNodeId[breakpoint.condition.path];
    181213                if (nodeId)
    182                     this.createDOMBreakpoint(nodeId, breakpoint.condition.type, !breakpoint.enabled);
     214                    this._createDOMBreakpoint(nodeId, breakpoint.condition.type, breakpoint.enabled, true);
    183215            }
     216            this._domBreakpointsRestored = true;
     217            this._saveBreakpoints();
    184218        }
    185219
    186         var breakpoints = this._domBreakpoints;
     220        var breakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
    187221        var pathToNodeId = {};
    188222        var pendingCalls = 0;
     
    197231            InspectorBackend.pushNodeByPathToFrontend(path, didPushNodeByPathToFrontend.bind(this, path));
    198232        }
    199     },
    200 
    201     _persistentBreakpoints: function()
    202     {
    203         var result = [];
    204         var breakpoints = WebInspector.settings.nativeBreakpoints;
    205         if (breakpoints instanceof Array) {
    206             for (var i = 0; i < breakpoints.length; ++i) {
    207                 var breakpoint = breakpoints[i];
    208                 if ("type" in breakpoint && "condition" in breakpoint)
    209                     result.push(breakpoint)
     233        if (!pendingCalls)
     234            this._domBreakpointsRestored = true;
     235    },
     236
     237    _saveBreakpoints: function()
     238    {
     239        var breakpoints = [];
     240        for (var breakpointId in this._nativeBreakpoints) {
     241            var breakpoint = this._nativeBreakpoints[breakpointId];
     242            var persistentBreakpoint = breakpoint._serializeToJSON();
     243            persistentBreakpoint.enabled = breakpoint.enabled;
     244            breakpoints.push(persistentBreakpoint);
     245        }
     246        if (!this._domBreakpointsRestored) {
     247            var stickyBreakpoints = this._stickyBreakpoints[WebInspector.settings.projectId] || [];
     248            for (var i = 0; i < stickyBreakpoints.length; ++i) {
     249                if (stickyBreakpoints[i].type === WebInspector.BreakpointManager.NativeBreakpointTypes.DOM)
     250                    breakpoints.push(stickyBreakpoints[i]);
    210251            }
    211252        }
    212         return result;
     253        WebInspector.settings.nativeBreakpoints = breakpoints;
     254
     255        this._stickyBreakpoints[WebInspector.settings.projectId] = breakpoints;
     256        InspectorBackend.setStickyBreakpoints(this._stickyBreakpoints);
     257    },
     258
     259    _validateBreakpoints: function(persistentBreakpoints)
     260    {
     261        var breakpoints = [];
     262        var breakpointsSet = {};
     263        for (var i = 0; i < persistentBreakpoints.length; ++i) {
     264            var breakpoint = persistentBreakpoints[i];
     265            if (!("type" in breakpoint && "enabled" in breakpoint && "condition" in breakpoint))
     266                continue;
     267            var id = breakpoint.type + ":";
     268            var condition = breakpoint.condition;
     269            if (breakpoint.type === WebInspector.BreakpointManager.NativeBreakpointTypes.DOM) {
     270                if (typeof condition.path !== "string" || typeof condition.type !== "number")
     271                    continue;
     272                id += condition.path + ":" + condition.type;
     273            } else if (breakpoint.type === WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener) {
     274                if (typeof condition.eventName !== "string")
     275                    continue;
     276                id += condition.eventName;
     277            } else if (breakpoint.type === WebInspector.BreakpointManager.NativeBreakpointTypes.XHR) {
     278                if (typeof condition.url !== "string")
     279                    continue;
     280                id += condition.url;
     281            }
     282            if (id in breakpointsSet)
     283                continue;
     284            breakpointsSet[id] = true;
     285            breakpoints.push(breakpoint);
     286        }
     287        return breakpoints;
    213288    },
    214289
     
    226301    {
    227302        return "xhr:" + url;
    228     },
    229 
    230     reset: function()
    231     {
    232         this._nativeBreakpoints = {};
    233303    }
    234304}
     
    236306WebInspector.BreakpointManager.prototype.__proto__ = WebInspector.Object.prototype;
    237307
    238 WebInspector.NativeBreakpoint = function(manager, id, enabled)
     308WebInspector.DOMBreakpoint = function(node, type)
     309{
     310    this._nodeId = node.id;
     311    this._path = node.path();
     312    this._type = type;
     313}
     314
     315WebInspector.DOMBreakpoint.prototype = {
     316    _enable: function()
     317    {
     318        InspectorBackend.setDOMBreakpoint(this._nodeId, this._type);
     319    },
     320
     321    _disable: function()
     322    {
     323        InspectorBackend.removeDOMBreakpoint(this._nodeId, this._type);
     324    },
     325
     326    _serializeToJSON: function()
     327    {
     328        var type = WebInspector.BreakpointManager.NativeBreakpointTypes.DOM;
     329        return { type: type, condition: { path: this._path, type: this._type } };
     330    }
     331}
     332
     333WebInspector.EventListenerBreakpoint = function(eventName)
     334{
     335    this._eventName = eventName;
     336}
     337
     338WebInspector.EventListenerBreakpoint.prototype = {
     339    _enable: function()
     340    {
     341        InspectorBackend.setEventListenerBreakpoint(this._eventName);
     342    },
     343
     344    _disable: function()
     345    {
     346        InspectorBackend.removeEventListenerBreakpoint(this._eventName);
     347    },
     348
     349    _serializeToJSON: function()
     350    {
     351        var type = WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener;
     352        return { type: type, condition: { eventName: this._eventName } };
     353    }
     354}
     355
     356WebInspector.XHRBreakpoint = function(url)
     357{
     358    this._url = url;
     359}
     360
     361WebInspector.XHRBreakpoint.prototype = {
     362    _enable: function()
     363    {
     364        InspectorBackend.setXHRBreakpoint(this._url);
     365    },
     366
     367    _disable: function()
     368    {
     369        InspectorBackend.removeXHRBreakpoint(this._url);
     370    },
     371
     372    _serializeToJSON: function()
     373    {
     374        var type = WebInspector.BreakpointManager.NativeBreakpointTypes.XHR;
     375        return { type: type, condition: { url: this._url } };
     376    }
     377}
     378
     379
     380
     381WebInspector.NativeBreakpointView = function(manager, id, enabled)
    239382{
    240383    this._manager = manager;
     
    244387}
    245388
    246 WebInspector.NativeBreakpoint.prototype = {
     389WebInspector.NativeBreakpointView.prototype = {
    247390    get enabled()
    248391    {
     
    253396    {
    254397        this._manager._setNativeBreakpointEnabled(this._id, enabled);
     398        this._enabled = enabled;
     399        this.dispatchEventToListeners("enable-changed");
    255400    },
    256401
     
    270415        this._manager._removeNativeBreakpoint(this._id);
    271416        this._onRemove();
     417        this.dispatchEventToListeners("removed");
    272418    },
    273419
     
    284430}
    285431
    286 WebInspector.NativeBreakpoint.prototype.__proto__ = WebInspector.Object.prototype;
    287 
    288 WebInspector.DOMBreakpoint = function(manager, id, enabled, node, type)
    289 {
    290     WebInspector.NativeBreakpoint.call(this, manager, id, enabled);
     432WebInspector.NativeBreakpointView.prototype.__proto__ = WebInspector.Object.prototype;
     433
     434WebInspector.DOMBreakpointView = function(manager, id, enabled, node, type)
     435{
     436    WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
    291437    this._node = node;
    292438    this._nodeId = node.id;
    293     this._path = node.path();
    294439    this._type = type;
    295     if (enabled)
    296         this._enable();
    297 
    298440    node.breakpoints[this._type] = this;
    299441}
    300442
    301 WebInspector.DOMBreakpoint.prototype = {
     443WebInspector.DOMBreakpointView.prototype = {
    302444    compareTo: function(other)
    303445    {
     
    345487    },
    346488
    347     _enable: function()
    348     {
    349         InspectorBackend.setDOMBreakpoint(this._nodeId, this._type);
    350     },
    351 
    352     _disable: function()
    353     {
    354         InspectorBackend.removeDOMBreakpoint(this._nodeId, this._type);
    355     },
    356 
    357     _serializeToJSON: function()
    358     {
    359         var type = WebInspector.BreakpointManager.NativeBreakpointTypes.DOM;
    360         return { type: type, enabled: this._enabled, condition: { path: this._path, type: this._type } };
    361     },
    362 
    363489    _onRemove: function()
    364490    {
     
    367493}
    368494
    369 WebInspector.DOMBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
    370 
    371 WebInspector.EventListenerBreakpoint = function(manager, id, enabled, eventName)
    372 {
    373     WebInspector.NativeBreakpoint.call(this, manager, id, enabled);
     495WebInspector.DOMBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
     496
     497WebInspector.EventListenerBreakpointView = function(manager, id, enabled, eventName)
     498{
     499    WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
    374500    this._eventName = eventName;
    375     if (enabled)
    376         this._enable();
    377 }
    378 
    379 WebInspector.EventListenerBreakpoint.eventNameForUI = function(eventName)
    380 {
    381     if (!WebInspector.EventListenerBreakpoint._eventNamesForUI) {
    382         WebInspector.EventListenerBreakpoint._eventNamesForUI = {
     501}
     502
     503WebInspector.EventListenerBreakpointView.eventNameForUI = function(eventName)
     504{
     505    if (!WebInspector.EventListenerBreakpointView._eventNamesForUI) {
     506        WebInspector.EventListenerBreakpointView._eventNamesForUI = {
    383507            "instrumentation:setTimer": WebInspector.UIString("Set Timer"),
    384508            "instrumentation:clearTimer": WebInspector.UIString("Clear Timer"),
     
    386510        };
    387511    }
    388     return WebInspector.EventListenerBreakpoint._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1);
    389 }
    390 
    391 WebInspector.EventListenerBreakpoint.prototype = {
     512    return WebInspector.EventListenerBreakpointView._eventNamesForUI[eventName] || eventName.substring(eventName.indexOf(":") + 1);
     513}
     514
     515WebInspector.EventListenerBreakpointView.prototype = {
     516    get eventName()
     517    {
     518        return this._eventName;
     519    },
     520
    392521    compareTo: function(other)
    393522    {
     
    408537    _uiEventName: function()
    409538    {
    410         return WebInspector.EventListenerBreakpoint.eventNameForUI(this._eventName);
    411     },
    412 
    413     _enable: function()
    414     {
    415         InspectorBackend.setEventListenerBreakpoint(this._eventName);
    416     },
    417 
    418     _disable: function()
    419     {
    420         InspectorBackend.removeEventListenerBreakpoint(this._eventName);
    421     },
    422 
    423     _serializeToJSON: function()
    424     {
    425         var type = WebInspector.BreakpointManager.NativeBreakpointTypes.EventListener;
    426         return { type: type, enabled: this._enabled, condition: { eventName: this._eventName } };
    427     }
    428 }
    429 
    430 WebInspector.EventListenerBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
    431 
    432 WebInspector.XHRBreakpoint = function(manager, id, enabled, url)
    433 {
    434     WebInspector.NativeBreakpoint.call(this, manager, id, enabled);
     539        return WebInspector.EventListenerBreakpointView.eventNameForUI(this._eventName);
     540    }
     541}
     542
     543WebInspector.EventListenerBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
     544
     545WebInspector.XHRBreakpointView = function(manager, id, enabled, url)
     546{
     547    WebInspector.NativeBreakpointView.call(this, manager, id, enabled);
    435548    this._url = url;
    436     if (enabled)
    437         this._enable();
    438 }
    439 
    440 WebInspector.XHRBreakpoint.prototype = {
     549}
     550
     551WebInspector.XHRBreakpointView.prototype = {
    441552    compareTo: function(other)
    442553    {
     
    464575        var status = WebInspector.UIString("Paused on a XMLHttpRequest.");
    465576        element.appendChild(document.createTextNode(status));
    466     },
    467 
    468     _enable: function()
    469     {
    470         InspectorBackend.setXHRBreakpoint(this._url);
    471     },
    472 
    473     _disable: function()
    474     {
    475         InspectorBackend.removeXHRBreakpoint(this._url);
    476     },
    477 
    478     _serializeToJSON: function()
    479     {
    480         var type = WebInspector.BreakpointManager.NativeBreakpointTypes.XHR;
    481         return { type: type, enabled: this._enabled, condition: { url: this._url } };
    482     }
    483 }
    484 
    485 WebInspector.XHRBreakpoint.prototype.__proto__ = WebInspector.NativeBreakpoint.prototype;
     577    }
     578}
     579
     580WebInspector.XHRBreakpointView.prototype.__proto__ = WebInspector.NativeBreakpointView.prototype;
    486581
    487582WebInspector.DOMBreakpointTypes = {
  • trunk/WebCore/inspector/front-end/BreakpointsSidebarPane.js

    r73913 r74103  
    3636
    3737    this.bodyElement.appendChild(this.emptyElement);
     38
     39    WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this);
    3840}
    3941
    4042WebInspector.BreakpointsSidebarPane.prototype = {
    41     reset: function()
    42     {
    43         this.listElement.removeChildren();
    44         if (this.listElement.parentElement) {
    45             this.bodyElement.removeChild(this.listElement);
    46             this.bodyElement.appendChild(this.emptyElement);
    47         }
    48     },
    49 
    5043    addBreakpointItem: function(breakpointItem)
    5144    {
     
    9588        this.listElement.removeChild(element);
    9689        if (!this.listElement.firstChild) {
     90            this.bodyElement.removeChild(this.listElement);
     91            this.bodyElement.appendChild(this.emptyElement);
     92        }
     93    },
     94
     95    _projectChanged: function()
     96    {
     97        this.listElement.removeChildren();
     98        if (this.listElement.parentElement) {
    9799            this.bodyElement.removeChild(this.listElement);
    98100            this.bodyElement.appendChild(this.emptyElement);
     
    260262    this.bodyElement.appendChild(this.categoriesElement);
    261263
    262     WebInspector.breakpointManager.addEventListener("event-listener-breakpoint-added", this._breakpointAdded, this);
     264    WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.ProjectChanged, this._projectChanged, this);
     265    WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.EventListenerBreakpointAdded, this._breakpointAdded, this);
    263266
    264267    this._breakpointItems = {};
     
    293296
    294297            var breakpointItem = {};
    295             var title = WebInspector.EventListenerBreakpoint.eventNameForUI(eventName);
     298            var title = WebInspector.EventListenerBreakpointView.eventNameForUI(eventName);
    296299            breakpointItem.element = new TreeElement(title);
    297300            categoryItem.element.appendChild(breakpointItem.element);
     
    343346    _breakpointAdded: function(event)
    344347    {
    345         var breakpoint = event.data.breakpoint;
    346         var eventName = event.data.eventName;
    347 
    348         var breakpointItem = this._breakpointItems[eventName];
     348        var breakpoint = event.data;
     349
     350        var breakpointItem = this._breakpointItems[breakpoint.eventName];
    349351        breakpointItem.breakpoint = breakpoint;
    350352        breakpoint.addEventListener("hit-state-changed", this._breakpointHitStateChanged.bind(this, breakpointItem));
     
    387389    },
    388390
    389     reset: function()
     391    _projectChanged: function()
    390392    {
    391393        for (var eventName in this._breakpointItems) {
  • trunk/WebCore/inspector/front-end/CallStackSidebarPane.js

    r73726 r74103  
    2727{
    2828    WebInspector.SidebarPane.call(this, WebInspector.UIString("Call Stack"));
    29     WebInspector.breakpointManager.addEventListener("native-breakpoint-hit", this._nativeBreakpointHit, this);
     29    WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.NativeBreakpointHit, this._nativeBreakpointHit, this);
    3030    WebInspector.debuggerModel.addEventListener("script-breakpoint-hit", this._scriptBreakpointHit, this);
    3131}
  • trunk/WebCore/inspector/front-end/ElementsPanel.js

    r74038 r74103  
    171171
    172172        delete this.currentQuery;
    173 
    174         if (Preferences.nativeInstrumentationEnabled)
    175             this.sidebarPanes.domBreakpoints.reset();
    176173    },
    177174
  • trunk/WebCore/inspector/front-end/ScriptsPanel.js

    r73730 r74103  
    444444
    445445        this.sidebarPanes.watchExpressions.refreshExpressions();
    446         if (!preserveItems) {
    447             this.sidebarPanes.jsBreakpoints.reset();
    448             if (Preferences.nativeInstrumentationEnabled) {
    449                 this.sidebarPanes.domBreakpoints.reset();
    450                 this.sidebarPanes.xhrBreakpoints.reset();
    451                 this.sidebarPanes.eventListenerBreakpoints.reset();
    452             }
     446        if (!preserveItems)
    453447            this.sidebarPanes.workers.reset();
    454         }
    455448    },
    456449
  • trunk/WebCore/inspector/front-end/Settings.js

    r73017 r74103  
    7171}
    7272
     73WebInspector.Settings.Events = {
     74    ProjectChanged: "project-changed"
     75}
     76
    7377WebInspector.Settings.prototype = {
    7478    installApplicationSetting: function(key, defaultValue)
     
    9296        if (fragmentIndex !== -1)
    9397            url = url.substring(0, fragmentIndex);
    94         this._inspectedURL = url;
     98        this._projectId = url;
     99        this.dispatchEventToListeners(WebInspector.Settings.Events.ProjectChanged);
     100    },
     101
     102    get projectId()
     103    {
     104        return this._projectId;
     105    },
     106
     107    findSettingForAllProjects: function(key)
     108    {
     109        var result = {};
     110        var regexp = "^" + key + ":(.*)";
     111        for (var i = 0; i < window.localStorage.length; ++i) {
     112            var fullKey =  window.localStorage.key(i);
     113            var match = fullKey.match(regexp);
     114            if (!match)
     115                continue;
     116            try {
     117                result[match[1]] = JSON.parse(window.localStorage[fullKey]);
     118            } catch(e) {
     119                window.localStorage.removeItem(fullKey);
     120            }
     121        }
     122        return result;
    95123    },
    96124
     
    124152    _formatProjectKey: function(key)
    125153    {
    126         return key + ":" + this._inspectedURL;
     154        return key + ":" + this._projectId;
    127155    }
    128156}
  • trunk/WebCore/inspector/front-end/inspector.js

    r73916 r74103  
    204204            pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data));
    205205        }
    206         WebInspector.breakpointManager.addEventListener("dom-breakpoint-added", breakpointAdded);
     206        WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.DOMBreakpointAdded, breakpointAdded);
    207207        return pane;
    208208    },
     
    215215            pane.addBreakpointItem(new WebInspector.BreakpointItem(event.data));
    216216        }
    217         WebInspector.breakpointManager.addEventListener("xhr-breakpoint-added", breakpointAdded);
     217        WebInspector.breakpointManager.addEventListener(WebInspector.BreakpointManager.Events.XHRBreakpointAdded, breakpointAdded);
    218218        return pane;
    219219    },
     
    12101210{
    12111211    this.debuggerModel.reset();
    1212     this.breakpointManager.reset();
    12131212
    12141213    for (var panelName in this.panels) {
     
    12231222    this.console.clearMessages();
    12241223    this.extensionServer.notifyInspectorReset();
    1225 
    1226     this.breakpointManager.restoreBreakpoints();
    12271224}
    12281225
     
    12371234    this.settings.inspectedURLChanged(url);
    12381235    this.extensionServer.notifyInspectedURLChanged();
    1239     if (!this._breakpointsRestored) {
    1240         this.breakpointManager.restoreBreakpoints();
    1241         this._breakpointsRestored = true;
    1242     }
    12431236}
    12441237
Note: See TracChangeset for help on using the changeset viewer.