2011-03-29 Ilya Tikhonovsky <loislo@chromium.org>
authorloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 16:12:09 +0000 (16:12 +0000)
committerloislo@chromium.org <loislo@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2011 16:12:09 +0000 (16:12 +0000)
        Reviewed by Yury Semikhatsky.

        Web Inspector: InspectorDOMAgent has unnecessary dependency from InspectorAgent.
        https://bugs.webkit.org/show_bug.cgi?id=57329

        * inspector/InspectorAgent.cpp:
        (WebCore::InspectorAgent::InspectorAgent):
        (WebCore::InspectorAgent::setFrontend):
        * inspector/InspectorAgent.h:
        * inspector/InspectorController.cpp:
        (WebCore::InspectorController::inspect):
        * inspector/InspectorDOMAgent.cpp:
        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
        (WebCore::InspectorDOMAgent::setFrontend):
        (WebCore::InspectorDOMAgent::handleMousePress):
        (WebCore::InspectorDOMAgent::inspect):
        (WebCore::InspectorDOMAgent::focusNode):
        (WebCore::InspectorDOMAgent::highlight):
        (WebCore::InspectorDOMAgent::hideHighlight):
        * inspector/InspectorDOMAgent.h:
        (WebCore::InspectorDOMAgent::create):

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

Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorAgent.cpp
Source/WebCore/inspector/InspectorAgent.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h

index 0378fd03a93115ce7804eaa9a40dfb72fc27a3b0..646ce3e4bdd074a69cd0b29c10bd6673c9ca10c9 100644 (file)
@@ -1,3 +1,27 @@
+2011-03-29  Ilya Tikhonovsky  <loislo@chromium.org>
+
+        Reviewed by Yury Semikhatsky.
+
+        Web Inspector: InspectorDOMAgent has unnecessary dependency from InspectorAgent.
+        https://bugs.webkit.org/show_bug.cgi?id=57329
+
+        * inspector/InspectorAgent.cpp:
+        (WebCore::InspectorAgent::InspectorAgent):
+        (WebCore::InspectorAgent::setFrontend):
+        * inspector/InspectorAgent.h:
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::inspect):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+        (WebCore::InspectorDOMAgent::setFrontend):
+        (WebCore::InspectorDOMAgent::handleMousePress):
+        (WebCore::InspectorDOMAgent::inspect):
+        (WebCore::InspectorDOMAgent::focusNode):
+        (WebCore::InspectorDOMAgent::highlight):
+        (WebCore::InspectorDOMAgent::hideHighlight):
+        * inspector/InspectorDOMAgent.h:
+        (WebCore::InspectorDOMAgent::create):
+
 2011-03-29  Eric Seidel  <eric@webkit.org>
 
         Reviewed by Nikolas Zimmermann.
index caaae3d38746552a300a13876471df4949da8153..22f46e50541cea81c4f8e88e4f77c559cb5f9f11 100644 (file)
@@ -100,7 +100,7 @@ InspectorAgent::InspectorAgent(Page* page, InspectorClient* client, InjectedScri
     , m_instrumentingAgents(new InstrumentingAgents())
     , m_injectedScriptManager(injectedScriptManager)
     , m_state(new InspectorState(client))
-    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), page, m_state.get(), injectedScriptManager))
+    , m_domAgent(InspectorDOMAgent::create(m_instrumentingAgents.get(), page, m_client, m_state.get(), injectedScriptManager))
     , m_cssAgent(new InspectorCSSAgent(m_instrumentingAgents.get(), m_domAgent.get()))
 #if ENABLE(DATABASE)
     , m_databaseAgent(InspectorDatabaseAgent::create(m_instrumentingAgents.get()))
@@ -186,43 +186,6 @@ void InspectorAgent::restoreInspectorStateFromCookie(const String& inspectorStat
 #endif
 }
 
