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 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 // the browser side (in RenderViewHostManger), to the IPCmessages and to the | 240 // the browser side (in RenderViewHostManger), to the IPCmessages and to the |
241 // RenderViewObserver. Thus, clearing decoding image cache on Navigate, seems | 241 // RenderViewObserver. Thus, clearing decoding image cache on Navigate, seems |
242 // a more acceptable compromise. | 242 // a more acceptable compromise. |
243 blink::WebImageCache::clear(); | 243 blink::WebImageCache::clear(); |
244 } | 244 } |
245 | 245 |
246 void AwRenderViewExt::FocusedNodeChanged(const blink::WebNode& node) { | 246 void AwRenderViewExt::FocusedNodeChanged(const blink::WebNode& node) { |
247 if (node.isNull() || !node.isElementNode() || !render_view()) | 247 if (node.isNull() || !node.isElementNode() || !render_view()) |
248 return; | 248 return; |
249 | 249 |
250 // Note: element is not const due to innerText() is not const. | 250 // Note: element is not const due to textContent() is not const. |
251 blink::WebElement element = node.toConst<blink::WebElement>(); | 251 blink::WebElement element = node.toConst<blink::WebElement>(); |
252 AwHitTestData data; | 252 AwHitTestData data; |
253 | 253 |
254 data.href = GetHref(element); | 254 data.href = GetHref(element); |
255 data.anchor_text = element.innerText(); | 255 data.anchor_text = element.textContent(); |
256 | 256 |
257 GURL absolute_link_url; | 257 GURL absolute_link_url; |
258 if (node.isLink()) | 258 if (node.isLink()) |
259 absolute_link_url = GetAbsoluteUrl(node, data.href); | 259 absolute_link_url = GetAbsoluteUrl(node, data.href); |
260 | 260 |
261 GURL absolute_image_url = GetChildImageUrlFromElement(element); | 261 GURL absolute_image_url = GetChildImageUrlFromElement(element); |
262 | 262 |
263 PopulateHitTestData(absolute_link_url, | 263 PopulateHitTestData(absolute_link_url, |
264 absolute_image_url, | 264 absolute_image_url, |
265 render_view()->IsEditableNode(node), | 265 render_view()->IsEditableNode(node), |
266 &data); | 266 &data); |
267 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); | 267 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); |
268 } | 268 } |
269 | 269 |
270 void AwRenderViewExt::OnDoHitTest(const gfx::PointF& touch_center, | 270 void AwRenderViewExt::OnDoHitTest(const gfx::PointF& touch_center, |
271 const gfx::SizeF& touch_area) { | 271 const gfx::SizeF& touch_area) { |
272 if (!render_view() || !render_view()->GetWebView()) | 272 if (!render_view() || !render_view()->GetWebView()) |
273 return; | 273 return; |
274 | 274 |
275 const blink::WebHitTestResult result = | 275 const blink::WebHitTestResult result = |
276 render_view()->GetWebView()->hitTestResultForTap( | 276 render_view()->GetWebView()->hitTestResultForTap( |
277 blink::WebPoint(touch_center.x(), touch_center.y()), | 277 blink::WebPoint(touch_center.x(), touch_center.y()), |
278 blink::WebSize(touch_area.width(), touch_area.height())); | 278 blink::WebSize(touch_area.width(), touch_area.height())); |
279 AwHitTestData data; | 279 AwHitTestData data; |
280 | 280 |
281 GURL absolute_image_url = result.absoluteImageURL(); | 281 GURL absolute_image_url = result.absoluteImageURL(); |
282 if (!result.urlElement().isNull()) { | 282 if (!result.urlElement().isNull()) { |
283 data.anchor_text = result.urlElement().innerText(); | 283 data.anchor_text = result.urlElement().textContent(); |
284 data.href = GetHref(result.urlElement()); | 284 data.href = GetHref(result.urlElement()); |
285 // If we hit an image that failed to load, Blink won't give us its URL. | 285 // If we hit an image that failed to load, Blink won't give us its URL. |
286 // Fall back to walking the DOM in this case. | 286 // Fall back to walking the DOM in this case. |
287 if (absolute_image_url.is_empty()) | 287 if (absolute_image_url.is_empty()) |
288 absolute_image_url = GetChildImageUrlFromElement(result.urlElement()); | 288 absolute_image_url = GetChildImageUrlFromElement(result.urlElement()); |
289 } | 289 } |
290 | 290 |
291 PopulateHitTestData(result.absoluteLinkURL(), | 291 PopulateHitTestData(result.absoluteLinkURL(), |
292 absolute_image_url, | 292 absolute_image_url, |
293 result.isContentEditable(), | 293 result.isContentEditable(), |
(...skipping 22 matching lines...) Expand all Loading... |
316 page_scale_factor); | 316 page_scale_factor); |
317 } | 317 } |
318 | 318 |
319 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 319 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
320 if (!render_view() || !render_view()->GetWebView()) | 320 if (!render_view() || !render_view()->GetWebView()) |
321 return; | 321 return; |
322 render_view()->GetWebView()->setBaseBackgroundColor(c); | 322 render_view()->GetWebView()->setBaseBackgroundColor(c); |
323 } | 323 } |
324 | 324 |
325 } // namespace android_webview | 325 } // namespace android_webview |
OLD | NEW |