OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> | 2 * Copyright (C) 2007, 2008 Rob Buis <buis@kde.org> |
3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@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. All rights reserved. | 5 * Copyright (C) 2009 Google, Inc. All rights reserved. |
6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 7 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
469 ASSERT(layoutObject); | 469 ASSERT(layoutObject); |
470 | 470 |
471 // FIXME: trying to compute a device space transform at record time is wrong . All clients | 471 // FIXME: trying to compute a device space transform at record time is wrong . All clients |
472 // should be updated to avoid relying on this information, and the method sh ould be removed. | 472 // should be updated to avoid relying on this information, and the method sh ould be removed. |
473 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * Su btreeContentTransformScope::currentContentTransformation(); | 473 AffineTransform ctm = deprecatedCalculateTransformToLayer(layoutObject) * Su btreeContentTransformScope::currentContentTransformation(); |
474 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); | 474 ctm.scale(layoutObject->document().frameHost()->deviceScaleFactor()); |
475 | 475 |
476 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); | 476 return narrowPrecisionToFloat(sqrt((pow(ctm.xScale(), 2) + pow(ctm.yScale(), 2)) / 2)); |
477 } | 477 } |
478 | 478 |
479 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText(LayoutObject* layoutObj ect, const FloatPoint& point) | |
480 { | |
481 // Try to search closest LayoutSVGText on sub-tree of `layoutObject`. | |
fs
2016/01/19 16:12:46
"Try to find the closest LayoutSVGText in the subt
| |
482 // When closest LayoutObject hasn't LayoutSVGText object, try to search on o ther LayoutObjects | |
fs
2016/01/19 16:12:46
LayoutSVGText's are not treat specially in any way
| |
483 // overlapped which store on the vector called `overlappedObjects` that they are candidates. | |
484 // If not find LayoutSVGText object on candidates, After all return nullptr. | |
485 LayoutObject* closestLayoutObject = nullptr; | |
486 float closestDistance = std::numeric_limits<float>::max(); | |
487 Vector<LayoutObject*> overlappedObjects; | |
488 for (LayoutObject* child = layoutObject->slowLastChild(); child; child = chi ld->previousSibling()) { | |
489 if (!child->isSVGContainer() && !child->isSVGText()) | |
490 continue; | |
491 if (child->isSVGHiddenContainer()) | |
492 continue; | |
493 if (!child->localToParentTransform().isInvertible()) | |
494 continue; | |
495 | |
496 FloatRect boundingBox = child->objectBoundingBox(); | |
497 FloatPoint childLocalPoint = child->localToParentTransform().inverse().m apPoint(point); | |
498 float distance = boundingBox.squaredDistanceTo(childLocalPoint); | |
499 | |
500 if (distance <= closestDistance) { | |
501 // The reason is that if the closest LayoutObject is not found Layou tSVGText, try to find | |
502 // LayoutSVGText object on other LayoutObjects overlapped by closest LayoutObject | |
503 if (closestLayoutObject && boundingBox.contains(closestLayoutObject- >objectBoundingBox())) { | |
fs
2016/01/19 16:12:46
To re-iterate: I don't think that 'overlaps' is a
| |
504 overlappedObjects.append(child); | |
505 continue; | |
506 } | |
507 | |
508 overlappedObjects.clear(); | |
509 | |
510 closestLayoutObject = child; | |
511 closestDistance = distance; | |
512 } | |
513 } | |
514 | |
515 if (!closestLayoutObject || closestLayoutObject->isSVGText()) | |
516 return closestLayoutObject; | |
517 | |
518 FloatPoint childLocalPoint = closestLayoutObject->localToParentTransform().i nverse().mapPoint(point); | |
519 if (LayoutObject* result = findClosestLayoutSVGText(closestLayoutObject, chi ldLocalPoint)) | |
520 return result; | |
521 | |
522 // No find LayoutSVGText on closest LayoutObject, after all try to search on other LayoutObjects which store | |
523 // on vector called `overlappedObjects`. | |
524 for (LayoutObject* overlappedObject : overlappedObjects) { | |
525 childLocalPoint = overlappedObject->localToParentTransform().inverse().m apPoint(point); | |
526 if (LayoutObject* result = findClosestLayoutSVGText(overlappedObject, ch ildLocalPoint)) | |
527 return result; | |
528 } | |
529 | |
530 return nullptr; | |
479 } | 531 } |
532 | |
533 } | |
OLD | NEW |