Web Inspector: adding pause icon for JavaScript debugging
authorcaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 14:04:58 +0000 (14:04 +0000)
committercaseq@chromium.org <caseq@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 18 Jul 2012 14:04:58 +0000 (14:04 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90880

Patch by Sergey Rogulenko <rogulenko@google.com> on 2012-07-18
Reviewed by Pavel Feldman.

Refactored DOMNodeHighlighter into InspectorOverlay class and added a feature to show a "pause" screen when
the Javascript debugger is paused.

* inspector/DOMNodeHighlighter.cpp:
(WebCore::InspectorOverlay::InspectorOverlay):
(WebCore::InspectorOverlay::paint):
(WebCore::InspectorOverlay::drawOutline):
(WebCore::InspectorOverlay::getHighlight):
(WebCore::InspectorOverlay::setPausedInDebugger):
(WebCore::InspectorOverlay::hideHighlight):
(WebCore):
(WebCore::InspectorOverlay::highlightNode):
(WebCore::InspectorOverlay::setHighlightData):
(WebCore::InspectorOverlay::clearHighlightData):
(WebCore::InspectorOverlay::highlightedNode):
(WebCore::InspectorOverlay::update):
(WebCore::InspectorOverlay::drawHighlight):
(WebCore::InspectorOverlay::drawPausedInDebugger):
* inspector/DOMNodeHighlighter.h:
(WebCore):
(InspectorOverlay):
(WebCore::InspectorOverlay::create):
* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
(WebCore::InspectorController::drawHighlight):
(WebCore::InspectorController::getHighlight):
(WebCore::InspectorController::highlightedNode):
* inspector/InspectorController.h:
(WebCore):
(InspectorController):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::InspectorDOMAgent):
(WebCore::InspectorDOMAgent::~InspectorDOMAgent):
(WebCore::InspectorDOMAgent::handleMousePress):
(WebCore::InspectorDOMAgent::mouseDidMoveOverElement):
(WebCore::InspectorDOMAgent::setSearchingForNode):
(WebCore::InspectorDOMAgent::setHighlightDataFromConfig):
(WebCore::InspectorDOMAgent::setInspectModeEnabled):
(WebCore::InspectorDOMAgent::highlightRect):
(WebCore::InspectorDOMAgent::highlightNode):
(WebCore::InspectorDOMAgent::highlightFrame):
(WebCore::InspectorDOMAgent::hideHighlight):
* inspector/InspectorDOMAgent.h:
(WebCore):
(WebCore::InspectorDOMAgent::create):
(InspectorDOMAgent):
* inspector/InspectorDebuggerAgent.h:
(InspectorDebuggerAgent):
* inspector/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::create):
(WebCore::InspectorPageAgent::InspectorPageAgent):
(WebCore::InspectorPageAgent::didPaint):
* inspector/InspectorPageAgent.h:
(WebCore):
* inspector/PageDebuggerAgent.cpp:
(WebCore::PageDebuggerAgent::create):
(WebCore::PageDebuggerAgent::PageDebuggerAgent):
(WebCore::PageDebuggerAgent::disable):
(WebCore):
(WebCore::PageDebuggerAgent::didPause):
(WebCore::PageDebuggerAgent::didContinue):
* inspector/PageDebuggerAgent.h:
(WebCore):
(PageDebuggerAgent):

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

12 files changed:
Source/WebCore/ChangeLog
Source/WebCore/inspector/DOMNodeHighlighter.cpp
Source/WebCore/inspector/DOMNodeHighlighter.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorController.h
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.h
Source/WebCore/inspector/InspectorDebuggerAgent.h
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorPageAgent.h
Source/WebCore/inspector/PageDebuggerAgent.cpp
Source/WebCore/inspector/PageDebuggerAgent.h

