2011-01-12 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 08:21:11 +0000 (08:21 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Jan 2011 08:21:11 +0000 (08:21 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: Extract BrowserDebuggerAgent from InspectorController, InspectorDOMAgent and InspectorDebugger agent.
        We have some methods of Debugger which are related to DOM.
        Lets extract these methods to BrowserDebugger agent.

        http://bugs.webkit.org/show_bug.cgi?id=52294

        * CMakeLists.txt:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
        * inspector/CodeGeneratorInspector.pm:
        * inspector/Inspector.idl:
        * inspector/InspectorBrowserDebuggerAgent.cpp: Added.
        (WebCore::InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent):
        (WebCore::InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent):
        (WebCore::InspectorBrowserDebuggerAgent::discardBindings):
        (WebCore::InspectorBrowserDebuggerAgent::setEventListenerBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::didInsertDOMNode):
        (WebCore::InspectorBrowserDebuggerAgent::didRemoveDOMNode):
        (WebCore::InspectorBrowserDebuggerAgent::setDOMBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::removeDOMBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::willInsertDOMNode):
        (WebCore::InspectorBrowserDebuggerAgent::willRemoveDOMNode):
        (WebCore::InspectorBrowserDebuggerAgent::willModifyDOMAttr):
        (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent):
        (WebCore::InspectorBrowserDebuggerAgent::hasBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints):
        (WebCore::InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded):
        (WebCore::InspectorBrowserDebuggerAgent::setXHRBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::removeXHRBreakpoint):
        (WebCore::InspectorBrowserDebuggerAgent::willSendXMLHttpRequest):
        (WebCore::InspectorBrowserDebuggerAgent::clearForPageNavigation):
        * inspector/InspectorBrowserDebuggerAgent.h: Added.
        (WebCore::InspectorBrowserDebuggerAgent::create):
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::InspectorController):
        (WebCore::InspectorController::inspectedPageDestroyed):
        (WebCore::InspectorController::didCommitLoad):
        (WebCore::InspectorController::enableDebuggerFromFrontend):
        (WebCore::InspectorController::disableDebugger):
        (WebCore::InspectorController::restoreStickyBreakpoints):
        (WebCore::InspectorController::restoreStickyBreakpoint):
        * inspector/InspectorController.h:
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::discardBindings):
        (WebCore::InspectorDOMAgent::didInsertDOMNode):
        (WebCore::InspectorDOMAgent::didRemoveDOMNode):
        * inspector/InspectorDOMAgent.h:
        * inspector/InspectorInstrumentation.cpp:
        (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl):
        (WebCore::InspectorInstrumentation::didInsertDOMNodeImpl):
        (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl):
        (WebCore::InspectorInstrumentation::didRemoveDOMNodeImpl):
        (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl):
        (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
        (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded):

2011-01-13  Ilya Tikhonovsky  <loislo@chromium.org>

        Reviewed by Yury Semikhatsky.

        Just small fix for problem with check-webkit-style.
        It just didn't work for this patch.
        Old code can't concatenate a list of strings with None.

        * Scripts/webkitpy/common/checkout/scm.py:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@75774 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/inspector/CodeGeneratorInspector.pm
Source/WebCore/inspector/Inspector.idl
Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp [new file with mode: 0644]
Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h [new file with mode: 0644]
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorInstrumentation.cpp
Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/scm.py

index c04e8a3..385400a 100644 (file)
@@ -1152,6 +1152,7 @@ SET(WebCore_SOURCES
     inspector/InjectedScript.cpp
     inspector/InjectedScriptHost.cpp
     inspector/InspectorApplicationCacheAgent.cpp
+    inspector/InspectorBrowserDebuggerAgent.cpp
     inspector/InspectorCSSAgent.cpp
     inspector/InspectorClient.cpp
     inspector/InspectorController.cpp
index 66e7741..c84a3cf 100644 (file)
@@ -1,3 +1,66 @@
+2011-01-12  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: Extract BrowserDebuggerAgent from InspectorController, InspectorDOMAgent and InspectorDebugger agent.
+        We have some methods of Debugger which are related to DOM.
+        Lets extract these methods to BrowserDebugger agent.
+
+        http://bugs.webkit.org/show_bug.cgi?id=52294
+
+        * CMakeLists.txt:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * inspector/CodeGeneratorInspector.pm:
+        * inspector/Inspector.idl:
+        * inspector/InspectorBrowserDebuggerAgent.cpp: Added.
+        (WebCore::InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent):
+        (WebCore::InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent):
+        (WebCore::InspectorBrowserDebuggerAgent::discardBindings):
+        (WebCore::InspectorBrowserDebuggerAgent::setEventListenerBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::didInsertDOMNode):
+        (WebCore::InspectorBrowserDebuggerAgent::didRemoveDOMNode):
+        (WebCore::InspectorBrowserDebuggerAgent::setDOMBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::removeDOMBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::willInsertDOMNode):
+        (WebCore::InspectorBrowserDebuggerAgent::willRemoveDOMNode):
+        (WebCore::InspectorBrowserDebuggerAgent::willModifyDOMAttr):
+        (WebCore::InspectorBrowserDebuggerAgent::descriptionForDOMEvent):
+        (WebCore::InspectorBrowserDebuggerAgent::hasBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints):
+        (WebCore::InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded):
+        (WebCore::InspectorBrowserDebuggerAgent::setXHRBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::removeXHRBreakpoint):
+        (WebCore::InspectorBrowserDebuggerAgent::willSendXMLHttpRequest):
+        (WebCore::InspectorBrowserDebuggerAgent::clearForPageNavigation):
+        * inspector/InspectorBrowserDebuggerAgent.h: Added.
+        (WebCore::InspectorBrowserDebuggerAgent::create):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::inspectedPageDestroyed):
+        (WebCore::InspectorController::didCommitLoad):
+        (WebCore::InspectorController::enableDebuggerFromFrontend):
+        (WebCore::InspectorController::disableDebugger):
+        (WebCore::InspectorController::restoreStickyBreakpoints):
+        (WebCore::InspectorController::restoreStickyBreakpoint):
+        * inspector/InspectorController.h:
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::discardBindings):
+        (WebCore::InspectorDOMAgent::didInsertDOMNode):
+        (WebCore::InspectorDOMAgent::didRemoveDOMNode):
+        * inspector/InspectorDOMAgent.h:
+        * inspector/InspectorInstrumentation.cpp:
+        (WebCore::InspectorInstrumentation::willInsertDOMNodeImpl):
+        (WebCore::InspectorInstrumentation::didInsertDOMNodeImpl):
+        (WebCore::InspectorInstrumentation::willRemoveDOMNodeImpl):
+        (WebCore::InspectorInstrumentation::didRemoveDOMNodeImpl):
+        (WebCore::InspectorInstrumentation::willModifyDOMAttrImpl):
+        (WebCore::InspectorInstrumentation::willSendXMLHttpRequestImpl):
+        (WebCore::InspectorInstrumentation::pauseOnNativeEventIfNeeded):
+
 2011-01-13  Kent Tamura  <tkent@chromium.org>
 
         Reviewed by Dimitri Glazkov.
