Title: [274215] trunk/Source
Revision
274215
Author
[email protected]
Date
2021-03-10 08:18:06 -0800 (Wed, 10 Mar 2021)

Log Message

Logic for updating the text selection when dragging selection handles should account for image overlays
https://bugs.webkit.org/show_bug.cgi?id=223010

Reviewed by Tim Horton.

Source/WebCore:

Rename `shouldUpdateSelectionForMouseDrag` to `shouldExtendSelectionToTargetNode`. See WebKit Changelog for more
details.

* html/HTMLElement.cpp:
(WebCore::HTMLElement::shouldExtendSelectionToTargetNode):
(WebCore::HTMLElement::shouldUpdateSelectionForMouseDrag): Deleted.
* html/HTMLElement.h:
* page/EventHandler.cpp:
(WebCore::EventHandler::updateSelectionForMouseDrag):

Source/WebKit:

Apply the same logic introduced in r272503 to iOS, when extending the selection by moving selection handles. In
the case where the hit-tested node is the image overlay container (as opposed to any text inside the container),
it's better avoid updating the selection, rather than extend the selection to the start of the image overlay.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::rangeForPointInRootViewCoordinates):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (274214 => 274215)


--- trunk/Source/WebCore/ChangeLog	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebCore/ChangeLog	2021-03-10 16:18:06 UTC (rev 274215)
@@ -1,3 +1,20 @@
+2021-03-10  Wenson Hsieh  <[email protected]>
+
+        Logic for updating the text selection when dragging selection handles should account for image overlays
+        https://bugs.webkit.org/show_bug.cgi?id=223010
+
+        Reviewed by Tim Horton.
+
+        Rename `shouldUpdateSelectionForMouseDrag` to `shouldExtendSelectionToTargetNode`. See WebKit Changelog for more
+        details.
+
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::shouldExtendSelectionToTargetNode):
+        (WebCore::HTMLElement::shouldUpdateSelectionForMouseDrag): Deleted.
+        * html/HTMLElement.h:
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateSelectionForMouseDrag):
+
 2021-03-10  Zalan Bujtas  <[email protected]>
 
         [Multi-column] Adjust the flow state of the descendants when going from not-inside-flow to inside-flow

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (274214 => 274215)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2021-03-10 16:18:06 UTC (rev 274215)
@@ -1201,7 +1201,7 @@
     return identifier;
 }
 
-bool HTMLElement::shouldUpdateSelectionForMouseDrag(const Node& targetNode, const VisibleSelection& selectionBeforeUpdate)
+bool HTMLElement::shouldExtendSelectionToTargetNode(const Node& targetNode, const VisibleSelection& selectionBeforeUpdate)
 {
     if (!is<HTMLDivElement>(targetNode))
         return true;

Modified: trunk/Source/WebCore/html/HTMLElement.h (274214 => 274215)


--- trunk/Source/WebCore/html/HTMLElement.h	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebCore/html/HTMLElement.h	2021-03-10 16:18:06 UTC (rev 274215)
@@ -126,7 +126,7 @@
     String enterKeyHint() const;
     void setEnterKeyHint(const String& value);
 
-    static bool shouldUpdateSelectionForMouseDrag(const Node& targetNode, const VisibleSelection& selectionBeforeUpdate);
+    WEBCORE_EXPORT static bool shouldExtendSelectionToTargetNode(const Node& targetNode, const VisibleSelection& selectionBeforeUpdate);
     bool hasImageOverlay() const;
     WEBCORE_EXPORT static bool isImageOverlayText(const Node&);
 

Modified: trunk/Source/WebCore/page/EventHandler.cpp (274214 => 274215)


--- trunk/Source/WebCore/page/EventHandler.cpp	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2021-03-10 16:18:06 UTC (rev 274215)
@@ -940,7 +940,7 @@
     if (!target)
         return;
 
-    if (!HTMLElement::shouldUpdateSelectionForMouseDrag(*target, m_frame.selection().selection()))
+    if (!HTMLElement::shouldExtendSelectionToTargetNode(*target, m_frame.selection().selection()))
         return;
 
     VisiblePosition targetPosition = selectionExtentRespectingEditingBoundary(m_frame.selection().selection(), hitTestResult.localPoint(), target);

Modified: trunk/Source/WebKit/ChangeLog (274214 => 274215)


--- trunk/Source/WebKit/ChangeLog	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebKit/ChangeLog	2021-03-10 16:18:06 UTC (rev 274215)
@@ -1,3 +1,17 @@
+2021-03-10  Wenson Hsieh  <[email protected]>
+
+        Logic for updating the text selection when dragging selection handles should account for image overlays
+        https://bugs.webkit.org/show_bug.cgi?id=223010
+
+        Reviewed by Tim Horton.
+
+        Apply the same logic introduced in r272503 to iOS, when extending the selection by moving selection handles. In
+        the case where the hit-tested node is the image overlay container (as opposed to any text inside the container),
+        it's better avoid updating the selection, rather than extend the selection to the start of the image overlay.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::rangeForPointInRootViewCoordinates):
+
 2021-03-10  Youenn Fablet  <[email protected]>
 
         Do not send sandbox extensions to WebProcess if capture happens in GPUProcess

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (274214 => 274215)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-03-10 15:49:01 UTC (rev 274214)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-03-10 16:18:06 UTC (rev 274215)
@@ -1513,13 +1513,20 @@
                 pointInDocument.setY(endY);
         }
     }
-    
+
+    auto hitTest = frame.eventHandler().hitTestResultAtPoint(pointInDocument, {
+        HitTestRequest::ReadOnly,
+        HitTestRequest::Active,
+        HitTestRequest::AllowVisibleChildFrameContentOnly,
+    });
+
+    auto targetNode = makeRefPtr(hitTest.targetNode());
+    if (targetNode && !HTMLElement::shouldExtendSelectionToTargetNode(*targetNode, existingSelection))
+        return WTF::nullopt;
+
+    Optional<SimpleRange> range;
     VisiblePosition result;
-    Optional<SimpleRange> range;
 
-    constexpr OptionSet<HitTestRequest::RequestType> hitType { HitTestRequest::ReadOnly, HitTestRequest::Active, HitTestRequest::AllowVisibleChildFrameContentOnly };
-    auto hitTest = frame.eventHandler().hitTestResultAtPoint(pointInDocument, hitType);
-    auto targetNode = makeRefPtr(hitTest.targetNode());
     if (targetNode)
         result = frame.eventHandler().selectionExtentRespectingEditingBoundary(frame.selection().selection(), hitTest.localPoint(), targetNode.get()).deepEquivalent();
     else
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to