Title: [263969] trunk/Source/WebCore
Revision
263969
Author
[email protected]
Date
2020-07-06 09:27:48 -0700 (Mon, 06 Jul 2020)

Log Message

Use RenderObject::positionForPoint instead of hit testing the entire view in closestEditablePositionInElementForAbsolutePoint
https://bugs.webkit.org/show_bug.cgi?id=213975

Reviewed by Wenson Hsieh.

The target renderer is known a priori so it is more efficient to hit test this directly
instead of indirectly by hit testing the entire view.

* editing/Editing.cpp:
(WebCore::closestEditablePositionInElementForAbsolutePoint):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (263968 => 263969)


--- trunk/Source/WebCore/ChangeLog	2020-07-06 15:18:24 UTC (rev 263968)
+++ trunk/Source/WebCore/ChangeLog	2020-07-06 16:27:48 UTC (rev 263969)
@@ -1,3 +1,16 @@
+2020-07-06  Daniel Bates  <[email protected]>
+
+        Use RenderObject::positionForPoint instead of hit testing the entire view in closestEditablePositionInElementForAbsolutePoint
+        https://bugs.webkit.org/show_bug.cgi?id=213975
+
+        Reviewed by Wenson Hsieh.
+
+        The target renderer is known a priori so it is more efficient to hit test this directly
+        instead of indirectly by hit testing the entire view.
+
+        * editing/Editing.cpp:
+        (WebCore::closestEditablePositionInElementForAbsolutePoint):
+
 2020-07-06  Carlos Garcia Campos  <[email protected]>
 
         [GTK][WPE] Change the cookies accept policy when ITP is enabled

Modified: trunk/Source/WebCore/editing/Editing.cpp (263968 => 263969)


--- trunk/Source/WebCore/editing/Editing.cpp	2020-07-06 15:18:24 UTC (rev 263968)
+++ trunk/Source/WebCore/editing/Editing.cpp	2020-07-06 16:27:48 UTC (rev 263969)
@@ -569,8 +569,6 @@
         return { };
 
     Ref<const Element> protectedElement { element };
-    auto frame = makeRef(*element.document().frame());
-
     element.document().updateLayoutIgnorePendingStylesheets();
 
     RenderObject* renderer = element.renderer();
@@ -585,8 +583,9 @@
     if (!renderer)
         return { };
     auto absoluteBoundingBox = renderer->absoluteBoundingBoxRect();
-    auto constrainedPoint = point.constrainedBetween(absoluteBoundingBox.minXMinYCorner(), absoluteBoundingBox.maxXMaxYCorner());
-    auto visiblePosition = frame->visiblePositionForPoint(constrainedPoint);
+    auto constrainedAbsolutePoint = point.constrainedBetween(absoluteBoundingBox.minXMinYCorner(), absoluteBoundingBox.maxXMaxYCorner());
+    auto localPoint = renderer->absoluteToLocal(constrainedAbsolutePoint, UseTransforms);
+    auto visiblePosition = renderer->positionForPoint(flooredLayoutPoint(localPoint), nullptr);
     return isEditablePosition(visiblePosition.deepEquivalent()) ? visiblePosition : VisiblePosition { };
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to