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 328a66f32efadc066fde63062f19eb7f505bd0d8..5c3f7ab54d2fbaa02e6a1cef414f0502787cca0e 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" |
@@ -273,6 +274,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() |