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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay) | 60 PageOverlay::PageOverlay(WebViewImpl* viewImpl, WebPageOverlay* overlay) |
61 : m_viewImpl(viewImpl) | 61 : m_viewImpl(viewImpl) |
62 , m_overlay(overlay) | 62 , m_overlay(overlay) |
63 , m_zOrder(0) | 63 , m_zOrder(0) |
64 { | 64 { |
65 } | 65 } |
66 | 66 |
67 class OverlayGraphicsLayerClientImpl : public WebCore::GraphicsLayerClient { | 67 class OverlayGraphicsLayerClientImpl : public WebCore::GraphicsLayerClient { |
68 public: | 68 public: |
69 static PassOwnPtr<OverlayGraphicsLayerClientImpl*> create(WebViewImpl* webVi
ewImpl, WebPageOverlay* overlay) | 69 static PassOwnPtr<OverlayGraphicsLayerClientImpl*> create(WebPageOverlay* ov
erlay) |
70 { | 70 { |
71 return adoptPtr(new OverlayGraphicsLayerClientImpl(webViewImpl, overlay)
); | 71 return adoptPtr(new OverlayGraphicsLayerClientImpl(overlay)); |
72 } | 72 } |
73 | 73 |
74 virtual ~OverlayGraphicsLayerClientImpl() { } | 74 virtual ~OverlayGraphicsLayerClientImpl() { } |
75 | 75 |
76 virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { } | 76 virtual void notifyAnimationStarted(const GraphicsLayer*, double time) { } |
77 | 77 |
78 virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, Graphi
csLayerPaintingPhase, const IntRect& inClip) | 78 virtual void paintContents(const GraphicsLayer*, GraphicsContext& gc, Graphi
csLayerPaintingPhase, const IntRect& inClip) |
79 { | 79 { |
80 gc.save(); | 80 gc.save(); |
81 m_overlay->paintPageOverlay(ToWebCanvas(&gc)); | 81 m_overlay->paintPageOverlay(ToWebCanvas(&gc)); |
82 gc.restore(); | 82 gc.restore(); |
83 } | 83 } |
84 | 84 |
85 virtual float deviceScaleFactor() const | |
86 { | |
87 return m_webViewImpl->deviceScaleFactor(); | |
88 } | |
89 | |
90 virtual float pageScaleFactor() const | |
91 { | |
92 return m_webViewImpl->pageScaleFactor(); | |
93 } | |
94 | |
95 private: | 85 private: |
96 OverlayGraphicsLayerClientImpl(WebViewImpl* webViewImpl, WebPageOverlay* ove
rlay) | 86 explicit OverlayGraphicsLayerClientImpl(WebPageOverlay* overlay) |
97 : m_overlay(overlay) | 87 : m_overlay(overlay) |
98 , m_webViewImpl(webViewImpl) | |
99 { | 88 { |
100 } | 89 } |
101 | 90 |
102 WebPageOverlay* m_overlay; | 91 WebPageOverlay* m_overlay; |
103 WebViewImpl* m_webViewImpl; | |
104 }; | 92 }; |
105 | 93 |
106 void PageOverlay::clear() | 94 void PageOverlay::clear() |
107 { | 95 { |
108 invalidateWebFrame(); | 96 invalidateWebFrame(); |
109 | 97 |
110 if (m_layer) { | 98 if (m_layer) { |
111 m_layer->removeFromParent(); | 99 m_layer->removeFromParent(); |
112 m_layer = nullptr; | 100 m_layer = nullptr; |
113 m_layerClient = nullptr; | 101 m_layerClient = nullptr; |
114 } | 102 } |
115 } | 103 } |
116 | 104 |
117 void PageOverlay::update() | 105 void PageOverlay::update() |
118 { | 106 { |
119 invalidateWebFrame(); | 107 invalidateWebFrame(); |
120 | 108 |
121 if (!m_layer) { | 109 if (!m_layer) { |
122 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_viewImpl, m_ove
rlay); | 110 m_layerClient = OverlayGraphicsLayerClientImpl::create(m_overlay); |
123 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la
yerClient.get()); | 111 m_layer = GraphicsLayer::create(m_viewImpl->graphicsLayerFactory(), m_la
yerClient.get()); |
124 m_layer->setName("WebViewImpl page overlay content"); | 112 m_layer->setName("WebViewImpl page overlay content"); |
125 m_layer->setDrawsContent(true); | 113 m_layer->setDrawsContent(true); |
126 } | 114 } |
127 | 115 |
128 FloatSize size(m_viewImpl->size()); | 116 FloatSize size(m_viewImpl->size()); |
129 if (size != m_layer->size()) { | 117 if (size != m_layer->size()) { |
130 // Triggers re-adding to root layer to ensure that we are on top of | 118 // Triggers re-adding to root layer to ensure that we are on top of |
131 // scrollbars. | 119 // scrollbars. |
132 m_layer->removeFromParent(); | 120 m_layer->removeFromParent(); |
(...skipping 26 matching lines...) Expand all Loading... |
159 // this is not on a critical codepath? In order to do so, we'd | 147 // this is not on a critical codepath? In order to do so, we'd |
160 // have to take scrolling into account. | 148 // have to take scrolling into account. |
161 const WebSize& size = m_viewImpl->size(); | 149 const WebSize& size = m_viewImpl->size(); |
162 WebRect damagedRect(0, 0, size.width, size.height); | 150 WebRect damagedRect(0, 0, size.width, size.height); |
163 if (m_viewImpl->client()) | 151 if (m_viewImpl->client()) |
164 m_viewImpl->client()->didInvalidateRect(damagedRect); | 152 m_viewImpl->client()->didInvalidateRect(damagedRect); |
165 } | 153 } |
166 } | 154 } |
167 | 155 |
168 } // namespace WebKit | 156 } // namespace WebKit |
OLD | NEW |