Changeset 61414 in webkit


Ignore:
Timestamp:
Jun 18, 2010 9:51:49 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2010-06-18 Pavel Podivilov <podivilov@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: persist breakpoints in inspector settings.
https://bugs.webkit.org/show_bug.cgi?id=14190

  • GNUmakefile.am:
  • WebCore.gypi:
  • WebCore.pro:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::InspectorController): (WebCore::InspectorController::setSessionSettings): (WebCore::InspectorController::didCommitLoad): (WebCore::InspectorController::setBreakpoint): (WebCore::InspectorController::removeBreakpoint): (WebCore::InspectorController::didParseSource): (WebCore::InspectorController::breakpointsSettingKey): (WebCore::InspectorController::loadBreakpoints): (WebCore::InspectorController::saveBreakpoints):
  • inspector/InspectorController.h:
  • inspector/InspectorValues.cpp: (WebCore::InspectorValue::parseJSON):
  • inspector/InspectorValues.h:
  • inspector/ScriptBreakpoint.cpp: Added. (WebCore::ScriptBreakpoint::sourceBreakpointsFromInspectorObject): (WebCore::ScriptBreakpoint::inspectorObjectFromSourceBreakpoints):
  • inspector/ScriptBreakpoint.h:
  • inspector/front-end/BreakpointManager.js: (WebInspector.BreakpointManager.prototype.addBreakpoint): (WebInspector.BreakpointManager.prototype.restoredBreakpoint): (WebInspector.BreakpointManager.prototype.breakpointsForSourceID): (WebInspector.BreakpointManager.prototype.breakpointsForURL): (WebInspector.BreakpointManager.prototype._addBreakpoint):
  • inspector/front-end/inspector.js: (WebInspector.restoredBreakpoint):
