| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * | 10 * |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 */ | 27 */ |
| 28 | 28 |
| 29 #include "web/PageOverlay.h" | 29 #include "web/PageOverlay.h" |
| 30 | 30 |
| 31 #include "core/frame/FrameHost.h" | 31 #include <memory> |
| 32 #include "core/frame/LocalFrame.h" | 32 #include "core/frame/LocalFrame.h" |
| 33 #include "core/frame/VisualViewport.h" | 33 #include "core/frame/VisualViewport.h" |
| 34 #include "core/page/Page.h" |
| 34 #include "core/page/scrolling/ScrollingCoordinator.h" | 35 #include "core/page/scrolling/ScrollingCoordinator.h" |
| 35 #include "platform/graphics/GraphicsContext.h" | 36 #include "platform/graphics/GraphicsContext.h" |
| 36 #include "platform/graphics/GraphicsLayer.h" | 37 #include "platform/graphics/GraphicsLayer.h" |
| 37 #include "platform/graphics/GraphicsLayerClient.h" | 38 #include "platform/graphics/GraphicsLayerClient.h" |
| 38 #include "platform/scroll/MainThreadScrollingReason.h" | 39 #include "platform/scroll/MainThreadScrollingReason.h" |
| 39 #include "public/platform/WebLayer.h" | 40 #include "public/platform/WebLayer.h" |
| 40 #include "public/web/WebViewClient.h" | 41 #include "public/web/WebViewClient.h" |
| 41 #include "web/WebDevToolsAgentImpl.h" | 42 #include "web/WebDevToolsAgentImpl.h" |
| 42 #include "web/WebFrameWidgetImpl.h" | 43 #include "web/WebFrameWidgetImpl.h" |
| 43 #include "web/WebLocalFrameImpl.h" | 44 #include "web/WebLocalFrameImpl.h" |
| 44 #include "wtf/PtrUtil.h" | 45 #include "wtf/PtrUtil.h" |
| 45 #include <memory> | |
| 46 | 46 |
| 47 namespace blink { | 47 namespace blink { |
| 48 | 48 |
| 49 std::unique_ptr<PageOverlay> PageOverlay::create( | 49 std::unique_ptr<PageOverlay> PageOverlay::create( |
| 50 WebLocalFrameImpl* frameImpl, | 50 WebLocalFrameImpl* frameImpl, |
| 51 std::unique_ptr<PageOverlay::Delegate> delegate) { | 51 std::unique_ptr<PageOverlay::Delegate> delegate) { |
| 52 return WTF::wrapUnique(new PageOverlay(frameImpl, std::move(delegate))); | 52 return WTF::wrapUnique(new PageOverlay(frameImpl, std::move(delegate))); |
| 53 } | 53 } |
| 54 | 54 |
| 55 PageOverlay::PageOverlay(WebLocalFrameImpl* frameImpl, | 55 PageOverlay::PageOverlay(WebLocalFrameImpl* frameImpl, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 80 | 80 |
| 81 if (WebDevToolsAgentImpl* devTools = m_frameImpl->devToolsAgentImpl()) | 81 if (WebDevToolsAgentImpl* devTools = m_frameImpl->devToolsAgentImpl()) |
| 82 devTools->willAddPageOverlay(m_layer.get()); | 82 devTools->willAddPageOverlay(m_layer.get()); |
| 83 | 83 |
| 84 // This is required for contents of overlay to stay in sync with the page | 84 // This is required for contents of overlay to stay in sync with the page |
| 85 // while scrolling. | 85 // while scrolling. |
| 86 WebLayer* platformLayer = m_layer->platformLayer(); | 86 WebLayer* platformLayer = m_layer->platformLayer(); |
| 87 platformLayer->addMainThreadScrollingReasons( | 87 platformLayer->addMainThreadScrollingReasons( |
| 88 MainThreadScrollingReason::kPageOverlay); | 88 MainThreadScrollingReason::kPageOverlay); |
| 89 if (frame->isMainFrame()) { | 89 if (frame->isMainFrame()) { |
| 90 frame->host()->visualViewport().containerLayer()->addChild(m_layer.get()); | 90 frame->page()->visualViewport().containerLayer()->addChild(m_layer.get()); |
| 91 } else { | 91 } else { |
| 92 toWebFrameWidgetImpl(m_frameImpl->frameWidget()) | 92 toWebFrameWidgetImpl(m_frameImpl->frameWidget()) |
| 93 ->rootGraphicsLayer() | 93 ->rootGraphicsLayer() |
| 94 ->addChild(m_layer.get()); | 94 ->addChild(m_layer.get()); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 FloatSize size(frame->host()->visualViewport().size()); | 98 FloatSize size(frame->page()->visualViewport().size()); |
| 99 if (size != m_layer->size()) | 99 if (size != m_layer->size()) |
| 100 m_layer->setSize(size); | 100 m_layer->setSize(size); |
| 101 | 101 |
| 102 m_layer->setNeedsDisplay(); | 102 m_layer->setNeedsDisplay(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 LayoutRect PageOverlay::visualRect() const { | 105 LayoutRect PageOverlay::visualRect() const { |
| 106 DCHECK(m_layer.get()); | 106 DCHECK(m_layer.get()); |
| 107 return LayoutRect(FloatPoint(), m_layer->size()); | 107 return LayoutRect(FloatPoint(), m_layer->size()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 IntRect PageOverlay::computeInterestRect(const GraphicsLayer* graphicsLayer, | 110 IntRect PageOverlay::computeInterestRect(const GraphicsLayer* graphicsLayer, |
| 111 const IntRect&) const { | 111 const IntRect&) const { |
| 112 return IntRect(IntPoint(), expandedIntSize(m_layer->size())); | 112 return IntRect(IntPoint(), expandedIntSize(m_layer->size())); |
| 113 } | 113 } |
| 114 | 114 |
| 115 void PageOverlay::paintContents(const GraphicsLayer* graphicsLayer, | 115 void PageOverlay::paintContents(const GraphicsLayer* graphicsLayer, |
| 116 GraphicsContext& gc, | 116 GraphicsContext& gc, |
| 117 GraphicsLayerPaintingPhase phase, | 117 GraphicsLayerPaintingPhase phase, |
| 118 const IntRect& interestRect) const { | 118 const IntRect& interestRect) const { |
| 119 DCHECK(m_layer); | 119 DCHECK(m_layer); |
| 120 m_delegate->paintPageOverlay(*this, gc, interestRect.size()); | 120 m_delegate->paintPageOverlay(*this, gc, interestRect.size()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 String PageOverlay::debugName(const GraphicsLayer*) const { | 123 String PageOverlay::debugName(const GraphicsLayer*) const { |
| 124 return "WebViewImpl Page Overlay Content Layer"; | 124 return "WebViewImpl Page Overlay Content Layer"; |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |