Chromium Code Reviews

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp

Issue 1870983002: Only hit-test SVG <text> foreground (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase; return early. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Index: third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
index 899e1708cfc4e5208cb27eb0e8e16bea1f71afc0..816f05054211cc3b972589d2005d8b48fa020fd8 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp
@@ -293,6 +293,10 @@ RootInlineBox* LayoutSVGText::createRootInlineBox()
bool LayoutSVGText::nodeAtFloatPoint(HitTestResult& result, const FloatPoint& pointInParent, HitTestAction hitTestAction)
{
+ // We only draw in the foreground phase, so we only hit-test then.
+ if (hitTestAction != HitTestForeground)
+ return false;
+
PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, result.hitTestRequest(), style()->pointerEvents());
bool isVisible = (style()->visibility() == VISIBLE);
if (isVisible || !hitRules.requireVisible) {
@@ -303,11 +307,17 @@ bool LayoutSVGText::nodeAtFloatPoint(HitTestResult& result, const FloatPoint& po
if (!SVGLayoutSupport::transformToUserSpaceAndCheckClipping(this, localToSVGParentTransform(), pointInParent, localPoint))
return false;
- if (hitRules.canHitBoundingBox && !objectBoundingBox().contains(localPoint))
- return false;
-
HitTestLocation hitTestLocation(localPoint);
- return LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), hitTestAction);
+ if (LayoutBlock::nodeAtPoint(result, hitTestLocation, LayoutPoint(), hitTestAction))
+ return true;
+
+ // Consider the bounding box if requested.
+ if (hitRules.canHitBoundingBox && objectBoundingBox().contains(localPoint)) {
+ const LayoutPoint& localLayoutPoint = roundedLayoutPoint(localPoint);
+ updateHitTestResult(result, localLayoutPoint);
+ if (result.addNodeToListBasedTestResult(node(), localLayoutPoint) == StopHitTesting)
+ return true;
+ }
}
}

Powered by Google App Engine