Changeset 61414 in webkit
- Timestamp:
- Jun 18, 2010 9:51:49 AM (14 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 1 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r61413 r61414 1 2010-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 1 40 2010-06-18 Darin Adler <darin@apple.com> 2 41 -
trunk/WebCore/GNUmakefile.am
r61376 r61414 1341 1341 WebCore/inspector/InspectorValues.h \ 1342 1342 WebCore/inspector/InspectorWorkerResource.h \ 1343 WebCore/inspector/ScriptBreakpoint.cpp \ 1343 1344 WebCore/inspector/ScriptBreakpoint.h \ 1344 1345 WebCore/inspector/ScriptDebugListener.h \ -
trunk/WebCore/WebCore.gypi
r61376 r61414 1703 1703 'inspector/InspectorValues.h', 1704 1704 'inspector/InspectorWorkerResource.h', 1705 'inspector/ScriptBreakpoint.cpp', 1705 1706 'inspector/ScriptBreakpoint.h', 1706 1707 'inspector/ScriptDebugListener.h', -
trunk/WebCore/WebCore.pro
r61376 r61414 722 722 inspector/InspectorTimelineAgent.cpp \ 723 723 inspector/InspectorValues.cpp \ 724 inspector/ScriptBreakpoint.cpp \ 724 725 inspector/TimelineRecordFactory.cpp \ 725 726 loader/archive/ArchiveFactory.cpp \ -
trunk/WebCore/WebCore.vcproj/WebCore.vcproj
r61376 r61414 46866 46866 </File> 46867 46867 <File 46868 RelativePath="..\inspector\ScriptBreakpoint.cpp" 46869 > 46870 </File> 46871 <File 46868 46872 RelativePath="..\inspector\ScriptBreakpoint.h" 46869 46873 > -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r61376 r61414 588 588 1CF6BE150E9BB4670025E1CD /* ObjCNodeFilterCondition.h in Headers */ = {isa = PBXBuildFile; fileRef = 1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */; }; 589 589 1CFAE3230A6D6A3F0032593D /* libobjc.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1CFAE3220A6D6A3F0032593D /* libobjc.dylib */; }; 590 200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */; }; 590 591 228C284510D82500009D0D0E /* ScriptWrappable.h in Headers */ = {isa = PBXBuildFile; fileRef = 228C284410D82500009D0D0E /* ScriptWrappable.h */; settings = {ATTRIBUTES = (Private, ); }; }; 591 592 24F54EAC101FE914000AE741 /* ApplicationCacheHost.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */; }; … … 6141 6142 1CF6BE130E9BB4670025E1CD /* ObjCNodeFilterCondition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCNodeFilterCondition.h; sourceTree = "<group>"; }; 6142 6143 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>"; }; 6143 6145 228C284410D82500009D0D0E /* ScriptWrappable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptWrappable.h; sourceTree = "<group>"; }; 6144 6146 24F54EAA101FE914000AE741 /* ApplicationCacheHost.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ApplicationCacheHost.cpp; sourceTree = "<group>"; }; … … 11231 11233 1C81BA050E97348300266E07 /* JavaScriptCallFrame.idl */, 11232 11234 BCC64F5F0DCFB84E0081EF3B /* localizedStrings.js */, 11235 200B190811C277D900DCCD3A /* ScriptBreakpoint.cpp */, 11233 11236 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */, 11234 11237 7AFD4FF3113277B60035B883 /* ScriptDebugListener.h */, … … 21749 21752 E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */, 21750 21753 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */, 21754 200B190911C277D900DCCD3A /* ScriptBreakpoint.cpp in Sources */, 21751 21755 ); 21752 21756 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/inspector/InspectorController.cpp
r61411 r61414 63 63 #include "InspectorFrontend.h" 64 64 #include "InspectorResource.h" 65 #include "InspectorValues.h" 65 66 #include "InspectorWorkerResource.h" 66 67 #include "InspectorTimelineAgent.h" … … 87 88 #include <wtf/CurrentTime.h> 88 89 #include <wtf/ListHashSet.h> 90 #include <wtf/MD5.h> 89 91 #include <wtf/RefCounted.h> 90 92 #include <wtf/StdLibExtras.h> … … 142 144 143 145 static unsigned s_inspectorControllerCount; 146 147 namespace { 148 149 String 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 } 144 167 145 168 InspectorController::InspectorController(Page* page, InspectorClient* client) … … 163 186 , m_attachDebuggerWhenShown(false) 164 187 , m_pausedScriptState(0) 188 , m_breakpointsLoaded(false) 165 189 , m_profilerEnabled(!WTF_USE_JSC) 166 190 , m_recordingUserInitiatedProfile(false) … … 235 259 void InspectorController::setSessionSettings(const String& settingsJSON) 236 260 { 237 m_sessionSettings = InspectorValue:: readJSON(settingsJSON);261 m_sessionSettings = InspectorValue::parseJSON(settingsJSON); 238 262 } 239 263 … … 693 717 m_sourceIDToURL.clear(); 694 718 m_scriptIDToContent.clear(); 719 m_stickyBreakpoints.clear(); 720 m_breakpointsLoaded = false; 695 721 #endif 696 722 #if ENABLE(JAVASCRIPT_DEBUGGER) && USE(JSC) … … 1715 1741 return; 1716 1742 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); 1718 1745 if (it == m_stickyBreakpoints.end()) 1719 it = m_stickyBreakpoints.set( url, SourceBreakpoints()).first;1746 it = m_stickyBreakpoints.set(key, SourceBreakpoints()).first; 1720 1747 it->second.set(lineNumber, breakpoint); 1748 saveBreakpoints(); 1721 1749 } 1722 1750 … … 1729 1757 return; 1730 1758 1731 HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find( url);1759 HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url)); 1732 1760 if (it != m_stickyBreakpoints.end()) 1733 1761 it->second.remove(lineNumber); 1762 saveBreakpoints(); 1734 1763 } 1735 1764 … … 1744 1773 return; 1745 1774 1746 HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(url); 1775 loadBreakpoints(); 1776 HashMap<String, SourceBreakpoints>::iterator it = m_stickyBreakpoints.find(md5Base16(url)); 1747 1777 if (it != m_stickyBreakpoints.end()) { 1748 1778 for (SourceBreakpoints::iterator breakpointIt = it->second.begin(); breakpointIt != it->second.end(); ++breakpointIt) { … … 1796 1826 function.appendArgument(jsonResult); 1797 1827 function.call(); 1828 } 1829 1830 String InspectorController::breakpointsSettingKey() 1831 { 1832 DEFINE_STATIC_LOCAL(String, keyPrefix, ("breakpoints:")); 1833 return keyPrefix + md5Base16(m_mainResource->requestURL()); 1834 } 1835 1836 void 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 1857 void 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()); 1798 1867 } 1799 1868 -
trunk/WebCore/inspector/InspectorController.h
r61411 r61414 330 330 void didEvaluateForTestInFrontend(long callId, const String& jsonResult); 331 331 332 #if ENABLE(JAVASCRIPT_DEBUGGER) 333 String breakpointsSettingKey(); 334 void loadBreakpoints(); 335 void saveBreakpoints(); 336 #endif 337 332 338 Page* m_inspectedPage; 333 339 InspectorClient* m_client; … … 379 385 HashMap<String, String> m_scriptIDToContent; 380 386 HashMap<String, SourceBreakpoints> m_stickyBreakpoints; 387 bool m_breakpointsLoaded; 381 388 382 389 bool m_profilerEnabled; -
trunk/WebCore/inspector/InspectorValues.cpp
r61360 r61414 500 500 } 501 501 502 PassRefPtr<InspectorValue> InspectorValue:: readJSON(const String& json)502 PassRefPtr<InspectorValue> InspectorValue::parseJSON(const String& json) 503 503 { 504 504 const UChar* start = json.characters(); -
trunk/WebCore/inspector/InspectorValues.h
r60774 r61414 74 74 virtual PassRefPtr<InspectorArray> asArray(); 75 75 76 static PassRefPtr<InspectorValue> readJSON(const String& json);76 static PassRefPtr<InspectorValue> parseJSON(const String& json); 77 77 78 78 String toJSONString() const; -
trunk/WebCore/inspector/ScriptBreakpoint.h
r55071 r61414 36 36 namespace WebCore { 37 37 38 class InspectorObject; 39 struct ScriptBreakpoint; 40 41 typedef HashMap<int, ScriptBreakpoint> SourceBreakpoints; 42 38 43 struct ScriptBreakpoint { 39 44 ScriptBreakpoint(bool enabled, const String& condition) … … 49 54 bool enabled; 50 55 String condition; 56 57 static void sourceBreakpointsFromInspectorObject(PassRefPtr<InspectorObject>, SourceBreakpoints*); 58 static PassRefPtr<InspectorObject> inspectorObjectFromSourceBreakpoints(const SourceBreakpoints&); 51 59 }; 52 53 typedef HashMap<int, ScriptBreakpoint> SourceBreakpoints;54 60 55 61 } // namespace WebCore -
trunk/WebCore/inspector/front-end/BreakpointManager.js
r60567 r61414 39 39 this._removeBreakpointFromBackend(this._oneTimeBreakpoint); 40 40 this._oneTimeBreakpoint = breakpoint; 41 // FIXME(40669): one time breakpoint will be persisted in inspector settings if not hit. 41 42 this._saveBreakpointOnBackend(breakpoint); 42 43 }, … … 52 53 addBreakpoint: function(sourceID, sourceURL, line, enabled, condition) 53 54 { 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 }, 63 64 64 65 removeBreakpoint: function(breakpoint) … … 79 80 } 80 81 return breakpoints; 81 }, 82 }, 82 83 83 84 breakpointsForURL: function(url) … … 88 89 breakpoints.push(this._breakpoints[id]); 89 90 } 90 return breakpoints; 91 return breakpoints; 91 92 }, 92 93 … … 95 96 this._breakpoints = {}; 96 97 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; 97 110 }, 98 111 -
trunk/WebCore/inspector/front-end/inspector.js
r61397 r61414 1345 1345 WebInspector.restoredBreakpoint = function(sourceID, sourceURL, line, enabled, condition) 1346 1346 { 1347 this.breakpointManager. addBreakpoint(sourceID, sourceURL, line, enabled, condition);1347 this.breakpointManager.restoredBreakpoint(sourceID, sourceURL, line, enabled, condition); 1348 1348 } 1349 1349
Note: See TracChangeset
for help on using the changeset viewer.