Title: [279057] trunk/Source/WebCore
Revision
279057
Author
za...@apple.com
Date
2021-06-20 12:46:09 -0700 (Sun, 20 Jun 2021)

Log Message

Move rectForPoint() static function out from the HitTestLocation class
https://bugs.webkit.org/show_bug.cgi?id=227182

Reviewed by Sam Weinig.

This function implicitly enlarges the hit test area which may trigger unexpected behavior.
It's better to not have it on the class's public interface.

* rendering/HitTestLocation.cpp:
(WebCore::rectForPoint):
(WebCore::HitTestLocation::rectForPoint): Deleted.
* rendering/HitTestLocation.h:
* rendering/LegacyEllipsisBox.cpp:
(WebCore::LegacyEllipsisBox::nodeAtPoint): While this may be a functionality change where we
replace the previously set area padding with 0 (actually 1px), I don't think that's what this is about.
* testing/Internals.cpp:
(WebCore::Internals::nodesFromRect const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (279056 => 279057)


--- trunk/Source/WebCore/ChangeLog	2021-06-20 18:17:18 UTC (rev 279056)
+++ trunk/Source/WebCore/ChangeLog	2021-06-20 19:46:09 UTC (rev 279057)
@@ -1,5 +1,25 @@
 2021-06-20  Alan Bujtas  <za...@apple.com>
 
+        Move rectForPoint() static function out from the HitTestLocation class
+        https://bugs.webkit.org/show_bug.cgi?id=227182
+
+        Reviewed by Sam Weinig.
+
+        This function implicitly enlarges the hit test area which may trigger unexpected behavior.
+        It's better to not have it on the class's public interface.
+
+        * rendering/HitTestLocation.cpp:
+        (WebCore::rectForPoint):
+        (WebCore::HitTestLocation::rectForPoint): Deleted.
+        * rendering/HitTestLocation.h:
+        * rendering/LegacyEllipsisBox.cpp:
+        (WebCore::LegacyEllipsisBox::nodeAtPoint): While this may be a functionality change where we
+        replace the previously set area padding with 0 (actually 1px), I don't think that's what this is about.
+        * testing/Internals.cpp:
+        (WebCore::Internals::nodesFromRect const):
+
+2021-06-20  Alan Bujtas  <za...@apple.com>
+
         Remove HitTestLocation(FloatPoint) c'tor
         https://bugs.webkit.org/show_bug.cgi?id=227179
 

Modified: trunk/Source/WebCore/rendering/HitTestLocation.cpp (279056 => 279057)


--- trunk/Source/WebCore/rendering/HitTestLocation.cpp	2021-06-20 18:17:18 UTC (rev 279056)
+++ trunk/Source/WebCore/rendering/HitTestLocation.cpp	2021-06-20 19:46:09 UTC (rev 279057)
@@ -24,6 +24,19 @@
 
 namespace WebCore {
 
+static IntRect rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
+{
+    IntPoint actualPoint(flooredIntPoint(point));
+    actualPoint -= IntSize(leftPadding, topPadding);
+
+    IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
+    // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
+    // FIXME: Remove this once non-rect based hit-detection stops using IntRect:intersects.
+    actualPadding += IntSize(1, 1);
+
+    return IntRect(actualPoint, actualPadding);
+}
+
 HitTestLocation::HitTestLocation() = default;
 
 HitTestLocation::HitTestLocation(const LayoutPoint& point)
@@ -142,17 +155,4 @@
     return rect.intersectsQuad(m_transformedRect);
 }
 
-IntRect HitTestLocation::rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
-{
-    IntPoint actualPoint(flooredIntPoint(point));
-    actualPoint -= IntSize(leftPadding, topPadding);
-
-    IntSize actualPadding(leftPadding + rightPadding, topPadding + bottomPadding);
-    // As IntRect is left inclusive and right exclusive (seeing IntRect::contains(x, y)), adding "1".
-    // FIXME: Remove this once non-rect based hit-detection stops using IntRect:intersects.
-    actualPadding += IntSize(1, 1);
-
-    return IntRect(actualPoint, actualPadding);
-}
-
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/HitTestLocation.h (279056 => 279057)


--- trunk/Source/WebCore/rendering/HitTestLocation.h	2021-06-20 18:17:18 UTC (rev 279056)
+++ trunk/Source/WebCore/rendering/HitTestLocation.h	2021-06-20 19:46:09 UTC (rev 279057)
@@ -48,13 +48,12 @@
     bool isRectilinear() const { return m_isRectilinear; }
     IntRect boundingBox() const { return m_boundingBox; }
     
-    WEBCORE_EXPORT static IntRect rectForPoint(const LayoutPoint&, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
     int topPadding() const { return roundedPoint().y() - m_boundingBox.y(); }
     int rightPadding() const { return m_boundingBox.maxX() - roundedPoint().x() - 1; }
     int bottomPadding() const { return m_boundingBox.maxY() - roundedPoint().y() - 1; }
     int leftPadding() const { return roundedPoint().x() - m_boundingBox.x(); }
 
-    bool intersects(const LayoutRect&) const;
+    WEBCORE_EXPORT bool intersects(const LayoutRect&) const;
     bool intersects(const FloatRect&) const;
     bool intersects(const RoundedRect&) const;
 

Modified: trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp (279056 => 279057)


--- trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp	2021-06-20 18:17:18 UTC (rev 279056)
+++ trunk/Source/WebCore/rendering/LegacyEllipsisBox.cpp	2021-06-20 19:46:09 UTC (rev 279057)
@@ -160,8 +160,8 @@
         }
     }
 
-    LayoutRect boundsRect { adjustedLocation, LayoutSize(LayoutUnit(logicalWidth()), m_height) };
-    if (visibleToHitTesting(request) && boundsRect.intersects(HitTestLocation::rectForPoint(locationInContainer.point(), 0, 0, 0, 0))) {
+    auto boundsRect = LayoutRect { adjustedLocation, LayoutSize(LayoutUnit(logicalWidth()), m_height) };
+    if (visibleToHitTesting(request) && locationInContainer.intersects(boundsRect)) {
         blockFlow().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(adjustedLocation));
         if (result.addNodeToListBasedTestResult(blockFlow().nodeForHitTest(), request, locationInContainer, boundsRect) == HitTestProgress::Stop)
             return true;

Modified: trunk/Source/WebCore/testing/Internals.cpp (279056 => 279057)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-06-20 18:17:18 UTC (rev 279056)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-06-20 19:46:09 UTC (rev 279057)
@@ -2312,13 +2312,13 @@
 
     HitTestRequest request(hitType);
 
+    auto hitTestResult = HitTestResult { point, topPadding, rightPadding, bottomPadding, leftPadding };
     // When ignoreClipping is false, this method returns null for coordinates outside of the viewport.
-    if (!request.ignoreClipping() && !frameView->visibleContentRect().intersects(HitTestLocation::rectForPoint(point, topPadding, rightPadding, bottomPadding, leftPadding)))
+    if (!request.ignoreClipping() && !hitTestResult.hitTestLocation().intersects(LayoutRect { frameView->visibleContentRect() }))
         return nullptr;
 
-    HitTestResult result(point, topPadding, rightPadding, bottomPadding, leftPadding);
-    document.hitTest(request, result);
-    auto matches = WTF::map(result.listBasedTestResult(), [](const auto& node) { return node.copyRef(); });
+    document.hitTest(request, hitTestResult);
+    auto matches = WTF::map(hitTestResult.listBasedTestResult(), [](const auto& node) { return node.copyRef(); });
     return RefPtr<NodeList> { StaticNodeList::create(WTFMove(matches)) };
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to