index 5547863..5732135 100644 (file)
             'inspector/InjectedScriptHost.h',
             'inspector/InspectorApplicationCacheAgent.cpp',
             'inspector/InspectorApplicationCacheAgent.h',
+            'inspector/InspectorBrowserDebuggerAgent.cpp',
+            'inspector/InspectorBrowserDebuggerAgent.h',
             'inspector/InspectorClient.cpp',
             'inspector/InspectorClient.h',
             'inspector/InspectorController.cpp',
index 819d569..1b24dbf 100644 (file)
@@ -1043,6 +1043,7 @@ SOURCES += \
     inspector/InjectedScript.cpp \
     inspector/InjectedScriptHost.cpp \
     inspector/InspectorApplicationCacheAgent.cpp \
+    inspector/InspectorBrowserDebuggerAgent.cpp \
     inspector/InspectorCSSAgent.cpp \
     inspector/InspectorClient.cpp \
     inspector/InspectorController.cpp \
@@ -1935,6 +1936,7 @@ HEADERS += \
     inspector/InjectedScript.h \
     inspector/InjectedScriptHost.h \
     inspector/InspectorApplicationCacheAgent.h \
+    inspector/InspectorBrowserDebuggerAgent.h \
     inspector/InspectorController.h \
     inspector/InspectorCSSAgent.h \
     inspector/InspectorDatabaseAgent.h \
index 4217908..fd983db 100755 (executable)
                                >
                        </File>
                        <File
+                               RelativePath="..\inspector\InspectorBrowserDebuggerAgent.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\inspector\InspectorBrowserDebuggerAgent.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\inspector\InspectorClient.cpp"
                                >
                        </File>
index bc3d04d..7130a38 100644 (file)
                4F707A9A11EF679400ACDA69 /* InspectorBackendDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */; };
                4FA3B90A125CD12200300BAD /* InspectorState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FA3B908125CD12100300BAD /* InspectorState.cpp */; };
                4FA3B90B125CD12200300BAD /* InspectorState.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FA3B909125CD12200300BAD /* InspectorState.h */; };