-void InspectorAgent::inspect(Node* node)
-{
-    if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE)
-        node = node->parentNode();
-    m_nodeToFocus = node;
-
-    if (!m_frontend)
-        return;
-
-    focusNode();
-}
-
-void InspectorAgent::focusNode()
-{
-    if (!enabled())
-        return;
-
-    ASSERT(m_frontend);
-    ASSERT(m_nodeToFocus);
-
-    RefPtr<Node> node = m_nodeToFocus.get();
-    m_nodeToFocus = 0;
-
-    Document* document = node->ownerDocument();
-    if (!document)
-        return;
-    Frame* frame = document->frame();
-    if (!frame)
-        return;
-
-    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldScriptState(frame));
-    if (injectedScript.hasNoValue())
-        return;
-
-    injectedScript.inspectNode(node.get());
-}
-
 void InspectorAgent::didClearWindowObjectInWorld(Frame* frame, DOMWrapperWorld* world)
 {
     if (world != mainThreadNormalWorld())
@@ -277,8 +240,6 @@ void InspectorAgent::setFrontend(InspectorFrontend* inspectorFrontend)
         m_frontend->inspector()->showPanel(m_showPanelAfterVisible);
         m_showPanelAfterVisible = String();
     }
-    if (m_nodeToFocus)
-        focusNode();
 #if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(WORKERS)
     WorkersMap::iterator workersEnd = m_workers.end();
     for (WorkersMap::iterator it = m_workers.begin(); it != workersEnd; ++it) {
index 62c9e829cdfd5ce1bf2ba57bbcb5ed34ffadf899..9a525a48f565f29312e827d6e10b2c873bb864e5 100644 (file)
@@ -115,8 +115,6 @@ public:
 
     void restoreInspectorStateFromCookie(const String& inspectorCookie);
 
-    void inspect(Node*);
-
     void setFrontend(InspectorFrontend*);
     InspectorFrontend* frontend() const { return m_frontend; }
     void disconnectFrontend();
@@ -203,7 +201,6 @@ private:
     PassRefPtr<InspectorObject> buildObjectForCookie(const Cookie&);
     PassRefPtr<InspectorArray> buildArrayForCookies(ListHashSet<Cookie>&);
 
-    void focusNode();
     bool isMainResourceLoader(DocumentLoader*, const KURL& requestUrl);
     void issueEvaluateForTestCommands();
 
@@ -230,7 +227,6 @@ private:
     OwnPtr<InspectorApplicationCacheAgent> m_applicationCacheAgent;
 #endif
 
-    RefPtr<Node> m_nodeToFocus;
     RefPtr<InspectorResourceAgent> m_resourceAgent;
     OwnPtr<InspectorRuntimeAgent> m_runtimeAgent;
 
index 80a5e890a7c14968b5a78bb53a9111aedf92bdb4..fe5f06a65290fe28c184c67d9981eb528510db1a 100644 (file)
@@ -219,7 +219,7 @@ void InspectorController::inspect(Node* node)
 
     show();
 
-    m_inspectorAgent->inspect(node);
+    m_inspectorAgent->domAgent()->inspect(node);
 }
 
 bool InspectorController::enabled() const
index 5b32d9be6a6fb17539699df08e22e6d412c143f1..06c597728cc9cba95eec9a678ca3d4fc473a8afd 100644 (file)
@@ -62,7 +62,6 @@
 #include "HTMLElement.h"
 #include "HTMLFrameOwnerElement.h"
 #include "InjectedScriptManager.h"
-#include "InspectorAgent.h"
 #include "InspectorClient.h"
 #include "InspectorFrontend.h"
 #include "InspectorResourceAgent.h"
@@ -258,9 +257,10 @@ void RevalidateStyleAttributeTask::onTimer(Timer<RevalidateStyleAttributeTask>*)
     m_elements.clear();
 }
 
-InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, Page* inspectedPage, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     : m_instrumentingAgents(instrumentingAgents)
     , m_inspectedPage(inspectedPage)
+    , m_client(client)
     , m_inspectorState(inspectorState)
     , m_injectedScriptManager(injectedScriptManager)
     , m_frontend(0)
@@ -284,6 +284,9 @@ void InspectorDOMAgent::setFrontend(InspectorFrontend* frontend)
     m_frontend = frontend->dom();
     m_instrumentingAgents->setInspectorDOMAgent(this);
     m_document = m_inspectedPage->mainFrame()->document();
+
+    if (m_nodeToFocus)
+        focusNode();
 }
 
 void InspectorDOMAgent::clearFrontend()
@@ -895,11 +898,44 @@ bool InspectorDOMAgent::handleMousePress()
     if (m_highlightedNode) {
         RefPtr<Node> node = m_highlightedNode;
         setSearchingForNode(false);
-        m_instrumentingAgents->inspectorAgent()->inspect(node.get());
+        inspect(node.get());
     }
     return true;
 }
 
