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 19 matching lines...) Expand all Loading... |
30 #include "core/layout/svg/LayoutSVGResourceClipper.h" | 30 #include "core/layout/svg/LayoutSVGResourceClipper.h" |
31 #include "core/layout/svg/LayoutSVGResourceFilter.h" | 31 #include "core/layout/svg/LayoutSVGResourceFilter.h" |
32 #include "core/layout/svg/LayoutSVGResourceMasker.h" | 32 #include "core/layout/svg/LayoutSVGResourceMasker.h" |
33 #include "core/layout/svg/LayoutSVGRoot.h" | 33 #include "core/layout/svg/LayoutSVGRoot.h" |
34 #include "core/layout/svg/LayoutSVGShape.h" | 34 #include "core/layout/svg/LayoutSVGShape.h" |
35 #include "core/layout/svg/LayoutSVGText.h" | 35 #include "core/layout/svg/LayoutSVGText.h" |
36 #include "core/layout/svg/LayoutSVGTransformableContainer.h" | 36 #include "core/layout/svg/LayoutSVGTransformableContainer.h" |
37 #include "core/layout/svg/LayoutSVGViewportContainer.h" | 37 #include "core/layout/svg/LayoutSVGViewportContainer.h" |
38 #include "core/layout/svg/SVGResources.h" | 38 #include "core/layout/svg/SVGResources.h" |
39 #include "core/layout/svg/SVGResourcesCache.h" | 39 #include "core/layout/svg/SVGResourcesCache.h" |
| 40 #include "core/page/Page.h" |
40 #include "core/paint/PaintLayer.h" | 41 #include "core/paint/PaintLayer.h" |
41 #include "core/svg/SVGElement.h" | 42 #include "core/svg/SVGElement.h" |
42 #include "platform/geometry/TransformState.h" | 43 #include "platform/geometry/TransformState.h" |
43 #include "platform/graphics/StrokeData.h" | 44 #include "platform/graphics/StrokeData.h" |
44 #include "wtf/MathExtras.h" | 45 #include "wtf/MathExtras.h" |
45 | 46 |
46 namespace blink { | 47 namespace blink { |
47 | 48 |
48 struct SearchCandidate { | 49 struct SearchCandidate { |
49 SearchCandidate() | 50 SearchCandidate() |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 AffineTransform contentTransformation = | 513 AffineTransform contentTransformation = |
513 subtreeContentTransformation * | 514 subtreeContentTransformation * |
514 AffineTransform(s_currentContentTransformation); | 515 AffineTransform(s_currentContentTransformation); |
515 contentTransformation.copyTransformTo(s_currentContentTransformation); | 516 contentTransformation.copyTransformTo(s_currentContentTransformation); |
516 } | 517 } |
517 | 518 |
518 SubtreeContentTransformScope::~SubtreeContentTransformScope() { | 519 SubtreeContentTransformScope::~SubtreeContentTransformScope() { |
519 m_savedContentTransformation.copyTransformTo(s_currentContentTransformation); | 520 m_savedContentTransformation.copyTransformTo(s_currentContentTransformation); |
520 } | 521 } |
521 | 522 |
522 float SVGLayoutSupport::calculateScreenFontSizeScalingFactor( | 523 AffineTransform SVGLayoutSupport::deprecatedCalculateTransformToLayer( |
523 const LayoutObject* layoutObject) { | 524 const LayoutObject* layoutObject) { |
524 AffineTransform transform; | 525 AffineTransform transform; |
525 while (layoutObject) { | 526 while (layoutObject) { |
526 transform = layoutObject->localToSVGParentTransform() * transform; | 527 transform = layoutObject->localToSVGParentTransform() * transform; |
527 if (layoutObject->isSVGRoot()) | 528 if (layoutObject->isSVGRoot()) |
528 break; | 529 break; |
529 layoutObject = layoutObject->parent(); | 530 layoutObject = layoutObject->parent(); |
530 } | 531 } |
531 transform.multiply( | 532 |
532 SubtreeContentTransformScope::currentContentTransformation()); | 533 // Continue walking up the layer tree, accumulating CSS transforms. |
533 return clampTo<float>( | 534 // FIXME: this queries layer compositing state - which is not |
534 sqrt((transform.xScaleSquared() + transform.yScaleSquared()) / 2)); | 535 // supported during layout. Hence, the result may not include all CSS |
| 536 // transforms. |
| 537 PaintLayer* layer = layoutObject ? layoutObject->enclosingLayer() : 0; |
| 538 while (layer && layer->isAllowedToQueryCompositingState()) { |
| 539 // We can stop at compositing layers, to match the backing resolution. |
| 540 // FIXME: should we be computing the transform to the nearest composited |
| 541 // layer, or the nearest composited layer that does not paint into its |
| 542 // ancestor? I think this is the nearest composited ancestor since we will |
| 543 // inherit its transforms in the composited layer tree. |
| 544 if (layer->compositingState() != NotComposited) |
| 545 break; |
| 546 |
| 547 if (TransformationMatrix* layerTransform = layer->transform()) |
| 548 transform = layerTransform->toAffineTransform() * transform; |
| 549 |
| 550 layer = layer->parent(); |
| 551 } |
| 552 |
| 553 return transform; |
| 554 } |
| 555 |
| 556 float SVGLayoutSupport::calculateScreenFontSizeScalingFactor( |
| 557 const LayoutObject* layoutObject) { |
| 558 DCHECK(layoutObject); |
| 559 |
| 560 // FIXME: trying to compute a device space transform at record time is wrong. |
| 561 // All clients should be updated to avoid relying on this information, and the |
| 562 // method should be removed. |
| 563 AffineTransform ctm = |
| 564 deprecatedCalculateTransformToLayer(layoutObject) * |
| 565 SubtreeContentTransformScope::currentContentTransformation(); |
| 566 ctm.scale(layoutObject->document().page()->deviceScaleFactorDeprecated()); |
| 567 |
| 568 return clampTo<float>(sqrt((ctm.xScaleSquared() + ctm.yScaleSquared()) / 2)); |
535 } | 569 } |
536 | 570 |
537 static inline bool compareCandidateDistance(const SearchCandidate& r1, | 571 static inline bool compareCandidateDistance(const SearchCandidate& r1, |
538 const SearchCandidate& r2) { | 572 const SearchCandidate& r2) { |
539 return r1.candidateDistance < r2.candidateDistance; | 573 return r1.candidateDistance < r2.candidateDistance; |
540 } | 574 } |
541 | 575 |
542 static inline float distanceToChildLayoutObject(LayoutObject* child, | 576 static inline float distanceToChildLayoutObject(LayoutObject* child, |
543 const FloatPoint& point) { | 577 const FloatPoint& point) { |
544 const AffineTransform& localToParentTransform = | 578 const AffineTransform& localToParentTransform = |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 } | 642 } |
609 | 643 |
610 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText( | 644 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText( |
611 LayoutObject* layoutObject, | 645 LayoutObject* layoutObject, |
612 const FloatPoint& point) { | 646 const FloatPoint& point) { |
613 return searchTreeForFindClosestLayoutSVGText(layoutObject, point) | 647 return searchTreeForFindClosestLayoutSVGText(layoutObject, point) |
614 .candidateLayoutObject; | 648 .candidateLayoutObject; |
615 } | 649 } |
616 | 650 |
617 } // namespace blink | 651 } // namespace blink |
OLD | NEW |