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 LayoutObject* closestLayoutObject = nullptr; | |
482 float closestDistance = std::numeric_limits<float>::max(); | |
483 Vector<LayoutObject*> overlappedObjects; | |
484 for (LayoutObject* child = layoutObject->slowLastChild(); child; child = chi ld->previousSibling()) { | |
485 if (!child->isSVGContainer() && !child->isSVGText()) | |
486 continue; | |
487 if (child->isSVGHiddenContainer()) | |
488 continue; | |
489 | |
490 FloatRect boundingBox = child->objectBoundingBox(); | |
fs
2016/01/19 13:30:04
Move down.
| |
491 | |
492 if (!child->localToParentTransform().isInvertible()) | |
493 continue; | |
494 | |
495 FloatPoint childLocalPoint = child->localToParentTransform().inverse().m apPoint(point); | |
496 float distance = boundingBox.squaredDistanceTo(childLocalPoint); | |
497 | |
498 if (distance <= closestDistance) { | |
499 // The reason is that if the closest LayoutObject is not found Layou tSVGText, try to find | |
500 // LayoutSVGText object on other LayoutObjects overlapped by closest LayoutObject | |
501 if (closestLayoutObject && boundingBox.contains(closestLayoutObject- >objectBoundingBox())) { | |
502 overlappedObjects.append(child); | |
503 continue; | |
504 } | |
505 | |
506 overlappedObjects.clear(); | |
507 | |
508 closestLayoutObject = child; | |
509 closestDistance = distance; | |
510 } | |
511 } | |
512 | |
513 if (!closestLayoutObject || closestLayoutObject->isSVGText()) | |
514 return closestLayoutObject; | |
515 | |
516 FloatPoint absolutePoint = closestLayoutObject->localToParentTransform().inv erse().mapPoint(point); | |
fs
2016/01/19 13:30:04
Calling this "pointInChild" or "childLocalPoint" l
| |
517 if (LayoutObject* result = findClosestLayoutSVGText(closestLayoutObject, abs olutePoint)) | |
518 return result; | |
519 | |
520 // No found LayoutSVGText on closest LayoutObject, after all try to search o n other LayoutObjects which store | |
521 // on vector called `overlappedObjects`. | |
522 LayoutObject* result; | |
523 for (LayoutObject* overlappedObject : overlappedObjects) { | |
524 absolutePoint = overlappedObject->localToParentTransform().inverse().map Point(point); | |
525 result = findClosestLayoutSVGText(overlappedObject, absolutePoint); | |
526 if (result) | |
fs
2016/01/19 13:30:04
You could write this like the previous version bef
| |
527 break; | |
528 } | |
529 | |
530 return result; | |
479 } | 531 } |
532 | |
533 } | |
OLD | NEW |