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, AffineTransform& localToParentTransform, 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->style()->visibility() != VISIBLE) | |
fs
2016/01/15 10:34:16
This is not correct at this level - 'visibility' c
| |
486 continue; | |
487 | |
488 if (!child->isSVGContainer() && !child->isSVGText()) | |
fs
2016/01/15 10:34:16
"Hidden containers" still return true for isSVGCon
| |
489 continue; | |
490 | |
491 FloatRect bound = child->objectBoundingBox(); | |
492 float distance = bound.squaredDistanceTo(child->localToParentTransform() .inverse().mapPoint(point)); | |
fs
2016/01/15 10:34:16
Since you're using the inverse transform you shoul
| |
493 | |
494 if (distance < closestDistance) { | |
495 AffineTransform transform; | |
496 | |
497 if (closestLayoutObject) { | |
498 transform = localToParentTransform * closestLayoutObject->localT oParentTransform(); | |
fs
2016/01/15 10:34:16
No need to transform by |localToParentTransform| s
| |
499 bound = (localToParentTransform * child->localToParentTransform( )).mapRect(bound); | |
500 } | |
501 | |
502 if (closestLayoutObject && bound.intersects(transform.mapRect(closes tLayoutObject->objectBoundingBox()))) { | |
fs
2016/01/15 10:34:16
Not quite sure why you'd need to check overlap bet
| |
503 overlappedObjects.append(child); | |
504 continue; | |
505 } | |
506 overlappedObjects.clear(); | |
507 | |
508 closestLayoutObject = child; | |
509 closestDistance = distance; | |
510 } | |
511 } | |
512 | |
513 if (closestLayoutObject && !closestLayoutObject->isSVGText()) { | |
fs
2016/01/15 10:34:16
Use "early-out style" when possible - i.e here you
| |
514 FloatPoint absolutePoint = closestLayoutObject->localToParentTransform() .inverse().mapPoint(point); | |
515 localToParentTransform = localToParentTransform * closestLayoutObject->l ocalToParentTransform(); | |
516 LayoutObject* result = findSelectedLayoutSVGText(closestLayoutObject, l ocalToParentTransform, absolutePoint); | |
517 | |
518 if (!result) { | |
519 localToParentTransform = localToParentTransform * closestLayoutObjec t->localToParentTransform().inverse(); | |
fs
2016/01/15 10:34:16
Maintaining the transform like this looks really e
| |
520 for (LayoutObject* overlappedObject : overlappedObjects) { | |
521 absolutePoint = overlappedObject->localToParentTransform().inver se().mapPoint(point); | |
522 localToParentTransform = localToParentTransform * overlappedObje ct->localToParentTransform(); | |
523 result = findSelectedLayoutSVGText(overlappedObject, localToPare ntTransform, absolutePoint); | |
524 if (result) | |
525 break; | |
526 localToParentTransform = localToParentTransform * overlappedObje ct->localToParentTransform().inverse(); | |
527 } | |
528 } | |
529 | |
530 closestLayoutObject = result; | |
531 } | |
532 | |
533 return closestLayoutObject; | |
479 } | 534 } |
535 | |
536 } | |
OLD | NEW |