Chromium Code Reviews| 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 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, Document& d ocument, ConstructionType constructionType) | 43 SVGGraphicsElement::SVGGraphicsElement(const QualifiedName& tagName, Document& d ocument, ConstructionType constructionType) |
| 44 : SVGElement(tagName, document, constructionType) | 44 : SVGElement(tagName, document, constructionType) |
| 45 { | 45 { |
| 46 registerAnimatedPropertiesForSVGGraphicsElement(); | 46 registerAnimatedPropertiesForSVGGraphicsElement(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 SVGGraphicsElement::~SVGGraphicsElement() | 49 SVGGraphicsElement::~SVGGraphicsElement() |
| 50 { | 50 { |
| 51 } | 51 } |
| 52 | 52 |
| 53 AffineTransform SVGGraphicsElement::getTransformToElement(SVGElement* target, Ex ceptionState& es, SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy) | |
|
pdr.
2013/11/08 23:50:48
There's no need to specify "SVGGraphicsElement::St
rwlbuis
2013/11/10 20:35:45
Done.
| |
| 54 { | |
| 55 AffineTransform ctm = getCTM(styleUpdateStrategy); | |
| 56 | |
| 57 if (target && target->isSVGGraphicsElement()) { | |
| 58 AffineTransform targetCTM = toSVGGraphicsElement(target)->getCTM(styleUp dateStrategy); | |
| 59 if (!targetCTM.isInvertible()) { | |
| 60 es.throwUninformativeAndGenericDOMException(InvalidStateError); | |
| 61 return ctm; | |
| 62 } | |
| 63 ctm = targetCTM.inverse() * ctm; | |
| 64 } | |
| 65 | |
| 66 return ctm; | |
| 67 } | |
| 68 | |
| 69 static AffineTransform computeCTM(SVGElement* element, SVGElement::CTMScope mode , SVGGraphicsElement::StyleUpdateStrategy styleUpdateStrategy) | |
| 70 { | |
| 71 ASSERT(element); | |
| 72 if (styleUpdateStrategy == SVGGraphicsElement::AllowStyleUpdate) | |
| 73 element->document().updateLayoutIgnorePendingStylesheets(); | |
| 74 | |
| 75 AffineTransform ctm; | |
| 76 | |
| 77 SVGElement* stopAtElement = mode == SVGGraphicsElement::NearestViewportScope ? SVGGraphicsElement::nearestViewportElement(element) : 0; | |
| 78 for (Element* currentElement = element; currentElement; currentElement = cur rentElement->parentOrShadowHostElement()) { | |
| 79 if (!currentElement->isSVGElement()) | |
| 80 break; | |
| 81 | |
| 82 ctm = toSVGElement(currentElement)->localCoordinateSpaceTransform(mode). multiply(ctm); | |
| 83 | |
| 84 // For getCTM() computation, stop at the nearest viewport element | |
| 85 if (currentElement == stopAtElement) | |
| 86 break; | |
| 87 } | |
| 88 | |
| 89 return ctm; | |
| 90 } | |
| 91 | |
| 53 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate gy) | 92 AffineTransform SVGGraphicsElement::getCTM(StyleUpdateStrategy styleUpdateStrate gy) |
| 54 { | 93 { |
| 55 return SVGLocatable::computeCTM(this, SVGLocatable::NearestViewportScope, st yleUpdateStrategy); | 94 return computeCTM(this, NearestViewportScope, styleUpdateStrategy); |
| 56 } | 95 } |
| 57 | 96 |
| 58 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate Strategy) | 97 AffineTransform SVGGraphicsElement::getScreenCTM(StyleUpdateStrategy styleUpdate Strategy) |
| 59 { | 98 { |
| 60 return SVGLocatable::computeCTM(this, SVGLocatable::ScreenScope, styleUpdate Strategy); | 99 return computeCTM(this, ScreenScope, styleUpdateStrategy); |
| 61 } | 100 } |
| 62 | 101 |
| 63 AffineTransform SVGGraphicsElement::animatedLocalTransform() const | 102 AffineTransform SVGGraphicsElement::animatedLocalTransform() const |
| 64 { | 103 { |
| 65 AffineTransform matrix; | 104 AffineTransform matrix; |
| 66 RenderStyle* style = renderer() ? renderer()->style() : 0; | 105 RenderStyle* style = renderer() ? renderer()->style() : 0; |
| 67 | 106 |
| 68 // If CSS property was set, use that, otherwise fallback to attribute (if se t). | 107 // If CSS property was set, use that, otherwise fallback to attribute (if se t). |
| 69 if (style && style->hasTransform()) { | 108 if (style && style->hasTransform()) { |
| 70 // Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath. | 109 // Note: objectBoundingBox is an emptyRect for elements like pattern or clipPath. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 151 object->setNeedsTransformUpdate(); | 190 object->setNeedsTransformUpdate(); |
| 152 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); | 191 RenderSVGResource::markForLayoutAndParentResourceInvalidation(object); |
| 153 return; | 192 return; |
| 154 } | 193 } |
| 155 | 194 |
| 156 ASSERT_NOT_REACHED(); | 195 ASSERT_NOT_REACHED(); |
| 157 } | 196 } |
| 158 | 197 |
| 159 SVGElement* SVGGraphicsElement::nearestViewportElement() const | 198 SVGElement* SVGGraphicsElement::nearestViewportElement() const |
| 160 { | 199 { |
| 161 return SVGTransformable::nearestViewportElement(this); | 200 return nearestViewportElement(this); |
| 162 } | 201 } |
| 163 | 202 |
| 164 SVGElement* SVGGraphicsElement::farthestViewportElement() const | 203 SVGElement* SVGGraphicsElement::farthestViewportElement() const |
| 165 { | 204 { |
| 166 return SVGTransformable::farthestViewportElement(this); | 205 return farthestViewportElement(this); |
| 206 } | |
| 207 | |
| 208 static bool isViewportElement(Node* node) | |
| 209 { | |
| 210 return (node->hasTagName(SVGNames::svgTag) | |
| 211 || node->hasTagName(SVGNames::symbolTag) | |
| 212 || node->hasTagName(SVGNames::foreignObjectTag) | |
| 213 || node->hasTagName(SVGNames::imageTag)); | |
|
pdr.
2013/11/08 23:50:48
This was probably a latent bug. Images don't have
rwlbuis
2013/11/10 20:35:45
I am not sure, this list is stated here:
http://w
pdr.
2013/11/11 00:02:09
Ah, you are correct. It looks like viewports and v
| |
| 214 } | |
| 215 | |
| 216 SVGElement* SVGGraphicsElement::nearestViewportElement(const SVGElement* element ) | |
| 217 { | |
| 218 ASSERT(element); | |
| 219 for (Element* current = element->parentOrShadowHostElement(); current; curre nt = current->parentOrShadowHostElement()) { | |
| 220 if (isViewportElement(current)) | |
| 221 return toSVGElement(current); | |
| 222 } | |
| 223 | |
| 224 return 0; | |
| 225 } | |
| 226 | |
| 227 SVGElement* SVGGraphicsElement::farthestViewportElement(const SVGElement* elemen t) | |
| 228 { | |
| 229 ASSERT(element); | |
| 230 SVGElement* farthest = 0; | |
| 231 for (Element* current = element->parentOrShadowHostElement(); current; curre nt = current->parentOrShadowHostElement()) { | |
| 232 if (isViewportElement(current)) | |
| 233 farthest = toSVGElement(current); | |
| 234 } | |
| 235 return farthest; | |
| 167 } | 236 } |
| 168 | 237 |
| 169 SVGRect SVGGraphicsElement::getBBox() | 238 SVGRect SVGGraphicsElement::getBBox() |
| 170 { | 239 { |
| 171 document().updateLayoutIgnorePendingStylesheets(); | 240 document().updateLayoutIgnorePendingStylesheets(); |
| 172 | 241 |
| 173 // FIXME: Eventually we should support getBBox for detached elements. | 242 // FIXME: Eventually we should support getBBox for detached elements. |
| 174 if (!renderer()) | 243 if (!renderer()) |
| 175 return SVGRect(); | 244 return SVGRect(); |
| 176 | 245 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 195 } | 264 } |
| 196 | 265 |
| 197 void SVGGraphicsElement::toClipPath(Path& path) | 266 void SVGGraphicsElement::toClipPath(Path& path) |
| 198 { | 267 { |
| 199 updatePathFromGraphicsElement(this, path); | 268 updatePathFromGraphicsElement(this, path); |
| 200 // FIXME: How do we know the element has done a layout? | 269 // FIXME: How do we know the element has done a layout? |
| 201 path.transform(animatedLocalTransform()); | 270 path.transform(animatedLocalTransform()); |
| 202 } | 271 } |
| 203 | 272 |
| 204 } | 273 } |
| OLD | NEW |