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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 return rect; | 109 return rect; |
110 } | 110 } |
111 | 111 |
112 LayoutRect rect; | 112 LayoutRect rect; |
113 const LayoutSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object, | 113 const LayoutSVGRoot& svgRoot = mapRectToSVGRootForPaintInvalidation(object, |
114 paintInvalidationRect, rect, strokeWidthForHairlinePadding); | 114 paintInvalidationRect, rect, strokeWidthForHairlinePadding); |
115 svgRoot.mapToVisibleRectInAncestorSpace(paintInvalidationContainer, rect, pa
intInvalidationState); | 115 svgRoot.mapToVisibleRectInAncestorSpace(paintInvalidationContainer, rect, pa
intInvalidationState); |
116 return rect; | 116 return rect; |
117 } | 117 } |
118 | 118 |
| 119 static const LayoutSVGRoot& computeTransformToSVGRoot(const LayoutObject& object
, AffineTransform& rootBorderBoxTransform) |
| 120 { |
| 121 ASSERT(object.isSVG() && !object.isSVGRoot()); |
| 122 |
| 123 const LayoutObject* parent; |
| 124 for (parent = &object; !parent->isSVGRoot(); parent = parent->parent()) |
| 125 rootBorderBoxTransform.preMultiply(parent->localToParentTransform()); |
| 126 |
| 127 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); |
| 128 rootBorderBoxTransform.preMultiply(svgRoot.localToBorderBoxTransform()); |
| 129 return svgRoot; |
| 130 } |
| 131 |
119 const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject& object, | 132 const LayoutSVGRoot& SVGLayoutSupport::mapRectToSVGRootForPaintInvalidation(cons
t LayoutObject& object, |
120 const FloatRect& localPaintInvalidationRect, LayoutRect& rect, float strokeW
idthForHairlinePadding) | 133 const FloatRect& localPaintInvalidationRect, LayoutRect& rect, float strokeW
idthForHairlinePadding) |
121 { | 134 { |
122 ASSERT(object.isSVG() && !object.isSVGRoot()); | |
123 | |
124 const LayoutObject* parent; | |
125 AffineTransform rootBorderBoxTransform; | 135 AffineTransform rootBorderBoxTransform; |
126 for (parent = &object; !parent->isSVGRoot(); parent = parent->parent()) | 136 const LayoutSVGRoot& svgRoot = computeTransformToSVGRoot(object, rootBorderB
oxTransform); |
127 rootBorderBoxTransform.preMultiply(parent->localToParentTransform()); | |
128 | |
129 const LayoutSVGRoot& svgRoot = toLayoutSVGRoot(*parent); | |
130 rootBorderBoxTransform.preMultiply(svgRoot.localToBorderBoxTransform()); | |
131 | 137 |
132 rect = adjustedEnclosingIntRect(rootBorderBoxTransform.mapRect(localPaintInv
alidationRect), | 138 rect = adjustedEnclosingIntRect(rootBorderBoxTransform.mapRect(localPaintInv
alidationRect), |
133 rootBorderBoxTransform, strokeWidthForHairlinePadding); | 139 rootBorderBoxTransform, strokeWidthForHairlinePadding); |
134 | |
135 return svgRoot; | 140 return svgRoot; |
136 } | 141 } |
137 | 142 |
138 void SVGLayoutSupport::mapLocalToAncestor(const LayoutObject* object, const Layo
utBoxModelObject* ancestor, TransformState& transformState, bool* wasFixed, cons
t PaintInvalidationState* paintInvalidationState) | 143 void SVGLayoutSupport::mapLocalToAncestor(const LayoutObject* object, const Layo
utBoxModelObject* ancestor, TransformState& transformState, bool* wasFixed, cons
t PaintInvalidationState* paintInvalidationState) |
139 { | 144 { |
140 transformState.applyTransform(object->localToParentTransform()); | 145 transformState.applyTransform(object->localToParentTransform()); |
141 | 146 |
142 if (paintInvalidationState && paintInvalidationState->canMapToContainer(ance
stor)) { | 147 if (paintInvalidationState && paintInvalidationState->canMapToContainer(ance
stor)) { |
143 // |svgTransform| contains localToBorderBoxTransform mentioned below. | 148 // |svgTransform| contains localToBorderBoxTransform mentioned below. |
144 transformState.applyTransform(paintInvalidationState->svgTransform()); | 149 transformState.applyTransform(paintInvalidationState->svgTransform()); |
145 transformState.move(paintInvalidationState->paintOffset()); | 150 transformState.move(paintInvalidationState->paintOffset()); |
146 return; | 151 return; |
147 } | 152 } |
148 | 153 |
149 LayoutObject* parent = object->parent(); | 154 LayoutObject* parent = object->parent(); |
150 | 155 |
151 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform | 156 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform |
152 // to map an element from SVG viewport coordinates to CSS box coordinates. | 157 // to map an element from SVG viewport coordinates to CSS box coordinates. |
153 // LayoutSVGRoot's mapLocalToAncestor method expects CSS box coordinates. | 158 // LayoutSVGRoot's mapLocalToAncestor method expects CSS box coordinates. |
154 if (parent->isSVGRoot()) | 159 if (parent->isSVGRoot()) |
155 transformState.applyTransform(toLayoutSVGRoot(parent)->localToBorderBoxT
ransform()); | 160 transformState.applyTransform(toLayoutSVGRoot(parent)->localToBorderBoxT
ransform()); |
156 | 161 |
157 MapCoordinatesFlags mode = UseTransforms; | 162 MapCoordinatesFlags mode = UseTransforms; |
158 parent->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintIn
validationState); | 163 parent->mapLocalToAncestor(ancestor, transformState, mode, wasFixed, paintIn
validationState); |
159 } | 164 } |
160 | 165 |
| 166 void SVGLayoutSupport::mapAncestorToLocal(const LayoutObject& object, const Layo
utBoxModelObject* ancestor, TransformState& transformState) |
| 167 { |
| 168 // |object| is either a LayoutSVGModelObject or a LayoutSVGBlock here. In |
| 169 // the former case, |object| can never be an ancestor while in the latter |
| 170 // the caller is responsible for doing the ancestor check. Because of this, |
| 171 // computing the transform to the SVG root is always what we want to do here
. |
| 172 ASSERT(ancestor != &object); |
| 173 ASSERT(object.isSVGContainer() || object.isSVGShape() || object.isSVGImage()
|| object.isSVGText() || object.isSVGForeignObject()); |
| 174 AffineTransform localToSVGRoot; |
| 175 const LayoutSVGRoot& svgRoot = computeTransformToSVGRoot(object, localToSVGR
oot); |
| 176 |
| 177 MapCoordinatesFlags mode = UseTransforms | ApplyContainerFlip; |
| 178 svgRoot.mapAncestorToLocal(ancestor, transformState, mode); |
| 179 |
| 180 transformState.applyTransform(localToSVGRoot); |
| 181 } |
| 182 |
161 const LayoutObject* SVGLayoutSupport::pushMappingToContainer(const LayoutObject*
object, const LayoutBoxModelObject* ancestorToStopAt, LayoutGeometryMap& geomet
ryMap) | 183 const LayoutObject* SVGLayoutSupport::pushMappingToContainer(const LayoutObject*
object, const LayoutBoxModelObject* ancestorToStopAt, LayoutGeometryMap& geomet
ryMap) |
162 { | 184 { |
163 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); | 185 ASSERT_UNUSED(ancestorToStopAt, ancestorToStopAt != object); |
164 | 186 |
165 LayoutObject* parent = object->parent(); | 187 LayoutObject* parent = object->parent(); |
166 | 188 |
167 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform | 189 // At the SVG/HTML boundary (aka LayoutSVGRoot), we apply the localToBorderB
oxTransform |
168 // to map an element from SVG viewport coordinates to CSS box coordinates. | 190 // to map an element from SVG viewport coordinates to CSS box coordinates. |
169 // LayoutSVGRoot's mapLocalToAncestor method expects CSS box coordinates. | 191 // LayoutSVGRoot's mapLocalToAncestor method expects CSS box coordinates. |
170 if (parent->isSVGRoot()) { | 192 if (parent->isSVGRoot()) { |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 | 588 |
567 return closestText; | 589 return closestText; |
568 } | 590 } |
569 | 591 |
570 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText(LayoutObject* layoutObj
ect, const FloatPoint& point) | 592 LayoutObject* SVGLayoutSupport::findClosestLayoutSVGText(LayoutObject* layoutObj
ect, const FloatPoint& point) |
571 { | 593 { |
572 return searchTreeForFindClosestLayoutSVGText(layoutObject, point).candidateL
ayoutObject; | 594 return searchTreeForFindClosestLayoutSVGText(layoutObject, point).candidateL
ayoutObject; |
573 } | 595 } |
574 | 596 |
575 } // namespace blink | 597 } // namespace blink |
OLD | NEW |