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 * Copyright (C) 2014 Google, Inc. |
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 SVGTests::Trace(visitor); | 50 SVGTests::Trace(visitor); |
51 } | 51 } |
52 | 52 |
53 static bool IsViewportElement(const Element& element) { | 53 static bool IsViewportElement(const Element& element) { |
54 return (isSVGSVGElement(element) || isSVGSymbolElement(element) || | 54 return (isSVGSVGElement(element) || isSVGSymbolElement(element) || |
55 isSVGForeignObjectElement(element) || isSVGImageElement(element)); | 55 isSVGForeignObjectElement(element) || isSVGImageElement(element)); |
56 } | 56 } |
57 | 57 |
58 AffineTransform SVGGraphicsElement::ComputeCTM( | 58 AffineTransform SVGGraphicsElement::ComputeCTM( |
59 SVGElement::CTMScope mode, | 59 SVGElement::CTMScope mode, |
60 SVGGraphicsElement::StyleUpdateStrategy style_update_strategy, | |
61 const SVGGraphicsElement* ancestor) const { | 60 const SVGGraphicsElement* ancestor) const { |
62 if (style_update_strategy == kAllowStyleUpdate) | |
63 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheets(); | |
64 | |
65 AffineTransform ctm; | 61 AffineTransform ctm; |
66 bool done = false; | 62 bool done = false; |
67 | 63 |
68 for (const Element* current_element = this; current_element && !done; | 64 for (const Element* current_element = this; current_element && !done; |
69 current_element = current_element->ParentOrShadowHostElement()) { | 65 current_element = current_element->ParentOrShadowHostElement()) { |
70 if (!current_element->IsSVGElement()) | 66 if (!current_element->IsSVGElement()) |
71 break; | 67 break; |
72 | 68 |
73 ctm = ToSVGElement(current_element) | 69 ctm = ToSVGElement(current_element) |
74 ->LocalCoordinateSpaceTransform(mode) | 70 ->LocalCoordinateSpaceTransform(mode) |
75 .Multiply(ctm); | 71 .Multiply(ctm); |
76 | 72 |
77 switch (mode) { | 73 switch (mode) { |
78 case kNearestViewportScope: | 74 case kNearestViewportScope: |
79 // Stop at the nearest viewport ancestor. | 75 // Stop at the nearest viewport ancestor. |
80 done = current_element != this && IsViewportElement(*current_element); | 76 done = current_element != this && IsViewportElement(*current_element); |
81 break; | 77 break; |
82 case kAncestorScope: | 78 case kAncestorScope: |
83 // Stop at the designated ancestor. | 79 // Stop at the designated ancestor. |
84 done = current_element == ancestor; | 80 done = current_element == ancestor; |
85 break; | 81 break; |
86 default: | 82 default: |
87 DCHECK_EQ(mode, kScreenScope); | 83 DCHECK_EQ(mode, kScreenScope); |
88 break; | 84 break; |
89 } | 85 } |
90 } | 86 } |
91 | |
92 return ctm; | 87 return ctm; |
93 } | 88 } |
94 | 89 |
95 AffineTransform SVGGraphicsElement::GetCTM( | 90 SVGMatrixTearOff* SVGGraphicsElement::getCTM() { |
96 StyleUpdateStrategy style_update_strategy) { | 91 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
97 return ComputeCTM(kNearestViewportScope, style_update_strategy); | 92 |
| 93 return SVGMatrixTearOff::Create(ComputeCTM(kNearestViewportScope)); |
98 } | 94 } |
99 | 95 |
100 AffineTransform SVGGraphicsElement::GetScreenCTM( | 96 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTM() { |
101 StyleUpdateStrategy style_update_strategy) { | 97 GetDocument().UpdateStyleAndLayoutIgnorePendingStylesheetsForNode(this); |
102 return ComputeCTM(kScreenScope, style_update_strategy); | |
103 } | |
104 | 98 |
105 SVGMatrixTearOff* SVGGraphicsElement::getCTMFromJavascript() { | 99 return SVGMatrixTearOff::Create(ComputeCTM(kScreenScope)); |
106 return SVGMatrixTearOff::Create(GetCTM()); | |
107 } | |
108 | |
109 SVGMatrixTearOff* SVGGraphicsElement::getScreenCTMFromJavascript() { | |
110 return SVGMatrixTearOff::Create(GetScreenCTM()); | |
111 } | 100 } |
112 | 101 |
113 void SVGGraphicsElement::CollectStyleForPresentationAttribute( | 102 void SVGGraphicsElement::CollectStyleForPresentationAttribute( |
114 const QualifiedName& name, | 103 const QualifiedName& name, |
115 const AtomicString& value, | 104 const AtomicString& value, |
116 MutableStylePropertySet* style) { | 105 MutableStylePropertySet* style) { |
117 if (name == SVGNames::transformAttr) { | 106 if (name == SVGNames::transformAttr) { |
118 AddPropertyToPresentationAttributeStyle( | 107 AddPropertyToPresentationAttributeStyle( |
119 style, CSSPropertyTransform, transform_->CurrentValue()->CssValue()); | 108 style, CSSPropertyTransform, transform_->CurrentValue()->CssValue()); |
120 return; | 109 return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 170 |
182 return GetLayoutObject()->ObjectBoundingBox(); | 171 return GetLayoutObject()->ObjectBoundingBox(); |
183 } | 172 } |
184 | 173 |
185 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { | 174 SVGRectTearOff* SVGGraphicsElement::getBBoxFromJavascript() { |
186 return SVGRectTearOff::Create(SVGRect::Create(GetBBox()), 0, | 175 return SVGRectTearOff::Create(SVGRect::Create(GetBBox()), 0, |
187 kPropertyIsNotAnimVal); | 176 kPropertyIsNotAnimVal); |
188 } | 177 } |
189 | 178 |
190 } // namespace blink | 179 } // namespace blink |
OLD | NEW |