+void InspectorDOMAgent::inspect(Node* node)
+{
+    if (node->nodeType() != Node::ELEMENT_NODE && node->nodeType() != Node::DOCUMENT_NODE)
+        node = node->parentNode();
+    m_nodeToFocus = node;
+
+    focusNode();
+}
+
+void InspectorDOMAgent::focusNode()
+{
+    if (!m_frontend)
+        return;
+
+    ASSERT(m_nodeToFocus);
+
+    RefPtr<Node> node = m_nodeToFocus.get();
+    m_nodeToFocus = 0;
+
+    Document* document = node->ownerDocument();
+    if (!document)
+        return;
+    Frame* frame = document->frame();
+    if (!frame)
+        return;
+
+    InjectedScript injectedScript = m_injectedScriptManager->injectedScriptFor(mainWorldScriptState(frame));
+    if (injectedScript.hasNoValue())
+        return;
+
+    injectedScript.inspectNode(node.get());
+}
+
 void InspectorDOMAgent::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
 {
     if (!m_searchingForNode)
@@ -935,7 +971,7 @@ void InspectorDOMAgent::highlight(ErrorString*, Node* node)
 {
     ASSERT_ARG(node, node);
     m_highlightedNode = node;
-    m_instrumentingAgents->inspectorAgent()->inspectorClient()->highlight(node);
+    m_client->highlight(node);
 }
 
 void InspectorDOMAgent::highlightDOMNode(ErrorString* error, int nodeId)
@@ -954,7 +990,7 @@ void InspectorDOMAgent::highlightFrame(ErrorString* error, const String& frameId
 void InspectorDOMAgent::hideHighlight(ErrorString*)
 {
     m_highlightedNode = 0;
-    m_instrumentingAgents->inspectorAgent()->inspectorClient()->hideHighlight();
+    m_client->hideHighlight();
 }
 
 void InspectorDOMAgent::resolveNode(ErrorString* error, int nodeId, RefPtr<InspectorObject>* result)
index dfe7669d251cb8d1744d12d385616335f8e9df2c..8aeb66b50faae368510a4665cb4a06689967cba3 100644 (file)
@@ -54,6 +54,7 @@ class Document;
 class Element;
 class Event;
 class GraphicsContext;
+class InspectorClient;
 class InspectorDOMAgent;
 class InspectorFrontend;
 class HitTestResult;
@@ -95,9 +96,9 @@ public:
         virtual void didModifyDOMAttr(Element*) = 0;
     };
 
-    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     {
-        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, page, inspectorState, injectedScriptManager));
+        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, page, client, inspectorState, injectedScriptManager));
     }
 
     ~InspectorDOMAgent();
@@ -158,6 +159,8 @@ public:
     bool handleMousePress();
     bool searchingForNodeInPage() const;
     void mouseDidMoveOverElement(const HitTestResult&, unsigned modifierFlags);
+    void inspect(Node*);
+    void focusNode();
 
     void drawNodeHighlight(GraphicsContext&) const;
 
@@ -171,7 +174,7 @@ public:
     static bool isWhitespace(Node*);
 
 private:
-    InspectorDOMAgent(InstrumentingAgents*, Page*, InspectorState*, InjectedScriptManager*);
+    InspectorDOMAgent(InstrumentingAgents*, Page*, InspectorClient*, InspectorState*, InjectedScriptManager*);
 
     void setSearchingForNode(bool enabled);
     void highlight(ErrorString*, Node*);
@@ -207,6 +210,7 @@ private:
 
     InstrumentingAgents* m_instrumentingAgents;
     Page* m_inspectedPage;
+    InspectorClient* m_client;
     InspectorState* m_inspectorState;
     InjectedScriptManager* m_injectedScriptManager;
     InspectorFrontend::DOM* m_frontend;
@@ -224,6 +228,7 @@ private:
     HashSet<RefPtr<Node> > m_searchResults;
     OwnPtr<RevalidateStyleAttributeTask> m_revalidateStyleAttrTask;
     RefPtr<Node> m_highlightedNode;
+    RefPtr<Node> m_nodeToFocus;
     bool m_searchingForNode;
 };