Index: Source/core/layout/svg/LayoutSVGInlineText.cpp |
diff --git a/Source/core/layout/svg/LayoutSVGInlineText.cpp b/Source/core/layout/svg/LayoutSVGInlineText.cpp |
index 69553b53f7abf9be827f39d611b7d3ff8fb6bca5..dfdcd684c0f49037cac0fe7601916e084d382add 100644 |
--- a/Source/core/layout/svg/LayoutSVGInlineText.cpp |
+++ b/Source/core/layout/svg/LayoutSVGInlineText.cpp |
@@ -177,15 +177,22 @@ PositionWithAffinity LayoutSVGInlineText::positionForPoint(const LayoutPoint& po |
SVGInlineTextBox* textBox = toSVGInlineTextBox(box); |
Vector<SVGTextFragment>& fragments = textBox->textFragments(); |
- unsigned textFragmentsSize = fragments.size(); |
+ unsigned textFragmentsSize = fragments.size(); |
for (unsigned i = 0; i < textFragmentsSize; ++i) { |
const SVGTextFragment& fragment = fragments.at(i); |
FloatRect fragmentRect(fragment.x, fragment.y - baseline, fragment.width, fragment.height); |
fragment.buildFragmentTransform(fragmentTransform); |
fragmentRect = fragmentTransform.mapRect(fragmentRect); |
+ // This is edge selection. If there is absolute-point between center and right edge of fragmentRect, |
+ // selects rightEndge. In other cases selects left edge. |
+ FloatPoint selectedEdge; |
+ if (absolutePoint.x() > fragmentRect.center().x() && absolutePoint.x() < fragmentRect.maxX()) { |
fs
2015/04/23 16:29:51
Why not just pick the closest edge? Using the left
|
+ selectedEdge = fragmentRect.rightEdgeMidPoint(); |
fs
2015/04/23 16:29:51
Rather than adding these new methods, you could do
|
+ } else { |
+ selectedEdge = fragmentRect.leftEdgeMidPoint(); |
+ } |
- float distance = powf(fragmentRect.x() - absolutePoint.x(), 2) + |
- powf(fragmentRect.y() + fragmentRect.height() / 2 - absolutePoint.y(), 2); |
+ float distance = (selectedEdge - absolutePoint).diagonalLengthSquared(); |
if (distance < closestDistance) { |
closestDistance = distance; |