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

Unified Diff: Source/core/layout/svg/LayoutSVGInlineText.cpp

Issue 1072403007: Fixup a bug about SVG text selection. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Draft 13 Created 5 years, 8 months 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: Source/core/layout/svg/LayoutSVGInlineText.cpp
diff --git a/Source/core/layout/svg/LayoutSVGInlineText.cpp b/Source/core/layout/svg/LayoutSVGInlineText.cpp
index 69553b53f7abf9be827f39d611b7d3ff8fb6bca5..1d7f3de0befae139c91d7ab8dbe7b9ae16559575 100644
--- a/Source/core/layout/svg/LayoutSVGInlineText.cpp
+++ b/Source/core/layout/svg/LayoutSVGInlineText.cpp
@@ -184,10 +184,13 @@ PositionWithAffinity LayoutSVGInlineText::positionForPoint(const LayoutPoint& po
fragment.buildFragmentTransform(fragmentTransform);
fragmentRect = fragmentTransform.mapRect(fragmentRect);
- float distance = powf(fragmentRect.x() - absolutePoint.x(), 2) +
- powf(fragmentRect.y() + fragmentRect.height() / 2 - absolutePoint.y(), 2);
+ float distance = 0;
+ if (!fragmentRect.contains(absolutePoint)) {
+ // Discard decimal point.
+ distance = floorf(fragmentRect.distanceFromPoint(absolutePoint));
+ }
- if (distance < closestDistance) {
+ if (distance <= closestDistance) {
closestDistance = distance;
closestDistanceBox = textBox;
closestDistanceFragment = &fragment;

Powered by Google App Engine
This is Rietveld 408576698