| OLD | NEW |
| 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 Loading... |
| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 LayoutReplaced::insertedIntoTree(); | 265 LayoutReplaced::insertedIntoTree(); |
| 265 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); | 266 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); |
| 266 } | 267 } |
| 267 | 268 |
| 268 void LayoutSVGRoot::willBeRemovedFromTree() | 269 void LayoutSVGRoot::willBeRemovedFromTree() |
| 269 { | 270 { |
| 270 SVGResourcesCache::clientWillBeRemovedFromTree(this); | 271 SVGResourcesCache::clientWillBeRemovedFromTree(this); |
| 271 LayoutReplaced::willBeRemovedFromTree(); | 272 LayoutReplaced::willBeRemovedFromTree(); |
| 272 } | 273 } |
| 273 | 274 |
| 275 PositionWithAffinity LayoutSVGRoot::positionForPoint(const LayoutPoint& point) |
| 276 { |
| 277 FloatPoint absolutePoint = FloatPoint(point); |
| 278 absolutePoint = m_localToBorderBoxTransform.inverse().mapPoint(absolutePoint
); |
| 279 LayoutObject* closestDescendant = SVGLayoutSupport::findClosestLayoutSVGText
(this, absolutePoint); |
| 280 |
| 281 if (!closestDescendant) |
| 282 return LayoutReplaced::positionForPoint(point); |
| 283 |
| 284 LayoutObject* layoutObject = closestDescendant; |
| 285 AffineTransform transform = closestDescendant->localToParentTransform(); |
| 286 transform.translate(toLayoutSVGText(closestDescendant)->location().x(), toLa
youtSVGText(closestDescendant)->location().y()); |
| 287 while (layoutObject) { |
| 288 layoutObject = layoutObject->parent(); |
| 289 if (layoutObject->isSVGRoot()) |
| 290 break; |
| 291 transform = layoutObject->localToParentTransform() * transform; |
| 292 } |
| 293 |
| 294 absolutePoint = transform.inverse().mapPoint(absolutePoint); |
| 295 |
| 296 return closestDescendant->positionForPoint(LayoutPoint(absolutePoint)); |
| 297 } |
| 298 |
| 274 // LayoutBox methods will expect coordinates w/o any transforms in coordinates | 299 // LayoutBox methods will expect coordinates w/o any transforms in coordinates |
| 275 // relative to our borderBox origin. This method gives us exactly that. | 300 // relative to our borderBox origin. This method gives us exactly that. |
| 276 void LayoutSVGRoot::buildLocalToBorderBoxTransform() | 301 void LayoutSVGRoot::buildLocalToBorderBoxTransform() |
| 277 { | 302 { |
| 278 SVGSVGElement* svg = toSVGSVGElement(node()); | 303 SVGSVGElement* svg = toSVGSVGElement(node()); |
| 279 ASSERT(svg); | 304 ASSERT(svg); |
| 280 float scale = style()->effectiveZoom(); | 305 float scale = style()->effectiveZoom(); |
| 281 FloatPoint translate = svg->currentTranslate(); | 306 FloatPoint translate = svg->currentTranslate(); |
| 282 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd
ingTop()); | 307 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd
ingTop()); |
| 283 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s
cale, contentHeight() / scale); | 308 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s
cale, contentHeight() / scale); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 updateHitTestResult(result, pointInBorderBox); | 424 updateHitTestResult(result, pointInBorderBox); |
| 400 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) | 425 if (result.addNodeToListBasedTestResult(node(), locationInContainer,
boundsRect) == StopHitTesting) |
| 401 return true; | 426 return true; |
| 402 } | 427 } |
| 403 } | 428 } |
| 404 | 429 |
| 405 return false; | 430 return false; |
| 406 } | 431 } |
| 407 | 432 |
| 408 } // namespace blink | 433 } // namespace blink |
| OLD | NEW |