Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

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

Issue 1454623002: Hit test SVG line boxes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add forgotten test. Sorry, test! Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp b/third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp
index 66d287986f29ced709aa9921a2c9eb06808c8df6..372d0fb7ae1b94c193b1f92ae17901a5e9850f26 100644
--- a/third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/line/SVGInlineTextBox.cpp
@@ -264,12 +264,24 @@ bool SVGInlineTextBox::nodeAtPoint(HitTestResult& result, const HitTestLocation&
LayoutPoint boxOrigin(x(), y());
boxOrigin.moveBy(accumulatedOffset);
LayoutRect rect(boxOrigin, size());
- // FIXME: both calls to rawValue() below is temporary and should be removed once the transition
- // to LayoutUnit-based types is complete (crbug.com/321237)
if (locationInContainer.intersects(rect)) {
- lineLayoutItem().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
- if (!result.addNodeToListBasedTestResult(lineLayoutItem().node(), locationInContainer, rect))
- return true;
+ LineLayoutSVGInlineText lineLayoutItem = LineLayoutSVGInlineText(this->lineLayoutItem());
+ ASSERT(lineLayoutItem.scalingFactor());
+ float baseline = lineLayoutItem.scaledFont().fontMetrics().floatAscent() / lineLayoutItem.scalingFactor();
+
+ AffineTransform fragmentTransform;
+ for (const auto& fragment : m_textFragments) {
+ FloatQuad fragmentQuad(FloatRect(fragment.x, fragment.y - baseline, fragment.width, fragment.height));
+ fragment.buildFragmentTransform(fragmentTransform);
+ if (!fragmentTransform.isIdentity())
+ fragmentQuad = fragmentTransform.mapQuad(fragmentQuad);
+
+ if (fragmentQuad.containsPoint(FloatPoint(locationInContainer.point()))) {
+ lineLayoutItem.updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+ if (!result.addNodeToListBasedTestResult(lineLayoutItem.node(), locationInContainer, rect))
+ return true;
+ }
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698