index 3fbec79..e1e9c98 100644 (file)
@@ -1,3 +1,75 @@
+2012-07-18  Sergey Rogulenko  <rogulenko@google.com>
+
+        Web Inspector: adding pause icon for JavaScript debugging
+        https://bugs.webkit.org/show_bug.cgi?id=90880
+
+        Reviewed by Pavel Feldman.
+
+        Refactored DOMNodeHighlighter into InspectorOverlay class and added a feature to show a "pause" screen when
+        the Javascript debugger is paused.
+
+        * inspector/DOMNodeHighlighter.cpp:
+        (WebCore::InspectorOverlay::InspectorOverlay):
+        (WebCore::InspectorOverlay::paint):
+        (WebCore::InspectorOverlay::drawOutline):
+        (WebCore::InspectorOverlay::getHighlight):
+        (WebCore::InspectorOverlay::setPausedInDebugger):
+        (WebCore::InspectorOverlay::hideHighlight):
+        (WebCore):
+        (WebCore::InspectorOverlay::highlightNode):
+        (WebCore::InspectorOverlay::setHighlightData):
+        (WebCore::InspectorOverlay::clearHighlightData):
+        (WebCore::InspectorOverlay::highlightedNode):
+        (WebCore::InspectorOverlay::update):
+        (WebCore::InspectorOverlay::drawHighlight):
+        (WebCore::InspectorOverlay::drawPausedInDebugger):
+        * inspector/DOMNodeHighlighter.h:
+        (WebCore):
+        (InspectorOverlay):
+        (WebCore::InspectorOverlay::create):
+        * inspector/InspectorController.cpp:
+        (WebCore::InspectorController::InspectorController):
+        (WebCore::InspectorController::drawHighlight):
+        (WebCore::InspectorController::getHighlight):
+        (WebCore::InspectorController::highlightedNode):
+        * inspector/InspectorController.h:
+        (WebCore):
+        (InspectorController):
+        * inspector/InspectorDOMAgent.cpp:
+        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
+        (WebCore::InspectorDOMAgent::~InspectorDOMAgent):
+        (WebCore::InspectorDOMAgent::handleMousePress):
+        (WebCore::InspectorDOMAgent::mouseDidMoveOverElement):
+        (WebCore::InspectorDOMAgent::setSearchingForNode):
+        (WebCore::InspectorDOMAgent::setHighlightDataFromConfig):
+        (WebCore::InspectorDOMAgent::setInspectModeEnabled):
+        (WebCore::InspectorDOMAgent::highlightRect):
+        (WebCore::InspectorDOMAgent::highlightNode):
+        (WebCore::InspectorDOMAgent::highlightFrame):
+        (WebCore::InspectorDOMAgent::hideHighlight):
+        * inspector/InspectorDOMAgent.h:
+        (WebCore):
+        (WebCore::InspectorDOMAgent::create):
+        (InspectorDOMAgent):
+        * inspector/InspectorDebuggerAgent.h:
+        (InspectorDebuggerAgent):
+        * inspector/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::create):
+        (WebCore::InspectorPageAgent::InspectorPageAgent):
+        (WebCore::InspectorPageAgent::didPaint):
+        * inspector/InspectorPageAgent.h:
+        (WebCore):
+        * inspector/PageDebuggerAgent.cpp:
+        (WebCore::PageDebuggerAgent::create):
+        (WebCore::PageDebuggerAgent::PageDebuggerAgent):
+        (WebCore::PageDebuggerAgent::disable):
+        (WebCore):
+        (WebCore::PageDebuggerAgent::didPause):
+        (WebCore::PageDebuggerAgent::didContinue):
+        * inspector/PageDebuggerAgent.h:
+        (WebCore):
+        (PageDebuggerAgent):
+
 2012-07-17  Andrey Kosyakov  <caseq@chromium.org>
 
         Web Inspector: intern strings when processing timeline records
index e4c7100..b022daa 100644 (file)
@@ -39,6 +39,7 @@
 #include "FrameView.h"
 #include "GraphicsContext.h"
 #include "GraphicsTypes.h"
+#include "InspectorClient.h"
 #include "Node.h"
 #include "Page.h"
 #include "Range.h"
@@ -462,9 +463,9 @@ static void getOrDrawNodeHighlight(GraphicsContext* context, HighlightData* high
         drawElementTitle(*context, node, renderer, pixelSnappedIntRect(boundingBox), pixelSnappedIntRect(titleAnchorBox), visibleRect, containingFrame->settings());
 }
 
