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 |
82 void SVGForeignObjectElement::collectStyleForPresentationAttribute(const Qualifi edName& name, const AtomicString& value, MutableStylePropertySet* style) | 83 void SVGForeignObjectElement::collectStyleForPresentationAttribute(const Qualifi edName& name, const AtomicString& value, MutableStylePropertySet* style) |
83 { | 84 { |
84 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) { | 85 RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute (name); |
86 if (property == m_width || property == m_height) { | |
85 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther ); | 87 RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther ); |
86 TrackExceptionState exceptionState; | 88 TrackExceptionState exceptionState; |
87 length->setValueAsString(value, exceptionState); | 89 length->setValueAsString(value, exceptionState); |
88 if (!exceptionState.hadException()) { | 90 if (!exceptionState.hadException()) { |
89 if (name == SVGNames::widthAttr) | 91 if (property == m_width) |
fs
2015/02/04 13:24:53
Maybe we could split this part out and land separa
Erik Dahlström (inactive)
2015/02/05 16:09:02
That shouldn't be the case no, but we should allow
| |
90 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); | 92 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); |
91 else if (name == SVGNames::heightAttr) | 93 else if (property == m_height) |
92 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value); | 94 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight , value); |
93 } | 95 } |
96 } else if (property == m_x) { | |
97 addPropertyToPresentationAttributeStyle(style, CSSPropertyX, m_x->curren tValue()->valueInSpecifiedUnits(), m_x->currentValue()->cssUnitTypeQuirk()); | |
fs
2015/02/04 13:24:53
Maybe turn this "pattern" into:
void addSVGLength
Erik Dahlström (inactive)
2015/02/05 16:09:02
Done.
| |
98 } else if (property == m_y) { | |
99 addPropertyToPresentationAttributeStyle(style, CSSPropertyY, m_y->curren tValue()->valueInSpecifiedUnits(), m_y->currentValue()->cssUnitTypeQuirk()); | |
94 } else { | 100 } else { |
95 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); | 101 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, st yle); |
96 } | 102 } |
97 } | 103 } |
98 | 104 |
99 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) | 105 void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) |
100 { | 106 { |
101 if (!isSupportedAttribute(attrName)) { | 107 if (!isSupportedAttribute(attrName)) { |
102 SVGGraphicsElement::svgAttributeChanged(attrName); | 108 SVGGraphicsElement::svgAttributeChanged(attrName); |
103 return; | 109 return; |
104 } | 110 } |
105 | 111 |
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); | 112 SVGElement::InvalidationGuard invalidationGuard(this); |
112 | 113 |
114 bool widthOrHeight = attrName == SVGNames::widthAttr | |
fs
2015/02/04 13:24:53
Maybe do the something similar for 'x' and 'y' (an
| |
115 || attrName == SVGNames::heightAttr; | |
116 | |
117 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || widthOrHei ght) { | |
118 invalidateSVGPresentationAttributeStyle(); | |
119 setNeedsStyleRecalc(LocalStyleChange, | |
120 widthOrHeight ? StyleChangeReasonForTracing::create(StyleChangeReaso n::SVGContainerSizeChange) : StyleChangeReasonForTracing::fromAttribute(attrName )); | |
121 } | |
122 | |
113 bool isLengthAttribute = attrName == SVGNames::xAttr | 123 bool isLengthAttribute = attrName == SVGNames::xAttr |
114 || attrName == SVGNames::yAttr | 124 || attrName == SVGNames::yAttr |
115 || attrName == SVGNames::widthAttr | 125 || widthOrHeight; |
116 || attrName == SVGNames::heightAttr; | |
117 | 126 |
118 if (isLengthAttribute) { | 127 if (isLengthAttribute) { |
119 updateRelativeLengthsInformation(); | 128 updateRelativeLengthsInformation(); |
120 if (RenderObject* renderer = this->renderer()) | 129 if (RenderObject* renderer = this->renderer()) |
121 markForLayoutAndParentResourceInvalidation(renderer); | 130 markForLayoutAndParentResourceInvalidation(renderer); |
122 } | 131 } |
123 } | 132 } |
124 | 133 |
125 RenderObject* SVGForeignObjectElement::createRenderer(RenderStyle*) | 134 RenderObject* SVGForeignObjectElement::createRenderer(RenderStyle*) |
126 { | 135 { |
(...skipping 20 matching lines...) Expand all Loading... | |
147 | 156 |
148 bool SVGForeignObjectElement::selfHasRelativeLengths() const | 157 bool SVGForeignObjectElement::selfHasRelativeLengths() const |
149 { | 158 { |
150 return m_x->currentValue()->isRelative() | 159 return m_x->currentValue()->isRelative() |
151 || m_y->currentValue()->isRelative() | 160 || m_y->currentValue()->isRelative() |
152 || m_width->currentValue()->isRelative() | 161 || m_width->currentValue()->isRelative() |
153 || m_height->currentValue()->isRelative(); | 162 || m_height->currentValue()->isRelative(); |
154 } | 163 } |
155 | 164 |
156 } // namespace blink | 165 } // namespace blink |
OLD | NEW |