Chromium Code Reviews| 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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 UpdatePageScaleFactor(); | 191 if (check_contents_size_timer_.IsRunning()) |
|
boliu
2015/09/28 18:30:47
no code duplication so close! factor out into a pr
hush (inactive)
2015/09/28 18:34:39
Done.
| |
| 192 return; | |
| 193 | |
| 194 check_contents_size_timer_.Start(FROM_HERE, | |
| 195 base::TimeDelta::FromMilliseconds(0), this, | |
| 196 &AwRenderViewExt::CheckContentsSizeAndScale); | |
| 192 } | 197 } |
| 193 | 198 |
| 194 void AwRenderViewExt::DidUpdateLayout() { | 199 void AwRenderViewExt::DidUpdateLayout() { |
| 195 if (check_contents_size_timer_.IsRunning()) | 200 if (check_contents_size_timer_.IsRunning()) |
| 196 return; | 201 return; |
| 197 | 202 |
| 198 check_contents_size_timer_.Start(FROM_HERE, | 203 check_contents_size_timer_.Start(FROM_HERE, |
| 199 base::TimeDelta::FromMilliseconds(0), this, | 204 base::TimeDelta::FromMilliseconds(0), this, |
| 200 &AwRenderViewExt::CheckContentsSize); | 205 &AwRenderViewExt::CheckContentsSizeAndScale); |
| 201 } | 206 } |
| 202 | 207 |
| 203 void AwRenderViewExt::UpdatePageScaleFactor() { | 208 void AwRenderViewExt::CheckContentsSizeAndScale() { |
| 204 if (page_scale_factor_ != render_view()->GetWebView()->pageScaleFactor()) { | 209 blink::WebView* webview = render_view()->GetWebView(); |
| 205 page_scale_factor_ = render_view()->GetWebView()->pageScaleFactor(); | 210 if (!webview) |
| 211 return; | |
| 212 | |
| 213 if (page_scale_factor_ != webview->pageScaleFactor()) { | |
| 214 page_scale_factor_ = webview->pageScaleFactor(); | |
| 206 Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), | 215 Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), |
| 207 page_scale_factor_)); | 216 page_scale_factor_)); |
| 208 } | 217 } |
| 209 } | |
| 210 | |
| 211 void AwRenderViewExt::CheckContentsSize() { | |
| 212 if (!render_view()->GetWebView()) | |
| 213 return; | |
| 214 | 218 |
| 215 gfx::Size contents_size; | 219 gfx::Size contents_size; |
| 216 | 220 |
| 217 blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame(); | 221 blink::WebFrame* main_frame = webview->mainFrame(); |
| 218 if (main_frame) | 222 if (main_frame) |
| 219 contents_size = main_frame->contentsSize(); | 223 contents_size = main_frame->contentsSize(); |
| 220 | 224 |
| 221 // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a | 225 // Fall back to contentsPreferredMinimumSize if the mainFrame is reporting a |
| 222 // 0x0 size (this happens during initial load). | 226 // 0x0 size (this happens during initial load). |
| 223 if (contents_size.IsEmpty()) { | 227 if (contents_size.IsEmpty()) { |
| 224 contents_size = render_view()->GetWebView()->contentsPreferredMinimumSize(); | 228 contents_size = webview->contentsPreferredMinimumSize(); |
| 225 } | 229 } |
| 226 | 230 |
| 227 if (contents_size == last_sent_contents_size_) | 231 if (contents_size == last_sent_contents_size_) |
| 228 return; | 232 return; |
| 229 | 233 |
| 230 last_sent_contents_size_ = contents_size; | 234 last_sent_contents_size_ = contents_size; |
| 231 Send(new AwViewHostMsg_OnContentsSizeChanged(routing_id(), contents_size)); | 235 Send(new AwViewHostMsg_OnContentsSizeChanged(routing_id(), contents_size)); |
| 232 } | 236 } |
| 233 | 237 |
| 234 void AwRenderViewExt::Navigate(const GURL& url) { | 238 void AwRenderViewExt::Navigate(const GURL& url) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 323 void AwRenderViewExt::OnSmoothScroll(int target_x, | 327 void AwRenderViewExt::OnSmoothScroll(int target_x, |
| 324 int target_y, | 328 int target_y, |
| 325 long duration_ms) { | 329 long duration_ms) { |
| 326 if (!render_view() || !render_view()->GetWebView()) | 330 if (!render_view() || !render_view()->GetWebView()) |
| 327 return; | 331 return; |
| 328 | 332 |
| 329 render_view()->GetWebView()->smoothScroll(target_x, target_y, duration_ms); | 333 render_view()->GetWebView()->smoothScroll(target_x, target_y, duration_ms); |
| 330 } | 334 } |
| 331 | 335 |
| 332 } // namespace android_webview | 336 } // namespace android_webview |
| OLD | NEW |