Chromium Code Reviews| Index: Source/web/InspectorOverlayImpl.cpp |
| diff --git a/Source/web/InspectorOverlayImpl.cpp b/Source/web/InspectorOverlayImpl.cpp |
| index 3b54b28a091778109e4b3becf3416087e4fff98a..79d672ebf637eea1d995e1a704a991dcd2e169c9 100644 |
| --- a/Source/web/InspectorOverlayImpl.cpp |
| +++ b/Source/web/InspectorOverlayImpl.cpp |
| @@ -48,17 +48,13 @@ |
| #include "platform/graphics/GraphicsContext.h" |
| #include "public/platform/Platform.h" |
| #include "public/platform/WebData.h" |
| +#include "web/PageOverlay.h" |
| #include "web/WebGraphicsContextImpl.h" |
| #include "web/WebInputEventConversion.h" |
| #include "web/WebLocalFrameImpl.h" |
| #include "web/WebViewImpl.h" |
| #include <v8.h> |
| -namespace OverlayZOrders { |
| -// Use 99 as a big z-order number so that highlight is above other overlays. |
| -static const int highlight = 99; |
| -} |
| - |
| namespace blink { |
| namespace { |
| @@ -92,6 +88,28 @@ DEFINE_TRACE(InspectorOverlayStub) |
| } // anonymous namespace |
| +class InspectorOverlayImpl::InspectorPageOverlayDelegate : public PageOverlay::Delegate { |
| +public: |
| + InspectorPageOverlayDelegate(InspectorOverlayImpl& overlay) |
| + : m_overlay(overlay) |
| + { } |
| + |
| + void paintPageOverlay(WebGraphicsContext* context, const WebSize& webViewSize) |
| + { |
| + if (m_overlay.isEmpty()) |
| + return; |
| + |
| + GraphicsContext& graphicsContext = toWebGraphicsContextImpl(context)->graphicsContext(); |
| + FrameView* view = m_overlay.overlayMainFrame()->view(); |
| + ASSERT(!view->needsLayout()); |
| + view->paint(&graphicsContext, IntRect(0, 0, view->width(), view->height())); |
| + } |
| + |
| +private: |
| + InspectorOverlayImpl& m_overlay; |
| +}; |
| + |
| + |
| class InspectorOverlayImpl::InspectorOverlayChromeClient final: public EmptyChromeClient { |
| public: |
| InspectorOverlayChromeClient(ChromeClient& client, InspectorOverlayImpl& overlay) |
| @@ -165,20 +183,12 @@ DEFINE_TRACE(InspectorOverlayImpl) |
| InspectorOverlay::trace(visitor); |
| } |
| -void InspectorOverlayImpl::paintPageOverlay(WebGraphicsContext* context, const WebSize& webViewSize) |
| -{ |
| - if (isEmpty()) |
| - return; |
| - |
| - GraphicsContext& graphicsContext = toWebGraphicsContextImpl(context)->graphicsContext(); |
| - FrameView* view = overlayMainFrame()->view(); |
| - ASSERT(!view->needsLayout()); |
| - view->paint(&graphicsContext, IntRect(0, 0, view->width(), view->height())); |
| -} |
| - |
| void InspectorOverlayImpl::invalidate() |
| { |
| - m_webViewImpl->addPageOverlay(this, OverlayZOrders::highlight); |
| + if (!m_pageOverlay) |
| + m_pageOverlay = PageOverlay::create(m_webViewImpl, adoptPtr(new InspectorPageOverlayDelegate(*this))); |
| + |
| + m_pageOverlay->update(); |
| } |
| void InspectorOverlayImpl::layout() |
| @@ -288,7 +298,8 @@ bool InspectorOverlayImpl::isEmpty() |
| void InspectorOverlayImpl::update() |
| { |
| if (isEmpty()) { |
| - m_webViewImpl->removePageOverlay(this); |
| + if (m_pageOverlay) |
| + m_pageOverlay.clear(); |
| return; |
| } |
| m_needsUpdate = true; |
| @@ -509,5 +520,18 @@ void InspectorOverlayImpl::setLayoutEditor(PassOwnPtrWillBeRawPtr<LayoutEditor> |
| m_overlayHost->setLayoutEditorListener(m_layoutEditor.get()); |
| } |
| +GraphicsLayer* InspectorOverlayImpl::graphicsLayer() |
| +{ |
| + if (!m_pageOverlay) |
| + return nullptr; |
| + |
| + return m_pageOverlay->graphicsLayer(); |
| +} |
| + |
| +void InspectorOverlayImpl::updatePageOverlay() |
|
dgozman
2015/07/30 10:17:31
updateGraphicsLayer? Or even better replace two me
sergeyv
2015/07/30 11:42:37
Done.
|
| +{ |
| + if (m_pageOverlay) |
| + m_pageOverlay->update(); |
| +} |
| } // namespace blink |