Diff
Modified: trunk/LayoutTests/ChangeLog (124641 => 124642)
--- trunk/LayoutTests/ChangeLog 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/LayoutTests/ChangeLog 2012-08-03 19:49:38 UTC (rev 124642)
@@ -1,3 +1,18 @@
+2012-08-03 Terry Anderson <tdander...@chromium.org>
+
+ Apply target fuzzing when sending a context menu event
+ https://bugs.webkit.org/show_bug.cgi?id=92914
+
+ Reviewed by Antonio Gomes.
+
+ New layout test to verify that context menus appear on links for a long press
+ gesture when TOUCH_ADJUSTMENT is enabled.
+
+ * platform/qt/Skipped:
+ Skipped on qt because gestureLongPress is not used for context menus.
+ * touchadjustment/touch-links-longpress-expected.txt: Added.
+ * touchadjustment/touch-links-longpress.html: Added.
+
2012-08-03 Stephen Chenney <schen...@chromium.org>
Crash when a clip path referencing a clip path changes documents
Modified: trunk/LayoutTests/platform/qt/Skipped (124641 => 124642)
--- trunk/LayoutTests/platform/qt/Skipped 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/LayoutTests/platform/qt/Skipped 2012-08-03 19:49:38 UTC (rev 124642)
@@ -2703,3 +2703,6 @@
# ENABLE(WIDGET_REGION) is disabled
fast/css/widget-region-parser.html
+
+# https://bugs.webkit.org/show_bug.cgi?id=92914
+touchadjustment/touch-links-longpress.html
Added: trunk/LayoutTests/touchadjustment/touch-links-longpress-expected.txt (0 => 124642)
--- trunk/LayoutTests/touchadjustment/touch-links-longpress-expected.txt (rev 0)
+++ trunk/LayoutTests/touchadjustment/touch-links-longpress-expected.txt 2012-08-03 19:49:38 UTC (rev 124642)
@@ -0,0 +1,17 @@
+Tests if a long press gesture on links will trigger a context menu when touch adjustment is used.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+Testing direct hits.
+PASS
+PASS
+PASS
+Testing indirect hits.
+PASS
+PASS
+PASS
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/touchadjustment/touch-links-longpress.html (0 => 124642)
--- trunk/LayoutTests/touchadjustment/touch-links-longpress.html (rev 0)
+++ trunk/LayoutTests/touchadjustment/touch-links-longpress.html 2012-08-03 19:49:38 UTC (rev 124642)
@@ -0,0 +1,87 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>Touch Adjustment : Testing that a context menu will appear on a long press - bug 92914</title>
+ <script src=""
+ <script src=""
+ <style>
+ #sandbox {
+ position: absolute;
+ left: 0px;
+ top: 0px;
+ }
+ </style>
+</head>
+
+<body>
+
+<div id="sandbox">
+<p><a href="" id="link1">I</a> propose to consider <a href="" id="link2">the question</a>, "Can machines think?"<br>This should begin with definitions of the meaning of the terms "machine" and <a href="" id="link3">"think."</a></p>
+</div>
+
+<p id='description'></p>
+<div id='console'></div>
+
+<script>
+ var element;
+ var adjustedNode;
+ // Set up shortcut access to elements
+ var e = {};
+ ['sandbox', 'link1', 'link2', 'link3'].forEach(function(a) {
+ e[a] = document.getElementById(a);
+ });
+
+ document._oncontextmenu_ = function() { debug("PASS"); }
+
+ function testLongPress(touchpoint)
+ {
+ if (eventSender.gestureLongPress)
+ eventSender.gestureLongPress(touchpoint.left, touchpoint.top);
+ else
+ debug("gestureLongPress not implemented by this platform.");
+ }
+
+ function testDirectTouch(element)
+ {
+ // Touch directly in the center of the element.
+ var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'center', 0, 20, 30);
+ testLongPress(touchpoint);
+ }
+
+ function testIndirectTouch(element)
+ {
+ // Touch just right of the element.
+ var touchpoint = offsetTouchPoint(findAbsoluteBounds(element), 'right', 10, 30, 20);
+ testLongPress(touchpoint);
+ }
+
+ function testDirectTouches()
+ {
+ debug('Testing direct hits.');
+ testDirectTouch(e.link1);
+ testDirectTouch(e.link2);
+ testDirectTouch(e.link3);
+ }
+
+ function testIndirectTouches()
+ {
+ debug('Testing indirect hits.');
+ testIndirectTouch(e.link1);
+ testIndirectTouch(e.link2);
+ testIndirectTouch(e.link3);
+ }
+
+ function runTests()
+ {
+ if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
+ description('Tests if a long press gesture on links will trigger a context menu when touch adjustment is used.');
+ testDirectTouches();
+ testIndirectTouches();
+ e.sandbox.style.display = 'none';
+ }
+ }
+ runTests();
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (124641 => 124642)
--- trunk/Source/WebCore/ChangeLog 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/Source/WebCore/ChangeLog 2012-08-03 19:49:38 UTC (rev 124642)
@@ -1,3 +1,31 @@
+2012-08-03 Terry Anderson <tdander...@chromium.org>
+
+ Apply target fuzzing when sending a context menu event
+ https://bugs.webkit.org/show_bug.cgi?id=92914
+
+ Reviewed by Antonio Gomes.
+
+ If TOUCH_ADJUSTMENT is enabled, use bestClickableNodeForTouchPoint to possibly
+ adjust the location of a context menu event. This change uses the same set of
+ candidates for touch adjustment as is used for a GestureTap event (which
+ admittedly is a simplifying assumption).
+
+ Test: touchadjustment/touch-links-longpress.html
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::handleGestureTap):
+ Some code moved to the new function adjustGesturePosition.
+ (WebCore):
+ (WebCore::EventHandler::adjustGesturePosition):
+ Added this function to avoid repeated code in handleGestureTap and
+ sendContextMenuEventForGesture.
+ (WebCore::EventHandler::sendContextMenuEventForGesture):
+ Try to adjust the location of |mouseEvent| to correspond to the most
+ probable gesture target. If no such target exists, the location of
+ |mouseEvent| is unchanged.
+ * page/EventHandler.h:
+ (EventHandler):
+
2012-08-03 Sheriff Bot <webkit.review....@gmail.com>
Unreviewed, rolling out r124475 and r124496.
Modified: trunk/Source/WebCore/page/EventHandler.cpp (124641 => 124642)
--- trunk/Source/WebCore/page/EventHandler.cpp 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2012-08-03 19:49:38 UTC (rev 124642)
@@ -2467,16 +2467,11 @@
bool EventHandler::handleGestureTap(const PlatformGestureEvent& gestureEvent)
{
- // FIXME: Refactor this code to not hit test multiple times.
+ // FIXME: Refactor this code to not hit test multiple times. We use the adjusted position to ensure that the correct node is targeted by the later redundant hit tests.
IntPoint adjustedPoint = gestureEvent.position();
#if ENABLE(TOUCH_ADJUSTMENT)
- if (!gestureEvent.area().isEmpty()) {
- Node* targetNode = 0;
- // For now we use the adjusted position to ensure the later redundant hit-tests hits the right node.
- bestClickableNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode);
- if (!targetNode)
- return false;
- }
+ if (!gestureEvent.area().isEmpty() && !adjustGesturePosition(gestureEvent, adjustedPoint))
+ return false;
#endif
bool defaultPrevented = false;
@@ -2538,6 +2533,13 @@
RefPtr<StaticHashSetNodeList> nodeList = StaticHashSetNodeList::adopt(result.rectBasedTestResult());
return findBestZoomableArea(targetNode, targetArea, touchCenter, touchRect, *nodeList.get());
}
+
+bool EventHandler::adjustGesturePosition(const PlatformGestureEvent& gestureEvent, IntPoint& adjustedPoint)
+{
+ Node* targetNode = 0;
+ bestClickableNodeForTouchPoint(gestureEvent.position(), IntSize(gestureEvent.area().width() / 2, gestureEvent.area().height() / 2), adjustedPoint, targetNode);
+ return targetNode;
+}
#endif
#if ENABLE(CONTEXT_MENUS)
@@ -2649,7 +2651,13 @@
#else
PlatformEvent::Type eventType = PlatformEvent::MousePressed;
#endif
- PlatformMouseEvent mouseEvent(event.position(), event.globalPosition(), RightButton, eventType, 1, false, false, false, false, WTF::currentTime());
+
+ IntPoint adjustedPoint = event.position();
+#if ENABLE(TOUCH_ADJUSTMENT)
+ if (!event.area().isEmpty())
+ adjustGesturePosition(event, adjustedPoint);
+#endif
+ PlatformMouseEvent mouseEvent(adjustedPoint, event.globalPosition(), RightButton, eventType, 1, false, false, false, false, WTF::currentTime());
return sendContextMenuEvent(mouseEvent);
}
#endif // ENABLE(GESTURE_EVENTS)
Modified: trunk/Source/WebCore/page/EventHandler.h (124641 => 124642)
--- trunk/Source/WebCore/page/EventHandler.h 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/Source/WebCore/page/EventHandler.h 2012-08-03 19:49:38 UTC (rev 124642)
@@ -170,6 +170,10 @@
#if ENABLE(TOUCH_ADJUSTMENT)
bool bestClickableNodeForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntPoint& targetPoint, Node*& targetNode);
bool bestZoomableAreaForTouchPoint(const IntPoint& touchCenter, const IntSize& touchRadius, IntRect& targetArea, Node*& targetNode);
+
+ // FIXME: Add a gesture type parameter so that different candidate selection criteria may be used for
+ // different gesture types. Currently TouchAdjustment::nodeRespondsToTapGesture is used for all types.
+ bool adjustGesturePosition(const PlatformGestureEvent&, IntPoint& adjustedPoint);
#endif
#if ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebKit/chromium/ChangeLog (124641 => 124642)
--- trunk/Source/WebKit/chromium/ChangeLog 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/Source/WebKit/chromium/ChangeLog 2012-08-03 19:49:38 UTC (rev 124642)
@@ -1,3 +1,16 @@
+2012-08-03 Terry Anderson <tdander...@chromium.org>
+
+ Apply target fuzzing when sending a context menu event
+ https://bugs.webkit.org/show_bug.cgi?id=92914
+
+ Reviewed by Antonio Gomes.
+
+ When constructing a PlatformEvent::GestureLongPress in WebInputEventConversion.cpp,
+ use |boundingBox| to specify |m_area|.
+
+ * src/WebInputEventConversion.cpp:
+ (WebKit::PlatformGestureEventBuilder::PlatformGestureEventBuilder):
+
2012-08-03 Leandro Gracia Gil <leandrogra...@chromium.org>
[Chromium] Add stubs for the find-in-page match rects API
Modified: trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp (124641 => 124642)
--- trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp 2012-08-03 19:47:08 UTC (rev 124641)
+++ trunk/Source/WebKit/chromium/src/WebInputEventConversion.cpp 2012-08-03 19:49:38 UTC (rev 124642)
@@ -165,6 +165,7 @@
break;
case WebInputEvent::GestureLongPress:
m_type = PlatformEvent::GestureLongPress;
+ m_area = IntSize(e.boundingBox.width, e.boundingBox.height);
break;
case WebInputEvent::GesturePinchBegin:
m_type = PlatformEvent::GesturePinchBegin;