| 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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); | 120 data->extra_data_for_type = data->img_src.possibly_invalid_spec(); |
| 121 } else if (is_editable) { | 121 } else if (is_editable) { |
| 122 data->type = AwHitTestData::EDIT_TEXT_TYPE; | 122 data->type = AwHitTestData::EDIT_TEXT_TYPE; |
| 123 DCHECK(data->extra_data_for_type.length() == 0); | 123 DCHECK(data->extra_data_for_type.length() == 0); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace | 127 } // namespace |
| 128 | 128 |
| 129 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) | 129 AwRenderViewExt::AwRenderViewExt(content::RenderView* render_view) |
| 130 : content::RenderViewObserver(render_view) { | 130 : content::RenderViewObserver(render_view), page_scale_factor_(0.0f) { |
| 131 render_view->GetWebView()->setPermissionClient(this); | 131 render_view->GetWebView()->setPermissionClient(this); |
| 132 } | 132 } |
| 133 | 133 |
| 134 AwRenderViewExt::~AwRenderViewExt() { | 134 AwRenderViewExt::~AwRenderViewExt() { |
| 135 } | 135 } |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { | 138 void AwRenderViewExt::RenderViewCreated(content::RenderView* render_view) { |
| 139 new AwRenderViewExt(render_view); // |render_view| takes ownership. | 139 new AwRenderViewExt(render_view); // |render_view| takes ownership. |
| 140 } | 140 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, | 187 void AwRenderViewExt::DidCommitProvisionalLoad(WebKit::WebFrame* frame, |
| 188 bool is_new_navigation) { | 188 bool is_new_navigation) { |
| 189 content::DocumentState* document_state = | 189 content::DocumentState* document_state = |
| 190 content::DocumentState::FromDataSource(frame->dataSource()); | 190 content::DocumentState::FromDataSource(frame->dataSource()); |
| 191 if (document_state->can_load_local_resources()) { | 191 if (document_state->can_load_local_resources()) { |
| 192 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); | 192 WebKit::WebSecurityOrigin origin = frame->document().securityOrigin(); |
| 193 origin.grantLoadLocalResources(); | 193 origin.grantLoadLocalResources(); |
| 194 } | 194 } |
| 195 } | 195 } |
| 196 | 196 |
| 197 void AwRenderViewExt::DidCommitCompositorFrame() { |
| 198 UpdatePageScaleFactor(); |
| 199 } |
| 200 |
| 201 void AwRenderViewExt::UpdatePageScaleFactor() { |
| 202 if (page_scale_factor_ != render_view()->GetWebView()->pageScaleFactor()) { |
| 203 page_scale_factor_ = render_view()->GetWebView()->pageScaleFactor(); |
| 204 Send(new AwViewHostMsg_PageScaleFactorChanged(routing_id(), |
| 205 page_scale_factor_)); |
| 206 } |
| 207 } |
| 208 |
| 197 void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) { | 209 void AwRenderViewExt::FocusedNodeChanged(const WebKit::WebNode& node) { |
| 198 if (node.isNull() || !node.isElementNode() || !render_view()) | 210 if (node.isNull() || !node.isElementNode() || !render_view()) |
| 199 return; | 211 return; |
| 200 | 212 |
| 201 // Note: element is not const due to innerText() is not const. | 213 // Note: element is not const due to innerText() is not const. |
| 202 WebKit::WebElement element = node.toConst<WebKit::WebElement>(); | 214 WebKit::WebElement element = node.toConst<WebKit::WebElement>(); |
| 203 AwHitTestData data; | 215 AwHitTestData data; |
| 204 | 216 |
| 205 data.href = GetHref(element); | 217 data.href = GetHref(element); |
| 206 data.anchor_text = element.innerText(); | 218 data.anchor_text = element.innerText(); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 } | 277 } |
| 266 | 278 |
| 267 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { | 279 void AwRenderViewExt::OnSetInitialPageScale(double page_scale_factor) { |
| 268 if (!render_view() || !render_view()->GetWebView()) | 280 if (!render_view() || !render_view()->GetWebView()) |
| 269 return; | 281 return; |
| 270 render_view()->GetWebView()->setInitialPageScaleOverride( | 282 render_view()->GetWebView()->setInitialPageScaleOverride( |
| 271 page_scale_factor); | 283 page_scale_factor); |
| 272 } | 284 } |
| 273 | 285 |
| 274 } // namespace android_webview | 286 } // namespace android_webview |
| OLD | NEW |