Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Side by Side Diff: sky/engine/web/PageOverlay.cpp

Issue 687003002: Remove PageOverlays. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/web/PageOverlay.h ('k') | sky/engine/web/PageOverlayList.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 *
16 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. AND ITS CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GOOGLE INC.
20 * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
27 */
28
29 #include "config.h"
30 #include "web/PageOverlay.h"
31
32 #include "core/frame/Settings.h"
33 #include "core/page/Page.h"
34 #include "platform/graphics/GraphicsContext.h"
35 #include "platform/graphics/GraphicsLayer.h"
36 #include "platform/graphics/GraphicsLayerClient.h"
37 #include "public/platform/WebLayer.h"
38 #include "public/web/WebPageOverlay.h"
39 #include "public/web/WebViewClient.h"
40 #include "web/WebViewImpl.h"
41
42 namespace blink {
43
44 namespace {
45
46 WebCanvas* ToWebCanvas(GraphicsContext* gc)
47 {
48 return gc->canvas();
49 }
50
51 } // namespace
52
53 PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverla y* overlay)
54 {
55 return adoptPtr(new PageOverlay(viewImpl, overlay));
56 }
57
58 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay)
59 : m_viewImpl(viewImpl)
60 , m_overlay(overlay)
61 , m_zOrder(0)
62 {
63 }
64
65 class OverlayGraphicsLayerClientImpl : public GraphicsLayerClient {
66 public:
67 static PassOwnPtr<OverlayGraphicsLayerClientImpl> create(WebPageOverlay* ove rlay)
68 {
69 return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay));
70 }
71
72 virtual ~OverlayGraphicsLayerClientImpl() { }
73
74 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi me) override { }
75
76 virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, Graphi csLayerPaintingPhase, const IntRect& inClip)
77 {
78 gc.save();
79 m_overlay->paintPageOverlay(ToWebCanvas(&gc));
80 gc.restore();
81 }
82
83 virtual String debugName(const GraphicsLayer* graphicsLayer) override
84 {
85 return String("WebViewImpl Page Overlay Content Layer");
86 }
87
88 private:
89 explicit OverlayGraphicsLayerClientImpl(WebPageOverlay* overlay)
90 : m_overlay(overlay)
91 {
92 }
93
94 WebPageOverlay* m_overlay;
95 };
96
97 void PageOverlay::clear()
98 {
99 invalidateWebFrame();
100
101 if (m_layer) {
102 m_layer->removeFromParent();
103 m_layer = nullptr;
104 m_layerClient = nullptr;
105 }
106 }
107
108 void PageOverlay::update()
109 {
110 invalidateWebFrame();
111
112 if (!m_layer) {
113 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay);
114 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la yerClient.get());
115 m_layer->setDrawsContent(true);
116
117 // This is required for contents of overlay to stay in sync with the pag e while scrolling.
118 WebLayer* platformLayer = m_layer->platformLayer();
119 platformLayer->setShouldScrollOnMainThread(true);
120 }
121
122 FloatSize size(m_viewImpl->size());
123 if (size != m_layer->size()) {
124 // Triggers re-adding to root layer to ensure that we are on top of
125 // scrollbars.
126 m_layer->removeFromParent();
127 m_layer->setSize(size);
128 }
129
130 m_viewImpl->setOverlayLayer(m_layer.get());
131 m_layer->setNeedsDisplay();
132 }
133
134 void PageOverlay::paintWebFrame(GraphicsContext& gc)
135 {
136 if (!m_viewImpl->isAcceleratedCompositingActive()) {
137 gc.save();
138 m_overlay->paintPageOverlay(ToWebCanvas(&gc));
139 gc.restore();
140 }
141 }
142
143 void PageOverlay::invalidateWebFrame()
144 {
145 // WebPageOverlay does the actual painting of the overlay.
146 // Here we just make sure to invalidate.
147 if (!m_viewImpl->isAcceleratedCompositingActive()) {
148 // FIXME: able to invalidate a smaller rect.
149 // FIXME: Is it important to just invalidate a smaller rect given that
150 // this is not on a critical codepath? In order to do so, we'd
151 // have to take scrolling into account.
152 const WebSize& size = m_viewImpl->size();
153 WebRect damagedRect(0, 0, size.width, size.height);
154 if (m_viewImpl->client())
155 m_viewImpl->client()->didInvalidateRect(damagedRect);
156 }
157 }
158
159 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/web/PageOverlay.h ('k') | sky/engine/web/PageOverlayList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698