-static void getOrDrawRectHighlight(GraphicsContext* context, Document* document, HighlightData* highlightData, Highlight *highlight)
+static void getOrDrawRectHighlight(GraphicsContext* context, Page* page, HighlightData* highlightData, Highlight *highlight)
 {
-    if (!document)
+    if (!page)
         return;
 
     FloatRect highlightRect(*(highlightData->rect));
@@ -473,7 +474,7 @@ static void getOrDrawRectHighlight(GraphicsContext* context, Document* document,
     highlight->quads.append(highlightRect);
 
     if (context) {
-        FrameView* view = document->frame()->view();
+        FrameView* view = page->mainFrame()->view();
         if (!view->delegatesScrolling()) {
             FloatRect visibleRect = view->visibleContentRect();
             context->translate(-visibleRect.x(), -visibleRect.y());
@@ -485,44 +486,137 @@ static void getOrDrawRectHighlight(GraphicsContext* context, Document* document,
 
 } // anonymous namespace
 
-namespace DOMNodeHighlighter {
+InspectorOverlay::InspectorOverlay(Page* page, InspectorClient* client)
+    : m_page(page)
+    , m_client(client)
+    , m_pausedInDebugger(false)
+{
+}
 
-void drawHighlight(GraphicsContext& context, Document* document, HighlightData* highlightData)
+void InspectorOverlay::paint(GraphicsContext& context)
 {
-    if (!highlightData)
-        return;
+    drawPausedInDebugger(context);
+    drawHighlight(context);
+}
 
-    Highlight highlight;
-    if (highlightData->node)
-        getOrDrawNodeHighlight(&context, highlightData, &highlight);
-    else if (highlightData->rect)
-        getOrDrawRectHighlight(&context, document, highlightData, &highlight);
+void InspectorOverlay::drawOutline(GraphicsContext& context, const LayoutRect& rect, const Color& color)
+{
+    FloatRect outlineRect = rect;
+    drawOutlinedQuad(context, outlineRect, Color(), color);
 }
 
-void getHighlight(Document* document, HighlightData* highlightData, Highlight* highlight)
+void InspectorOverlay::getHighlight(Highlight* highlight) const
 {
-    if (!highlightData)
+    if (!m_highlightData)
         return;
 
-    highlight->contentColor = highlightData->content;
-    highlight->paddingColor = highlightData->padding;
-    highlight->borderColor = highlightData->border;
-    highlight->marginColor = highlightData->margin;
+    highlight->contentColor = m_highlightData->content;
+    highlight->paddingColor = m_highlightData->padding;
+    highlight->borderColor = m_highlightData->border;
+    highlight->marginColor = m_highlightData->margin;
     highlight->type = HighlightTypeRects;
 
-    if (highlightData->node)
-        getOrDrawNodeHighlight(0, highlightData, highlight);
-    else if (highlightData->rect)
-        getOrDrawRectHighlight(0, document, highlightData, highlight);
+    if (m_highlightData->node)
+        getOrDrawNodeHighlight(0, m_highlightData.get(), highlight);
+    else if (m_highlightData->rect)
+        getOrDrawRectHighlight(0, m_page, m_highlightData.get(), highlight);
 }
 
-void drawOutline(GraphicsContext& context, const LayoutRect& rect, const Color& color)
+void InspectorOverlay::setPausedInDebugger(bool flag)
 {
-    FloatRect outlineRect = rect;
-    drawOutlinedQuad(context, outlineRect, Color(), color);
+    m_pausedInDebugger = flag;
+    update();
 }
 
-} // namespace DOMNodeHighlighter
+void InspectorOverlay::hideHighlight()
+{
+    if (m_highlightData) {
+        // FIXME: Clear entire highlight data here, store config upon setInspectModeEnabled
+        m_highlightData->rect.clear();
+        m_highlightData->node.clear();
+    }
+    update();
+}
+
+void InspectorOverlay::highlightNode(Node* node)
+{
+    if (m_highlightData)
+        m_highlightData->node = node;
+    update();
+}
+
+void InspectorOverlay::setHighlightData(PassOwnPtr<HighlightData> highlightData)
+{
+    m_highlightData = highlightData;
+    update();
+}
+
+void InspectorOverlay::clearHighlightData()
+{
+    m_highlightData.clear();
+    update();
+}
+
+Node* InspectorOverlay::highlightedNode() const
+{
+    return m_highlightData ? m_highlightData->node.get() : 0;
+}
+
+void InspectorOverlay::update()
+{
+    if (m_highlightData || m_pausedInDebugger)
+        m_client->highlight();
+    else
+        m_client->hideHighlight();
+}
+
+void InspectorOverlay::drawHighlight(GraphicsContext& context)
+{
+    if (!m_highlightData || (!m_highlightData->rect && !m_highlightData->node))
+        return;
+
+    Highlight highlight;
+    if (m_highlightData->node)
+        getOrDrawNodeHighlight(&context, m_highlightData.get(), &highlight);
+    else if (m_highlightData->rect)
+        getOrDrawRectHighlight(&context, m_page, m_highlightData.get(), &highlight);
+}
+
+void InspectorOverlay::drawPausedInDebugger(GraphicsContext& context)
+{
+    if (!m_pausedInDebugger)
+        return;
+
+    DEFINE_STATIC_LOCAL(Color, backgroundColor, (0, 0, 0, 31));
+    DEFINE_STATIC_LOCAL(Color, textBackgroundColor, (255, 255, 194));
+    DEFINE_STATIC_LOCAL(Color, borderColor, (128, 128, 128));
+    DEFINE_STATIC_LOCAL(int, fontHeight, (24));
+
+    Frame* frame = m_page->mainFrame();
+    Settings* settings = frame->settings();
+    IntRect visibleRect = frame->view()->visibleContentRect();
+
+    context.setFillColor(backgroundColor, ColorSpaceDeviceRGB);
+    context.drawRect(visibleRect);
+
+    FontDescription desc;
+    setUpFontDescription(desc, settings);
+    desc.setComputedSize(fontHeight);
+    Font font = Font(desc, 0, 0);
+    font.update(0);
+
+    String text = "Paused in debugger.";
+    TextRun textRun(text);
+    IntRect titleRect = enclosingIntRect(font.selectionRectForText(textRun, IntPoint(), fontHeight));
+    titleRect.inflate(rectInflatePx);
+    titleRect.setLocation(IntPoint(visibleRect.width() / 2 - titleRect.width() / 2, 0));
+
+    context.setFillColor(textBackgroundColor, ColorSpaceDeviceRGB);
+    context.setStrokeColor(borderColor, ColorSpaceDeviceRGB);
+    context.drawRect(titleRect);
+    context.setFillColor(Color::black, ColorSpaceDeviceRGB);
+    context.drawText(font, textRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + fontHeight));
+}
 
 } // namespace WebCore
 
index f7b6f00..fea6165 100644 (file)
 #include "Color.h"
 #include "FloatQuad.h"
 #include "LayoutTypes.h"
+#include "Node.h"
 
 #include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
 #include <wtf/RefPtr.h>
 #include <wtf/Vector.h>
 
 namespace WebCore {
 
 class Color;
-class Document;
-class FrameView;
 class GraphicsContext;
+class InspectorClient;
+class IntRect;
 class Node;
+class Page;
 
 struct HighlightData {
     Color content;
@@ -75,13 +78,38 @@ struct Highlight {
     Vector<FloatQuad> quads;
 };
 
-namespace DOMNodeHighlighter {
+class InspectorOverlay {
+public:
+    static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
+    {
+        return adoptPtr(new InspectorOverlay(page, client));
+    }
 
-void drawHighlight(GraphicsContext&, Document*, HighlightData*);
-void getHighlight(Document*, HighlightData*, Highlight*);
-void drawOutline(GraphicsContext&, const LayoutRect&, const Color&);
+    void paint(GraphicsContext&);
+    void drawOutline(GraphicsContext&, const LayoutRect&, const Color&);
+    void getHighlight(Highlight*) const;
 
-} // namespace DOMNodeHighlighter
+    void setPausedInDebugger(bool);
+
+    void hideHighlight();
+    void highlightNode(Node*);
+    void setHighlightData(PassOwnPtr<HighlightData>);
+    void clearHighlightData();
+
+    Node* highlightedNode() const;
+
+private:
+    InspectorOverlay(Page*, InspectorClient*);
+
+    void update();
+    void drawHighlight(GraphicsContext&);
+    void drawPausedInDebugger(GraphicsContext&);
+
+    Page* m_page;
+    InspectorClient* m_client;
+    bool m_pausedInDebugger;
+    OwnPtr<HighlightData> m_highlightData;
+};
 
 } // namespace WebCore
 
index 912bbaa..c3f9f08 100644 (file)
@@ -34,6 +34,7 @@
 
 #include "InspectorController.h"
 
+#include "DOMNodeHighlighter.h"
 #include "Frame.h"
 #include "GraphicsContext.h"
 #include "IdentifiersFactory.h"
@@ -78,6 +79,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     : m_instrumentingAgents(adoptPtr(new InstrumentingAgents()))
     , m_injectedScriptManager(InjectedScriptManager::createForPage())
     , m_state(adoptPtr(new InspectorState(inspectorClient)))
+    , m_overlay(InspectorOverlay::create(page, inspectorClient))
     , m_page(page)
     , m_inspectorClient(inspectorClient)
 {
@@ -85,12 +87,12 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     m_inspectorAgent = inspectorAgentPtr.get();
     m_agents.append(inspectorAgentPtr.release());
 
-    OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_inspectorAgent, m_state.get(), m_injectedScriptManager.get(), inspectorClient));
+    OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_inspectorAgent, m_state.get(), m_injectedScriptManager.get(), inspectorClient, m_overlay.get()));
     InspectorPageAgent* pageAgent = pageAgentPtr.get();
     m_pageAgent = pageAgentPtr.get();
     m_agents.append(pageAgentPtr.release());
 
