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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2007, 2008, 2009 Rob Buis <buis@kde.org>
4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org> 4 * Copyright (C) 2007 Eric Seidel <eric@webkit.org>
5 * Copyright (C) 2009 Google, Inc. 5 * Copyright (C) 2009 Google, Inc.
6 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 10 matching lines...) Expand all
21 * Boston, MA 02110-1301, USA. 21 * Boston, MA 02110-1301, USA.
22 */ 22 */
23 23
24 #include "core/layout/svg/LayoutSVGRoot.h" 24 #include "core/layout/svg/LayoutSVGRoot.h"
25 25
26 #include "core/frame/LocalFrame.h" 26 #include "core/frame/LocalFrame.h"
27 #include "core/layout/HitTestResult.h" 27 #include "core/layout/HitTestResult.h"
28 #include "core/layout/LayoutAnalyzer.h" 28 #include "core/layout/LayoutAnalyzer.h"
29 #include "core/layout/LayoutPart.h" 29 #include "core/layout/LayoutPart.h"
30 #include "core/layout/LayoutView.h" 30 #include "core/layout/LayoutView.h"
31 #include "core/layout/svg/LayoutSVGText.h"
31 #include "core/layout/svg/SVGLayoutSupport.h" 32 #include "core/layout/svg/SVGLayoutSupport.h"
32 #include "core/layout/svg/SVGResourcesCache.h" 33 #include "core/layout/svg/SVGResourcesCache.h"
33 #include "core/paint/PaintLayer.h" 34 #include "core/paint/PaintLayer.h"
34 #include "core/paint/SVGRootPainter.h" 35 #include "core/paint/SVGRootPainter.h"
35 #include "core/svg/SVGElement.h" 36 #include "core/svg/SVGElement.h"
36 #include "core/svg/SVGSVGElement.h" 37 #include "core/svg/SVGSVGElement.h"
37 #include "core/svg/graphics/SVGImage.h" 38 #include "core/svg/graphics/SVGImage.h"
38 #include "platform/LengthFunctions.h" 39 #include "platform/LengthFunctions.h"
39 40
40 namespace blink { 41 namespace blink {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 LayoutReplaced::insertedIntoTree(); 270 LayoutReplaced::insertedIntoTree();
270 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); 271 SVGResourcesCache::clientWasAddedToTree(this, styleRef());
271 } 272 }
272 273
273 void LayoutSVGRoot::willBeRemovedFromTree() 274 void LayoutSVGRoot::willBeRemovedFromTree()
274 { 275 {
275 SVGResourcesCache::clientWillBeRemovedFromTree(this); 276 SVGResourcesCache::clientWillBeRemovedFromTree(this);
276 LayoutReplaced::willBeRemovedFromTree(); 277 LayoutReplaced::willBeRemovedFromTree();
277 } 278 }
278 279
280 PositionWithAffinity LayoutSVGRoot::positionForPoint(const LayoutPoint& point)
281 {
282 FloatPoint absolutePoint = FloatPoint(point);
283 absolutePoint = m_localToBorderBoxTransform.inverse().mapPoint(absolutePoint );
284 LayoutObject* closestDescendant = SVGLayoutSupport::findClosestLayoutSVGText (this, absolutePoint);
285
286 if (!closestDescendant)
287 return LayoutReplaced::positionForPoint(point);
288
289 LayoutObject* layoutObject = closestDescendant;
290 AffineTransform transform = closestDescendant->localToParentTransform();
291 transform.translate(toLayoutSVGText(closestDescendant)->location().x(), toLa youtSVGText(closestDescendant)->location().y());
292 while (layoutObject) {
293 layoutObject = layoutObject->parent();
294 if (layoutObject->isSVGRoot())
295 break;
296 transform = layoutObject->localToParentTransform() * transform;
297 }
298
299 absolutePoint = transform.inverse().mapPoint(absolutePoint);
300
301 return closestDescendant->positionForPoint(LayoutPoint(absolutePoint));
302 }
303
279 // LayoutBox methods will expect coordinates w/o any transforms in coordinates 304 // LayoutBox methods will expect coordinates w/o any transforms in coordinates
280 // relative to our borderBox origin. This method gives us exactly that. 305 // relative to our borderBox origin. This method gives us exactly that.
281 void LayoutSVGRoot::buildLocalToBorderBoxTransform() 306 void LayoutSVGRoot::buildLocalToBorderBoxTransform()
282 { 307 {
283 SVGSVGElement* svg = toSVGSVGElement(node()); 308 SVGSVGElement* svg = toSVGSVGElement(node());
284 ASSERT(svg); 309 ASSERT(svg);
285 float scale = style()->effectiveZoom(); 310 float scale = style()->effectiveZoom();
286 FloatPoint translate = svg->currentTranslate(); 311 FloatPoint translate = svg->currentTranslate();
287 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop()); 312 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop());
288 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale); 313 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 updateHitTestResult(result, pointInBorderBox); 429 updateHitTestResult(result, pointInBorderBox);
405 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting) 430 if (result.addNodeToListBasedTestResult(node(), locationInContainer, boundsRect) == StopHitTesting)
406 return true; 431 return true;
407 } 432 }
408 } 433 }
409 434
410 return false; 435 return false;
411 } 436 }
412 437
413 } // namespace blink 438 } // namespace blink
OLDNEW
« 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