Chromium Code Reviews| Index: Source/core/svg/SVGForeignObjectElement.cpp |
| diff --git a/Source/core/svg/SVGForeignObjectElement.cpp b/Source/core/svg/SVGForeignObjectElement.cpp |
| index 04d74d6ab08f7816dd0e8d8365bf61c6d1d29288..43218aed980b83d60cdf0bb0baa7ff59ca711229 100644 |
| --- a/Source/core/svg/SVGForeignObjectElement.cpp |
| +++ b/Source/core/svg/SVGForeignObjectElement.cpp |
| @@ -74,23 +74,29 @@ void SVGForeignObjectElement::parseAttribute(const QualifiedName& name, const At |
| bool SVGForeignObjectElement::isPresentationAttribute(const QualifiedName& name) const |
| { |
| - if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) |
| + if (name == SVGNames::xAttr || name == SVGNames::yAttr |
| + || name == SVGNames::widthAttr || name == SVGNames::heightAttr) |
| return true; |
| return SVGGraphicsElement::isPresentationAttribute(name); |
| } |
| void SVGForeignObjectElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStylePropertySet* style) |
| { |
| - if (name == SVGNames::widthAttr || name == SVGNames::heightAttr) { |
| + RefPtrWillBeRawPtr<SVGAnimatedPropertyBase> property = propertyFromAttribute(name); |
| + if (property == m_width || property == m_height) { |
| RefPtrWillBeRawPtr<SVGLength> length = SVGLength::create(LengthModeOther); |
| TrackExceptionState exceptionState; |
| length->setValueAsString(value, exceptionState); |
| if (!exceptionState.hadException()) { |
| - if (name == SVGNames::widthAttr) |
| + 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
|
| addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value); |
| - else if (name == SVGNames::heightAttr) |
| + else if (property == m_height) |
| addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value); |
| } |
| + } else if (property == m_x) { |
| + addPropertyToPresentationAttributeStyle(style, CSSPropertyX, m_x->currentValue()->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.
|
| + } else if (property == m_y) { |
| + addPropertyToPresentationAttributeStyle(style, CSSPropertyY, m_y->currentValue()->valueInSpecifiedUnits(), m_y->currentValue()->cssUnitTypeQuirk()); |
| } else { |
| SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, style); |
| } |
| @@ -103,17 +109,20 @@ void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName) |
| return; |
| } |
| - if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) { |
| + SVGElement::InvalidationGuard invalidationGuard(this); |
| + |
| + bool widthOrHeight = attrName == SVGNames::widthAttr |
|
fs
2015/02/04 13:24:53
Maybe do the something similar for 'x' and 'y' (an
|
| + || attrName == SVGNames::heightAttr; |
| + |
| + if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr || widthOrHeight) { |
| invalidateSVGPresentationAttributeStyle(); |
| - setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SVGContainerSizeChange)); |
| + setNeedsStyleRecalc(LocalStyleChange, |
| + widthOrHeight ? StyleChangeReasonForTracing::create(StyleChangeReason::SVGContainerSizeChange) : StyleChangeReasonForTracing::fromAttribute(attrName)); |
| } |
| - SVGElement::InvalidationGuard invalidationGuard(this); |
| - |
| bool isLengthAttribute = attrName == SVGNames::xAttr |
| - || attrName == SVGNames::yAttr |
| - || attrName == SVGNames::widthAttr |
| - || attrName == SVGNames::heightAttr; |
| + || attrName == SVGNames::yAttr |
| + || widthOrHeight; |
| if (isLengthAttribute) { |
| updateRelativeLengthsInformation(); |