OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "android_webview/renderer/aw_render_view_ext.h" | 5 #include "android_webview/renderer/aw_render_view_ext.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "android_webview/common/aw_hit_test_data.h" | 9 #include "android_webview/common/aw_hit_test_data.h" |
10 #include "android_webview/common/render_view_messages.h" | 10 #include "android_webview/common/render_view_messages.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 139 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
140 } else if (is_editable) { | 140 } else if (is_editable) { |
141 data->type = AwHitTestData::EDIT_TEXT_TYPE; | 141 data->type = AwHitTestData::EDIT_TEXT_TYPE; |
142 DCHECK_EQ(0u, data->extra_data_for_type.length()); | 142 DCHECK_EQ(0u, data->extra_data_for_type.length()); |
143 } | 143 } |
144 } | 144 } |
145 | 145 |
146 } // namespace | 146 } // namespace |
147 | 147 |
148 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | 148 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
149 : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) { | 149 : content::RenderViewObserver(render_view) { |
150 } | 150 } |
151 | 151 |
152 AwRenderViewExt::~AwRenderViewExt() { | 152 AwRenderViewExt::~AwRenderViewExt() { |
153 } | 153 } |
154 | 154 |
155 // static | 155 // static |
156 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | 156 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
157 new AwRenderViewExt(render_view); // |render_view| takes ownership. | 157 new AwRenderViewExt(render_view); // |render_view| takes ownership. |
158 } | 158 } |
159 | 159 |
(...skipping 21 matching lines...) Expand all Loading... |
181 blink::WebDocument document = webview->mainFrame()->document(); | 181 blink::WebDocument document = webview->mainFrame()->document(); |
182 const blink::WebElement child_img = GetImgChild(document); | 182 const blink::WebElement child_img = GetImgChild(document); |
183 hasImages = !child_img.isNull(); | 183 hasImages = !child_img.isNull(); |
184 } | 184 } |
185 } | 185 } |
186 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, | 186 Send(new AwViewHostMsg_DocumentHasImagesResponse(routing_id(), id, |
187 hasImages)); | 187 hasImages)); |
188 } | 188 } |
189 | 189 |
190 void AwRenderViewExt::DidCommitCompositorFrame() { | 190 void AwRenderViewExt::DidCommitCompositorFrame() { |
191 PostCheckContentsSizeAndScale(); | 191 PostCheckContentsSize(); |
192 } | 192 } |
193 | 193 |
194 void AwRenderViewExt::DidUpdateLayout() { | 194 void AwRenderViewExt::DidUpdateLayout() { |
195 PostCheckContentsSizeAndScale(); | 195 PostCheckContentsSize(); |
196 } | 196 } |
197 | 197 |
198 void AwRenderViewExt::PostCheckContentsSizeAndScale() { | 198 void AwRenderViewExt::PostCheckContentsSize() { |
199 if (check_contents_size_timer_.IsRunning()) | 199 if (check_contents_size_timer_.IsRunning()) |
200 return; | 200 return; |
201 | 201 |
202 check_contents_size_timer_.Start(FROM_HERE, | 202 check_contents_size_timer_.Start(FROM_HERE, |
203 base::TimeDelta::FromMilliseconds(0), this, | 203 base::TimeDelta::FromMilliseconds(0), this, |
204 &AwRenderViewExt::CheckContentsSizeAndScale); | 204 &AwRenderViewExt::CheckContentsSize); |
205 } | 205 } |
206 | 206 |
207 void AwRenderViewExt::CheckContentsSizeAndScale() { | 207 void AwRenderViewExt::CheckContentsSize() { |
208 blink::WebView* webview = render_view()->GetWebView(); | 208 blink::WebView* webview = render_view()->GetWebView(); |
209 if (!webview) | 209 if (!webview) |
210 return; | 210 return; |
211 | 211 |
212 if (page_scale_factor_ != webview->pageScaleFactor()) { | |
213 page_scale_factor_ = webview->pageScaleFactor(); | |
214 Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), | |
215 page_scale_factor_)); | |
216 } | |
217 | |
218 gfx::Size contents_size; | 212 gfx::Size contents_size; |
219 | 213 |
220 blink::WebFrame* main_frame = webview->mainFrame(); | 214 blink::WebFrame* main_frame = webview->mainFrame(); |
221 if (main_frame) | 215 if (main_frame) |
222 contents_size = main_frame->contentsSize(); | 216 contents_size = main_frame->contentsSize(); |
223 | 217 |
224 // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a | 218 // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a |
225 // 0x0 size (this happens during initial load). | 219 // 0x0 size (this happens during initial load). |
226 if (contents_size.IsEmpty()) { | 220 if (contents_size.IsEmpty()) { |
227 contents_size = webview->contentsPreferredMinimumSize(); | 221 contents_size = webview->contentsPreferredMinimumSize(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 void AwRenderViewExt::OnSmoothScroll(int target_x, | 320 void AwRenderViewExt::OnSmoothScroll(int target_x, |
327 int target_y, | 321 int target_y, |
328 long duration_ms) { | 322 long duration_ms) { |
329 if (!render_view() || !render_view()->GetWebView()) | 323 if (!render_view() || !render_view()->GetWebView()) |
330 return; | 324 return; |
331 | 325 |
332 render_view()->GetWebView()->smoothScroll(target_x, target_y, duration_ms); | 326 render_view()->GetWebView()->smoothScroll(target_x, target_y, duration_ms); |
333 } | 327 } |
334 | 328 |
335 } // namespace android_webview | 329 } // namespace android_webview |
OLD | NEW |