Diff
Modified: trunk/Source/WebCore/ChangeLog (279065 => 279066)
--- trunk/Source/WebCore/ChangeLog 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/ChangeLog 2021-06-21 15:08:43 UTC (rev 279066)
@@ -1,3 +1,25 @@
+2021-06-21 Alan Bujtas <[email protected]>
+
+ Remove redundant HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
+ https://bugs.webkit.org/show_bug.cgi?id=227186
+
+ Reviewed by Sam Weinig.
+
+ Let's use the LayoutRect based c'tor at the only callsite (Internals).
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::hitTestResultAtPoint const):
+ * page/EventHandler.h:
+ * rendering/HitTestLocation.cpp:
+ (WebCore::HitTestLocation::HitTestLocation):
+ (WebCore::rectForPoint): Deleted.
+ (WebCore::m_isRectBased): Deleted.
+ * rendering/HitTestLocation.h:
+ * rendering/HitTestResult.cpp:
+ * rendering/HitTestResult.h:
+ * testing/Internals.cpp:
+ (WebCore::Internals::nodesFromRect const):
+
2021-06-20 Alan Bujtas <[email protected]>
HitTestLocation::m_boundingBox should be able hold subpixel values
Modified: trunk/Source/WebCore/page/EventHandler.cpp (279065 => 279066)
--- trunk/Source/WebCore/page/EventHandler.cpp 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2021-06-21 15:08:43 UTC (rev 279066)
@@ -1155,9 +1155,9 @@
}
#endif // ENABLE(DRAG_SUPPORT)
-HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, OptionSet<HitTestRequest::Type> hitType, const LayoutSize& padding) const
+HitTestResult EventHandler::hitTestResultAtPoint(const LayoutPoint& point, OptionSet<HitTestRequest::Type> hitType) const
{
- ASSERT((hitType & HitTestRequest::Type::CollectMultipleElements) || padding.isEmpty());
+ ASSERT(!hitType.contains(HitTestRequest::Type::CollectMultipleElements));
Ref<Frame> protectedFrame(m_frame);
@@ -1169,18 +1169,15 @@
FrameView* mainView = mainFrame.view();
if (frameView && mainView) {
IntPoint mainFramePoint = mainView->rootViewToContents(frameView->contentsToRootView(roundedIntPoint(point)));
- return mainFrame.eventHandler().hitTestResultAtPoint(mainFramePoint, hitType, padding);
+ return mainFrame.eventHandler().hitTestResultAtPoint(mainFramePoint, hitType);
}
}
- unsigned nonNegativePaddingWidth = std::max<LayoutUnit>(0, padding.width()).toUnsigned();
- unsigned nonNegativePaddingHeight = std::max<LayoutUnit>(0, padding.height()).toUnsigned();
-
// We should always start hit testing a clean tree.
if (auto* frameView = m_frame.view())
frameView->updateLayoutAndStyleIfNeededRecursive();
- HitTestResult result(point, nonNegativePaddingHeight, nonNegativePaddingWidth, nonNegativePaddingHeight, nonNegativePaddingWidth);
+ auto result = HitTestResult { point };
auto* document = m_frame.document();
if (!document)
return result;
Modified: trunk/Source/WebCore/page/EventHandler.h (279065 => 279066)
--- trunk/Source/WebCore/page/EventHandler.h 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/page/EventHandler.h 2021-06-21 15:08:43 UTC (rev 279066)
@@ -155,7 +155,7 @@
WEBCORE_EXPORT void dispatchFakeMouseMoveEventSoon();
void dispatchFakeMouseMoveEventSoonInQuad(const FloatQuad&);
- WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&, OptionSet<HitTestRequest::Type>, const LayoutSize& padding = LayoutSize()) const;
+ WEBCORE_EXPORT HitTestResult hitTestResultAtPoint(const LayoutPoint&, OptionSet<HitTestRequest::Type>) const;
bool mousePressed() const { return m_mousePressed; }
Node* mousePressNode() const { return m_mousePressNode.get(); }
Modified: trunk/Source/WebCore/rendering/HitTestLocation.cpp (279065 => 279066)
--- trunk/Source/WebCore/rendering/HitTestLocation.cpp 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/rendering/HitTestLocation.cpp 2021-06-21 15:08:43 UTC (rev 279066)
@@ -24,23 +24,11 @@
namespace WebCore {
-static LayoutRect rectForPoint(const LayoutPoint& point, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
-{
- auto adjustedPosition = LayoutPoint { flooredIntPoint(point) };
- adjustedPosition -= LayoutSize { leftPadding, topPadding };
-
- auto width = LayoutUnit { leftPadding + rightPadding };
- auto height = LayoutUnit { 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.
- return { adjustedPosition, LayoutSize { width + 1, height + 1 } };
-}
-
HitTestLocation::HitTestLocation() = default;
HitTestLocation::HitTestLocation(const LayoutPoint& point)
: m_point(point)
- , m_boundingBox(rectForPoint(point, 0, 0, 0, 0))
+ , m_boundingBox(LayoutRect { flooredIntPoint(point), LayoutSize { 1, 1 } })
, m_transformedPoint(point)
, m_transformedRect(m_boundingBox)
{
@@ -65,15 +53,6 @@
{
}
-HitTestLocation::HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
- : m_point(centerPoint)
- , m_boundingBox(rectForPoint(centerPoint, topPadding, rightPadding, bottomPadding, leftPadding))
- , m_transformedPoint(centerPoint)
- , m_transformedRect(FloatQuad { m_boundingBox })
- , m_isRectBased(topPadding || rightPadding || bottomPadding || leftPadding)
-{
-}
-
HitTestLocation::HitTestLocation(const HitTestLocation& other, const LayoutSize& offset)
: m_point(other.m_point)
, m_boundingBox(other.m_boundingBox)
Modified: trunk/Source/WebCore/rendering/HitTestLocation.h (279065 => 279066)
--- trunk/Source/WebCore/rendering/HitTestLocation.h 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/rendering/HitTestLocation.h 2021-06-21 15:08:43 UTC (rev 279066)
@@ -32,7 +32,6 @@
HitTestLocation(const FloatPoint&, const FloatQuad&);
HitTestLocation(const LayoutRect&);
- HitTestLocation(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
// Make a copy the HitTestLocation in a new region by applying given offset to internal point and area.
HitTestLocation(const HitTestLocation&, const LayoutSize& offset);
Modified: trunk/Source/WebCore/rendering/HitTestResult.cpp (279065 => 279066)
--- trunk/Source/WebCore/rendering/HitTestResult.cpp 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/rendering/HitTestResult.cpp 2021-06-21 15:08:43 UTC (rev 279066)
@@ -75,12 +75,6 @@
{
}
-HitTestResult::HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding)
- : m_hitTestLocation(centerPoint, topPadding, rightPadding, bottomPadding, leftPadding)
- , m_pointInInnerNodeFrame(centerPoint)
-{
-}
-
HitTestResult::HitTestResult(const HitTestLocation& other)
: m_hitTestLocation(other)
, m_pointInInnerNodeFrame(m_hitTestLocation.point())
Modified: trunk/Source/WebCore/rendering/HitTestResult.h (279065 => 279066)
--- trunk/Source/WebCore/rendering/HitTestResult.h 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/rendering/HitTestResult.h 2021-06-21 15:08:43 UTC (rev 279066)
@@ -46,8 +46,6 @@
WEBCORE_EXPORT explicit HitTestResult(const LayoutPoint&);
WEBCORE_EXPORT explicit HitTestResult(const LayoutRect&);
- WEBCORE_EXPORT HitTestResult(const LayoutPoint& centerPoint, unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
-
WEBCORE_EXPORT explicit HitTestResult(const HitTestLocation&);
WEBCORE_EXPORT HitTestResult(const HitTestResult&);
WEBCORE_EXPORT ~HitTestResult();
Modified: trunk/Source/WebCore/testing/Internals.cpp (279065 => 279066)
--- trunk/Source/WebCore/testing/Internals.cpp 2021-06-21 10:13:28 UTC (rev 279065)
+++ trunk/Source/WebCore/testing/Internals.cpp 2021-06-21 15:08:43 UTC (rev 279066)
@@ -2312,7 +2312,13 @@
HitTestRequest request(hitType);
- auto hitTestResult = HitTestResult { point, topPadding, rightPadding, bottomPadding, leftPadding };
+ auto hitTestResult = [&] {
+ auto size = LayoutSize { leftPadding + rightPadding + 1, topPadding + bottomPadding + 1 };
+ if (size.isEmpty())
+ return HitTestResult { point };
+ auto adjustedPosition = LayoutPoint { flooredIntPoint(point) } - LayoutSize { leftPadding, topPadding };
+ return HitTestResult { LayoutRect { adjustedPosition, size } };
+ }();
// When ignoreClipping is false, this method returns null for coordinates outside of the viewport.
if (!request.ignoreClipping() && !hitTestResult.hitTestLocation().intersects(LayoutRect { frameView->visibleContentRect() }))
return nullptr;