-    OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get(), m_injectedScriptManager.get()));
+    OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), m_injectedScriptManager.get(), m_overlay.get()));
     m_domAgent = domAgentPtr.get();
     m_agents.append(domAgentPtr.release());
 
@@ -130,7 +132,7 @@ InspectorController::InspectorController(Page* page, InspectorClient* inspectorC
     m_agents.append(consoleAgentPtr.release());
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
-    OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
+    OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get(), m_overlay.get()));
     m_debuggerAgent = debuggerAgentPtr.get();
     m_agents.append(debuggerAgentPtr.release());
 
@@ -297,12 +299,12 @@ void InspectorController::evaluateForTestInFrontend(long callId, const String& s
 
 void InspectorController::drawHighlight(GraphicsContext& context) const
 {
-    m_domAgent->drawHighlight(context);
+    m_overlay->paint(context);
 }
 
 void InspectorController::getHighlight(Highlight* highlight) const
 {
-    m_domAgent->getHighlight(highlight);
+    m_overlay->getHighlight(highlight);
 }
 
 void InspectorController::inspect(Node* node)
@@ -344,7 +346,7 @@ void InspectorController::hideHighlight()
 
 Node* InspectorController::highlightedNode() const
 {
-    return m_domAgent->highlightedNode();
+    return m_overlay->highlightedNode();
 }
 
 #if ENABLE(JAVASCRIPT_DEBUGGER)
index b7e1cbf..90996e5 100644 (file)
@@ -52,6 +52,7 @@ class InspectorDebuggerAgent;
 class InspectorFrontend;
 class InspectorFrontendChannel;
 class InspectorFrontendClient;
+class InspectorOverlay;
 class InspectorPageAgent;
 class InspectorProfilerAgent;
 class InspectorResourceAgent;
@@ -120,6 +121,7 @@ private:
     OwnPtr<InstrumentingAgents> m_instrumentingAgents;
     OwnPtr<InjectedScriptManager> m_injectedScriptManager;
     OwnPtr<InspectorState> m_state;
+    OwnPtr<InspectorOverlay> m_overlay;
 
     InspectorAgent* m_inspectorAgent;
     InspectorDOMAgent* m_domAgent;
index 9079589..a5a26bc 100644 (file)
@@ -66,7 +66,6 @@
 #include "HitTestResult.h"
 #include "IdentifiersFactory.h"
 #include "InjectedScriptManager.h"
-#include "InspectorClient.h"
 #include "InspectorFrontend.h"
 #include "InspectorHistory.h"
 #include "InspectorPageAgent.h"
@@ -194,11 +193,11 @@ String InspectorDOMAgent::toErrorString(const ExceptionCode& ec)
     return "";
 }
 
-InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
     : InspectorBaseAgent<InspectorDOMAgent>("DOM", instrumentingAgents, inspectorState)
     , m_pageAgent(pageAgent)
-    , m_client(client)
     , m_injectedScriptManager(injectedScriptManager)
+    , m_overlay(overlay)
     , m_frontend(0)
     , m_domListener(0)
     , m_lastNodeId(1)
@@ -210,7 +209,6 @@ InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, I
 InspectorDOMAgent::~InspectorDOMAgent()
 {
     reset();
-    ASSERT(!m_highlightData || (!m_highlightData->node && !m_highlightData->rect));
     ASSERT(!m_searchingForNode);
 }
 
@@ -270,11 +268,6 @@ Vector<Document*> InspectorDOMAgent::documents()
     return result;
 }
 
-Node* InspectorDOMAgent::highlightedNode() const
-{
-    return m_highlightData ? m_highlightData->node.get() : 0;
-}
-
 void InspectorDOMAgent::reset()
 {
     if (m_history)
@@ -938,11 +931,11 @@ bool InspectorDOMAgent::handleMousePress()
     if (!m_searchingForNode)
         return false;
 
-    if (m_highlightData && m_highlightData->node) {
-        RefPtr<Node> node = m_highlightData->node;
-        inspect(node.get());
+    if (Node* node = m_overlay->highlightedNode()) {
+        inspect(node);
+        return true;
     }
-    return true;
+    return false;
 }
 
 void InspectorDOMAgent::inspect(Node* node)
@@ -982,16 +975,14 @@ void InspectorDOMAgent::focusNode()
 
 void InspectorDOMAgent::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
 {
-    if (!m_searchingForNode || !m_highlightData)
+    if (!m_searchingForNode)
         return;
 
     Node* node = result.innerNode();
     while (node && node->nodeType() == Node::TEXT_NODE)
         node = node->parentNode();
-    if (node) {
-        m_highlightData->node = node;
-        highlight();
-    }
+    if (node)
+        m_overlay->highlightNode(node);
 }
 
 void InspectorDOMAgent::setSearchingForNode(bool enabled, InspectorObject* highlightConfig)
@@ -1004,48 +995,42 @@ void InspectorDOMAgent::setSearchingForNode(bool enabled, InspectorObject* highl
     else {
         ErrorString error;
         hideHighlight(&error);
-        m_highlightData.clear();
+        m_overlay->clearHighlightData();
     }
 }
 
-void InspectorDOMAgent::setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<InspectorObject>* highlightConfig)
-{
-    setSearchingForNode(enabled, highlightConfig ? highlightConfig->get() : 0);
-}
-
 bool InspectorDOMAgent::setHighlightDataFromConfig(InspectorObject* highlightConfig)
 {
     if (!highlightConfig) {
-        m_highlightData.clear();
+        m_overlay->clearHighlightData();
         return false;
     }
 
-    m_highlightData = adoptPtr(new HighlightData());
+    OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
     bool showInfo = false; // Default: false (do not show a tooltip).
     highlightConfig->getBoolean("showInfo", &showInfo);
-    m_highlightData->showInfo = showInfo;
-    m_highlightData->content = parseConfigColor("contentColor", highlightConfig);
-    m_highlightData->contentOutline = parseConfigColor("contentOutlineColor", highlightConfig);
-    m_highlightData->padding = parseConfigColor("paddingColor", highlightConfig);
-    m_highlightData->border = parseConfigColor("borderColor", highlightConfig);
-    m_highlightData->margin = parseConfigColor("marginColor", highlightConfig);
+    highlightData->showInfo = showInfo;
+    highlightData->content = parseConfigColor("contentColor", highlightConfig);
+    highlightData->contentOutline = parseConfigColor("contentOutlineColor", highlightConfig);
+    highlightData->padding = parseConfigColor("paddingColor", highlightConfig);
+    highlightData->border = parseConfigColor("borderColor", highlightConfig);
+    highlightData->margin = parseConfigColor("marginColor", highlightConfig);
+    m_overlay->setHighlightData(highlightData.release());
     return true;
 }
 