Location:
trunk/WebCore
Files:
1 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r61413 r61414  
     12010-06-18  Pavel Podivilov  <podivilov@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: persist breakpoints in inspector settings.
     6        https://bugs.webkit.org/show_bug.cgi?id=14190
     7
     8        * GNUmakefile.am:
     9        * WebCore.gypi:
     10        * WebCore.pro:
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * WebCore.xcodeproj/project.pbxproj:
     13        * inspector/InspectorController.cpp:
     14        (WebCore::InspectorController::InspectorController):
     15        (WebCore::InspectorController::setSessionSettings):
     16        (WebCore::InspectorController::didCommitLoad):
     17        (WebCore::InspectorController::setBreakpoint):
     18        (WebCore::InspectorController::removeBreakpoint):
     19        (WebCore::InspectorController::didParseSource):
     20        (WebCore::InspectorController::breakpointsSettingKey):
     21        (WebCore::InspectorController::loadBreakpoints):
     22        (WebCore::InspectorController::saveBreakpoints):
     23        * inspector/InspectorController.h:
     24        * inspector/InspectorValues.cpp:
     25        (WebCore::InspectorValue::parseJSON):
     26        * inspector/InspectorValues.h:
     27        * inspector/ScriptBreakpoint.cpp: Added.
     28        (WebCore::ScriptBreakpoint::sourceBreakpointsFromInspectorObject):
     29        (WebCore::ScriptBreakpoint::inspectorObjectFromSourceBreakpoints):
     30        * inspector/ScriptBreakpoint.h:
     31        * inspector/front-end/BreakpointManager.js:
     32        (WebInspector.BreakpointManager.prototype.addBreakpoint):
     33        (WebInspector.BreakpointManager.prototype.restoredBreakpoint):
     34        (WebInspector.BreakpointManager.prototype.breakpointsForSourceID):
     35        (WebInspector.BreakpointManager.prototype.breakpointsForURL):
     36        (WebInspector.BreakpointManager.prototype._addBreakpoint):
     37        * inspector/front-end/inspector.js:
     38        (WebInspector.restoredBreakpoint):
     39
    1402010-06-18  Darin Adler  <darin@apple.com>
    241
  • trunk/WebCore/GNUmakefile.am

    r61376 r61414  
    13411341        WebCore/inspector/InspectorValues.h \
    13421342        WebCore/inspector/InspectorWorkerResource.h \
     1343        WebCore/inspector/ScriptBreakpoint.cpp \
    13431344        WebCore/inspector/ScriptBreakpoint.h \
    13441345        WebCore/inspector/ScriptDebugListener.h \
  • trunk/WebCore/WebCore.gypi

    r61376 r61414  
    17031703            'inspector/InspectorValues.h',
    17041704            'inspector/InspectorWorkerResource.h',
     1705            'inspector/ScriptBreakpoint.cpp',
    17051706            'inspector/ScriptBreakpoint.h',
    17061707            'inspector/ScriptDebugListener.h',
  • trunk/WebCore/WebCore.pro

    r61376 r61414  
    722722    inspector/InspectorTimelineAgent.cpp \
    723723    inspector/InspectorValues.cpp \
     724    inspector/ScriptBreakpoint.cpp \
    724725    inspector/TimelineRecordFactory.cpp \
    725726    loader/archive/ArchiveFactory.cpp \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r61376 r61414  
    4686646866                        </File>
    4686746867                        <File
     46868                                RelativePath="..\inspector\ScriptBreakpoint.cpp"
     46869                                >
     46870                        </File>
     46871                        <File
    4686846872                                RelativePath="..\inspector\ScriptBreakpoint.h"
    4686946873                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r61376 r61414  
    588588                1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */; };
    589589                1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; };
     590                200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */; };
    590591                228C284510D82500009D0D0E /* ScriptWrappable.h in Headers */ = {isa = PBXBuildFile; fileRef = 228C284410D82500009D0D0E /* ScriptWrappable.h */; settings = {ATTRIBUTES = (Private, ); }; };
    591592                24F54EAC101FE914000AE741 /* ApplicationCacheHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */; };
     
    61416142                1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCNodeFilterCondition.h; sourceTree = "<group>"; };
    61426143                1CFAE3220A6D6A3F0032593D /* libobjc.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libobjc.dylib; path = /usr/lib/libobjc.dylib; sourceTree = "<absolute>"; };
     6144                200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptBreakpoint.cpp; sourceTree = "<group>"; };
    61436145                228C284410D82500009D0D0E /* ScriptWrappable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappable.h; sourceTree = "<group>"; };
    61446146                24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheHost.cpp; sourceTree = "<group>"; };
     
    1123111233                                1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */,
    1123211234                                BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */,
     11235                                200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */,
    1123311236                                7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */,
    1123411237                                7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */,
     
    2174921752                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
    2175021753                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
     21754                                200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */,
    2175121755                        );
    2175221756                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/inspector/InspectorController.cpp

    r61411 r61414  
    6363#include "InspectorFrontend.h"
    6464#include "InspectorResource.h"
     65#include "InspectorValues.h"
    6566#include "InspectorWorkerResource.h"
    6667#include "InspectorTimelineAgent.h"
     
    8788#include <wtf/CurrentTime.h>
    8889#include <wtf/ListHashSet.h>
     90#include <wtf/MD5.h>
    8991#include <wtf/RefCounted.h>
    9092#include <wtf/StdLibExtras.h>
     
    142144
    143145static unsigned s_inspectorControllerCount;
     146
     147namespace {
     148
     149String md5Base16(const String& string)
     150{
     151    static const char digits[] = "0123456789abcdef";
     152
     153    MD5 md5;
     154    md5.addBytes(reinterpret_cast<const uint8_t*>(string.characters()), string.length() * 2);
     155    Vector<uint8_t, 16> digest;
     156    md5.checksum(digest);
     157
     158    Vector<char, 32> result;
     159    for (int i = 0; i < 16; ++i) {
     160        result.append(digits[(digest[i] >> 4) & 0xf]);
     161        result.append(digits[digest[i] & 0xf]);
     162    }
     163    return String(result.data(), result.size());
     164}
     165
     166}
    144167
    145168InspectorController::InspectorController(Page* page, InspectorClient* client)
     
    163186    , m_attachDebuggerWhenShown(false)
    164187    , m_pausedScriptState(0)
     188    , m_breakpointsLoaded(false)
    165189    , m_profilerEnabled(!WTF_USE_JSC)
    166190    , m_recordingUserInitiatedProfile(false)
     
    235259void InspectorController::setSessionSettings(const String& settingsJSON)
    236260{
    237     m_sessionSettings = InspectorValue::readJSON(settingsJSON);
     261    m_sessionSettings = InspectorValue::parseJSON(settingsJSON);
    238262}
    239263
     
    693717        m_sourceIDToURL.clear();
    694718        m_scriptIDToContent.clear();
     719        m_stickyBreakpoints.clear();
     720        m_breakpointsLoaded = false;
    695721#endif
    696722#if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC)
     
    17151741        return;
    17161742
    1717     HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(url);
     1743    String key = md5Base16(url);
     1744    HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(key);
    17181745    if (it == m_stickyBreakpoints.end())
    1719         it = m_stickyBreakpoints.set(url, SourceBreakpoints()).first;
     1746        it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first;
    17201747    it->second.set(lineNumber, breakpoint);
     1748    saveBreakpoints();
    17211749}
    17221750
     
    17291757        return;
    17301758
    1731     HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(url);
     1759    HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
    17321760    if (it != m_stickyBreakpoints.end())
    17331761        it->second.remove(lineNumber);
     1762    saveBreakpoints();
    17341763}
    17351764
     
    17441773        return;
    17451774
    1746     HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(url);
     1775    loadBreakpoints();
     1776    HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url));
    17471777    if (it != m_stickyBreakpoints.end()) {
    17481778        for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) {
     
    17961826    function.appendArgument(jsonResult);
    17971827    function.call();
     1828}
     1829
     1830String InspectorController::breakpointsSettingKey()
     1831{
     1832    DEFINE_STATIC_LOCAL(String, keyPrefix, ("breakpoints:"));
     1833    return keyPrefix + md5Base16(m_mainResource->requestURL());
     1834}
     1835
     1836void InspectorController::loadBreakpoints()
     1837{
     1838    if (m_breakpointsLoaded)
     1839        return;
     1840    m_breakpointsLoaded = true;
     1841
     1842    RefPtr<InspectorValue> parsedSetting = InspectorValue::parseJSON(setting(breakpointsSettingKey()));
     1843    if (!parsedSetting)
     1844        return;
     1845    RefPtr<InspectorObject> breakpoints = parsedSetting->asObject();
     1846    if (!breakpoints)
     1847        return;
     1848    for (InspectorObject::iterator it = breakpoints->begin(); it != breakpoints->end(); ++it) {
     1849        RefPtr<InspectorObject> breakpointsForURL = it->second->asObject();
     1850        if (!breakpointsForURL)
     1851            continue;
     1852        HashMap<String, SourceBreakpoints>::iterator sourceBreakpointsIt = m_stickyBreakpoints.set(it->first, SourceBreakpoints()).first;
     1853        ScriptBreakpoint::sourceBreakpointsFromInspectorObject(breakpointsForURL, &sourceBreakpointsIt->second);
     1854    }
     1855}
     1856
     1857void InspectorController::saveBreakpoints()
     1858{
     1859    RefPtr<InspectorObject> breakpoints = InspectorObject::create();
     1860    for (HashMap<String, SourceBreakpoints>::iterator it(m_stickyBreakpoints.begin()); it != m_stickyBreakpoints.end(); ++it) {
     1861        if (it->second.isEmpty())
     1862            continue;
     1863        RefPtr<InspectorObject> breakpointsForURL = ScriptBreakpoint::inspectorObjectFromSourceBreakpoints(it->second);
     1864        breakpoints->set(it->first, breakpointsForURL);
     1865    }
     1866    setSetting(breakpointsSettingKey(), breakpoints->toJSONString());
    17981867}
    17991868
  • trunk/WebCore/inspector/InspectorController.h

    r61411 r61414  
    330330    void didEvaluateForTestInFrontend(long callId, const String& jsonResult);
    331331
     332#if ENABLE(JAVASCRIPT_DEBUGGER)
     333    String breakpointsSettingKey();
     334    void loadBreakpoints();
     335    void saveBreakpoints();
     336#endif
     337
    332338    Page* m_inspectedPage;
    333339    InspectorClient* m_client;
     
    379385    HashMap<String, String> m_scriptIDToContent;
    380386    HashMap<String, SourceBreakpoints> m_stickyBreakpoints;
     387    bool m_breakpointsLoaded;
    381388
    382389    bool m_profilerEnabled;
  • trunk/WebCore/inspector/InspectorValues.cpp

    r61360 r61414  
    500500}
    501501
    502 PassRefPtr<InspectorValue> InspectorValue::readJSON(const String& json)
     502PassRefPtr<InspectorValue> InspectorValue::parseJSON(const String& json)
    503503{
    504504    const UChar* start = json.characters();
  • trunk/WebCore/inspector/InspectorValues.h

    r60774 r61414  
    7474    virtual PassRefPtr<InspectorArray> asArray();
    7575
    76     static PassRefPtr<InspectorValue> readJSON(const String& json);
     76    static PassRefPtr<InspectorValue> parseJSON(const String& json);
    7777
    7878    String toJSONString() const;
  • trunk/WebCore/inspector/ScriptBreakpoint.h

    r55071 r61414  
    3636namespace WebCore {
    3737
     38class InspectorObject;
     39struct ScriptBreakpoint;
     40
     41typedef HashMap<int, ScriptBreakpoint> SourceBreakpoints;
     42
    3843struct ScriptBreakpoint {
    3944    ScriptBreakpoint(bool enabled, const String& condition)
     
    4954    bool enabled;
    5055    String condition;
     56
     57    static void sourceBreakpointsFromInspectorObject(PassRefPtr<InspectorObject>, SourceBreakpoints*);
     58    static PassRefPtr<InspectorObject> inspectorObjectFromSourceBreakpoints(const SourceBreakpoints&);
    5159};
    52 
    53 typedef HashMap<int, ScriptBreakpoint> SourceBreakpoints;
    5460
    5561} // namespace WebCore
  • trunk/WebCore/inspector/front-end/BreakpointManager.js

    r60567 r61414  
    3939            this._removeBreakpointFromBackend(this._oneTimeBreakpoint);
    4040        this._oneTimeBreakpoint = breakpoint;
     41        // FIXME(40669): one time breakpoint will be persisted in inspector settings if not hit.
    4142        this._saveBreakpointOnBackend(breakpoint);
    4243    },
     
    5253    addBreakpoint: function(sourceID, sourceURL, line, enabled, condition)
    5354    {
    54         var breakpoint = new WebInspector.Breakpoint(this, sourceID, sourceURL, line, enabled, condition);
    55         if (this._breakpoints[breakpoint.id])
    56             return;
    57         if (this._oneTimeBreakpoint && (this._oneTimeBreakpoint.id == breakpoint.id))
    58             delete this._oneTimeBreakpoint;
    59         this._breakpoints[breakpoint.id] = breakpoint;
    60         this._saveBreakpointOnBackend(breakpoint);
    61         this.dispatchEventToListeners("breakpoint-added", breakpoint);
    62     },   
     55        var breakpoint = this._addBreakpoint(sourceID, sourceURL, line, enabled, condition);
     56        if (breakpoint)
     57            this._saveBreakpointOnBackend(breakpoint);
     58    },
     59
     60    restoredBreakpoint: function(sourceID, sourceURL, line, enabled, condition)
     61    {
     62        this._addBreakpoint(sourceID, sourceURL, line, enabled, condition);
     63    },
    6364
    6465    removeBreakpoint: function(breakpoint)
     
    7980        }
    8081        return breakpoints;
    81     },   
     82    },
    8283
    8384    breakpointsForURL: function(url)
     
    8889                breakpoints.push(this._breakpoints[id]);
    8990        }
    90         return breakpoints;       
     91        return breakpoints;
    9192    },
    9293
     
    9596        this._breakpoints = {};
    9697        delete this._oneTimeBreakpoint;
     98    },
     99
     100    _addBreakpoint: function(sourceID, sourceURL, line, enabled, condition)
     101    {
     102        var breakpoint = new WebInspector.Breakpoint(this, sourceID, sourceURL, line, enabled, condition);
     103        if (this._breakpoints[breakpoint.id])
     104            return;
     105        if (this._oneTimeBreakpoint && (this._oneTimeBreakpoint.id == breakpoint.id))
     106            delete this._oneTimeBreakpoint;
     107        this._breakpoints[breakpoint.id] = breakpoint;
     108        this.dispatchEventToListeners("breakpoint-added", breakpoint);
     109        return breakpoint;
    97110    },
    98111
  • trunk/WebCore/inspector/front-end/inspector.js

    r61397 r61414  
    13451345WebInspector.restoredBreakpoint = function(sourceID, sourceURL, line, enabled, condition)
    13461346{
    1347     this.breakpointManager.addBreakpoint(sourceID, sourceURL, line, enabled, condition);
     1347    this.breakpointManager.restoredBreakpoint(sourceID, sourceURL, line, enabled, condition);
    13481348}
    13491349
Note: See TracChangeset for help on using the changeset viewer.