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

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

Issue 1541083002: Fix invalid selection produced when dragging mouse outside the SVG text element (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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: third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
index 6a16ef6e0c526312cb58eb02bede00019b3fea8b..db4d0b0cc71111fb78273faa00c8f9454c82c535 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.cpp
@@ -28,6 +28,7 @@
#include "core/layout/LayoutAnalyzer.h"
#include "core/layout/LayoutPart.h"
#include "core/layout/LayoutView.h"
+#include "core/layout/svg/LayoutSVGText.h"
#include "core/layout/svg/SVGLayoutSupport.h"
#include "core/layout/svg/SVGResourcesCache.h"
#include "core/paint/PaintLayer.h"
@@ -276,6 +277,30 @@ void LayoutSVGRoot::willBeRemovedFromTree()
LayoutReplaced::willBeRemovedFromTree();
}
+PositionWithAffinity LayoutSVGRoot::positionForPoint(const LayoutPoint& point)
+{
+ FloatPoint absolutePoint = FloatPoint(point);
+ absolutePoint = m_localToBorderBoxTransform.inverse().mapPoint(absolutePoint);
+ LayoutObject* closestDescendant = SVGLayoutSupport::findClosestLayoutSVGText(this, absolutePoint);
+
+ if (!closestDescendant)
+ return LayoutReplaced::positionForPoint(point);
+
+ LayoutObject* layoutObject = closestDescendant;
+ AffineTransform transform = closestDescendant->localToParentTransform();
+ transform.translate(toLayoutSVGText(closestDescendant)->location().x(), toLayoutSVGText(closestDescendant)->location().y());
+ while (layoutObject) {
+ layoutObject = layoutObject->parent();
+ if (layoutObject->isSVGRoot())
+ break;
+ transform = layoutObject->localToParentTransform() * transform;
+ }
+
+ absolutePoint = transform.inverse().mapPoint(absolutePoint);
+
+ return closestDescendant->positionForPoint(LayoutPoint(absolutePoint));
+}
+
// LayoutBox methods will expect coordinates w/o any transforms in coordinates
// relative to our borderBox origin. This method gives us exactly that.
void LayoutSVGRoot::buildLocalToBorderBoxTransform()
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/LayoutSVGRoot.h ('k') | third_party/WebKit/Source/core/layout/svg/LayoutSVGText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698