-void InspectorDOMAgent::highlight()
+void InspectorDOMAgent::setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<InspectorObject>* highlightConfig)
 {
-    // This method requires m_highlightData to have been filled in by its client.
-    ASSERT(m_highlightData);
-    m_client->highlight();
+    setSearchingForNode(enabled, highlightConfig ? highlightConfig->get() : 0);
 }
 
 void InspectorDOMAgent::highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
 {
-    m_highlightData = adoptPtr(new HighlightData());
-    m_highlightData->rect = adoptPtr(new IntRect(x, y, width, height));
-    m_highlightData->content = parseColor(color);
-    m_highlightData->contentOutline = parseColor(outlineColor);
-    m_client->highlight();
+    OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
+    highlightData->rect = adoptPtr(new IntRect(x, y, width, height));
+    highlightData->content = parseColor(color);
+    highlightData->contentOutline = parseColor(outlineColor);
+    m_overlay->setHighlightData(highlightData.release());
 }
 
 void InspectorDOMAgent::highlightNode(
@@ -1053,12 +1038,9 @@ void InspectorDOMAgent::highlightNode(
     int nodeId,
     const RefPtr<InspectorObject>& highlightConfig)
 {
-    if (Node* node = nodeForId(nodeId)) {
-        if (setHighlightDataFromConfig(highlightConfig.get())) {
-            m_highlightData->node = node;
-            highlight();
-        }
-    }
+    if (Node* node = nodeForId(nodeId))
+        if (setHighlightDataFromConfig(highlightConfig.get()))
+            m_overlay->highlightNode(node);
 }
 
 void InspectorDOMAgent::highlightFrame(
@@ -1069,22 +1051,18 @@ void InspectorDOMAgent::highlightFrame(
 {
     Frame* frame = m_pageAgent->frameForId(frameId);
     if (frame && frame->ownerElement()) {
-        m_highlightData = adoptPtr(new HighlightData());
-        m_highlightData->node = frame->ownerElement();
-        m_highlightData->showInfo = true; // Always show tooltips for frames.
-        m_highlightData->content = parseColor(color);
-        m_highlightData->contentOutline = parseColor(outlineColor);
-        highlight();
+        OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
+        highlightData->node = frame->ownerElement();
+        highlightData->showInfo = true; // Always show tooltips for frames.
+        highlightData->content = parseColor(color);
+        highlightData->contentOutline = parseColor(outlineColor);
+        m_overlay->setHighlightData(highlightData.release());
     }
 }
 
 void InspectorDOMAgent::hideHighlight(ErrorString*)
 {
-    if (m_highlightData) {
-        m_highlightData->node.clear();
-        m_highlightData->rect.clear();
-    }
-    m_client->hideHighlight();
+    m_overlay->hideHighlight();
 }
 
 void InspectorDOMAgent::moveTo(ErrorString* errorString, int nodeId, int targetElementId, const int* const anchorNodeId, int* newNodeId)
@@ -1599,22 +1577,6 @@ PassRefPtr<TypeBuilder::Runtime::RemoteObject> InspectorDOMAgent::resolveNode(No
     return injectedScript.wrapNode(node, objectGroup);
 }
 
-void InspectorDOMAgent::drawHighlight(GraphicsContext& context) const
-{
-    if (!m_highlightData)
-        return;
-
-    DOMNodeHighlighter::drawHighlight(context, m_highlightData->node ? m_highlightData->node->document() : m_document.get(), m_highlightData.get());
-}
-
-void InspectorDOMAgent::getHighlight(Highlight* highlight) const
-{
-    if (!m_highlightData)
-        return;
-
-    DOMNodeHighlighter::getHighlight(m_highlightData->node ? m_highlightData->node->document() : m_document.get(), m_highlightData.get(), highlight);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INSPECTOR)
index b05ab57..9106230 100644 (file)
@@ -55,12 +55,10 @@ class DOMEditor;
 class Document;
 class Element;
 class Event;
-class GraphicsContext;
-class InspectorClient;
 class InspectorFrontend;
 class InspectorHistory;
+class InspectorOverlay;
 class InspectorPageAgent;
-class IntRect;
 class HitTestResult;
 class HTMLElement;
 class InspectorState;
@@ -71,9 +69,6 @@ class RevalidateStyleAttributeTask;
 class ScriptValue;
 class ShadowRoot;
 
-struct Highlight;
-struct HighlightData;
-
 typedef String ErrorString;
 
 #if ENABLE(INSPECTOR)
@@ -103,9 +98,9 @@ public:
         virtual void didModifyDOMAttr(Element*) = 0;
     };
 
-    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
+    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
     {
-        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, client, inspectorState, injectedScriptManager));
+        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, inspectorState, injectedScriptManager, overlay));
     }
 
     static String toErrorString(const ExceptionCode&);
@@ -151,8 +146,6 @@ public:
     virtual void redo(ErrorString*);
     virtual void markUndoableState(ErrorString*);
 
-    Node* highlightedNode() const;
-
     void getEventListeners(Node*, Vector<EventListenerInfo>& listenersArray, bool includeAncestors);
 
     // Methods called from the InspectorInstrumentation.
@@ -185,9 +178,6 @@ public:
     void inspect(Node*);
     void focusNode();
 
-    void drawHighlight(GraphicsContext&) const;
-    void getHighlight(Highlight*) const;
-
     InspectorHistory* history() { return m_history.get(); }
 
     // We represent embedded doms as a part of the same hierarchy. Hence we treat children of frame owners differently.
@@ -205,11 +195,10 @@ public:
     InspectorPageAgent* pageAgent() { return m_pageAgent; }
 
 private:
-    InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorState*, InjectedScriptManager*);
+    InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*, InjectedScriptManager*, InspectorOverlay*);
 
     void setSearchingForNode(bool enabled, InspectorObject* highlightConfig);
     bool setHighlightDataFromConfig(InspectorObject* highlightConfig);
-    void highlight();
 
     // Node-related methods.
     typedef HashMap<RefPtr<Node>, int> NodeToIdMap;
@@ -241,8 +230,8 @@ private:
 #endif
 
     InspectorPageAgent* m_pageAgent;
-    InspectorClient* m_client;
     InjectedScriptManager* m_injectedScriptManager;
+    InspectorOverlay* m_overlay;
     InspectorFrontend::DOM* m_frontend;
     DOMListener* m_domListener;
     NodeToIdMap m_documentNodeToIdMap;
@@ -256,7 +245,6 @@ private:
     typedef HashMap<String, Vector<RefPtr<Node> > > SearchResults;
     SearchResults m_searchResults;
     OwnPtr<RevalidateStyleAttributeTask> m_revalidateStyleAttrTask;
-    OwnPtr<HighlightData> m_highlightData;
     RefPtr<Node> m_nodeToFocus;
     bool m_searchingForNode;
     OwnPtr<InspectorHistory> m_history;
index 09c97d1..b2e79ad 100644 (file)
@@ -133,17 +133,18 @@ protected:
     InjectedScriptManager* injectedScriptManager() { return m_injectedScriptManager; }
     virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
 
+    virtual void disable();
+    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
+    virtual void didContinue();
+
 private:
     void enable();
-    void disable();
     bool enabled();
 
     PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::CallFrame> > currentCallFrames();
 
     virtual void didParseSource(const String& scriptId, const Script&);
     virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
-    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
-    virtual void didContinue();
 
     void setPauseOnExceptionsImpl(ErrorString*, int);
 
index ef34537..9676d13 100644 (file)
@@ -223,9 +223,9 @@ bool InspectorPageAgent::sharedBufferContent(PassRefPtr<SharedBuffer> buffer, co
     return decodeSharedBuffer(buffer, textEncodingName, result);
 }
 
-PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
+PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay)
 {
-    return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, inspectorAgent, state, injectedScriptManager, client));
+    return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, inspectorAgent, state, injectedScriptManager, client, overlay));
 }
 
 // static
@@ -308,13 +308,14 @@ TypeBuilder::Page::ResourceType::Enum InspectorPageAgent::cachedResourceTypeJson
     return resourceTypeJson(cachedResourceType(cachedResource));
 }
 
-InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
+InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay)
     : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspectorState)
     , m_page(page)
     , m_inspectorAgent(inspectorAgent)
     , m_injectedScriptManager(injectedScriptManager)
     , m_client(client)
     , m_frontend(0)
