Title: [125329] trunk/Source
Revision
125329
Author
[email protected]
Date
2012-08-10 14:45:43 -0700 (Fri, 10 Aug 2012)

Log Message

[chromium] Upstream Android changes to WebFrameImpl::selectRange
https://bugs.webkit.org/show_bug.cgi?id=92513

Patch by Iain Merrick <[email protected]> on 2012-08-10
Reviewed by Ryosuke Niwa.

Source/WebCore:

Make this function public we so can call it from the WebKit layer.

* page/EventHandler.h:
(EventHandler):

Source/WebKit/chromium:

This change is driven by the Chromium port on the Android platform,
but it should be suitable for other touch-based platforms. We reuse
selectionExtentRespectingEditingBoundary (extracted from EventHandler
into VisibleSelection).

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::selectRange):
(WebKit::WebFrameImpl::visiblePositionForWindowPoint):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (125328 => 125329)


--- trunk/Source/WebCore/ChangeLog	2012-08-10 21:42:57 UTC (rev 125328)
+++ trunk/Source/WebCore/ChangeLog	2012-08-10 21:45:43 UTC (rev 125329)
@@ -1,3 +1,15 @@
+2012-08-10  Iain Merrick  <[email protected]>
+
+        [chromium] Upstream Android changes to WebFrameImpl::selectRange
+        https://bugs.webkit.org/show_bug.cgi?id=92513
+
+        Reviewed by Ryosuke Niwa.
+
+        Make this function public we so can call it from the WebKit layer.
+
+        * page/EventHandler.h:
+        (EventHandler):
+
 2012-08-10  Mario Sanchez Prada  <[email protected]>
 
         [GTK] Broken implementation of AtkText and AtkEditableText for password fields

Modified: trunk/Source/WebCore/page/EventHandler.h (125328 => 125329)


--- trunk/Source/WebCore/page/EventHandler.h	2012-08-10 21:42:57 UTC (rev 125328)
+++ trunk/Source/WebCore/page/EventHandler.h	2012-08-10 21:45:43 UTC (rev 125329)
@@ -230,6 +230,8 @@
     bool handleTouchEvent(const PlatformTouchEvent&);
 #endif
 
+    static Node* targetNode(const HitTestResult&);
+
 private:
 #if ENABLE(DRAG_SUPPORT)
     static DragState& dragState();
@@ -246,7 +248,6 @@
     bool handleMouseDoubleClickEvent(const PlatformMouseEvent&);
 
     static Node* targetNode(const MouseEventWithHitTestResults&);
-    static Node* targetNode(const HitTestResult&);
 
     bool handleMousePressEvent(const MouseEventWithHitTestResults&);
     bool handleMousePressEventSingleClick(const MouseEventWithHitTestResults&);

Modified: trunk/Source/WebKit/chromium/ChangeLog (125328 => 125329)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-10 21:42:57 UTC (rev 125328)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-10 21:45:43 UTC (rev 125329)
@@ -1,3 +1,19 @@
+2012-08-10  Iain Merrick  <[email protected]>
+
+        [chromium] Upstream Android changes to WebFrameImpl::selectRange
+        https://bugs.webkit.org/show_bug.cgi?id=92513
+
+        Reviewed by Ryosuke Niwa.
+
+        This change is driven by the Chromium port on the Android platform,
+        but it should be suitable for other touch-based platforms. We reuse
+        selectionExtentRespectingEditingBoundary (extracted from EventHandler
+        into VisibleSelection).
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::selectRange):
+        (WebKit::WebFrameImpl::visiblePositionForWindowPoint):
+
 2012-08-10  Dana Jansens  <[email protected]>
 
         [chromium] Remove targetSurface pointer from CCRenderPass

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (125328 => 125329)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-08-10 21:42:57 UTC (rev 125328)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-08-10 21:45:43 UTC (rev 125329)
@@ -1458,11 +1458,22 @@
 
 void WebFrameImpl::selectRange(const WebPoint& start, const WebPoint& end)
 {
-    VisibleSelection selection(visiblePositionForWindowPoint(start),
-                               visiblePositionForWindowPoint(end));
+    VisiblePosition startPosition = visiblePositionForWindowPoint(start);
+    VisiblePosition endPosition = visiblePositionForWindowPoint(end);
 
-    if (frame()->selection()->shouldChangeSelection(selection))
-        frame()->selection()->setSelection(selection, CharacterGranularity);
+    // To correctly handle editable boundaries, we adjust the selection by setting its extent
+    // while keeping its base fixed. For a touch-based UI, this means that moving the selection
+    // handles behaves like a drag-select with the mouse, which is what we want here. If both
+    // endpoints changed, we need to set the extent twice.
+    // FIXME: the WebFrame::SelectRange API should explicitly state which endpoint is moving.
+    VisibleSelection newSelection = frame()->selection()->selection();
+    if (startPosition != newSelection.visibleStart())
+        newSelection = VisibleSelection(newSelection.visibleEnd(), startPosition);
+    if (endPosition != newSelection.visibleEnd())
+        newSelection = VisibleSelection(newSelection.visibleStart(), endPosition);
+
+    if (frame()->selection()->shouldChangeSelection(newSelection))
+        frame()->selection()->setSelection(newSelection, CharacterGranularity);
 }
 
 void WebFrameImpl::selectRange(const WebRange& webRange)
@@ -1484,13 +1495,9 @@
 
     frame()->document()->renderView()->layer()->hitTest(request, result);
 
-    // Matching the logic in MouseEventWithHitTestResults::targetNode()
-    Node* node = result.innerNode();
+    Node* node = EventHandler::targetNode(result);
     if (!node)
         return VisiblePosition();
-    Element* element = node->parentElement();
-    if (!node->inDocument() && element && element->inDocument())
-        node = element;
 
     return node->renderer()->positionForPoint(result.localPoint());
 }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to