Changeset 84781 in webkit


Ignore:
Timestamp:
Apr 25, 2011 10:10:51 AM (13 years ago)
Author:
bweinstein@apple.com
Message:

WebKit2: Web Inspector: Support highlighting page elements
https://bugs.webkit.org/show_bug.cgi?id=59263
<rdar://problem/8767659>

Reviewed by Alice Liu.

Support highlighting of page elements for the inspector in WebKit2 by
having the WebInspectorClient be a PageOverlay Client and be responsible
for calling InspectorController::drawNodeHighlight.

  • WebProcess/WebCoreSupport/WebInspectorClient.cpp:

(WebKit::WebInspectorClient::highlight): Create our overlay if it hasn't been created,

or call setNeedsDisplay if it has.

(WebKit::WebInspectorClient::hideHighlight): Uninstall the page overlay if it exists.
(WebKit::WebInspectorClient::pageOverlayDestroyed):
(WebKit::WebInspectorClient::willMoveToWebPage): If it's being destroyed (moving to a null

WebPage), clear the member variable.

(WebKit::WebInspectorClient::didMoveToWebPage):
(WebKit::WebInspectorClient::drawRect): Call InspectorController::drawNodeHighlight.
(WebKit::WebInspectorClient::mouseEvent):

  • WebProcess/WebCoreSupport/WebInspectorClient.h:

(WebKit::WebInspectorClient::WebInspectorClient): Add a new member variable.

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r84769 r84781  
     12011-04-25  Brian Weinstein  <bweinstein@apple.com>
     2
     3        Reviewed by Alice Liu.
     4
     5        WebKit2: Web Inspector: Support highlighting page elements
     6        https://bugs.webkit.org/show_bug.cgi?id=59263
     7        <rdar://problem/8767659>
     8
     9        Support highlighting of page elements for the inspector in WebKit2 by
     10        having the WebInspectorClient be a PageOverlay Client and be responsible
     11        for calling InspectorController::drawNodeHighlight.
     12
     13        * WebProcess/WebCoreSupport/WebInspectorClient.cpp:
     14        (WebKit::WebInspectorClient::highlight): Create our overlay if it hasn't been created,
     15            or call setNeedsDisplay if it has.
     16        (WebKit::WebInspectorClient::hideHighlight): Uninstall the page overlay if it exists.
     17        (WebKit::WebInspectorClient::pageOverlayDestroyed):
     18        (WebKit::WebInspectorClient::willMoveToWebPage): If it's being destroyed (moving to a null
     19            WebPage), clear the member variable.
     20        (WebKit::WebInspectorClient::didMoveToWebPage):
     21        (WebKit::WebInspectorClient::drawRect): Call InspectorController::drawNodeHighlight.
     22        (WebKit::WebInspectorClient::mouseEvent):
     23        * WebProcess/WebCoreSupport/WebInspectorClient.h:
     24        (WebKit::WebInspectorClient::WebInspectorClient): Add a new member variable.
     25
    1262011-04-25  Jon Lee  <jonlee@apple.com>
    227
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.cpp

    r79335 r84781  
    5757void WebInspectorClient::highlight(Node*)
    5858{
    59     notImplemented();
     59    if (!m_highlightOverlay) {
     60        RefPtr<PageOverlay> highlightOverlay = PageOverlay::create(this);
     61        m_highlightOverlay = highlightOverlay.get();
     62        m_page->installPageOverlay(highlightOverlay.release());
     63    } else
     64        m_highlightOverlay->setNeedsDisplay();
    6065}
    6166
    6267void WebInspectorClient::hideHighlight()
    6368{
    64     notImplemented();
     69    if (m_highlightOverlay)
     70        m_page->uninstallPageOverlay(m_highlightOverlay, false);
    6571}
    6672
     
    8692}
    8793
     94void WebInspectorClient::pageOverlayDestroyed(PageOverlay*)
     95{
     96}
     97
     98void WebInspectorClient::willMoveToWebPage(PageOverlay*, WebPage* webPage)
     99{
     100    if (webPage)
     101        return;
     102
     103    // The page overlay is moving away from the web page, reset it.
     104    ASSERT(m_highlightOverlay);
     105    m_highlightOverlay = 0;
     106}
     107
     108void WebInspectorClient::didMoveToWebPage(PageOverlay*, WebPage*)
     109{
     110}
     111
     112void WebInspectorClient::drawRect(PageOverlay* overlay, WebCore::GraphicsContext& context, const WebCore::IntRect& dirtyRect)
     113{
     114    m_page->corePage()->inspectorController()->drawNodeHighlight(context);
     115}
     116
     117bool WebInspectorClient::mouseEvent(PageOverlay*, const WebMouseEvent&)
     118{
     119    return false;
     120}
     121
    88122} // namespace WebKit
    89123
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebInspectorClient.h

    r72666 r84781  
    2929#if ENABLE(INSPECTOR)
    3030
     31#include "PageOverlay.h"
     32
    3133#include <WebCore/InspectorClient.h>
     34
     35namespace WebCore {
     36    class GraphicsContext;
     37    class IntRect;
     38}
    3239
    3340namespace WebKit {
     
    3542class WebPage;
    3643
    37 class WebInspectorClient : public WebCore::InspectorClient {
     44class WebInspectorClient : public WebCore::InspectorClient, private PageOverlay::Client {
    3845public:
    3946    WebInspectorClient(WebPage* page)
    4047        : m_page(page)
     48        , m_highlightOverlay(0)
    4149    {
    4250    }
     
    5563    virtual bool sendMessageToFrontend(const String&);
    5664
     65    // PageOverlay::Client
     66    virtual void pageOverlayDestroyed(PageOverlay*);
     67    virtual void willMoveToWebPage(PageOverlay*, WebPage*);
     68    virtual void didMoveToWebPage(PageOverlay*, WebPage*);
     69    virtual void drawRect(PageOverlay*, WebCore::GraphicsContext&, const WebCore::IntRect&);
     70    virtual bool mouseEvent(PageOverlay*, const WebMouseEvent&);
     71
    5772    WebPage* m_page;
     73    PageOverlay* m_highlightOverlay;
    5874};
    5975
Note: See TracChangeset for help on using the changeset viewer.