OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Inc. All rights reserved. |
3 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> | 3 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); | 67 return supportedAttributes.contains<SVGAttributeHashTranslator>(attrName); |
68 } | 68 } |
69 | 69 |
70 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At
omicString& value) | 70 void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At
omicString& value) |
71 { | 71 { |
72 parseAttributeNew(name, value); | 72 parseAttributeNew(name, value); |
73 } | 73 } |
74 | 74 |
75 bool SVGForeignObjectElement::isPresentationAttribute(const QualifiedName& name)
const | 75 bool SVGForeignObjectElement::isPresentationAttribute(const QualifiedName& name)
const |
76 { | 76 { |
77 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) | 77 if (name == SVGNames::xAttr || name == SVGNames::yAttr |
| 78 || name == SVGNames::widthAttr || name == SVGNames::heightAttr) |
78 return true; | 79 return true; |
79 return SVGGraphicsElement::isPresentationAttribute(name); | 80 return SVGGraphicsElement::isPresentationAttribute(name); |
80 } | 81 } |
81 | 82 |
| 83 bool SVGForeignObjectElement::isPresentationAttributeWithSVGDOM(const QualifiedN
ame& attrName) const |
| 84 { |
| 85 if (attrName == SVGNames::xAttr || attrName== SVGNames::yAttr |
| 86 || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) |
| 87 return true; |
| 88 return SVGGraphicsElement::isPresentationAttributeWithSVGDOM(attrName); |
| 89 } |
| 90 |
82 void SVGForeignObjectElement::collectStyleForPresentationAttribute(const Qualifi
edName& name, const AtomicString& value, MutableStylePropertySet* style) | 91 void SVGForeignObjectElement::collectStyleForPresentationAttribute(const Qualifi
edName& name, const AtomicString& value, MutableStylePropertySet* style) |
83 { | 92 { |
84 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) { | 93 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute
(name); |
| 94 if (property == m_width || property == m_height) { |
85 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther
); | 95 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther
); |
86 TrackExceptionState exceptionState; | 96 TrackExceptionState exceptionState; |
87 length->setValueAsString(value, exceptionState); | 97 length->setValueAsString(value, exceptionState); |
88 if (!exceptionState.hadException()) { | 98 if (!exceptionState.hadException()) { |
89 if (name == SVGNames::widthAttr) | 99 if (property == m_width) |
90 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth,
value); | 100 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth,
value); |
91 else if (name == SVGNames::heightAttr) | 101 else if (property == m_height) |
92 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight
, value); | 102 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight
, value); |
93 } | 103 } |
| 104 } else if (property == m_x) { |
| 105 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m
_x->currentValue()); |
| 106 } else if (property == m_y) { |
| 107 addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m
_y->currentValue()); |
94 } else { | 108 } else { |
95 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st
yle); | 109 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st
yle); |
96 } | 110 } |
97 } | 111 } |
98 | 112 |
99 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) | 113 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) |
100 { | 114 { |
101 if (!isSupportedAttribute(attrName)) { | 115 if (!isSupportedAttribute(attrName)) { |
102 SVGGraphicsElement::svgAttributeChanged(attrName); | 116 SVGGraphicsElement::svgAttributeChanged(attrName); |
103 return; | 117 return; |
104 } | 118 } |
105 | 119 |
106 if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) { | |
107 invalidateSVGPresentationAttributeStyle(); | |
108 setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::creat
e(StyleChangeReason::SVGContainerSizeChange)); | |
109 } | |
110 | |
111 SVGElement::InvalidationGuard invalidationGuard(this); | 120 SVGElement::InvalidationGuard invalidationGuard(this); |
112 | 121 |
113 bool isLengthAttribute = attrName == SVGNames::xAttr | 122 bool isWidthHeightAttribute = attrName == SVGNames::widthAttr |
114 || attrName == SVGNames::yAttr | 123 || attrName == SVGNames::heightAttr; |
115 || attrName == SVGNames::widthAttr | 124 bool isXYAttribute = attrName == SVGNames::xAttr || attrName == SVGNames::yA
ttr; |
116 || attrName == SVGNames::heightAttr; | |
117 | 125 |
118 if (isLengthAttribute) { | 126 if (isXYAttribute || isWidthHeightAttribute) { |
| 127 invalidateSVGPresentationAttributeStyle(); |
| 128 setNeedsStyleRecalc(LocalStyleChange, |
| 129 isWidthHeightAttribute ? StyleChangeReasonForTracing::create(StyleCh
angeReason::SVGContainerSizeChange) : StyleChangeReasonForTracing::fromAttribute
(attrName)); |
| 130 |
119 updateRelativeLengthsInformation(); | 131 updateRelativeLengthsInformation(); |
120 if (LayoutObject* renderer = this->renderer()) | 132 if (LayoutObject* renderer = this->renderer()) |
121 markForLayoutAndParentResourceInvalidation(renderer); | 133 markForLayoutAndParentResourceInvalidation(renderer); |
122 } | 134 } |
123 } | 135 } |
124 | 136 |
125 LayoutObject* SVGForeignObjectElement::createRenderer(const RenderStyle&) | 137 LayoutObject* SVGForeignObjectElement::createRenderer(const RenderStyle&) |
126 { | 138 { |
127 return new RenderSVGForeignObject(this); | 139 return new RenderSVGForeignObject(this); |
128 } | 140 } |
(...skipping 18 matching lines...) Expand all Loading... |
147 | 159 |
148 bool SVGForeignObjectElement::selfHasRelativeLengths() const | 160 bool SVGForeignObjectElement::selfHasRelativeLengths() const |
149 { | 161 { |
150 return m_x->currentValue()->isRelative() | 162 return m_x->currentValue()->isRelative() |
151 || m_y->currentValue()->isRelative() | 163 || m_y->currentValue()->isRelative() |
152 || m_width->currentValue()->isRelative() | 164 || m_width->currentValue()->isRelative() |
153 || m_height->currentValue()->isRelative(); | 165 || m_height->currentValue()->isRelative(); |
154 } | 166 } |
155 | 167 |
156 } // namespace blink | 168 } // namespace blink |
OLD | NEW |