OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 }; | 1188 }; |
1189 | 1189 |
1190 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web
String& id) | 1190 static bool tapElementById(WebView* webView, WebInputEvent::Type type, const Web
String& id) |
1191 { | 1191 { |
1192 ASSERT(webView); | 1192 ASSERT(webView); |
1193 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele
ment>>(webView->mainFrame()->document().getElementById(id)); | 1193 RefPtrWillBeRawPtr<Element> element = static_cast<PassRefPtrWillBeRawPtr<Ele
ment>>(webView->mainFrame()->document().getElementById(id)); |
1194 if (!element) | 1194 if (!element) |
1195 return false; | 1195 return false; |
1196 | 1196 |
1197 element->scrollIntoViewIfNeeded(); | 1197 element->scrollIntoViewIfNeeded(); |
| 1198 |
| 1199 // TODO(bokan): Technically incorrect, event positions should be in viewport
space. crbug.com/371902. |
1198 IntPoint center = element->screenRect().center(); | 1200 IntPoint center = element->screenRect().center(); |
1199 | 1201 |
1200 // FIXME: This will be unnecessary since screenRect() will be fixed once crb
ug.com/371902 lands. | |
1201 PinchViewport& pinchViewport = element->document().frameHost()->pinchViewpor
t(); | |
1202 IntPoint centerInViewport = center; | |
1203 centerInViewport.moveBy(-flooredIntPoint(pinchViewport.location())); | |
1204 centerInViewport.scale(pinchViewport.scale(), pinchViewport.scale()); | |
1205 | |
1206 WebGestureEvent event; | 1202 WebGestureEvent event; |
1207 event.type = type; | 1203 event.type = type; |
1208 event.x = centerInViewport.x(); | 1204 event.x = center.x(); |
1209 event.y = centerInViewport.y(); | 1205 event.y = center.y(); |
1210 | 1206 |
1211 webView->handleInputEvent(event); | 1207 webView->handleInputEvent(event); |
1212 runPendingTasks(); | 1208 runPendingTasks(); |
1213 return true; | 1209 return true; |
1214 } | 1210 } |
1215 | 1211 |
1216 TEST_F(WebViewTest, DetectContentAroundPosition) | 1212 TEST_F(WebViewTest, DetectContentAroundPosition) |
1217 { | 1213 { |
1218 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_listeners.html")); | 1214 URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c
_str()), WebString::fromUTF8("content_listeners.html")); |
1219 | 1215 |
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2492 // Test without any preventDefault. | 2488 // Test without any preventDefault. |
2493 client.reset(); | 2489 client.reset(); |
2494 frame->executeScript(WebScriptSource("setTest('none');")); | 2490 frame->executeScript(WebScriptSource("setTest('none');")); |
2495 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); | 2491 EXPECT_TRUE(tapElementById(webView, WebInputEvent::GestureTap, WebString::fr
omUTF8("target"))); |
2496 EXPECT_TRUE(client.getWasCalled()); | 2492 EXPECT_TRUE(client.getWasCalled()); |
2497 | 2493 |
2498 m_webViewHelper.reset(); // Remove dependency on locally scoped client. | 2494 m_webViewHelper.reset(); // Remove dependency on locally scoped client. |
2499 } | 2495 } |
2500 | 2496 |
2501 } // namespace | 2497 } // namespace |
OLD | NEW |