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

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, 11 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 fbe5909f7a0917a37e843ac9a56c9a385ae59861..be5def8bbf1ac29a879dfbea665bed018c3d47ee 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"
@@ -281,6 +282,41 @@ void LayoutSVGRoot::willBeRemovedFromTree()
LayoutReplaced::willBeRemovedFromTree();
}
+PositionWithAffinity LayoutSVGRoot::positionForPoint(const LayoutPoint& point)
+{
+ FloatPoint absolutePoint = FloatPoint(point);
+ absolutePoint = m_localToBorderBoxTransform.inverse().mapPoint(absolutePoint);
+ LayoutObject* closestDescendant = SVGLayoutSupport::findSelectedLayoutSVGText(this, absolutePoint);
+
+ if (!closestDescendant)
+ return LayoutReplaced::positionForPoint(point);
+
+ LayoutObject* layoutObject = closestDescendant;
+ AffineTransform transform;
+ while (layoutObject) {
fs 2016/01/18 12:44:11 The computation done by this loop does not look co
+ layoutObject = layoutObject->parent();
+ if (layoutObject->isSVGRoot())
+ break;
+ transform = layoutObject->localToParentTransform() * transform;
+ }
+
+ AffineTransform closestDescendantTransform;
+ if (toLayoutSVGText(closestDescendant)->location().x())
fs 2016/01/18 12:44:11 I don't see why this is needed.
hyunjunekim2 2016/01/18 13:32:48 It needs codes. Because the transform is not appli
fs 2016/01/18 13:56:23 Ah, this is compensating for the reverse thing in
+ closestDescendantTransform.setE(toLayoutSVGText(closestDescendant)->location().x());
+ if (toLayoutSVGText(closestDescendant)->location().y())
+ closestDescendantTransform.setF(toLayoutSVGText(closestDescendant)->location().y());
+
+ transform = transform * closestDescendantTransform;
+
+ absolutePoint = transform.inverse().mapPoint(absolutePoint);
+ if (absolutePoint.x() < 0)
fs 2016/01/18 12:44:11 Suggest to push this down into the callee chain.
+ absolutePoint.setX(0);
+ if (absolutePoint.y() < 0)
+ absolutePoint.setY(0);
+
+ return closestDescendant->positionForPoint(LayoutPoint(absolutePoint.x(), absolutePoint.y()));
fs 2016/01/18 12:44:11 LayoutPoint(absolutePoint) should work just fine.
+}
+
// 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()

Powered by Google App Engine
This is Rietveld 408576698