Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1654)

Unified Diff: Source/core/svg/SVGForeignObjectElement.cpp

Issue 896773002: [svg2] Make 'x' and 'y' presentation attributes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/svg/SVGForeignObjectElement.h ('k') | Source/core/svg/SVGImageElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/svg/SVGForeignObjectElement.cpp
diff --git a/Source/core/svg/SVGForeignObjectElement.cpp b/Source/core/svg/SVGForeignObjectElement.cpp
index 58ae096d07ea5e6f9c80a2383c4ef7977f71d8ec..a549ff8327d17e5dc0e13b08801148a210d6f8cc 100644
--- a/Source/core/svg/SVGForeignObjectElement.cpp
+++ b/Source/core/svg/SVGForeignObjectElement.cpp
@@ -74,23 +74,37 @@ 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);
}
+bool SVGForeignObjectElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attrName) const
+{
+ if (attrName == SVGNames::xAttr || attrName== SVGNames::yAttr
+ || attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr)
+ return true;
+ return SVGGraphicsElement::isPresentationAttributeWithSVGDOM(attrName);
+}
+
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)
addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);
- else if (name == SVGNames::heightAttr)
+ else if (property == m_height)
addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value);
}
+ } else if (property == m_x) {
+ addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyX, *m_x->currentValue());
+ } else if (property == m_y) {
+ addSVGLengthPropertyToPresentationAttributeStyle(style, CSSPropertyY, *m_y->currentValue());
} else {
SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, style);
}
@@ -103,19 +117,17 @@ void SVGForeignObjectElement::svgAttributeChanged(const QualifiedName& attrName)
return;
}
- if (attrName == SVGNames::widthAttr || attrName == SVGNames::heightAttr) {
- invalidateSVGPresentationAttributeStyle();
- setNeedsStyleRecalc(LocalStyleChange, StyleChangeReasonForTracing::create(StyleChangeReason::SVGContainerSizeChange));
- }
-
SVGElement::InvalidationGuard invalidationGuard(this);
- bool isLengthAttribute = attrName == SVGNames::xAttr
- || attrName == SVGNames::yAttr
- || attrName == SVGNames::widthAttr
- || attrName == SVGNames::heightAttr;
+ bool isWidthHeightAttribute = attrName == SVGNames::widthAttr
+ || attrName == SVGNames::heightAttr;
+ bool isXYAttribute = attrName == SVGNames::xAttr || attrName == SVGNames::yAttr;
+
+ if (isXYAttribute || isWidthHeightAttribute) {
+ invalidateSVGPresentationAttributeStyle();
+ setNeedsStyleRecalc(LocalStyleChange,
+ isWidthHeightAttribute ? StyleChangeReasonForTracing::create(StyleChangeReason::SVGContainerSizeChange) : StyleChangeReasonForTracing::fromAttribute(attrName));
- if (isLengthAttribute) {
updateRelativeLengthsInformation();
if (LayoutObject* renderer = this->renderer())
markForLayoutAndParentResourceInvalidation(renderer);
« no previous file with comments | « Source/core/svg/SVGForeignObjectElement.h ('k') | Source/core/svg/SVGImageElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698