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 21 matching lines...) Expand all Loading... |
32 #include "core/frame/Settings.h" | 32 #include "core/frame/Settings.h" |
33 #include "core/page/Page.h" | 33 #include "core/page/Page.h" |
34 #include "platform/graphics/GraphicsContext.h" | 34 #include "platform/graphics/GraphicsContext.h" |
35 #include "platform/graphics/GraphicsLayer.h" | 35 #include "platform/graphics/GraphicsLayer.h" |
36 #include "platform/graphics/GraphicsLayerClient.h" | 36 #include "platform/graphics/GraphicsLayerClient.h" |
37 #include "public/platform/WebLayer.h" | 37 #include "public/platform/WebLayer.h" |
38 #include "public/web/WebPageOverlay.h" | 38 #include "public/web/WebPageOverlay.h" |
39 #include "public/web/WebViewClient.h" | 39 #include "public/web/WebViewClient.h" |
40 #include "web/WebViewImpl.h" | 40 #include "web/WebViewImpl.h" |
41 | 41 |
42 using namespace blink; | |
43 | |
44 namespace blink { | 42 namespace blink { |
45 | 43 |
46 namespace { | 44 namespace { |
47 | 45 |
48 WebCanvas* ToWebCanvas(GraphicsContext* gc) | 46 WebCanvas* ToWebCanvas(GraphicsContext* gc) |
49 { | 47 { |
50 return gc->canvas(); | 48 return gc->canvas(); |
51 } | 49 } |
52 | 50 |
53 } // namespace | 51 } // namespace |
54 | 52 |
55 PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverla
y* overlay) | 53 PassOwnPtr<PageOverlay> PageOverlay::create(WebViewImpl* viewImpl, WebPageOverla
y* overlay) |
56 { | 54 { |
57 return adoptPtr(new PageOverlay(viewImpl, overlay)); | 55 return adoptPtr(new PageOverlay(viewImpl, overlay)); |
58 } | 56 } |
59 | 57 |
60 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay) | 58 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay) |
61 : m_viewImpl(viewImpl) | 59 : m_viewImpl(viewImpl) |
62 , m_overlay(overlay) | 60 , m_overlay(overlay) |
63 , m_zOrder(0) | 61 , m_zOrder(0) |
64 { | 62 { |
65 } | 63 } |
66 | 64 |
67 class OverlayGraphicsLayerClientImpl : public blink::GraphicsLayerClient { | 65 class OverlayGraphicsLayerClientImpl : public GraphicsLayerClient { |
68 public: | 66 public: |
69 static PassOwnPtr<OverlayGraphicsLayerClientImpl> create(WebPageOverlay* ove
rlay) | 67 static PassOwnPtr<OverlayGraphicsLayerClientImpl> create(WebPageOverlay* ove
rlay) |
70 { | 68 { |
71 return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay)); | 69 return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay)); |
72 } | 70 } |
73 | 71 |
74 virtual ~OverlayGraphicsLayerClientImpl() { } | 72 virtual ~OverlayGraphicsLayerClientImpl() { } |
75 | 73 |
76 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) OVERRIDE { } | 74 virtual void notifyAnimationStarted(const GraphicsLayer*, double monotonicTi
me) OVERRIDE { } |
77 | 75 |
(...skipping 17 matching lines...) Expand all Loading... |
95 | 93 |
96 WebPageOverlay* m_overlay; | 94 WebPageOverlay* m_overlay; |
97 }; | 95 }; |
98 | 96 |
99 void PageOverlay::clear() | 97 void PageOverlay::clear() |
100 { | 98 { |
101 invalidateWebFrame(); | 99 invalidateWebFrame(); |
102 | 100 |
103 if (m_layer) { | 101 if (m_layer) { |
104 m_layer->removeFromParent(); | 102 m_layer->removeFromParent(); |
105 if (blink::Page* page = m_viewImpl->page()) | 103 if (Page* page = m_viewImpl->page()) |
106 page->inspectorController().didRemovePageOverlay(m_layer.get()); | 104 page->inspectorController().didRemovePageOverlay(m_layer.get()); |
107 m_layer = nullptr; | 105 m_layer = nullptr; |
108 m_layerClient = nullptr; | 106 m_layerClient = nullptr; |
109 } | 107 } |
110 } | 108 } |
111 | 109 |
112 void PageOverlay::update() | 110 void PageOverlay::update() |
113 { | 111 { |
114 invalidateWebFrame(); | 112 invalidateWebFrame(); |
115 | 113 |
116 if (!m_layer) { | 114 if (!m_layer) { |
117 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay); | 115 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay); |
118 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la
yerClient.get()); | 116 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la
yerClient.get()); |
119 m_layer->setDrawsContent(true); | 117 m_layer->setDrawsContent(true); |
120 | 118 |
121 if (blink::Page* page = m_viewImpl->page()) | 119 if (Page* page = m_viewImpl->page()) |
122 page->inspectorController().willAddPageOverlay(m_layer.get()); | 120 page->inspectorController().willAddPageOverlay(m_layer.get()); |
123 | 121 |
124 // This is required for contents of overlay to stay in sync with the pag
e while scrolling. | 122 // This is required for contents of overlay to stay in sync with the pag
e while scrolling. |
125 WebLayer* platformLayer = m_layer->platformLayer(); | 123 WebLayer* platformLayer = m_layer->platformLayer(); |
126 platformLayer->setShouldScrollOnMainThread(true); | 124 platformLayer->setShouldScrollOnMainThread(true); |
127 } | 125 } |
128 | 126 |
129 FloatSize size(m_viewImpl->size()); | 127 FloatSize size(m_viewImpl->size()); |
130 if (size != m_layer->size()) { | 128 if (size != m_layer->size()) { |
131 // Triggers re-adding to root layer to ensure that we are on top of | 129 // Triggers re-adding to root layer to ensure that we are on top of |
(...skipping 25 matching lines...) Expand all Loading... |
157 // this is not on a critical codepath? In order to do so, we'd | 155 // this is not on a critical codepath? In order to do so, we'd |
158 // have to take scrolling into account. | 156 // have to take scrolling into account. |
159 const WebSize& size = m_viewImpl->size(); | 157 const WebSize& size = m_viewImpl->size(); |
160 WebRect damagedRect(0, 0, size.width, size.height); | 158 WebRect damagedRect(0, 0, size.width, size.height); |
161 if (m_viewImpl->client()) | 159 if (m_viewImpl->client()) |
162 m_viewImpl->client()->didInvalidateRect(damagedRect); | 160 m_viewImpl->client()->didInvalidateRect(damagedRect); |
163 } | 161 } |
164 } | 162 } |
165 | 163 |
166 } // namespace blink | 164 } // namespace blink |
OLD | NEW |