+    , m_overlay(overlay)
     , m_lastScriptIdentifier(0)
     , m_lastPaintContext(0)
     , m_didLoadEventFire(false)
@@ -885,7 +886,7 @@ void InspectorPageAgent::didPaint()
         Color(0, 0, 0xFF, 0x3F),
     };
 
-    DOMNodeHighlighter::drawOutline(*m_lastPaintContext, m_lastPaintRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
+    m_overlay->drawOutline(*m_lastPaintContext, m_lastPaintRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
 
     m_lastPaintContext = 0;
 }
index 964bc85..c3b9a6d 100644 (file)
@@ -53,6 +53,7 @@ class InspectorAgent;
 class InspectorArray;
 class InspectorClient;
 class InspectorObject;
+class InspectorOverlay;
 class InspectorState;
 class InstrumentingAgents;
 class KURL;
@@ -77,7 +78,7 @@ public:
         OtherResource
     };
 
-    static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*);
+    static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*, InspectorOverlay*);
 
     static bool cachedResourceContent(CachedResource*, String* result, bool* base64Encoded);
     static bool sharedBufferContent(PassRefPtr<SharedBuffer>, const String& textEncodingName, bool withBase64Encode, String* result);
@@ -137,7 +138,7 @@ public:
     static DocumentLoader* assertDocumentLoader(ErrorString*, Frame*);
 
 private:
-    InspectorPageAgent(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*);
+    InspectorPageAgent(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*, InspectorOverlay*);
     void updateViewMetrics(int, int, double, bool);
 
     PassRefPtr<TypeBuilder::Page::Frame> buildObjectForFrame(Frame*);
@@ -147,6 +148,7 @@ private:
     InjectedScriptManager* m_injectedScriptManager;
     InspectorClient* m_client;
     InspectorFrontend::Page* m_frontend;
+    InspectorOverlay* m_overlay;
     long m_lastScriptIdentifier;
     String m_pendingScriptToEvaluateOnLoadOnce;
     String m_scriptToEvaluateOnLoadOnce;
index a586edf..4b4592a 100644 (file)
 #include "PageDebuggerAgent.h"
 
 #include "Console.h"
+#include "DOMNodeHighlighter.h"
 #include "Page.h"
 #include "PageScriptDebugServer.h"
 
 namespace WebCore {
 
-PassOwnPtr<PageDebuggerAgent> PageDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
+PassOwnPtr<PageDebuggerAgent> PageDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
 {
-    return adoptPtr(new PageDebuggerAgent(instrumentingAgents, inspectorState, inspectedPage, injectedScriptManager));
+    return adoptPtr(new PageDebuggerAgent(instrumentingAgents, inspectorState, inspectedPage, injectedScriptManager, overlay));
 }
 
-PageDebuggerAgent::PageDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
+PageDebuggerAgent::PageDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
     : InspectorDebuggerAgent(instrumentingAgents, inspectorState, injectedScriptManager)
     , m_inspectedPage(inspectedPage)
+    , m_overlay(overlay)
 {
 }
 
@@ -92,6 +94,23 @@ InjectedScript PageDebuggerAgent::injectedScriptForEval(ErrorString* errorString
     return injectedScript;
 }
 
+void PageDebuggerAgent::disable()
+{
+    InspectorDebuggerAgent::disable();
+    m_overlay->setPausedInDebugger(false);
+}
+
+void PageDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
+{
+    InspectorDebuggerAgent::didPause(scriptState, callFrames, exception);
+    m_overlay->setPausedInDebugger(true);
+}
+
+void PageDebuggerAgent::didContinue()
+{
+    InspectorDebuggerAgent::didContinue();
+    m_overlay->setPausedInDebugger(false);
+}
 
 } // namespace WebCore
 
index 9dbd513..d90fdeb 100644 (file)
@@ -37,6 +37,7 @@
 
 namespace WebCore {
 
+class InspectorOverlay;
 class Page;
 class PageScriptDebugServer;
 
@@ -44,7 +45,7 @@ class PageDebuggerAgent : public InspectorDebuggerAgent {
     WTF_MAKE_NONCOPYABLE(PageDebuggerAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<PageDebuggerAgent> create(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
+    static PassOwnPtr<PageDebuggerAgent> create(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*, InspectorOverlay*);
     virtual ~PageDebuggerAgent();
 
 private:
@@ -56,8 +57,13 @@ private:
 
     virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId);
 
-    PageDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
+    virtual void disable();
+    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
+    virtual void didContinue();
+
+    PageDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*, InspectorOverlay*);
     Page* const m_inspectedPage;
+    InspectorOverlay* m_overlay;
 };
 
 } // namespace WebCore