OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008 Rob Buis <buis@kde.org> |
4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. | 4 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
5 * | 5 * |
6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
10 * | 10 * |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "wtf/AutoReset.h" | 25 #include "wtf/AutoReset.h" |
26 | 26 |
27 namespace blink { | 27 namespace blink { |
28 | 28 |
29 LayoutSVGResourceMarker::LayoutSVGResourceMarker(SVGMarkerElement* node) | 29 LayoutSVGResourceMarker::LayoutSVGResourceMarker(SVGMarkerElement* node) |
30 : LayoutSVGResourceContainer(node), m_needsTransformUpdate(true) {} | 30 : LayoutSVGResourceContainer(node), m_needsTransformUpdate(true) {} |
31 | 31 |
32 LayoutSVGResourceMarker::~LayoutSVGResourceMarker() {} | 32 LayoutSVGResourceMarker::~LayoutSVGResourceMarker() {} |
33 | 33 |
34 void LayoutSVGResourceMarker::layout() { | 34 void LayoutSVGResourceMarker::layout() { |
35 ASSERT(needsLayout()); | 35 DCHECK(needsLayout()); |
36 if (m_isInLayout) | 36 if (m_isInLayout) |
37 return; | 37 return; |
38 | 38 |
39 AutoReset<bool> inLayoutChange(&m_isInLayout, true); | 39 AutoReset<bool> inLayoutChange(&m_isInLayout, true); |
40 | 40 |
41 // LayoutSVGHiddenContainer overwrites layout(). We need the | 41 // LayoutSVGHiddenContainer overwrites layout(). We need the |
42 // layouting of LayoutSVGContainer for calculating local | 42 // layouting of LayoutSVGContainer for calculating local |
43 // transformations and paint invalidation. | 43 // transformations and paint invalidation. |
44 LayoutSVGContainer::layout(); | 44 LayoutSVGContainer::layout(); |
45 | 45 |
46 clearInvalidationMask(); | 46 clearInvalidationMask(); |
47 } | 47 } |
48 | 48 |
49 void LayoutSVGResourceMarker::removeAllClientsFromCache( | 49 void LayoutSVGResourceMarker::removeAllClientsFromCache( |
50 bool markForInvalidation) { | 50 bool markForInvalidation) { |
51 markAllClientsForInvalidation(markForInvalidation | 51 markAllClientsForInvalidation(markForInvalidation |
52 ? LayoutAndBoundariesInvalidation | 52 ? LayoutAndBoundariesInvalidation |
53 : ParentOnlyInvalidation); | 53 : ParentOnlyInvalidation); |
54 } | 54 } |
55 | 55 |
56 void LayoutSVGResourceMarker::removeClientFromCache(LayoutObject* client, | 56 void LayoutSVGResourceMarker::removeClientFromCache(LayoutObject* client, |
57 bool markForInvalidation) { | 57 bool markForInvalidation) { |
58 ASSERT(client); | 58 DCHECK(client); |
59 markClientForInvalidation(client, markForInvalidation | 59 markClientForInvalidation(client, markForInvalidation |
60 ? BoundariesInvalidation | 60 ? BoundariesInvalidation |
61 : ParentOnlyInvalidation); | 61 : ParentOnlyInvalidation); |
62 } | 62 } |
63 | 63 |
64 FloatRect LayoutSVGResourceMarker::markerBoundaries( | 64 FloatRect LayoutSVGResourceMarker::markerBoundaries( |
65 const AffineTransform& markerTransformation) const { | 65 const AffineTransform& markerTransformation) const { |
66 FloatRect coordinates = LayoutSVGContainer::visualRectInLocalSVGCoordinates(); | 66 FloatRect coordinates = LayoutSVGContainer::visualRectInLocalSVGCoordinates(); |
67 | 67 |
68 // Map visual rect into parent coordinate space, in which the marker | 68 // Map visual rect into parent coordinate space, in which the marker |
69 // boundaries have to be evaluated. | 69 // boundaries have to be evaluated. |
70 coordinates = localToSVGParentTransform().mapRect(coordinates); | 70 coordinates = localToSVGParentTransform().mapRect(coordinates); |
71 | 71 |
72 return markerTransformation.mapRect(coordinates); | 72 return markerTransformation.mapRect(coordinates); |
73 } | 73 } |
74 | 74 |
75 FloatPoint LayoutSVGResourceMarker::referencePoint() const { | 75 FloatPoint LayoutSVGResourceMarker::referencePoint() const { |
76 SVGMarkerElement* marker = toSVGMarkerElement(element()); | 76 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
77 ASSERT(marker); | 77 DCHECK(marker); |
78 | 78 |
79 SVGLengthContext lengthContext(marker); | 79 SVGLengthContext lengthContext(marker); |
80 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), | 80 return FloatPoint(marker->refX()->currentValue()->value(lengthContext), |
81 marker->refY()->currentValue()->value(lengthContext)); | 81 marker->refY()->currentValue()->value(lengthContext)); |
82 } | 82 } |
83 | 83 |
84 float LayoutSVGResourceMarker::angle() const { | 84 float LayoutSVGResourceMarker::angle() const { |
85 return toSVGMarkerElement(element())->orientAngle()->currentValue()->value(); | 85 return toSVGMarkerElement(element())->orientAngle()->currentValue()->value(); |
86 } | 86 } |
87 | 87 |
(...skipping 28 matching lines...) Expand all Loading... |
116 // contents so we include the value in each marker's transform. | 116 // contents so we include the value in each marker's transform. |
117 FloatPoint mappedReferencePoint = | 117 FloatPoint mappedReferencePoint = |
118 localToSVGParentTransform().mapPoint(referencePoint()); | 118 localToSVGParentTransform().mapPoint(referencePoint()); |
119 transform.translate(-mappedReferencePoint.x(), -mappedReferencePoint.y()); | 119 transform.translate(-mappedReferencePoint.x(), -mappedReferencePoint.y()); |
120 return transform; | 120 return transform; |
121 } | 121 } |
122 | 122 |
123 bool LayoutSVGResourceMarker::shouldPaint() const { | 123 bool LayoutSVGResourceMarker::shouldPaint() const { |
124 // An empty viewBox disables rendering. | 124 // An empty viewBox disables rendering. |
125 SVGMarkerElement* marker = toSVGMarkerElement(element()); | 125 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
126 ASSERT(marker); | 126 DCHECK(marker); |
127 return !marker->viewBox()->isSpecified() || | 127 return !marker->viewBox()->isSpecified() || |
128 !marker->viewBox()->currentValue()->isValid() || | 128 !marker->viewBox()->currentValue()->isValid() || |
129 !marker->viewBox()->currentValue()->value().isEmpty(); | 129 !marker->viewBox()->currentValue()->value().isEmpty(); |
130 } | 130 } |
131 | 131 |
132 void LayoutSVGResourceMarker::setNeedsTransformUpdate() { | 132 void LayoutSVGResourceMarker::setNeedsTransformUpdate() { |
133 setMayNeedPaintInvalidationSubtree(); | 133 setMayNeedPaintInvalidationSubtree(); |
134 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { | 134 if (RuntimeEnabledFeatures::slimmingPaintInvalidationEnabled()) { |
135 // The transform paint property relies on the SVG transform being up-to-date | 135 // The transform paint property relies on the SVG transform being up-to-date |
136 // (see: PaintPropertyTreeBuilder::updateTransformForNonRootSVG). | 136 // (see: PaintPropertyTreeBuilder::updateTransformForNonRootSVG). |
137 setNeedsPaintPropertyUpdate(); | 137 setNeedsPaintPropertyUpdate(); |
138 } | 138 } |
139 m_needsTransformUpdate = true; | 139 m_needsTransformUpdate = true; |
140 } | 140 } |
141 | 141 |
142 SVGTransformChange LayoutSVGResourceMarker::calculateLocalTransform() { | 142 SVGTransformChange LayoutSVGResourceMarker::calculateLocalTransform() { |
143 if (!m_needsTransformUpdate) | 143 if (!m_needsTransformUpdate) |
144 return SVGTransformChange::None; | 144 return SVGTransformChange::None; |
145 | 145 |
146 SVGMarkerElement* marker = toSVGMarkerElement(element()); | 146 SVGMarkerElement* marker = toSVGMarkerElement(element()); |
147 ASSERT(marker); | 147 DCHECK(marker); |
148 | 148 |
149 SVGLengthContext lengthContext(marker); | 149 SVGLengthContext lengthContext(marker); |
150 float width = marker->markerWidth()->currentValue()->value(lengthContext); | 150 float width = marker->markerWidth()->currentValue()->value(lengthContext); |
151 float height = marker->markerHeight()->currentValue()->value(lengthContext); | 151 float height = marker->markerHeight()->currentValue()->value(lengthContext); |
152 m_viewportSize = FloatSize(width, height); | 152 m_viewportSize = FloatSize(width, height); |
153 | 153 |
154 SVGTransformChangeDetector changeDetector(m_localToParentTransform); | 154 SVGTransformChangeDetector changeDetector(m_localToParentTransform); |
155 m_localToParentTransform = marker->viewBoxToViewTransform( | 155 m_localToParentTransform = marker->viewBoxToViewTransform( |
156 m_viewportSize.width(), m_viewportSize.height()); | 156 m_viewportSize.width(), m_viewportSize.height()); |
157 | 157 |
158 m_needsTransformUpdate = false; | 158 m_needsTransformUpdate = false; |
159 return changeDetector.computeChange(m_localToParentTransform); | 159 return changeDetector.computeChange(m_localToParentTransform); |
160 } | 160 } |
161 | 161 |
162 } // namespace blink | 162 } // namespace blink |
OLD | NEW |