| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2008 Nikolas Zimmermann <zimmermann@kde.org> |
| 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2006 Rob Buis <buis@kde.org> |
| 4 * Copyright (C) 2014 Google, Inc. |
| 4 * | 5 * |
| 5 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 8 * 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. |
| 9 * | 10 * |
| 10 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 if (!targetCTM.isInvertible()) { | 60 if (!targetCTM.isInvertible()) { |
| 60 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); | 61 exceptionState.throwDOMException(InvalidStateError, "The target tran
sformation is not invertable."); |
| 61 return nullptr; | 62 return nullptr; |
| 62 } | 63 } |
| 63 ctm = targetCTM.inverse() * ctm; | 64 ctm = targetCTM.inverse() * ctm; |
| 64 } | 65 } |
| 65 | 66 |
| 66 return SVGMatrixTearOff::create(ctm); | 67 return SVGMatrixTearOff::create(ctm); |
| 67 } | 68 } |
| 68 | 69 |
| 69 static AffineTransform computeCTM(SVGGraphicsElement* element, SVGElement::CTMSc
ope mode, SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy) | 70 static bool isViewportElement(const Element* element) |
| 70 { | 71 { |
| 71 ASSERT(element); | 72 return (element->hasTagName(SVGNames::svgTag) |
| 72 if (styleUpdateStrategy == SVGGraphicsElement::AllowStyleUpdate) | 73 || element->hasTagName(SVGNames::symbolTag) |
| 73 element->document().updateLayoutIgnorePendingStylesheets(); | 74 || element->hasTagName(SVGNames::foreignObjectTag) |
| 75 || element->hasTagName(SVGNames::imageTag)); |
| 76 } |
| 77 |
| 78 AffineTransform SVGGraphicsElement::computeCTM(SVGElement::CTMScope mode, |
| 79 SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy, const SVGGraphi
csElement* ancestor) const |
| 80 { |
| 81 if (styleUpdateStrategy == AllowStyleUpdate) |
| 82 document().updateLayoutIgnorePendingStylesheets(); |
| 74 | 83 |
| 75 AffineTransform ctm; | 84 AffineTransform ctm; |
| 85 bool done = false; |
| 76 | 86 |
| 77 SVGElement* stopAtElement = mode == SVGGraphicsElement::NearestViewportScope
? element->nearestViewportElement() : 0; | 87 for (const Element* currentElement = this; currentElement && !done; |
| 78 for (Element* currentElement = element; currentElement; currentElement = cur
rentElement->parentOrShadowHostElement()) { | 88 currentElement = currentElement->parentOrShadowHostElement()) { |
| 79 if (!currentElement->isSVGElement()) | 89 if (!currentElement->isSVGElement()) |
| 80 break; | 90 break; |
| 81 | 91 |
| 82 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode).
multiply(ctm); | 92 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode).
multiply(ctm); |
| 83 | 93 |
| 84 // For getCTM() computation, stop at the nearest viewport element | 94 switch (mode) { |
| 85 if (currentElement == stopAtElement) | 95 case NearestViewportScope: |
| 96 // Stop at the nearest viewport ancestor. |
| 97 done = currentElement != this && isViewportElement(currentElement); |
| 86 break; | 98 break; |
| 99 case AncestorScope: |
| 100 // Stop at the designated ancestor. |
| 101 done = currentElement == ancestor; |
| 102 break; |
| 103 default: |
| 104 ASSERT(mode == ScreenScope); |
| 105 break; |
| 106 } |
| 87 } | 107 } |
| 88 | 108 |
| 89 return ctm; | 109 return ctm; |
| 90 } | 110 } |
| 91 | 111 |
| 92 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate
gy) | 112 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate
gy) |
| 93 { | 113 { |
| 94 return computeCTM(this, NearestViewportScope, styleUpdateStrategy); | 114 return computeCTM(NearestViewportScope, styleUpdateStrategy); |
| 95 } | 115 } |
| 96 | 116 |
| 97 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate
Strategy) | 117 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate
Strategy) |
| 98 { | 118 { |
| 99 return computeCTM(this, ScreenScope, styleUpdateStrategy); | 119 return computeCTM(ScreenScope, styleUpdateStrategy); |
| 100 } | 120 } |
| 101 | 121 |
| 102 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript() | 122 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getCTMFromJavascript() |
| 103 { | 123 { |
| 104 return SVGMatrixTearOff::create(getCTM()); | 124 return SVGMatrixTearOff::create(getCTM()); |
| 105 } | 125 } |
| 106 | 126 |
| 107 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() | 127 PassRefPtr<SVGMatrixTearOff> SVGGraphicsElement::getScreenCTMFromJavascript() |
| 108 { | 128 { |
| 109 return SVGMatrixTearOff::create(getScreenCTM()); | 129 return SVGMatrixTearOff::create(getScreenCTM()); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 217 |
| 198 if (attrName == SVGNames::transformAttr) { | 218 if (attrName == SVGNames::transformAttr) { |
| 199 object->setNeedsTransformUpdate(); | 219 object->setNeedsTransformUpdate(); |
| 200 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); | 220 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); |
| 201 return; | 221 return; |
| 202 } | 222 } |
| 203 | 223 |
| 204 ASSERT_NOT_REACHED(); | 224 ASSERT_NOT_REACHED(); |
| 205 } | 225 } |
| 206 | 226 |
| 207 static bool isViewportElement(Node* node) | |
| 208 { | |
| 209 return (node->hasTagName(SVGNames::svgTag) | |
| 210 || node->hasTagName(SVGNames::symbolTag) | |
| 211 || node->hasTagName(SVGNames::foreignObjectTag) | |
| 212 || node->hasTagName(SVGNames::imageTag)); | |
| 213 } | |
| 214 | |
| 215 SVGElement* SVGGraphicsElement::nearestViewportElement() const | 227 SVGElement* SVGGraphicsElement::nearestViewportElement() const |
| 216 { | 228 { |
| 217 for (Element* current = parentOrShadowHostElement(); current; current = curr
ent->parentOrShadowHostElement()) { | 229 for (Element* current = parentOrShadowHostElement(); current; current = curr
ent->parentOrShadowHostElement()) { |
| 218 if (isViewportElement(current)) | 230 if (isViewportElement(current)) |
| 219 return toSVGElement(current); | 231 return toSVGElement(current); |
| 220 } | 232 } |
| 221 | 233 |
| 222 return 0; | 234 return 0; |
| 223 } | 235 } |
| 224 | 236 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 255 } | 267 } |
| 256 | 268 |
| 257 void SVGGraphicsElement::toClipPath(Path& path) | 269 void SVGGraphicsElement::toClipPath(Path& path) |
| 258 { | 270 { |
| 259 updatePathFromGraphicsElement(this, path); | 271 updatePathFromGraphicsElement(this, path); |
| 260 // FIXME: How do we know the element has done a layout? | 272 // FIXME: How do we know the element has done a layout? |
| 261 path.transform(animatedLocalTransform()); | 273 path.transform(animatedLocalTransform()); |
| 262 } | 274 } |
| 263 | 275 |
| 264 } | 276 } |
| OLD | NEW |