Changeset 122966 in webkit


Ignore:
Timestamp:
Jul 18, 2012 7:04:58 AM (12 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: adding pause icon for JavaScript debugging
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):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r122964 r122966  
     12012-07-18  Sergey Rogulenko  <rogulenko@google.com>
     2
     3        Web Inspector: adding pause icon for JavaScript debugging
     4        https://bugs.webkit.org/show_bug.cgi?id=90880
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Refactored DOMNodeHighlighter into InspectorOverlay class and added a feature to show a "pause" screen when
     9        the Javascript debugger is paused.
     10
     11        * inspector/DOMNodeHighlighter.cpp:
     12        (WebCore::InspectorOverlay::InspectorOverlay):
     13        (WebCore::InspectorOverlay::paint):
     14        (WebCore::InspectorOverlay::drawOutline):
     15        (WebCore::InspectorOverlay::getHighlight):
     16        (WebCore::InspectorOverlay::setPausedInDebugger):
     17        (WebCore::InspectorOverlay::hideHighlight):
     18        (WebCore):
     19        (WebCore::InspectorOverlay::highlightNode):
     20        (WebCore::InspectorOverlay::setHighlightData):
     21        (WebCore::InspectorOverlay::clearHighlightData):
     22        (WebCore::InspectorOverlay::highlightedNode):
     23        (WebCore::InspectorOverlay::update):
     24        (WebCore::InspectorOverlay::drawHighlight):
     25        (WebCore::InspectorOverlay::drawPausedInDebugger):
     26        * inspector/DOMNodeHighlighter.h:
     27        (WebCore):
     28        (InspectorOverlay):
     29        (WebCore::InspectorOverlay::create):
     30        * inspector/InspectorController.cpp:
     31        (WebCore::InspectorController::InspectorController):
     32        (WebCore::InspectorController::drawHighlight):
     33        (WebCore::InspectorController::getHighlight):
     34        (WebCore::InspectorController::highlightedNode):
     35        * inspector/InspectorController.h:
     36        (WebCore):
     37        (InspectorController):
     38        * inspector/InspectorDOMAgent.cpp:
     39        (WebCore::InspectorDOMAgent::InspectorDOMAgent):
     40        (WebCore::InspectorDOMAgent::~InspectorDOMAgent):
     41        (WebCore::InspectorDOMAgent::handleMousePress):
     42        (WebCore::InspectorDOMAgent::mouseDidMoveOverElement):
     43        (WebCore::InspectorDOMAgent::setSearchingForNode):
     44        (WebCore::InspectorDOMAgent::setHighlightDataFromConfig):
     45        (WebCore::InspectorDOMAgent::setInspectModeEnabled):
     46        (WebCore::InspectorDOMAgent::highlightRect):
     47        (WebCore::InspectorDOMAgent::highlightNode):
     48        (WebCore::InspectorDOMAgent::highlightFrame):
     49        (WebCore::InspectorDOMAgent::hideHighlight):
     50        * inspector/InspectorDOMAgent.h:
     51        (WebCore):
     52        (WebCore::InspectorDOMAgent::create):
     53        (InspectorDOMAgent):
     54        * inspector/InspectorDebuggerAgent.h:
     55        (InspectorDebuggerAgent):
     56        * inspector/InspectorPageAgent.cpp:
     57        (WebCore::InspectorPageAgent::create):
     58        (WebCore::InspectorPageAgent::InspectorPageAgent):
     59        (WebCore::InspectorPageAgent::didPaint):
     60        * inspector/InspectorPageAgent.h:
     61        (WebCore):
     62        * inspector/PageDebuggerAgent.cpp:
     63        (WebCore::PageDebuggerAgent::create):
     64        (WebCore::PageDebuggerAgent::PageDebuggerAgent):
     65        (WebCore::PageDebuggerAgent::disable):
     66        (WebCore):
     67        (WebCore::PageDebuggerAgent::didPause):
     68        (WebCore::PageDebuggerAgent::didContinue):
     69        * inspector/PageDebuggerAgent.h:
     70        (WebCore):
     71        (PageDebuggerAgent):
     72
    1732012-07-17  Andrey Kosyakov  <caseq@chromium.org>
    274
  • trunk/Source/WebCore/inspector/DOMNodeHighlighter.cpp

    r115172 r122966  
    4040#include "GraphicsContext.h"
    4141#include "GraphicsTypes.h"
     42#include "InspectorClient.h"
    4243#include "Node.h"
    4344#include "Page.h"
     
    463464}
    464465
    465 static void getOrDrawRectHighlight(GraphicsContext* context, Document* document, HighlightData* highlightData, Highlight *highlight)
    466 {
    467     if (!document)
     466static void getOrDrawRectHighlight(GraphicsContext* context, Page* page, HighlightData* highlightData, Highlight *highlight)
     467{
     468    if (!page)
    468469        return;
    469470
     
    474475
    475476    if (context) {
    476         FrameView* view = document->frame()->view();
     477        FrameView* view = page->mainFrame()->view();
    477478        if (!view->delegatesScrolling()) {
    478479            FloatRect visibleRect = view->visibleContentRect();
     
    486487} // anonymous namespace
    487488
    488 namespace DOMNodeHighlighter {
    489 
    490 void drawHighlight(GraphicsContext& context, Document* document, HighlightData* highlightData)
    491 {
    492     if (!highlightData)
    493         return;
    494 
    495     Highlight highlight;
    496     if (highlightData->node)
    497         getOrDrawNodeHighlight(&context, highlightData, &highlight);
    498     else if (highlightData->rect)
    499         getOrDrawRectHighlight(&context, document, highlightData, &highlight);
    500 }
    501 
    502 void getHighlight(Document* document, HighlightData* highlightData, Highlight* highlight)
    503 {
    504     if (!highlightData)
    505         return;
    506 
    507     highlight->contentColor = highlightData->content;
    508     highlight->paddingColor = highlightData->padding;
    509     highlight->borderColor = highlightData->border;
    510     highlight->marginColor = highlightData->margin;
    511     highlight->type = HighlightTypeRects;
    512 
    513     if (highlightData->node)
    514         getOrDrawNodeHighlight(0, highlightData, highlight);
    515     else if (highlightData->rect)
    516         getOrDrawRectHighlight(0, document, highlightData, highlight);
    517 }
    518 
    519 void drawOutline(GraphicsContext& context, const LayoutRect& rect, const Color& color)
     489InspectorOverlay::InspectorOverlay(Page* page, InspectorClient* client)
     490    : m_page(page)
     491    , m_client(client)
     492    , m_pausedInDebugger(false)
     493{
     494}
     495
     496void InspectorOverlay::paint(GraphicsContext& context)
     497{
     498    drawPausedInDebugger(context);
     499    drawHighlight(context);
     500}
     501
     502void InspectorOverlay::drawOutline(GraphicsContext& context, const LayoutRect& rect, const Color& color)
    520503{
    521504    FloatRect outlineRect = rect;
     
    523506}
    524507
    525 } // namespace DOMNodeHighlighter
     508void InspectorOverlay::getHighlight(Highlight* highlight) const
     509{
     510    if (!m_highlightData)
     511        return;
     512
     513    highlight->contentColor = m_highlightData->content;
     514    highlight->paddingColor = m_highlightData->padding;
     515    highlight->borderColor = m_highlightData->border;
     516    highlight->marginColor = m_highlightData->margin;
     517    highlight->type = HighlightTypeRects;
     518
     519    if (m_highlightData->node)
     520        getOrDrawNodeHighlight(0, m_highlightData.get(), highlight);
     521    else if (m_highlightData->rect)
     522        getOrDrawRectHighlight(0, m_page, m_highlightData.get(), highlight);
     523}
     524
     525void InspectorOverlay::setPausedInDebugger(bool flag)
     526{
     527    m_pausedInDebugger = flag;
     528    update();
     529}
     530
     531void InspectorOverlay::hideHighlight()
     532{
     533    if (m_highlightData) {
     534        // FIXME: Clear entire highlight data here, store config upon setInspectModeEnabled
     535        m_highlightData->rect.clear();
     536        m_highlightData->node.clear();
     537    }
     538    update();
     539}
     540
     541void InspectorOverlay::highlightNode(Node* node)
     542{
     543    if (m_highlightData)
     544        m_highlightData->node = node;
     545    update();
     546}
     547
     548void InspectorOverlay::setHighlightData(PassOwnPtr<HighlightData> highlightData)
     549{
     550    m_highlightData = highlightData;
     551    update();
     552}
     553
     554void InspectorOverlay::clearHighlightData()
     555{
     556    m_highlightData.clear();
     557    update();
     558}
     559
     560Node* InspectorOverlay::highlightedNode() const
     561{
     562    return m_highlightData ? m_highlightData->node.get() : 0;
     563}
     564
     565void InspectorOverlay::update()
     566{
     567    if (m_highlightData || m_pausedInDebugger)
     568        m_client->highlight();
     569    else
     570        m_client->hideHighlight();
     571}
     572
     573void InspectorOverlay::drawHighlight(GraphicsContext& context)
     574{
     575    if (!m_highlightData || (!m_highlightData->rect && !m_highlightData->node))
     576        return;
     577
     578    Highlight highlight;
     579    if (m_highlightData->node)
     580        getOrDrawNodeHighlight(&context, m_highlightData.get(), &highlight);
     581    else if (m_highlightData->rect)
     582        getOrDrawRectHighlight(&context, m_page, m_highlightData.get(), &highlight);
     583}
     584
     585void InspectorOverlay::drawPausedInDebugger(GraphicsContext& context)
     586{
     587    if (!m_pausedInDebugger)
     588        return;
     589
     590    DEFINE_STATIC_LOCAL(Color, backgroundColor, (0, 0, 0, 31));
     591    DEFINE_STATIC_LOCAL(Color, textBackgroundColor, (255, 255, 194));
     592    DEFINE_STATIC_LOCAL(Color, borderColor, (128, 128, 128));
     593    DEFINE_STATIC_LOCAL(int, fontHeight, (24));
     594
     595    Frame* frame = m_page->mainFrame();
     596    Settings* settings = frame->settings();
     597    IntRect visibleRect = frame->view()->visibleContentRect();
     598
     599    context.setFillColor(backgroundColor, ColorSpaceDeviceRGB);
     600    context.drawRect(visibleRect);
     601
     602    FontDescription desc;
     603    setUpFontDescription(desc, settings);
     604    desc.setComputedSize(fontHeight);
     605    Font font = Font(desc, 0, 0);
     606    font.update(0);
     607
     608    String text = "Paused in debugger.";
     609    TextRun textRun(text);
     610    IntRect titleRect = enclosingIntRect(font.selectionRectForText(textRun, IntPoint(), fontHeight));
     611    titleRect.inflate(rectInflatePx);
     612    titleRect.setLocation(IntPoint(visibleRect.width() / 2 - titleRect.width() / 2, 0));
     613
     614    context.setFillColor(textBackgroundColor, ColorSpaceDeviceRGB);
     615    context.setStrokeColor(borderColor, ColorSpaceDeviceRGB);
     616    context.drawRect(titleRect);
     617    context.setFillColor(Color::black, ColorSpaceDeviceRGB);
     618    context.drawText(font, textRun, IntPoint(titleRect.x() + rectInflatePx, titleRect.y() + fontHeight));
     619}
    526620
    527621} // namespace WebCore
  • trunk/Source/WebCore/inspector/DOMNodeHighlighter.h

    r108338 r122966  
    3333#include "FloatQuad.h"
    3434#include "LayoutTypes.h"
     35#include "Node.h"
    3536
    3637#include <wtf/OwnPtr.h>
     38#include <wtf/PassOwnPtr.h>
    3739#include <wtf/RefPtr.h>
    3840#include <wtf/Vector.h>
     
    4143
    4244class Color;
    43 class Document;
    44 class FrameView;
    4545class GraphicsContext;
     46class InspectorClient;
     47class IntRect;
    4648class Node;
     49class Page;
    4750
    4851struct HighlightData {
     
    7679};
    7780
    78 namespace DOMNodeHighlighter {
     81class InspectorOverlay {
     82public:
     83    static PassOwnPtr<InspectorOverlay> create(Page* page, InspectorClient* client)
     84    {
     85        return adoptPtr(new InspectorOverlay(page, client));
     86    }
    7987
    80 void drawHighlight(GraphicsContext&, Document*, HighlightData*);
    81 void getHighlight(Document*, HighlightData*, Highlight*);
    82 void drawOutline(GraphicsContext&, const LayoutRect&, const Color&);
     88    void paint(GraphicsContext&);
     89    void drawOutline(GraphicsContext&, const LayoutRect&, const Color&);
     90    void getHighlight(Highlight*) const;
    8391
    84 } // namespace DOMNodeHighlighter
     92    void setPausedInDebugger(bool);
     93
     94    void hideHighlight();
     95    void highlightNode(Node*);
     96    void setHighlightData(PassOwnPtr<HighlightData>);
     97    void clearHighlightData();
     98
     99    Node* highlightedNode() const;
     100
     101private:
     102    InspectorOverlay(Page*, InspectorClient*);
     103
     104    void update();
     105    void drawHighlight(GraphicsContext&);
     106    void drawPausedInDebugger(GraphicsContext&);
     107
     108    Page* m_page;
     109    InspectorClient* m_client;
     110    bool m_pausedInDebugger;
     111    OwnPtr<HighlightData> m_highlightData;
     112};
    85113
    86114} // namespace WebCore
  • trunk/Source/WebCore/inspector/InspectorController.cpp

    r122838 r122966  
    3535#include "InspectorController.h"
    3636
     37#include "DOMNodeHighlighter.h"
    3738#include "Frame.h"
    3839#include "GraphicsContext.h"
     
    7980    , m_injectedScriptManager(InjectedScriptManager::createForPage())
    8081    , m_state(adoptPtr(new InspectorState(inspectorClient)))
     82    , m_overlay(InspectorOverlay::create(page, inspectorClient))
    8183    , m_page(page)
    8284    , m_inspectorClient(inspectorClient)
     
    8688    m_agents.append(inspectorAgentPtr.release());
    8789
    88     OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_inspectorAgent, m_state.get(), m_injectedScriptManager.get(), inspectorClient));
     90    OwnPtr<InspectorPageAgent> pageAgentPtr(InspectorPageAgent::create(m_instrumentingAgents.get(), page, m_inspectorAgent, m_state.get(), m_injectedScriptManager.get(), inspectorClient, m_overlay.get()));
    8991    InspectorPageAgent* pageAgent = pageAgentPtr.get();
    9092    m_pageAgent = pageAgentPtr.get();
    9193    m_agents.append(pageAgentPtr.release());
    9294
    93     OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, inspectorClient, m_state.get(), m_injectedScriptManager.get()));
     95    OwnPtr<InspectorDOMAgent> domAgentPtr(InspectorDOMAgent::create(m_instrumentingAgents.get(), pageAgent, m_state.get(), m_injectedScriptManager.get(), m_overlay.get()));
    9496    m_domAgent = domAgentPtr.get();
    9597    m_agents.append(domAgentPtr.release());
     
    131133
    132134#if ENABLE(JAVASCRIPT_DEBUGGER)
    133     OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get()));
     135    OwnPtr<InspectorDebuggerAgent> debuggerAgentPtr(PageDebuggerAgent::create(m_instrumentingAgents.get(), m_state.get(), page, m_injectedScriptManager.get(), m_overlay.get()));
    134136    m_debuggerAgent = debuggerAgentPtr.get();
    135137    m_agents.append(debuggerAgentPtr.release());
     
    298300void InspectorController::drawHighlight(GraphicsContext& context) const
    299301{
    300     m_domAgent->drawHighlight(context);
     302    m_overlay->paint(context);
    301303}
    302304
    303305void InspectorController::getHighlight(Highlight* highlight) const
    304306{
    305     m_domAgent->getHighlight(highlight);
     307    m_overlay->getHighlight(highlight);
    306308}
    307309
     
    345347Node* InspectorController::highlightedNode() const
    346348{
    347     return m_domAgent->highlightedNode();
     349    return m_overlay->highlightedNode();
    348350}
    349351
  • trunk/Source/WebCore/inspector/InspectorController.h

    r122838 r122966  
    5353class InspectorFrontendChannel;
    5454class InspectorFrontendClient;
     55class InspectorOverlay;
    5556class InspectorPageAgent;
    5657class InspectorProfilerAgent;
     
    121122    OwnPtr<InjectedScriptManager> m_injectedScriptManager;
    122123    OwnPtr<InspectorState> m_state;
     124    OwnPtr<InspectorOverlay> m_overlay;
    123125
    124126    InspectorAgent* m_inspectorAgent;
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.cpp

    r122106 r122966  
    6767#include "IdentifiersFactory.h"
    6868#include "InjectedScriptManager.h"
    69 #include "InspectorClient.h"
    7069#include "InspectorFrontend.h"
    7170#include "InspectorHistory.h"
     
    195194}
    196195
    197 InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     196InspectorDOMAgent::InspectorDOMAgent(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
    198197    : InspectorBaseAgent<InspectorDOMAgent>("DOM", instrumentingAgents, inspectorState)
    199198    , m_pageAgent(pageAgent)
    200     , m_client(client)
    201199    , m_injectedScriptManager(injectedScriptManager)
     200    , m_overlay(overlay)
    202201    , m_frontend(0)
    203202    , m_domListener(0)
     
    211210{
    212211    reset();
    213     ASSERT(!m_highlightData || (!m_highlightData->node && !m_highlightData->rect));
    214212    ASSERT(!m_searchingForNode);
    215213}
     
    269267    }
    270268    return result;
    271 }
    272 
    273 Node* InspectorDOMAgent::highlightedNode() const
    274 {
    275     return m_highlightData ? m_highlightData->node.get() : 0;
    276269}
    277270
     
    939932        return false;
    940933
    941     if (m_highlightData && m_highlightData->node) {
    942         RefPtr<Node> node = m_highlightData->node;
    943         inspect(node.get());
    944     }
    945     return true;
     934    if (Node* node = m_overlay->highlightedNode()) {
     935        inspect(node);
     936        return true;
     937    }
     938    return false;
    946939}
    947940
     
    983976void InspectorDOMAgent::mouseDidMoveOverElement(const HitTestResult& result, unsigned)
    984977{
    985     if (!m_searchingForNode || !m_highlightData)
     978    if (!m_searchingForNode)
    986979        return;
    987980
     
    989982    while (node && node->nodeType() == Node::TEXT_NODE)
    990983        node = node->parentNode();
    991     if (node) {
    992         m_highlightData->node = node;
    993         highlight();
    994     }
     984    if (node)
     985        m_overlay->highlightNode(node);
    995986}
    996987
     
    1005996        ErrorString error;
    1006997        hideHighlight(&error);
    1007         m_highlightData.clear();
    1008     }
    1009 }
    1010 
    1011 void InspectorDOMAgent::setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<InspectorObject>* highlightConfig)
    1012 {
    1013     setSearchingForNode(enabled, highlightConfig ? highlightConfig->get() : 0);
     998        m_overlay->clearHighlightData();
     999    }
    10141000}
    10151001
     
    10171003{
    10181004    if (!highlightConfig) {
    1019         m_highlightData.clear();
     1005        m_overlay->clearHighlightData();
    10201006        return false;
    10211007    }
    10221008
    1023     m_highlightData = adoptPtr(new HighlightData());
     1009    OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
    10241010    bool showInfo = false; // Default: false (do not show a tooltip).
    10251011    highlightConfig->getBoolean("showInfo", &showInfo);
    1026     m_highlightData->showInfo = showInfo;
    1027     m_highlightData->content = parseConfigColor("contentColor", highlightConfig);
    1028     m_highlightData->contentOutline = parseConfigColor("contentOutlineColor", highlightConfig);
    1029     m_highlightData->padding = parseConfigColor("paddingColor", highlightConfig);
    1030     m_highlightData->border = parseConfigColor("borderColor", highlightConfig);
    1031     m_highlightData->margin = parseConfigColor("marginColor", highlightConfig);
     1012    highlightData->showInfo = showInfo;
     1013    highlightData->content = parseConfigColor("contentColor", highlightConfig);
     1014    highlightData->contentOutline = parseConfigColor("contentOutlineColor", highlightConfig);
     1015    highlightData->padding = parseConfigColor("paddingColor", highlightConfig);
     1016    highlightData->border = parseConfigColor("borderColor", highlightConfig);
     1017    highlightData->margin = parseConfigColor("marginColor", highlightConfig);
     1018    m_overlay->setHighlightData(highlightData.release());
    10321019    return true;
    10331020}
    10341021
    1035 void InspectorDOMAgent::highlight()
    1036 {
    1037     // This method requires m_highlightData to have been filled in by its client.
    1038     ASSERT(m_highlightData);
    1039     m_client->highlight();
     1022void InspectorDOMAgent::setInspectModeEnabled(ErrorString*, bool enabled, const RefPtr<InspectorObject>* highlightConfig)
     1023{
     1024    setSearchingForNode(enabled, highlightConfig ? highlightConfig->get() : 0);
    10401025}
    10411026
    10421027void InspectorDOMAgent::highlightRect(ErrorString*, int x, int y, int width, int height, const RefPtr<InspectorObject>* color, const RefPtr<InspectorObject>* outlineColor)
    10431028{
    1044     m_highlightData = adoptPtr(new HighlightData());
    1045     m_highlightData->rect = adoptPtr(new IntRect(x, y, width, height));
    1046     m_highlightData->content = parseColor(color);
    1047     m_highlightData->contentOutline = parseColor(outlineColor);
    1048     m_client->highlight();
     1029    OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
     1030    highlightData->rect = adoptPtr(new IntRect(x, y, width, height));
     1031    highlightData->content = parseColor(color);
     1032    highlightData->contentOutline = parseColor(outlineColor);
     1033    m_overlay->setHighlightData(highlightData.release());
    10491034}
    10501035
     
    10541039    const RefPtr<InspectorObject>& highlightConfig)
    10551040{
    1056     if (Node* node = nodeForId(nodeId)) {
    1057         if (setHighlightDataFromConfig(highlightConfig.get())) {
    1058             m_highlightData->node = node;
    1059             highlight();
    1060         }
    1061     }
     1041    if (Node* node = nodeForId(nodeId))
     1042        if (setHighlightDataFromConfig(highlightConfig.get()))
     1043            m_overlay->highlightNode(node);
    10621044}
    10631045
     
    10701052    Frame* frame = m_pageAgent->frameForId(frameId);
    10711053    if (frame && frame->ownerElement()) {
    1072         m_highlightData = adoptPtr(new HighlightData());
    1073         m_highlightData->node = frame->ownerElement();
    1074         m_highlightData->showInfo = true; // Always show tooltips for frames.
    1075         m_highlightData->content = parseColor(color);
    1076         m_highlightData->contentOutline = parseColor(outlineColor);
    1077         highlight();
     1054        OwnPtr<HighlightData> highlightData = adoptPtr(new HighlightData());
     1055        highlightData->node = frame->ownerElement();
     1056        highlightData->showInfo = true; // Always show tooltips for frames.
     1057        highlightData->content = parseColor(color);
     1058        highlightData->contentOutline = parseColor(outlineColor);
     1059        m_overlay->setHighlightData(highlightData.release());
    10781060    }
    10791061}
     
    10811063void InspectorDOMAgent::hideHighlight(ErrorString*)
    10821064{
    1083     if (m_highlightData) {
    1084         m_highlightData->node.clear();
    1085         m_highlightData->rect.clear();
    1086     }
    1087     m_client->hideHighlight();
     1065    m_overlay->hideHighlight();
    10881066}
    10891067
     
    16001578}
    16011579
    1602 void InspectorDOMAgent::drawHighlight(GraphicsContext& context) const
    1603 {
    1604     if (!m_highlightData)
    1605         return;
    1606 
    1607     DOMNodeHighlighter::drawHighlight(context, m_highlightData->node ? m_highlightData->node->document() : m_document.get(), m_highlightData.get());
    1608 }
    1609 
    1610 void InspectorDOMAgent::getHighlight(Highlight* highlight) const
    1611 {
    1612     if (!m_highlightData)
    1613         return;
    1614 
    1615     DOMNodeHighlighter::getHighlight(m_highlightData->node ? m_highlightData->node->document() : m_document.get(), m_highlightData.get(), highlight);
    1616 }
    1617 
    16181580} // namespace WebCore
    16191581
  • trunk/Source/WebCore/inspector/InspectorDOMAgent.h

    r118367 r122966  
    5656class Element;
    5757class Event;
    58 class GraphicsContext;
    59 class InspectorClient;
    6058class InspectorFrontend;
    6159class InspectorHistory;
     60class InspectorOverlay;
    6261class InspectorPageAgent;
    63 class IntRect;
    6462class HitTestResult;
    6563class HTMLElement;
     
    7169class ScriptValue;
    7270class ShadowRoot;
    73 
    74 struct Highlight;
    75 struct HighlightData;
    7671
    7772typedef String ErrorString;
     
    10499    };
    105100
    106     static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorClient* client, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager)
     101    static PassOwnPtr<InspectorDOMAgent> create(InstrumentingAgents* instrumentingAgents, InspectorPageAgent* pageAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
    107102    {
    108         return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, client, inspectorState, injectedScriptManager));
     103        return adoptPtr(new InspectorDOMAgent(instrumentingAgents, pageAgent, inspectorState, injectedScriptManager, overlay));
    109104    }
    110105
     
    152147    virtual void markUndoableState(ErrorString*);
    153148
    154     Node* highlightedNode() const;
    155 
    156149    void getEventListeners(Node*, Vector<EventListenerInfo>& listenersArray, bool includeAncestors);
    157150
     
    186179    void focusNode();
    187180
    188     void drawHighlight(GraphicsContext&) const;
    189     void getHighlight(Highlight*) const;
    190 
    191181    InspectorHistory* history() { return m_history.get(); }
    192182
     
    206196
    207197private:
    208     InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorClient*, InspectorState*, InjectedScriptManager*);
     198    InspectorDOMAgent(InstrumentingAgents*, InspectorPageAgent*, InspectorState*, InjectedScriptManager*, InspectorOverlay*);
    209199
    210200    void setSearchingForNode(bool enabled, InspectorObject* highlightConfig);
    211201    bool setHighlightDataFromConfig(InspectorObject* highlightConfig);
    212     void highlight();
    213202
    214203    // Node-related methods.
     
    242231
    243232    InspectorPageAgent* m_pageAgent;
    244     InspectorClient* m_client;
    245233    InjectedScriptManager* m_injectedScriptManager;
     234    InspectorOverlay* m_overlay;
    246235    InspectorFrontend::DOM* m_frontend;
    247236    DOMListener* m_domListener;
     
    257246    SearchResults m_searchResults;
    258247    OwnPtr<RevalidateStyleAttributeTask> m_revalidateStyleAttrTask;
    259     OwnPtr<HighlightData> m_highlightData;
    260248    RefPtr<Node> m_nodeToFocus;
    261249    bool m_searchingForNode;
  • trunk/Source/WebCore/inspector/InspectorDebuggerAgent.h

    r121549 r122966  
    134134    virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId) = 0;
    135135
     136    virtual void disable();
     137    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
     138    virtual void didContinue();
     139
    136140private:
    137141    void enable();
    138     void disable();
    139142    bool enabled();
    140143
     
    143146    virtual void didParseSource(const String& scriptId, const Script&);
    144147    virtual void failedToParseSource(const String& url, const String& data, int firstLine, int errorLine, const String& errorMessage);
    145     virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
    146     virtual void didContinue();
    147148
    148149    void setPauseOnExceptionsImpl(ErrorString*, int);
  • trunk/Source/WebCore/inspector/InspectorPageAgent.cpp

    r122652 r122966  
    224224}
    225225
    226 PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
    227 {
    228     return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, inspectorAgent, state, injectedScriptManager, client));
     226PassOwnPtr<InspectorPageAgent> InspectorPageAgent::create(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* state, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay)
     227{
     228    return adoptPtr(new InspectorPageAgent(instrumentingAgents, page, inspectorAgent, state, injectedScriptManager, client, overlay));
    229229}
    230230
     
    309309}
    310310
    311 InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorClient* client)
     311InspectorPageAgent::InspectorPageAgent(InstrumentingAgents* instrumentingAgents, Page* page, InspectorAgent* inspectorAgent, InspectorState* inspectorState, InjectedScriptManager* injectedScriptManager, InspectorClient* client, InspectorOverlay* overlay)
    312312    : InspectorBaseAgent<InspectorPageAgent>("Page", instrumentingAgents, inspectorState)
    313313    , m_page(page)
     
    316316    , m_client(client)
    317317    , m_frontend(0)
     318    , m_overlay(overlay)
    318319    , m_lastScriptIdentifier(0)
    319320    , m_lastPaintContext(0)
     
    886887    };
    887888
    888     DOMNodeHighlighter::drawOutline(*m_lastPaintContext, m_lastPaintRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
     889    m_overlay->drawOutline(*m_lastPaintContext, m_lastPaintRect, colors[colorSelector++ % WTF_ARRAY_LENGTH(colors)]);
    889890
    890891    m_lastPaintContext = 0;
  • trunk/Source/WebCore/inspector/InspectorPageAgent.h

    r122532 r122966  
    5454class InspectorClient;
    5555class InspectorObject;
     56class InspectorOverlay;
    5657class InspectorState;
    5758class InstrumentingAgents;
     
    7879    };
    7980
    80     static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*);
     81    static PassOwnPtr<InspectorPageAgent> create(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*, InspectorOverlay*);
    8182
    8283    static bool cachedResourceContent(CachedResource*, String* result, bool* base64Encoded);
     
    138139
    139140private:
    140     InspectorPageAgent(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*);
     141    InspectorPageAgent(InstrumentingAgents*, Page*, InspectorAgent*, InspectorState*, InjectedScriptManager*, InspectorClient*, InspectorOverlay*);
    141142    void updateViewMetrics(int, int, double, bool);
    142143
     
    148149    InspectorClient* m_client;
    149150    InspectorFrontend::Page* m_frontend;
     151    InspectorOverlay* m_overlay;
    150152    long m_lastScriptIdentifier;
    151153    String m_pendingScriptToEvaluateOnLoadOnce;
  • trunk/Source/WebCore/inspector/PageDebuggerAgent.cpp

    r121014 r122966  
    3636
    3737#include "Console.h"
     38#include "DOMNodeHighlighter.h"
    3839#include "Page.h"
    3940#include "PageScriptDebugServer.h"
     
    4142namespace WebCore {
    4243
    43 PassOwnPtr<PageDebuggerAgent> PageDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
     44PassOwnPtr<PageDebuggerAgent> PageDebuggerAgent::create(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
    4445{
    45     return adoptPtr(new PageDebuggerAgent(instrumentingAgents, inspectorState, inspectedPage, injectedScriptManager));
     46    return adoptPtr(new PageDebuggerAgent(instrumentingAgents, inspectorState, inspectedPage, injectedScriptManager, overlay));
    4647}
    4748
    48 PageDebuggerAgent::PageDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager)
     49PageDebuggerAgent::PageDebuggerAgent(InstrumentingAgents* instrumentingAgents, InspectorState* inspectorState, Page* inspectedPage, InjectedScriptManager* injectedScriptManager, InspectorOverlay* overlay)
    4950    : InspectorDebuggerAgent(instrumentingAgents, inspectorState, injectedScriptManager)
    5051    , m_inspectedPage(inspectedPage)
     52    , m_overlay(overlay)
    5153{
    5254}
     
    9395}
    9496
     97void PageDebuggerAgent::disable()
     98{
     99    InspectorDebuggerAgent::disable();
     100    m_overlay->setPausedInDebugger(false);
     101}
     102
     103void PageDebuggerAgent::didPause(ScriptState* scriptState, const ScriptValue& callFrames, const ScriptValue& exception)
     104{
     105    InspectorDebuggerAgent::didPause(scriptState, callFrames, exception);
     106    m_overlay->setPausedInDebugger(true);
     107}
     108
     109void PageDebuggerAgent::didContinue()
     110{
     111    InspectorDebuggerAgent::didContinue();
     112    m_overlay->setPausedInDebugger(false);
     113}
    95114
    96115} // namespace WebCore
  • trunk/Source/WebCore/inspector/PageDebuggerAgent.h

    r121014 r122966  
    3838namespace WebCore {
    3939
     40class InspectorOverlay;
    4041class Page;
    4142class PageScriptDebugServer;
     
    4546    WTF_MAKE_FAST_ALLOCATED;
    4647public:
    47     static PassOwnPtr<PageDebuggerAgent> create(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
     48    static PassOwnPtr<PageDebuggerAgent> create(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*, InspectorOverlay*);
    4849    virtual ~PageDebuggerAgent();
    4950
     
    5758    virtual InjectedScript injectedScriptForEval(ErrorString*, const int* executionContextId);
    5859
    59     PageDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*);
     60    virtual void disable();
     61    virtual void didPause(ScriptState*, const ScriptValue& callFrames, const ScriptValue& exception);
     62    virtual void didContinue();
     63
     64    PageDebuggerAgent(InstrumentingAgents*, InspectorState*, Page*, InjectedScriptManager*, InspectorOverlay*);
    6065    Page* const m_inspectedPage;
     66    InspectorOverlay* m_overlay;
    6167};
    6268
Note: See TracChangeset for help on using the changeset viewer.