OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> | 2 * Copyright (C) 2004, 2005, 2007 Nikolas Zimmermann <zimmermann@kde.org> |
3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@kde.org> | 3 * Copyright (C) 2004, 2005, 2007 Rob Buis <buis@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. | 5 * Copyright (C) 2009 Google, Inc. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 SVGElement* element = this->element(); | 60 SVGElement* element = this->element(); |
61 ASSERT(element); | 61 ASSERT(element); |
62 if (!isSVGSVGElement(*element)) | 62 if (!isSVGSVGElement(*element)) |
63 return; | 63 return; |
64 SVGSVGElement* svg = toSVGSVGElement(element); | 64 SVGSVGElement* svg = toSVGSVGElement(element); |
65 FloatRect oldViewport = m_viewport; | 65 FloatRect oldViewport = m_viewport; |
66 | 66 |
67 SVGLengthContext lengthContext(element); | 67 SVGLengthContext lengthContext(element); |
68 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg->
y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l
engthContext), svg->height()->currentValue()->value(lengthContext)); | 68 m_viewport = FloatRect(svg->x()->currentValue()->value(lengthContext), svg->
y()->currentValue()->value(lengthContext), svg->width()->currentValue()->value(l
engthContext), svg->height()->currentValue()->value(lengthContext)); |
69 | 69 |
70 SVGElement* correspondingElement = svg->correspondingElement(); | |
71 if (correspondingElement && svg->isInShadowTree()) { | |
72 const HashSet<SVGElementInstance*>& instances = correspondingElement->in
stancesForElement(); | |
73 ASSERT(!instances.isEmpty()); | |
74 | |
75 SVGUseElement* useElement = 0; | |
76 const HashSet<SVGElementInstance*>::const_iterator end = instances.end()
; | |
77 for (HashSet<SVGElementInstance*>::const_iterator it = instances.begin()
; it != end; ++it) { | |
78 const SVGElementInstance* instance = (*it); | |
79 ASSERT(isSVGSVGElement(instance->correspondingElement()) || isSVGSym
bolElement(instance->correspondingElement())); | |
80 if (instance->shadowTreeElement() == svg) { | |
81 ASSERT(correspondingElement == instance->correspondingElement())
; | |
82 useElement = instance->directUseElement(); | |
83 if (!useElement) | |
84 useElement = instance->correspondingUseElement(); | |
85 break; | |
86 } | |
87 } | |
88 | |
89 ASSERT(useElement); | |
90 bool isSymbolElement = isSVGSymbolElement(*correspondingElement); | |
91 | |
92 // Spec (<use> on <symbol>): This generated 'svg' will always have expli
cit values for attributes width and height. | |
93 // If attributes width and/or height are provided on the 'use' element,
then these attributes | |
94 // will be transferred to the generated 'svg'. If attributes width and/o
r height are not specified, | |
95 // the generated 'svg' element will use values of 100% for these attribu
tes. | |
96 | |
97 // Spec (<use> on <svg>): If attributes width and/or height are provided
on the 'use' element, then these | |
98 // values will override the corresponding attributes on the 'svg' in the
generated tree. | |
99 | |
100 SVGLengthContext lengthContext(element); | |
101 if (useElement->hasAttribute(SVGNames::widthAttr)) | |
102 m_viewport.setWidth(useElement->width()->currentValue()->value(lengt
hContext)); | |
103 else if (isSymbolElement && svg->hasAttribute(SVGNames::widthAttr)) { | |
104 RefPtr<SVGLength> containerWidth = SVGLength::create(LengthModeWidth
); | |
105 containerWidth->setValueAsString("100%", ASSERT_NO_EXCEPTION); | |
106 m_viewport.setWidth(containerWidth->value(lengthContext)); | |
107 } | |
108 | |
109 if (useElement->hasAttribute(SVGNames::heightAttr)) | |
110 m_viewport.setHeight(useElement->height()->currentValue()->value(len
gthContext)); | |
111 else if (isSymbolElement && svg->hasAttribute(SVGNames::heightAttr)) { | |
112 RefPtr<SVGLength> containerHeight = SVGLength::create(LengthModeHeig
ht); | |
113 containerHeight->setValueAsString("100%", ASSERT_NO_EXCEPTION); | |
114 m_viewport.setHeight(containerHeight->value(lengthContext)); | |
115 } | |
116 } | |
117 | |
118 if (oldViewport != m_viewport) { | 70 if (oldViewport != m_viewport) { |
119 setNeedsBoundariesUpdate(); | 71 setNeedsBoundariesUpdate(); |
120 setNeedsTransformUpdate(); | 72 setNeedsTransformUpdate(); |
121 } | 73 } |
122 } | 74 } |
123 | 75 |
124 bool RenderSVGViewportContainer::calculateLocalTransform() | 76 bool RenderSVGViewportContainer::calculateLocalTransform() |
125 { | 77 { |
126 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGRenderSupport::tra
nsformToRootChanged(parent()); | 78 m_didTransformToRootUpdate = m_needsTransformUpdate || SVGRenderSupport::tra
nsformToRootChanged(parent()); |
127 if (!m_needsTransformUpdate) | 79 if (!m_needsTransformUpdate) |
(...skipping 28 matching lines...) Expand all Loading... |
156 { | 108 { |
157 ASSERT(element()); | 109 ASSERT(element()); |
158 // An empty viewBox disables rendering. | 110 // An empty viewBox disables rendering. |
159 if (isSVGSVGElement(*element()) && toSVGSVGElement(*element()).hasEmptyViewB
ox()) | 111 if (isSVGSVGElement(*element()) && toSVGSVGElement(*element()).hasEmptyViewB
ox()) |
160 return; | 112 return; |
161 | 113 |
162 RenderSVGContainer::paint(paintInfo, paintOffset); | 114 RenderSVGContainer::paint(paintInfo, paintOffset); |
163 } | 115 } |
164 | 116 |
165 } | 117 } |
OLD | NEW |