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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 GetAbsoluteSrcUrl(child_img); | 259 GetAbsoluteSrcUrl(child_img); |
260 } | 260 } |
261 | 261 |
262 PopulateHitTestData(absolute_link_url, | 262 PopulateHitTestData(absolute_link_url, |
263 absolute_image_url, | 263 absolute_image_url, |
264 render_view()->IsEditableNode(node), | 264 render_view()->IsEditableNode(node), |
265 &data); | 265 &data); |
266 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); | 266 Send(new AwViewHostMsg_UpdateHitTestData(routing_id(), data)); |
267 } | 267 } |
268 | 268 |
269 void AwRenderViewExt::OnDoHitTest(int view_x, int view_y) { | 269 void AwRenderViewExt::OnDoHitTest(int view_x, |
270 int view_y, | |
271 float touch_major_0, | |
272 float touch_major_1) { | |
270 if (!render_view() || !render_view()->GetWebView()) | 273 if (!render_view() || !render_view()->GetWebView()) |
271 return; | 274 return; |
272 | 275 |
276 // touch_major_1 refers to the touch area radius of the 2nd finger, if there | |
277 // are 2 fingers touching | |
278 // the screen. Some devices can report multiple movement traces at the same | |
279 // time, but not all. | |
280 // This follows what WebInputEventUtil::CreateWebTouchPoint is doing. | |
281 int radius = 0.5f * std::max(touch_major_0, touch_major_1); | |
boliu
2014/08/14 16:36:53
hmm, should we do max or min here...?
jdduke (slow)
2014/08/14 17:01:57
Sorry for the drive-by, but why put this max logic
hush (inactive)
2014/08/14 17:03:32
Sorry. I'm probably just doing a random thing here
boliu
2014/08/14 17:05:18
Use the first point here.
hush (inactive)
2014/08/14 17:25:22
Thanks Jared for the comments! By "following what
| |
282 const blink::WebSize touch_area(radius, radius); | |
273 const blink::WebHitTestResult result = | 283 const blink::WebHitTestResult result = |
274 render_view()->GetWebView()->hitTestResultAt( | 284 render_view()->GetWebView()->hitTestResultAt( |
275 blink::WebPoint(view_x, view_y)); | 285 blink::WebPoint(view_x, view_y), touch_area); |
276 AwHitTestData data; | 286 AwHitTestData data; |
277 | 287 |
278 if (!result.urlElement().isNull()) { | 288 if (!result.urlElement().isNull()) { |
279 data.anchor_text = result.urlElement().innerText(); | 289 data.anchor_text = result.urlElement().innerText(); |
280 data.href = GetHref(result.urlElement()); | 290 data.href = GetHref(result.urlElement()); |
281 } | 291 } |
282 | 292 |
283 PopulateHitTestData(result.absoluteLinkURL(), | 293 PopulateHitTestData(result.absoluteLinkURL(), |
284 result.absoluteImageURL(), | 294 result.absoluteImageURL(), |
285 result.isContentEditable(), | 295 result.isContentEditable(), |
(...skipping 28 matching lines...) Expand all Loading... | |
314 render_view()->GetWebView()->setFixedLayoutSize(size); | 324 render_view()->GetWebView()->setFixedLayoutSize(size); |
315 } | 325 } |
316 | 326 |
317 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { | 327 void AwRenderViewExt::OnSetBackgroundColor(SkColor c) { |
318 if (!render_view() || !render_view()->GetWebView()) | 328 if (!render_view() || !render_view()->GetWebView()) |
319 return; | 329 return; |
320 render_view()->GetWebView()->setBaseBackgroundColor(c); | 330 render_view()->GetWebView()->setBaseBackgroundColor(c); |
321 } | 331 } |
322 | 332 |
323 } // namespace android_webview | 333 } // namespace android_webview |
OLD | NEW |