+               4FC2842412DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FC2842212DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h */; };
+               4FC2842512DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FC2842312DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp */; };
                4FD8D0F2119C718B002FA825 /* ScriptGCEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4FD8D0F0119C718B002FA825 /* ScriptGCEvent.cpp */; };
                4FD8D0F3119C718B002FA825 /* ScriptGCEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 4FD8D0F1119C718B002FA825 /* ScriptGCEvent.h */; };
                510184690B08602A004A825F /* CachedPage.h in Headers */ = {isa = PBXBuildFile; fileRef = 510184670B08602A004A825F /* CachedPage.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4F707A9811EF679400ACDA69 /* InspectorBackendDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBackendDispatcher.h; sourceTree = "<group>"; };
                4FA3B908125CD12100300BAD /* InspectorState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorState.cpp; sourceTree = "<group>"; };
                4FA3B909125CD12200300BAD /* InspectorState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorState.h; sourceTree = "<group>"; };
+               4FC2842212DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBrowserDebuggerAgent.h; sourceTree = "<group>"; };
+               4FC2842312DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorBrowserDebuggerAgent.cpp; sourceTree = "<group>"; };
                4FD8D0F0119C718B002FA825 /* ScriptGCEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptGCEvent.cpp; sourceTree = "<group>"; };
                4FD8D0F1119C718B002FA825 /* ScriptGCEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptGCEvent.h; sourceTree = "<group>"; };
                510184670B08602A004A825F /* CachedPage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedPage.h; sourceTree = "<group>"; };
                                7A563F9512DF5C9100F4536D /* InjectedScriptSource.js */,
                                B885E8D211E06DD2009FFBF4 /* InspectorApplicationCacheAgent.cpp */,
                                B885E8D311E06DD2009FFBF4 /* InspectorApplicationCacheAgent.h */,
+                               4FC2842212DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h */,
+                               4FC2842312DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp */,
                                7A1F2B51126C61B20006A7E6 /* InspectorClient.cpp */,
                                1C81B9580E97330800266E07 /* InspectorClient.h */,
                                1C81B9570E97330800266E07 /* InspectorController.cpp */,
                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
                                2E37DFDB12DBAFB800A6B233 /* DOMURL.h in Headers */,
                                2E37E00612DBC5A400A6B233 /* JSDOMURL.h in Headers */,
+                               4FC2842412DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
                                2E37DFDA12DBAFB800A6B233 /* DOMURL.cpp in Sources */,
                                2E37E00512DBC5A400A6B233 /* JSDOMURL.cpp in Sources */,
+                               4FC2842512DDF27E00BF42E4 /* InspectorBrowserDebuggerAgent.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
index b8aea0e..30cc565 100644 (file)
@@ -25,6 +25,11 @@ $typeTransform{"Debugger"} = {
     "header" => "InspectorDebuggerAgent.h",
     "domainAccessor" => "m_inspectorController->m_debuggerAgent",
 };
+$typeTransform{"BrowserDebugger"} = {
+    "forward" => "InspectorBrowserDebuggerAgent",
+    "header" => "InspectorBrowserDebuggerAgent.h",
+    "domainAccessor" => "m_inspectorController->m_browserDebuggerAgent",
+};
 $typeTransform{"Database"} = {
     "forward" => "InspectorDatabaseAgent",
     "header" => "InspectorDatabaseAgent.h",
index 87b38c2..d3e6296 100644 (file)
@@ -223,6 +223,9 @@ module core {
 
         [domain=Inspector] void enableDebuggerFromFrontend(in boolean always);
         [domain=Inspector] void disableDebugger(in boolean always);
+
+        [domain=Inspector] void setStickyBreakpoints(in Object breakpoints);
+
         [notify, domain=Debugger] void debuggerWasEnabled();
         [notify, domain=Debugger] void debuggerWasDisabled();
 
@@ -237,16 +240,12 @@ module core {
         [domain=Debugger] void setBreakpoint(in String sourceID, in unsigned int lineNumber, in String condition, in boolean enabled, out String breakpointId, out unsigned int actualLineNumber);
         [domain=Debugger] void removeBreakpoint(in String breakpointId);
 
-        [domain=Inspector] void setStickyBreakpoints(in Object breakpoints); // FIXME: Move to newly introduced BrowserDebugger.
-
-        [domain=DOM] void setDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger.
-        [domain=DOM] void removeDOMBreakpoint(in long nodeId, in long type); // FIXME: Move to newly introduced BrowserDebugger.
-
-        [domain=Inspector] void setEventListenerBreakpoint(in String eventName); // FIXME: Move to newly introduced BrowserDebugger.
-        [domain=Inspector] void removeEventListenerBreakpoint(in String eventName); // FIXME: Move to newly introduced BrowserDebugger.
-
-        [domain=Inspector] void setXHRBreakpoint(in String url); // FIXME: Move to newly introduced BrowserDebugger.
-        [domain=Inspector] void removeXHRBreakpoint(in String url); // FIXME: Move to newly introduced BrowserDebugger.
+        [domain=BrowserDebugger] void setDOMBreakpoint(in long nodeId, in long type);
+        [domain=BrowserDebugger] void removeDOMBreakpoint(in long nodeId, in long type);
+        [domain=BrowserDebugger] void setEventListenerBreakpoint(in String eventName);
+        [domain=BrowserDebugger] void removeEventListenerBreakpoint(in String eventName);
+        [domain=BrowserDebugger] void setXHRBreakpoint(in String url);
+        [domain=BrowserDebugger] void removeXHRBreakpoint(in String url);
 
         [domain=Debugger] void stepOver();
         [domain=Debugger] void stepInto();
diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.cpp
new file mode 100644 (file)
index 0000000..ad01929
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include "InspectorBrowserDebuggerAgent.h"
+
+#if ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
+
+#include "HTMLElement.h"
+#include "InspectorController.h"
+#include "InspectorDOMAgent.h"
+#include "InspectorDebuggerAgent.h"
+#include "InspectorState.h"
+
+namespace {
+
+enum DOMBreakpointType {
+    SubtreeModified = 0,
+    AttributeModified,
+    NodeRemoved,
+    DOMBreakpointTypesCount
+};
+
+static const char* const domNativeBreakpointType = "DOM";
+static const char* const eventListenerNativeBreakpointType = "EventListener";
+static const char* const xhrNativeBreakpointType = "XHR";
+
+const uint32_t inheritableDOMBreakpointTypesMask = (1 << SubtreeModified);
+const int domBreakpointDerivedTypeShift = 16;
+
+}
+
+namespace WebCore {
+
+InspectorBrowserDebuggerAgent::InspectorBrowserDebuggerAgent(InspectorController* controller)
+    : m_controller(controller)
+    , m_hasXHRBreakpointWithEmptyURL(false)
+{
+}
+
+InspectorBrowserDebuggerAgent::~InspectorBrowserDebuggerAgent()
+{
+}
+
+void InspectorBrowserDebuggerAgent::discardBindings()
+{
+    m_breakpoints.clear();
+}
+
+void InspectorBrowserDebuggerAgent::setEventListenerBreakpoint(const String& eventName)
+{
+    m_eventListenerBreakpoints.add(eventName);
+}
+
+void InspectorBrowserDebuggerAgent::removeEventListenerBreakpoint(const String& eventName)
+{
+    m_eventListenerBreakpoints.remove(eventName);
+}
+
+void InspectorBrowserDebuggerAgent::didInsertDOMNode(Node* node)
+{
+    if (m_breakpoints.size()) {
+        uint32_t mask = m_breakpoints.get(InspectorDOMAgent::innerParentNode(node));
+        uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTypeShift)) & inheritableDOMBreakpointTypesMask;
+        if (inheritableTypesMask)
+            updateSubtreeBreakpoints(node, inheritableTypesMask, true);
+    }
+}
+
+void InspectorBrowserDebuggerAgent::didRemoveDOMNode(Node* node)
+{
+    if (m_breakpoints.size()) {
+        // Remove subtree breakpoints.
+        m_breakpoints.remove(node);
+        Vector<Node*> stack(1, InspectorDOMAgent::innerFirstChild(node));
+        do {
+            Node* node = stack.last();
+            stack.removeLast();
+            if (!node)
+                continue;
+            m_breakpoints.remove(node);
+            stack.append(InspectorDOMAgent::innerFirstChild(node));
+            stack.append(InspectorDOMAgent::innerNextSibling(node));
+        } while (!stack.isEmpty());
+    }
+}
+
+void InspectorBrowserDebuggerAgent::setDOMBreakpoint(long nodeId, long type)
+{
+    Node* node = m_controller->m_domAgent->nodeForId(nodeId);
+    if (!node)
+        return;
+
+    uint32_t rootBit = 1 << type;
+    m_breakpoints.set(node, m_breakpoints.get(node) | rootBit);
+    if (rootBit & inheritableDOMBreakpointTypesMask) {
+        for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child))
+            updateSubtreeBreakpoints(child, rootBit, true);
+    }
+}
+
+void InspectorBrowserDebuggerAgent::removeDOMBreakpoint(long nodeId, long type)
+{
+    Node* node = m_controller->m_domAgent->nodeForId(nodeId);
+    if (!node)
+        return;
+
+    uint32_t rootBit = 1 << type;
+    uint32_t mask = m_breakpoints.get(node) & ~rootBit;
+    if (mask)
+        m_breakpoints.set(node, mask);
+    else
+        m_breakpoints.remove(node);
+
+    if ((rootBit & inheritableDOMBreakpointTypesMask) && !(mask & (rootBit << domBreakpointDerivedTypeShift))) {
+        for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child))
+            updateSubtreeBreakpoints(child, rootBit, false);
+    }
+}
+
+void InspectorBrowserDebuggerAgent::willInsertDOMNode(Node*, Node* parent)
+{
+    InspectorDebuggerAgent* debuggerAgent = m_controller->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    if (hasBreakpoint(parent, SubtreeModified)) {
+        RefPtr<InspectorObject> eventData = InspectorObject::create();
+        descriptionForDOMEvent(parent, SubtreeModified, true, eventData.get());
+        eventData->setString("breakpointType", domNativeBreakpointType);
+        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+    }
+}
+
+void InspectorBrowserDebuggerAgent::willRemoveDOMNode(Node* node)
+{
+    InspectorDebuggerAgent* debuggerAgent = m_controller->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    if (hasBreakpoint(node, NodeRemoved)) {
+        RefPtr<InspectorObject> eventData = InspectorObject::create();
+        descriptionForDOMEvent(node, NodeRemoved, false, eventData.get());
+        eventData->setString("breakpointType", domNativeBreakpointType);
+        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+    } else if (hasBreakpoint(InspectorDOMAgent::innerParentNode(node), SubtreeModified)) {
+        RefPtr<InspectorObject> eventData = InspectorObject::create();
+        descriptionForDOMEvent(node, SubtreeModified, false, eventData.get());
+        eventData->setString("breakpointType", domNativeBreakpointType);
+        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+    }
+}
+
+void InspectorBrowserDebuggerAgent::willModifyDOMAttr(Element* element)
+{
+    InspectorDebuggerAgent* debuggerAgent = m_controller->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    if (hasBreakpoint(element, AttributeModified)) {
+        RefPtr<InspectorObject> eventData = InspectorObject::create();
+        descriptionForDOMEvent(element, AttributeModified, false, eventData.get());
+        eventData->setString("breakpointType", domNativeBreakpointType);
+        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+    }
+}
+
+void InspectorBrowserDebuggerAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, InspectorObject* description)
+{
+    ASSERT(hasBreakpoint(target, breakpointType));
+
+    Node* breakpointOwner = target;
+    if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) {
+        // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint.
+        // Target node may be unknown to frontend, so we need to push it first.
+        long targetNodeId = m_controller->m_domAgent->pushNodePathToFrontend(target);
+        ASSERT(targetNodeId);
+        description->setNumber("targetNodeId", targetNodeId);
+
+        // Find breakpoint owner node.
+        if (!insertion)
+            breakpointOwner = InspectorDOMAgent::innerParentNode(target);
+        ASSERT(breakpointOwner);
+        while (!(m_breakpoints.get(breakpointOwner) & (1 << breakpointType))) {
+            breakpointOwner = InspectorDOMAgent::innerParentNode(breakpointOwner);
+            ASSERT(breakpointOwner);
+        }
+
+        if (breakpointType == SubtreeModified)
+            description->setBoolean("insertion", insertion);
+    }
+
+    long breakpointOwnerNodeId = m_controller->m_domAgent->pushNodePathToFrontend(breakpointOwner);
+    ASSERT(breakpointOwnerNodeId);
+    description->setNumber("nodeId", breakpointOwnerNodeId);
+    description->setNumber("type", breakpointType);
+}
+
+bool InspectorBrowserDebuggerAgent::hasBreakpoint(Node* node, long type)
+{
+    uint32_t rootBit = 1 << type;
+    uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift;
+    return m_breakpoints.get(node) & (rootBit | derivedBit);
+}
+
+void InspectorBrowserDebuggerAgent::updateSubtreeBreakpoints(Node* node, uint32_t rootMask, bool set)
+{
+    uint32_t oldMask = m_breakpoints.get(node);
+    uint32_t derivedMask = rootMask << domBreakpointDerivedTypeShift;
+    uint32_t newMask = set ? oldMask | derivedMask : oldMask & ~derivedMask;
+    if (newMask)
+        m_breakpoints.set(node, newMask);
+    else
+        m_breakpoints.remove(node);
+
+    uint32_t newRootMask = rootMask & ~newMask;
+    if (!newRootMask)
+        return;
+
+    for (Node* child = InspectorDOMAgent::innerFirstChild(node); child; child = InspectorDOMAgent::innerNextSibling(child))
+        updateSubtreeBreakpoints(child, newRootMask, set);
+}
+
+void InspectorBrowserDebuggerAgent::pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous)
+{
+    InspectorDebuggerAgent* debuggerAgent = m_controller->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data());
+    if (!m_eventListenerBreakpoints.contains(fullEventName))
+        return;
+
+    RefPtr<InspectorObject> eventData = InspectorObject::create();
+    eventData->setString("breakpointType", eventListenerNativeBreakpointType);
+    eventData->setString("eventName", fullEventName);
+    if (synchronous)
+        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+    else
+        debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData.release());
+}
+
+void InspectorBrowserDebuggerAgent::setXHRBreakpoint(const String& url)
+{
+    if (url.isEmpty())
+        m_hasXHRBreakpointWithEmptyURL = true;
+    else
+        m_XHRBreakpoints.add(url);
+}
+
+void InspectorBrowserDebuggerAgent::removeXHRBreakpoint(const String& url)
+{
+    if (url.isEmpty())
+        m_hasXHRBreakpointWithEmptyURL = false;
+    else
+        m_XHRBreakpoints.remove(url);
+}
+
+void InspectorBrowserDebuggerAgent::willSendXMLHttpRequest(const String& url)
+{
+    InspectorDebuggerAgent* debuggerAgent = m_controller->m_debuggerAgent.get();
+    if (!debuggerAgent)
+        return;
+
+    String breakpointURL;
+    if (m_hasXHRBreakpointWithEmptyURL)
+        breakpointURL = "";
+    else {
+        for (HashSet<String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) {
+            if (url.contains(*it)) {
+                breakpointURL = *it;
+                break;
+            }
+        }
+    }
+
+    if (!breakpointURL.isNull())
+        return;
+
+    RefPtr<InspectorObject> eventData = InspectorObject::create();
+    eventData->setString("breakpointType", xhrNativeBreakpointType);
+    eventData->setString("breakpointURL", breakpointURL);
+    eventData->setString("url", url);
+    debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData.release());
+}
+
+void InspectorBrowserDebuggerAgent::clearForPageNavigation()
+{
+    m_eventListenerBreakpoints.clear();
+    m_XHRBreakpoints.clear();
+    m_hasXHRBreakpointWithEmptyURL = false;
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(INSPECTOR) && ENABLE(JAVASCRIPT_DEBUGGER)
diff --git a/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h b/Source/WebCore/inspector/InspectorBrowserDebuggerAgent.h
new file mode 100644 (file)
index 0000000..d8a5b7f
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *     * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef InspectorBrowserDebuggerAgent_h
+#define InspectorBrowserDebuggerAgent_h
+
+#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
+
+#include "PlatformString.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/HashSet.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/text/StringHash.h>
+
+namespace WebCore {
+
+class Element;
+class InspectorController;
+class InspectorObject;
+class Node;
+
+class InspectorBrowserDebuggerAgent : public Noncopyable {
+public:
+    static PassOwnPtr<InspectorBrowserDebuggerAgent> create(InspectorController* controller)
+    {
+        return adoptPtr(new InspectorBrowserDebuggerAgent(controller));
+    }
+
+    virtual ~InspectorBrowserDebuggerAgent();
+
+    // BrowserDebugger API for InspectorFrontend
+    void setXHRBreakpoint(const String& url);
+    void removeXHRBreakpoint(const String& url);
+    void setEventListenerBreakpoint(const String& eventName);
+    void removeEventListenerBreakpoint(const String& eventName);
+    void setDOMBreakpoint(long nodeId, long type);
+    void removeDOMBreakpoint(long nodeId, long type);
+
+    // InspectorInstrumentation API
+    void willInsertDOMNode(Node*, Node* parent);
+    void didInsertDOMNode(Node*);
+    void willRemoveDOMNode(Node*);
+    void didRemoveDOMNode(Node*);
+    void willModifyDOMAttr(Element*);
+    void willSendXMLHttpRequest(const String& url);
+    void pauseOnNativeEventIfNeeded(const String& categoryType, const String& eventName, bool synchronous);
+
+    void clearForPageNavigation();
+private:
+    InspectorBrowserDebuggerAgent(InspectorController*);
+
+    void descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, InspectorObject* description);
+    void updateSubtreeBreakpoints(Node*, uint32_t rootMask, bool set);
+    bool hasBreakpoint(Node*, long type);
+    void discardBindings();
+
+    InspectorController* m_controller;
+    HashMap<Node*, uint32_t> m_breakpoints;
+    HashSet<String> m_eventListenerBreakpoints;
+    HashSet<String> m_XHRBreakpoints;
+    bool m_hasXHRBreakpointWithEmptyURL;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR)
+
+#endif // !defined(InspectorBrowserDebuggerAgent_h)
index 20da731..836d63d 100644 (file)
@@ -58,6 +58,7 @@
 #include "InjectedScript.h"
 #include "InjectedScriptHost.h"
 #include "InspectorBackendDispatcher.h"
+#include "InspectorBrowserDebuggerAgent.h"
 #include "InspectorCSSAgent.h"
 #include "InspectorClient.h"
 #include "InspectorDOMAgent.h"
@@ -147,7 +148,6 @@ InspectorController::InspectorController(Page* page, InspectorClient* client)
     , m_injectedScriptHost(InjectedScriptHost::create(this))
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     , m_attachDebuggerWhenShown(false)
-    , m_hasXHRBreakpointWithEmptyURL(false)
     , m_profilerAgent(InspectorProfilerAgent::create(this))
 #endif
 {
@@ -177,6 +177,7 @@ void InspectorController::inspectedPageDestroyed()
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     m_debuggerAgent.clear();
+    m_browserDebuggerAgent.clear();
 #endif
     ASSERT(m_inspectedPage);
     m_inspectedPage = 0;
@@ -725,6 +726,8 @@ void InspectorController::didCommitLoad(DocumentLoader* loader)
 #if ENABLE(JAVASCRIPT_DEBUGGER)
         if (m_debuggerAgent) {
             m_debuggerAgent->clearForPageNavigation();
+            if (m_browserDebuggerAgent)
+                m_browserDebuggerAgent->clearForPageNavigation();
             restoreStickyBreakpoints();
         }
 #endif
@@ -1179,6 +1182,7 @@ void InspectorController::enableDebuggerFromFrontend(bool always)
     ASSERT(m_inspectedPage);
 
     m_debuggerAgent = InspectorDebuggerAgent::create(this, m_frontend.get());
+    m_browserDebuggerAgent = InspectorBrowserDebuggerAgent::create(this);
     restoreStickyBreakpoints();
 
     m_frontend->debuggerWasEnabled();
@@ -1211,6 +1215,7 @@ void InspectorController::disableDebugger(bool always)
     ASSERT(m_inspectedPage);
 
     m_debuggerAgent.clear();
+    m_browserDebuggerAgent.clear();
 
     m_attachDebuggerWhenShown = false;
 
@@ -1231,10 +1236,6 @@ void InspectorController::setStickyBreakpoints(PassRefPtr<InspectorObject> break
 
 void InspectorController::restoreStickyBreakpoints()
 {
-    m_eventListenerBreakpoints.clear();
-    m_XHRBreakpoints.clear();
-    m_hasXHRBreakpointWithEmptyURL = false;
-
     RefPtr<InspectorObject> allBreakpoints = m_state->getObject(InspectorState::stickyBreakpoints);
     KURL url = m_inspectedPage->mainFrame()->loader()->url();
     url.removeFragmentIdentifier();
@@ -1263,13 +1264,14 @@ void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> br
     if (!condition)
         return;
 
-    if (type == eventListenerBreakpointType) {
+    if (type == eventListenerBreakpointType && m_browserDebuggerAgent) {
         if (!enabled)
             return;
         String eventName;
-        if (condition->getString("eventName", &eventName))
-            setEventListenerBreakpoint(eventName);
-    } else if (type == javaScriptBreakpointType) {
+        if (!condition->getString("eventName", &eventName))
+            return;
+        m_browserDebuggerAgent->setEventListenerBreakpoint(eventName);
+    } else if (type == javaScriptBreakpointType && m_debuggerAgent) {
         String url;
         if (!condition->getString("url", &url))
             return;
@@ -1279,63 +1281,16 @@ void InspectorController::restoreStickyBreakpoint(PassRefPtr<InspectorObject> br
         String javaScriptCondition;
         if (!condition->getString("condition", &javaScriptCondition))
             return;
-        if (m_debuggerAgent)
-            m_debuggerAgent->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled);
-    } else if (type == xhrBreakpointType) {
+        m_debuggerAgent->setStickyBreakpoint(url, static_cast<unsigned>(lineNumber), javaScriptCondition, enabled);
+    } else if (type == xhrBreakpointType && m_browserDebuggerAgent) {
         if (!enabled)
             return;
         String url;
-        if (condition->getString("url", &url))
-            setXHRBreakpoint(url);
-    }
-}
-
-void InspectorController::setEventListenerBreakpoint(const String& eventName)
-{
-    m_eventListenerBreakpoints.add(eventName);
-}
-
-void InspectorController::removeEventListenerBreakpoint(const String& eventName)
-{
-    m_eventListenerBreakpoints.remove(eventName);
-}
-
-bool InspectorController::hasEventListenerBreakpoint(const String& eventName)
-{
-    return m_eventListenerBreakpoints.contains(eventName);
-}
-
-void InspectorController::setXHRBreakpoint(const String& url)
-{
-    if (url.isEmpty())
-        m_hasXHRBreakpointWithEmptyURL = true;
-    else
-        m_XHRBreakpoints.add(url);
-}
-
-void InspectorController::removeXHRBreakpoint(const String& url)
-{
-    if (url.isEmpty())
-        m_hasXHRBreakpointWithEmptyURL = false;
-    else
-        m_XHRBreakpoints.remove(url);
-}
-
-bool InspectorController::hasXHRBreakpoint(const String& url, String* breakpointURL)
-{
-    if (m_hasXHRBreakpointWithEmptyURL) {
-        *breakpointURL = "";
-        return true;
-    }
-    for (HashSet<String>::iterator it = m_XHRBreakpoints.begin(); it != m_XHRBreakpoints.end(); ++it) {
-        if (url.contains(*it)) {
-            *breakpointURL = *it;
-            return true;
-        }
+        if (!condition->getString("url", &url))
+            return;
+        m_browserDebuggerAgent->setXHRBreakpoint(url);
     }
-    return false;
 }
-
 #endif
 
 void InspectorController::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)
index fef2a6d..3baf575 100644 (file)
@@ -57,6 +57,7 @@ class InjectedScript;
 class InjectedScriptHost;
 class InspectorArray;
 class InspectorBackendDispatcher;
+class InspectorBrowserDebuggerAgent;
 class InspectorClient;
 class InspectorCSSAgent;
 class InspectorDOMAgent;
@@ -234,12 +235,6 @@ public:
     void resume();
 
     void setStickyBreakpoints(PassRefPtr<InspectorObject> breakpoints);
-    void setEventListenerBreakpoint(const String& eventName);
-    void removeEventListenerBreakpoint(const String& eventName);
-    bool hasEventListenerBreakpoint(const String& eventName);
-    void setXHRBreakpoint(const String& url);
-    void removeXHRBreakpoint(const String& url);
-    bool hasXHRBreakpoint(const String& url, String* breakpointURL);
 #endif
 
     void setInjectedScriptSource(const String& source);
@@ -266,6 +261,7 @@ public:
 private:
     friend class InspectorBackend;
     friend class InspectorBackendDispatcher;
+    friend class InspectorBrowserDebuggerAgent;
     friend class InspectorInstrumentation;
     friend class InjectedScriptHost;
 
@@ -372,10 +368,7 @@ private:
 #if ENABLE(JAVASCRIPT_DEBUGGER)
     bool m_attachDebuggerWhenShown;
     OwnPtr<InspectorDebuggerAgent> m_debuggerAgent;
-
-    HashSet<String> m_eventListenerBreakpoints;
-    HashSet<String> m_XHRBreakpoints;
-    bool m_hasXHRBreakpointWithEmptyURL;
+    OwnPtr<InspectorBrowserDebuggerAgent> m_browserDebuggerAgent;
 
     OwnPtr<InspectorProfilerAgent> m_profilerAgent;
 #endif
index 5d8f408..19ae30d 100644 (file)
@@ -204,16 +204,6 @@ public:
     virtual ~MatchPlainTextJob() { }
 };
 
-enum DOMBreakpointType {
-    SubtreeModified = 0,
-    AttributeModified,
-    NodeRemoved,
-    DOMBreakpointTypesCount
-};
-
-const uint32_t inheritableDOMBreakpointTypesMask = (1 << SubtreeModified);
-const int domBreakpointDerivedTypeShift = 16;
-
 }
 
 InspectorDOMAgent::InspectorDOMAgent(InspectorFrontend* frontend)
@@ -404,7 +394,6 @@ void InspectorDOMAgent::discardBindings()
     releaseDanglingNodes();
     m_childrenRequested.clear();
     m_inspectedNodes.clear();
-    m_breakpoints.clear();
 }
 
 Node* InspectorDOMAgent::nodeForId(long id)
@@ -769,101 +758,6 @@ void InspectorDOMAgent::searchCanceled()
     m_searchResults.clear();
 }
 
-void InspectorDOMAgent::setDOMBreakpoint(long nodeId, long type)
-{
-    Node* node = nodeForId(nodeId);
-    if (!node)
-        return;
-
-    uint32_t rootBit = 1 << type;
-    m_breakpoints.set(node, m_breakpoints.get(node) | rootBit);
-    if (rootBit & inheritableDOMBreakpointTypesMask) {
-        for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child))
-            updateSubtreeBreakpoints(child, rootBit, true);
-    }
-}
-
-void InspectorDOMAgent::removeDOMBreakpoint(long nodeId, long type)
-{
-    Node* node = nodeForId(nodeId);
-    if (!node)
-        return;
-
-    uint32_t rootBit = 1 << type;
-    uint32_t mask = m_breakpoints.get(node) & ~rootBit;
-    if (mask)
-        m_breakpoints.set(node, mask);
-    else
-        m_breakpoints.remove(node);
-
-    if ((rootBit & inheritableDOMBreakpointTypesMask) && !(mask & (rootBit << domBreakpointDerivedTypeShift))) {
-        for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child))
-            updateSubtreeBreakpoints(child, rootBit, false);
-    }
-}
-
-bool InspectorDOMAgent::shouldBreakOnNodeInsertion(Node*, Node* parent, PassRefPtr<InspectorObject> details)
-{
-    if (hasBreakpoint(parent, SubtreeModified)) {
-        descriptionForDOMEvent(parent, SubtreeModified, true, details);
-        return true;
-    }
-    return false;
-}
-
-bool InspectorDOMAgent::shouldBreakOnNodeRemoval(Node* node, PassRefPtr<InspectorObject> details)
-{
-    if (hasBreakpoint(node, NodeRemoved)) {
-        descriptionForDOMEvent(node, NodeRemoved, false, details);
-        return true;
-    }
-    if (hasBreakpoint(innerParentNode(node), SubtreeModified)) {
-        descriptionForDOMEvent(node, SubtreeModified, false, details);
-        return true;
-    }
-    return false;
-}
-
-bool InspectorDOMAgent::shouldBreakOnAttributeModification(Element* element, PassRefPtr<InspectorObject> details)
-{
-    if (hasBreakpoint(element, AttributeModified)) {
-        descriptionForDOMEvent(element, AttributeModified, false, details);
-        return true;
-    }
-    return false;
-}
-
-void InspectorDOMAgent::descriptionForDOMEvent(Node* target, long breakpointType, bool insertion, PassRefPtr<InspectorObject> description)
-{
-    ASSERT(hasBreakpoint(target, breakpointType));
-
-    Node* breakpointOwner = target;
-    if ((1 << breakpointType) & inheritableDOMBreakpointTypesMask) {
-        // For inheritable breakpoint types, target node isn't always the same as the node that owns a breakpoint.
-        // Target node may be unknown to frontend, so we need to push it first.
-        long targetNodeId = pushNodePathToFrontend(target);
-        ASSERT(targetNodeId);
-        description->setNumber("targetNodeId", targetNodeId);
-
-        // Find breakpoint owner node.
-        if (!insertion)
-            breakpointOwner = innerParentNode(target);
-        ASSERT(breakpointOwner);
-        while (!(m_breakpoints.get(breakpointOwner) & (1 << breakpointType))) {
-            breakpointOwner = innerParentNode(breakpointOwner);
-            ASSERT(breakpointOwner);
-        }
-
-        if (breakpointType == SubtreeModified)
-            description->setBoolean("insertion", insertion);
-    }
-
-    long breakpointOwnerNodeId = m_documentNodeToIdMap.get(breakpointOwner);
-    ASSERT(breakpointOwnerNodeId);
-    description->setNumber("nodeId", breakpointOwnerNodeId);
-    description->setNumber("type", breakpointType);
-}
-
 String InspectorDOMAgent::documentURLString(Document* document) const
 {
     if (!document || document->url().isNull())
@@ -1070,13 +964,6 @@ void InspectorDOMAgent::didInsertDOMNode(Node* node)
     if (isWhitespace(node))
         return;
 
-    if (m_breakpoints.size()) {
-        uint32_t mask = m_breakpoints.get(innerParentNode(node));
-        uint32_t inheritableTypesMask = (mask | (mask >> domBreakpointDerivedTypeShift)) & inheritableDOMBreakpointTypesMask;
-        if (inheritableTypesMask)
-            updateSubtreeBreakpoints(node, inheritableTypesMask, true);
-    }
-
     // We could be attaching existing subtree. Forget the bindings.
     unbind(node, &m_documentNodeToIdMap);
 
@@ -1103,21 +990,6 @@ void InspectorDOMAgent::didRemoveDOMNode(Node* node)
     if (isWhitespace(node))
         return;
 
-    if (m_breakpoints.size()) {
-        // Remove subtree breakpoints.
-        m_breakpoints.remove(node);
-        Vector<Node*> stack(1, innerFirstChild(node));
-        do {
-            Node* node = stack.last();
-            stack.removeLast();
-            if (!node)
-                continue;
-            m_breakpoints.remove(node);
-            stack.append(innerFirstChild(node));
-            stack.append(innerNextSibling(node));
-        } while (!stack.isEmpty());
-    }
-
     ContainerNode* parent = node->parentNode();
     long parentId = m_documentNodeToIdMap.get(parent);
     // If parent is not mapped yet -> ignore the event.
@@ -1157,31 +1029,6 @@ void InspectorDOMAgent::characterDataModified(CharacterData* characterData)
     m_frontend->characterDataModified(id, characterData->data());
 }
 
-bool InspectorDOMAgent::hasBreakpoint(Node* node, long type)
-{
-    uint32_t rootBit = 1 << type;
-    uint32_t derivedBit = rootBit << domBreakpointDerivedTypeShift;
-    return m_breakpoints.get(node) & (rootBit | derivedBit);
-}
-
-void InspectorDOMAgent::updateSubtreeBreakpoints(Node* node, uint32_t rootMask, bool set)
-{
-    uint32_t oldMask = m_breakpoints.get(node);
-    uint32_t derivedMask = rootMask << domBreakpointDerivedTypeShift;
-    uint32_t newMask = set ? oldMask | derivedMask : oldMask & ~derivedMask;
-    if (newMask)
-        m_breakpoints.set(node, newMask);
-    else
-        m_breakpoints.remove(node);
-
-    uint32_t newRootMask = rootMask & ~newMask;
-    if (!newRootMask)
-        return;
-
-    for (Node* child = innerFirstChild(node); child; child = innerNextSibling(child))
-        updateSubtreeBreakpoints(child, newRootMask, set);
-}
-
 Node* InspectorDOMAgent::nodeForPath(const String& path)
 {
     // The path is of form "1,HTML,2,BODY,1,DIV"
index 36627f5..9ea690c 100644 (file)
@@ -144,8 +144,14 @@ namespace WebCore {
 
         String documentURLString(Document* document) const;
 
-        void setDOMBreakpoint(long nodeId, long type);
-        void removeDOMBreakpoint(long nodeId, long type);
+        // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently.
+        // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics.
+        static Node* innerFirstChild(Node*);
+        static Node* innerNextSibling(Node*);
+        static Node* innerPreviousSibling(Node*);
+        static unsigned innerChildNodeCount(Node*);
+        static Node* innerParentNode(Node*);
+        static bool isWhitespace(Node*);
 
     private:
         void startListeningFrameDocument(Node* frameOwnerNode);
@@ -170,15 +176,6 @@ namespace WebCore {
         PassRefPtr<InspectorArray> buildArrayForContainerChildren(Node* container, int depth, NodeToIdMap* nodesMap);
         PassRefPtr<InspectorObject> buildObjectForEventListener(const RegisteredEventListener& registeredEventListener, const AtomicString& eventType, Node* node);
 
-        // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently.
-        // We also skip whitespace text nodes conditionally. Following methods encapsulate these specifics.
-        Node* innerFirstChild(Node* node);
-        Node* innerNextSibling(Node* node);
-        Node* innerPreviousSibling(Node* node);
-        unsigned innerChildNodeCount(Node* node);
-        Node* innerParentNode(Node* node);
-        bool isWhitespace(Node* node);
-
         Document* mainFrameDocument() const;
 
         void onMatchJobsTimer(Timer<InspectorDOMAgent>*);
@@ -203,7 +200,6 @@ namespace WebCore {
         Timer<InspectorDOMAgent> m_matchJobsTimer;
         HashSet<RefPtr<Node> > m_searchResults;
         Vector<long> m_inspectedNodes;
-        HashMap<Node*, uint32_t> m_breakpoints;
     };
 
 #endif
index 9395dd5..1f199ec 100644 (file)
@@ -38,6 +38,7 @@
 #include "Event.h"
 #include "EventContext.h"
 #include "InspectorApplicationCacheAgent.h"
+#include "InspectorBrowserDebuggerAgent.h"
 #include "InspectorController.h"
 #include "InspectorDOMAgent.h"
 #include "InspectorDebuggerAgent.h"
 
 namespace WebCore {
 
-static const char* const domNativeBreakpointType = "DOM";
-static const char* const eventListenerNativeBreakpointType = "EventListener";
-static const char* const xhrNativeBreakpointType = "XHR";
-
 static const char* const listenerEventCategoryType = "listener";
 static const char* const instrumentationEventCategoryType = "instrumentation";
 
@@ -81,17 +78,8 @@ static bool eventHasListeners(const AtomicString& eventType, DOMWindow* window,
 void InspectorInstrumentation::willInsertDOMNodeImpl(InspectorController* inspectorController, Node* node, Node* parent)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
-    InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get();
-    if (!domAgent)
-        return;
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    if (domAgent->shouldBreakOnNodeInsertion(node, parent, eventData)) {
-        eventData->setString("breakpointType", domNativeBreakpointType);
-        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
-    }
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->willInsertDOMNode(node, parent);
 #endif
 }
 
@@ -99,27 +87,26 @@ void InspectorInstrumentation::didInsertDOMNodeImpl(InspectorController* inspect
 {
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->didInsertDOMNode(node);
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->didInsertDOMNode(node);
+#endif
 }
 
 void InspectorInstrumentation::willRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
-    InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get();
-    if (!domAgent)
-        return;
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    if (domAgent->shouldBreakOnNodeRemoval(node, eventData)) {
-        eventData->setString("breakpointType", domNativeBreakpointType);
-        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
-    }
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->willRemoveDOMNode(node);
 #endif
 }
 
 void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspectorController, Node* node)
 {
+#if ENABLE(JAVASCRIPT_DEBUGGER)
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->didRemoveDOMNode(node);
+#endif
     if (InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get())
         domAgent->didRemoveDOMNode(node);
 }
@@ -127,17 +114,8 @@ void InspectorInstrumentation::didRemoveDOMNodeImpl(InspectorController* inspect
 void InspectorInstrumentation::willModifyDOMAttrImpl(InspectorController* inspectorController, Element* element)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
-    InspectorDOMAgent* domAgent = inspectorController->m_domAgent.get();
-    if (!domAgent)
-        return;
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    if (domAgent->shouldBreakOnAttributeModification(element, eventData)) {
-        eventData->setString("breakpointType", domNativeBreakpointType);
-        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
-    }
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->willModifyDOMAttr(element);
 #endif
 }
 
@@ -156,19 +134,8 @@ void InspectorInstrumentation::characterDataModifiedImpl(InspectorController* in
 void InspectorInstrumentation::willSendXMLHttpRequestImpl(InspectorController* inspectorController, const String& url)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
-
-    String breakpointURL;
-    if (!inspectorController->hasXHRBreakpoint(url, &breakpointURL))
-        return;
-
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    eventData->setString("breakpointType", xhrNativeBreakpointType);
-    eventData->setString("breakpointURL", breakpointURL);
-    eventData->setString("url", url);
-    debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->willSendXMLHttpRequest(url);
 #endif
 }
 
@@ -546,19 +513,8 @@ bool InspectorInstrumentation::hasFrontend(InspectorController* inspectorControl
 void InspectorInstrumentation::pauseOnNativeEventIfNeeded(InspectorController* inspectorController, const String& categoryType, const String& eventName, bool synchronous)
 {
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    InspectorDebuggerAgent* debuggerAgent = inspectorController->m_debuggerAgent.get();
-    if (!debuggerAgent)
-        return;
-    String fullEventName = String::format("%s:%s", categoryType.utf8().data(), eventName.utf8().data());
-    if (!inspectorController->hasEventListenerBreakpoint(fullEventName))
-        return;
-    RefPtr<InspectorObject> eventData = InspectorObject::create();
-    eventData->setString("breakpointType", eventListenerNativeBreakpointType);
-    eventData->setString("eventName", fullEventName);
-    if (synchronous)
-        debuggerAgent->breakProgram(NativeBreakpointDebuggerEventType, eventData);
-    else
-        debuggerAgent->schedulePauseOnNextStatement(NativeBreakpointDebuggerEventType, eventData);
+    if (InspectorBrowserDebuggerAgent* browserDebuggerAgent = inspectorController->m_browserDebuggerAgent.get())
+        browserDebuggerAgent->pauseOnNativeEventIfNeeded(categoryType, eventName, synchronous);
 #endif
 }
 
index 3590016..a7e507d 100644 (file)
@@ -1,3 +1,13 @@
+2011-01-13  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Just small fix for problem with check-webkit-style.
+        It just didn't work for this patch.
+        Old code can't concatenate a list of strings with None.
+
+        * Scripts/webkitpy/common/checkout/scm.py:
+
 2011-01-13  David Levin  <levin@chromium.org>
 
         Reviewed by Shinichiro Hamaji.
index d5d29f5..c871f8c 100644 (file)
@@ -749,6 +749,8 @@ class Git(SCM):
         """Returns a byte array (str()) representing the patch file.
         Patch files are effectively binary since they may contain
         files of multiple different encodings."""
+        if changed_files == None:
+            changed_files = []
         return self.run(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit), "--"] + changed_files, decode_output=False, cwd=self.checkout_root)
 
     def _run_git_svn_find_rev(self, arg):