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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 LayoutReplaced::insertedIntoTree(); | 275 LayoutReplaced::insertedIntoTree(); |
275 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); | 276 SVGResourcesCache::clientWasAddedToTree(this, styleRef()); |
276 } | 277 } |
277 | 278 |
278 void LayoutSVGRoot::willBeRemovedFromTree() | 279 void LayoutSVGRoot::willBeRemovedFromTree() |
279 { | 280 { |
280 SVGResourcesCache::clientWillBeRemovedFromTree(this); | 281 SVGResourcesCache::clientWillBeRemovedFromTree(this); |
281 LayoutReplaced::willBeRemovedFromTree(); | 282 LayoutReplaced::willBeRemovedFromTree(); |
282 } | 283 } |
283 | 284 |
285 PositionWithAffinity LayoutSVGRoot::positionForPoint(const LayoutPoint& point) | |
286 { | |
287 LayoutObject* closestDescendant = nullptr; | |
288 float closestDistance = std::numeric_limits<float>::max(); | |
289 FloatPoint absolutePoint(point); | |
290 | |
291 for (LayoutObject* descendant = firstChild(); descendant; descendant = desce ndant->nextInPreOrder(this)) { | |
292 if (descendant->isSVGText()) { | |
293 FloatRect boundaries = toLayoutSVGText(descendant)->objectBoundingBo x(); | |
294 FloatPoint closestPoint; | |
295 closestPoint.setX(std::max(std::min(absolutePoint.x(), boundaries.ma xX()), boundaries.x())); | |
296 closestPoint.setY(std::max(std::min(absolutePoint.y(), boundaries.ma xY()), boundaries.y())); | |
297 float distance = (absolutePoint - closestPoint).diagonalLengthSquare d(); | |
298 | |
299 if (distance < closestDistance) { | |
300 closestDistance = distance; | |
301 closestDescendant = descendant; | |
hyunjunekim2
2016/01/11 09:13:17
1. Find closest LayoutSVGText from mouse which is
| |
302 } | |
303 } | |
304 } | |
305 | |
306 if (!closestDescendant) | |
307 return createPositionWithAffinity(0); | |
hyunjunekim2
2016/01/11 09:13:16
2. If no has LayoutSVGText, return 0.
| |
308 | |
309 AffineTransform transform; | |
310 transform.makeIdentity(); | |
311 if (toLayoutSVGText(closestDescendant)->location().x()) | |
312 transform.setE(toLayoutSVGText(closestDescendant)->location().x()); | |
313 if (toLayoutSVGText(closestDescendant)->location().y()) | |
314 transform.setF(toLayoutSVGText(closestDescendant)->location().y()); | |
315 | |
316 LayoutObject* layoutObject = closestDescendant; | |
317 while (layoutObject) { | |
318 layoutObject = layoutObject->parent(); | |
319 if (layoutObject->isSVGRoot()) | |
320 break; | |
321 transform = layoutObject->localToParentTransform() * transform; | |
322 } | |
323 | |
324 transform = m_localToBorderBoxTransform * transform; | |
hyunjunekim2
2016/01/11 09:13:16
3. Make a Matrix M. M is (Root's child Matrix) * (
| |
325 absolutePoint = transform.inverse().mapPoint(absolutePoint); | |
hyunjunekim2
2016/01/11 09:13:16
5. LayoutSVGText's local coordinate = M^-1 * point
| |
326 | |
327 if (absolutePoint.x() < 0) | |
328 absolutePoint.setX(0); | |
329 if (absolutePoint.y() < 0) | |
330 absolutePoint.setY(0); | |
331 | |
332 return closestDescendant->positionForPoint(LayoutPoint(absolutePoint.x(), ab solutePoint.y())); | |
hyunjunekim2
2016/01/11 09:13:16
6. After calculate position For Point on LayoutSVG
| |
333 } | |
334 | |
284 // LayoutBox methods will expect coordinates w/o any transforms in coordinates | 335 // LayoutBox methods will expect coordinates w/o any transforms in coordinates |
285 // relative to our borderBox origin. This method gives us exactly that. | 336 // relative to our borderBox origin. This method gives us exactly that. |
286 void LayoutSVGRoot::buildLocalToBorderBoxTransform() | 337 void LayoutSVGRoot::buildLocalToBorderBoxTransform() |
287 { | 338 { |
288 SVGSVGElement* svg = toSVGSVGElement(node()); | 339 SVGSVGElement* svg = toSVGSVGElement(node()); |
289 ASSERT(svg); | 340 ASSERT(svg); |
290 float scale = style()->effectiveZoom(); | 341 float scale = style()->effectiveZoom(); |
291 FloatPoint translate = svg->currentTranslate(); | 342 FloatPoint translate = svg->currentTranslate(); |
292 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop()); | 343 LayoutSize borderAndPadding(borderLeft() + paddingLeft(), borderTop() + padd ingTop()); |
293 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale); | 344 m_localToBorderBoxTransform = svg->viewBoxToViewTransform(contentWidth() / s cale, contentHeight() / scale); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
409 updateHitTestResult(result, pointInBorderBox); | 460 updateHitTestResult(result, pointInBorderBox); |
410 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) | 461 if (!result.addNodeToListBasedTestResult(node(), locationInContainer , boundsRect)) |
411 return true; | 462 return true; |
412 } | 463 } |
413 } | 464 } |
414 | 465 |
415 return false; | 466 return false; |
416 } | 467 } |
417 | 468 |
418 } | 469 } |
OLD | NEW |