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::findSelectedLayoutSVGText(LayoutObject* layoutOb ject, const FloatPoint point) | |
fs
2016/01/18 12:44:11
"Selected" doesn't seem like the correct term here
| |
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->isSVGContainer() && child->isSVGHiddenContainer()) | |
fs
2016/01/18 12:44:11
No need to check isSVGContainer() again. It would
| |
488 continue; | |
489 | |
490 FloatRect bound = child->objectBoundingBox(); | |
fs
2016/01/18 12:44:11
Move down to just before you need it and rename to
| |
491 | |
492 if (!child->localToParentTransform().isInvertible()) | |
493 continue; | |
494 | |
495 FloatPoint childLocalPoint = child->localToParentTransform().inverse().m apPoint(point); | |
496 float distance = bound.squaredDistanceTo(childLocalPoint); | |
497 | |
498 if (distance < closestDistance) { | |
499 // If child is overlapped by closesLayoutObject, It's candiate to se arch sub-tree. | |
fs
2016/01/18 12:44:11
Lot's of typos that needs fixing here ("closesLayo
| |
500 // When closestLayoutObject' sub-tree hasn't LayoutSVGText object, t ry to search | |
501 // on the sub-tree which store on vector called `overlappedObjects`. | |
502 if (closestLayoutObject && bound.contains(closestLayoutObject->objec tBoundingBox())) { | |
fs
2016/01/18 12:44:11
I don't quite see why the "overlapped" property ma
| |
503 overlappedObjects.append(child); | |
504 continue; | |
505 } | |
506 | |
507 overlappedObjects.clear(); | |
508 | |
509 closestLayoutObject = child; | |
510 closestDistance = distance; | |
511 } | |
512 } | |
513 | |
514 if (!closestLayoutObject || closestLayoutObject->isSVGText()) | |
515 return closestLayoutObject; | |
516 | |
517 FloatPoint absolutePoint = closestLayoutObject->localToParentTransform().inv erse().mapPoint(point); | |
518 LayoutObject* result = findSelectedLayoutSVGText(closestLayoutObject, absol utePoint); | |
fs
2016/01/18 12:44:11
if (LayoutObject* result = ...)
return result;
| |
519 | |
520 // No found LayoutSVGText on closest subtree, after all try to search on the sub-tree which store | |
521 // on vector called `overlappedObjects`. | |
522 if (!result) { | |
523 for (LayoutObject* overlappedObject : overlappedObjects) { | |
524 absolutePoint = overlappedObject->localToParentTransform().inverse() .mapPoint(point); | |
525 result = findSelectedLayoutSVGText(overlappedObject, absolutePoint); | |
526 if (result) | |
527 break; | |
528 } | |
529 } | |
530 | |
531 return result; | |
479 } | 532 } |
533 | |
534 } | |
OLD | NEW |