Changeset 171341 in webkit
- Timestamp:
- Jul 22, 2014 6:27:38 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 6 added
- 39 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r171323 r171341 1 2014-07-18 Dirk Schulze <krit@webkit.org> 2 3 Turn width/height to presentation attributes 4 https://bugs.webkit.org/show_bug.cgi?id=135046 5 6 Reviewed by Dean Jackson. 7 8 We already had a lot of tests for animating width/height as property. 9 So far they assumed that this is not possible. They simply needed to 10 be updated. 11 12 Furthermore, I added reference tests to test different inheritance 13 scenarios of CSS properties and setting them to elements. 14 15 A parsing test makes sure that the global property values inherit is 16 supported as well as CSS parsing rules for SVG attributes. 17 Negative tests test not-allowed behavior. 18 19 * platform/mac/svg/W3C-SVG-1.1/coords-units-03-b-expected.txt: 20 * svg/animations/attributeTypes-expected.txt: 21 * svg/animations/resources/attributeTypes.svg: 22 * svg/animations/script-tests/attributeTypes.js: 23 (sample1): 24 (sample2): 25 (sample3): 26 * svg/css/getComputedStyle-basic-expected.txt: 27 * svg/css/parse-height-expected.txt: Added. 28 * svg/css/parse-height.html: Added. 29 * svg/css/parse-width-expected.txt: Added. 30 * svg/css/parse-width.html: Added. 31 * svg/css/width-height-presentation-attribute-expected.svg: Added. 32 * svg/css/width-height-presentation-attribute.svg: Added. 33 * svg/custom/mask-excessive-malloc-expected.txt: 34 * svg/hixie/error/015-expected.txt: 35 1 36 2014-07-21 Diego Pino Garcia <dpino@igalia.com> 2 37 -
trunk/LayoutTests/platform/mac/svg/W3C-SVG-1.1/coords-units-03-b-expected.txt
r161884 r171341 39 39 RenderSVGInlineText {#text} at (0,0) size 158x15 40 40 chunk 1 text run 1 at (230.00,80.00) startOffset 0 endOffset 30 width 158.00: "Relative to font x-height (ex)" 41 RenderSVGContainer {g} at (20,140) size 200x142 RenderSVGRect {rect} at (20,140) size 200x1 [fill={[type=SOLID] [color=#000000]}] [x=20.00] [y=80.00] [width=200.00] [height=1.00]41 RenderSVGContainer {g} at (20,140) size 180x1 42 RenderSVGRect {rect} at (20,140) size 180x1 [fill={[type=SOLID] [color=#000000]}] [x=20.00] [y=80.00] [width=200.00] [height=1.00] 43 43 RenderSVGText {text} at (20,86) size 93x16 contains 1 chunk(s) 44 44 RenderSVGInlineText {#text} at (0,0) size 93x15 -
trunk/LayoutTests/platform/mac/svg/zoom/page/zoom-foreignObject-expected.txt
r168350 r171341 17 17 RenderSVGRect {rect} at (0,0) size 361x289 [stroke={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=250.00] [height=200.00] 18 18 RenderSVGForeignObject {foreignObject} at (260,0) size 250x200 19 RenderSVGRoot {svg} at (260,5) size 250x1 4520 RenderSVGContainer {g} at (260,5) size 250x1 45 [transform={m=((3.00,0.26)(0.26,3.02)) t=(0.00,0.00)}]19 RenderSVGRoot {svg} at (260,5) size 250x195 20 RenderSVGContainer {g} at (260,5) size 250x195 [transform={m=((3.00,0.26)(0.26,3.02)) t=(0.00,0.00)}] 21 21 RenderSVGText {text} at (0,1) size 82x19 contains 1 chunk(s) 22 22 RenderSVGInlineText {#text} at (0,0) size 82x19 -
trunk/LayoutTests/svg/animations/attributeTypes-expected.txt
r110574 r171341 12 12 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 13 13 PASS color.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 14 PASS rect2.width.animVal.value is 10 015 PASS rect2.width.baseVal.value is 10 014 PASS rect2.width.animVal.value is 10 15 PASS rect2.width.baseVal.value is 10 16 16 PASS color.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 17 17 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 … … 34 34 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 35 35 PASS color.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 36 PASS rect2.width.animVal.value is 10037 PASS rect2.width.baseVal.value is 10 036 PASS rect2.width.animVal.value is 55 37 PASS rect2.width.baseVal.value is 10 38 38 PASS color.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 39 39 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 … … 57 57 PASS color.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 58 58 PASS rect2.width.animVal.value is 100 59 PASS rect2.width.baseVal.value is 10 059 PASS rect2.width.baseVal.value is 10 60 60 PASS color.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 61 61 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 … … 79 79 PASS color.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 80 80 PASS rect2.width.animVal.value is 100 81 PASS rect2.width.baseVal.value is 10 081 PASS rect2.width.baseVal.value is 10 82 82 PASS color.red.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 83 83 PASS color.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 128 -
trunk/LayoutTests/svg/animations/resources/attributeTypes.svg
r109679 r171341 9 9 10 10 <!-- 'width' is a XML attribute, attributeType is set to "CSS". 'width' is not a presentation attribute, so this animation won't run. --> 11 <rect x="150" width="10 0" height="100" fill="green">12 <animate id="an2" attributeType="CSS" attributeName="width" fill="freeze" from="10 0" to="10" begin="0s" dur="4s"/>11 <rect x="150" width="10" height="100" fill="green"> 12 <animate id="an2" attributeType="CSS" attributeName="width" fill="freeze" from="10" to="100" begin="0s" dur="4s"/> 13 13 </rect> 14 14 -
trunk/LayoutTests/svg/animations/script-tests/attributeTypes.js
r110574 r171341 8 8 expectFillColor(rect1, 0, 128, 0); 9 9 10 shouldBe ("rect2.width.animVal.value", "100");11 shouldBe("rect2.width.baseVal.value", "10 0");10 shouldBeCloseEnough("rect2.width.animVal.value", "10"); 11 shouldBe("rect2.width.baseVal.value", "10"); 12 12 expectFillColor(rect2, 0, 128, 0); 13 13 … … 28 28 expectFillColor(rect1, 0, 128, 0); 29 29 30 shouldBe ("rect2.width.animVal.value", "100");31 shouldBe("rect2.width.baseVal.value", "10 0");30 shouldBeCloseEnough("rect2.width.animVal.value", "55"); 31 shouldBe("rect2.width.baseVal.value", "10"); 32 32 expectFillColor(rect2, 0, 128, 0); 33 33 … … 48 48 expectFillColor(rect1, 0, 128, 0); 49 49 50 shouldBe ("rect2.width.animVal.value", "100");51 shouldBe("rect2.width.baseVal.value", "10 0");50 shouldBeCloseEnough("rect2.width.animVal.value", "100"); 51 shouldBe("rect2.width.baseVal.value", "10"); 52 52 expectFillColor(rect2, 0, 128, 0); 53 53 -
trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
r170996 r171341 91 91 rect: style.getPropertyValue(font-weight) : normal 92 92 rect: style.getPropertyCSSValue(font-weight) : [object CSSPrimitiveValue] 93 rect: style.getPropertyValue(height) : auto93 rect: style.getPropertyValue(height) : 100px 94 94 rect: style.getPropertyCSSValue(height) : [object CSSPrimitiveValue] 95 95 rect: style.getPropertyValue(image-rendering) : auto … … 191 191 rect: style.getPropertyValue(widows) : auto 192 192 rect: style.getPropertyCSSValue(widows) : [object CSSPrimitiveValue] 193 rect: style.getPropertyValue(width) : auto193 rect: style.getPropertyValue(width) : 100px 194 194 rect: style.getPropertyCSSValue(width) : [object CSSPrimitiveValue] 195 195 rect: style.getPropertyValue(word-break) : normal -
trunk/LayoutTests/svg/custom/mask-excessive-malloc-expected.txt
r149088 r171341 6 6 RenderSVGRect {rect} at (0,0) size 800x600 [fill={[type=SOLID] [color=#FFFFFF]}] [x=0.00] [y=0.00] [width=2147483648.00] [height=2147483648.00] 7 7 RenderSVGPath {path} at (200,200) size 100x200 [fill={[type=SOLID] [color=#0000FF]}] [data="M 200 200 L 300 200 L 300 400 L 200 400 Z"] 8 [masker="mask"] RenderSVGResourceMasker {mask} at (190,180) size 2147483520x21474835208 [masker="mask"] RenderSVGResourceMasker {mask} at (190,180) size 33554238x33554248 -
trunk/LayoutTests/svg/hixie/error/015-expected.txt
r149088 r171341 5 5 RenderSVGRoot {svg} at (0,0) size 300x200 6 6 RenderSVGRect {rect} at (0,0) size 300x200 [fill={[type=SOLID] [color=#008000]}] [x=0.00] [y=0.00] [width=300.00] [height=200.00] 7 RenderSVGRect {rect} at (0,0) size 0x0 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=0.00] [height=200.00]7 RenderSVGRect {rect} at (0,0) size 300x200 [fill={[type=SOLID] [color=#FF0000]}] [x=0.00] [y=0.00] [width=0.00] [height=200.00] -
trunk/Source/WebCore/ChangeLog
r171339 r171341 1 2014-07-18 Dirk Schulze <krit@webkit.org> 2 3 Turn width/height to presentation attributes 4 https://bugs.webkit.org/show_bug.cgi?id=135046 5 6 Reviewed by Dean Jackson. 7 8 The elements <svg>, <image>, <pattern>, <mask> and <foreignObject> have the 9 'width' and 'height' attributes. So far they can just be set by SVG DOM or 10 setAttribute. Furthermore, animations just work with SVG Animation - No support 11 for CSS Animations and CSS Transitions. We started to turn the width and height 12 attributes on SVG roots to presentation attributes already. A presentation 13 attribute is a CSS property that can also be set by DOM (or now by SVG DOM). 14 15 This patch turns all width and height attributes to presentation attributes. It 16 basically allows authors to style width and height with CSS as well. Width and 17 height can now be set with CSS style sheets and can be animated with CSS. 18 19 To some degree it made it possible to remove code duplication. However, since 20 SVG DOM requires us to use SVGLength types and since we did not turn all 21 SVG attributes to the CSS length values (and our internal Length struct) yet, 22 we still need a hybrid - a bridge between SVGLength (for SVG DOM) and Length (for 23 RenderStyle). Once we move all attributes to use the Length struct, we can make SVGLength 24 a wrapper for Length and can move more code to the render tree. 25 26 The current challenge is to synchronize SVG DOM, normal DOM and RenderStyle. 27 With this patch we handle most part in RenderStyle. SVG DOM changes are 28 synchronized to DOM and RenderStyle will call needsStyleRecalc. Furthermore, 29 SVG Animations will continue to animate the SVG DOM (and synchronize the changes 30 back to RenderStyle) if the element has a JS property for the currently animated 31 attribute. 32 33 Short example: 34 35 <rect> 36 <animate attributeName="width"> 37 </rect> 38 39 The <rect> element has the SVG DOM property 'width'. Therefore, we animate the SVG DOM 40 property and synchronize RenderStyle. 41 42 <ellipse> 43 <animate attributeName="width"> 44 </ellipse> 45 46 The <ellipse> element does NOT have the SVG DOM property 'width'. Therefore, we 47 animate the CSS property directly. With synchronizing RenderStyle in all cases, we 48 make sure that the CSS cascade works even on animating on multiple SVG hierarchy 49 levels (animation of 'width' on <g> and inheriting the property value on a child 50 <rect>). 51 52 With using presentation attributes, we also inherit the CSS property parsing for 53 SVG attributes. <rect width=" 100px "> is possible now. (Note the trailing whitespaces.) 54 This follows a recent resolution of the SVG WG. 55 56 Since we turned width and height to presentation attributes, the layout optimization 57 selfHasRelativeLengths() in the DOM can't be used anymore. selfHasRelativeLengths() was 58 intended to solve a problem where we did not layout relatively position/sized elements 59 when the parent changes its size. However, as a side effect it did not call layout 60 for absolutely positioned/sized elements since the layout does not change. I run 61 all performance tests that we have and even wrote a test with hundreds of elements 62 that would be affected by this optimization. The differences were inside the sigma 63 of a normal test run. (Means I couldn't measure a performance difference.) 64 Therefore, it is not worth it to keep the "optimization" around and I will probably 65 remove it entirely for all basic shapes but <path> and <polygon> in future patches. 66 67 Tests: svg/css/parse-height.html 68 svg/css/parse-width.html 69 svg/css/width-height-presentation-attribute-expected.svg 70 svg/css/width-height-presentation-attribute.svg 71 72 * css/CSSComputedStyleDeclaration.cpp: 73 (WebCore::ComputedStyleExtractor::propertyValue): We never calculated the computed 74 value of width/height for SVG elements and returned auto instead. This is based 75 on a rule of CSS 2 and needs to be fixed in CSS3. 76 * css/DeprecatedStyleBuilder.cpp: 77 (WebCore::ApplyPropertyLength::applyValue): Length always incorporates the zoom level. 78 In SVG we still apply the zoom after all operations by scaling the context. We need 79 to take this in account for Length and don't apply zoom on SVG inline elements. 80 * css/StyleResolver.cpp: 81 (WebCore::StyleResolver::useSVGZoomRulesForLength): 82 See above. 83 * css/StyleResolver.h: 84 * rendering/svg/RenderSVGRect.cpp: 85 (WebCore::RenderSVGRect::updateShapeFromElement): Do not call width() and height() on 86 SVG DOM but use the values of RenderStyle instead. 87 * rendering/svg/SVGPathData.cpp: 88 (WebCore::updatePathFromRectElement): Ditto. 89 * svg/SVGAnimateElement.cpp: 90 (WebCore::SVGAnimateElement::resetAnimatedType): We need to differ between CSS properties 91 with and without SVG DOM on the current element. In the later case we animate the 92 SVG DOM and need to synch RenderStyle. 93 (WebCore::SVGAnimateElement::clearAnimatedType): Ditto. 94 (WebCore::SVGAnimateElement::applyResultsToTarget): Ditto. 95 * svg/SVGAnimationElement.cpp: 96 (WebCore::SVGAnimationElement::isTargetAttributeCSSProperty): This checks if the CSS property 97 has to be synched with SVG DOM. 98 (WebCore::SVGAnimationElement::shouldApplyAnimation): Ditto. 99 * svg/SVGAnimationElement.h: 100 * svg/SVGElement.cpp: 101 (WebCore::populateAttributeNameToCSSPropertyIDMap): Add width and heigth to the CSS property 102 list for presentation attributes. 103 (WebCore::populateCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): CSS properties with 104 SVG DOM synchronization need to be treated differently. Collect them in a separate map. 105 (WebCore::cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap): Caller for the map. 106 (WebCore::SVGElement::animatedPropertyTypeForAttribute): We need to check both maps here: 107 CSS properties and CSS properties with SVG DOM synch. 108 (WebCore::SVGElement::isAnimatableCSSProperty): Ditto. 109 (WebCore::SVGElement::isPresentationAttributeWithSVGDOM): Just return true if the property name 110 is in the map of properties with SVG DOM for the current element. 111 * svg/SVGElement.h: 112 (WebCore::SVGElement::invalidateSVGPresentationAttributeStyle): Call needsStyleRecalc. 113 * svg/SVGFilterElement.cpp: Make width/height presentation attribute. 114 (WebCore::SVGFilterElement::svgAttributeChanged): 115 (WebCore::SVGFilterElement::selfHasRelativeLengths): Deleted. 116 * svg/SVGFilterElement.h: Ditto. 117 * svg/SVGForeignObjectElement.cpp: 118 (WebCore::SVGForeignObjectElement::svgAttributeChanged): 119 (WebCore::SVGForeignObjectElement::selfHasRelativeLengths): Deleted. 120 * svg/SVGForeignObjectElement.h: 121 * svg/SVGImageElement.cpp: Ditto. 122 (WebCore::SVGImageElement::svgAttributeChanged): 123 (WebCore::SVGImageElement::isPresentationAttribute): Deleted. 124 (WebCore::SVGImageElement::collectStyleForPresentationAttribute): Deleted. 125 (WebCore::SVGImageElement::selfHasRelativeLengths): Deleted. 126 * svg/SVGImageElement.h: 127 * svg/SVGLength.h: Transform an Length value to an absolute value by taking the SVG viewport 128 into account. (An SVG viewport is not the same as the CSS viewport.) 129 * svg/SVGLengthContext.cpp: Ditto. 130 (WebCore::SVGLengthContext::valueForLength): 131 * svg/SVGLengthContext.h: 132 * svg/SVGMaskElement.cpp: Make width/height presentation attribute. 133 (WebCore::SVGMaskElement::svgAttributeChanged): 134 (WebCore::SVGMaskElement::selfHasRelativeLengths): Deleted. 135 * svg/SVGMaskElement.h: 136 * svg/SVGPatternElement.cpp: Ditto. 137 (WebCore::SVGPatternElement::svgAttributeChanged): 138 (WebCore::SVGPatternElement::selfHasRelativeLengths): Deleted. 139 * svg/SVGPatternElement.h: 140 * svg/SVGRectElement.cpp: Ditto. 141 (WebCore::SVGRectElement::svgAttributeChanged): 142 (WebCore::SVGRectElement::selfHasRelativeLengths): Deleted. 143 * svg/SVGRectElement.h: 144 * svg/SVGSVGElement.cpp: Ditto. 145 (WebCore::SVGSVGElement::svgAttributeChanged): Clean up redundant layout calls. 146 (WebCore::SVGSVGElement::isPresentationAttribute): Deleted. 147 (WebCore::SVGSVGElement::collectStyleForPresentationAttribute): Deleted. 148 * svg/SVGSVGElement.h: 149 * svg/properties/SVGAnimatedProperty.cpp: Synchronize SVG DOM with DOM. 150 (WebCore::SVGAnimatedProperty::commitChange): 151 1 152 2014-07-22 Adrian Perez de Castro <aperez@igalia.com> 2 153 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r171010 r171341 2118 2118 #endif /* ENABLE(CSS_GRID_LAYOUT) */ 2119 2119 case CSSPropertyHeight: 2120 if (renderer ) {2120 if (renderer && !renderer->isRenderSVGModelObject()) { 2121 2121 // According to http://www.w3.org/TR/CSS2/visudet.html#the-height-property, 2122 2122 // the "height" property does not apply for non-replaced inline elements. … … 2422 2422 return cssValuePool().createValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER); 2423 2423 case CSSPropertyWidth: 2424 if (renderer ) {2424 if (renderer && !renderer->isRenderSVGModelObject()) { 2425 2425 // According to http://www.w3.org/TR/CSS2/visudet.html#the-width-property, 2426 2426 // the "width" property does not apply for non-replaced inline elements. -
trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp
r170996 r171341 385 385 } 386 386 387 CSSToLengthConversionData conversionData = styleResolver->useSVGZoomRulesForLength() ? 388 styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) 389 : styleResolver->state().cssToLengthConversionData(); 387 390 if (autoEnabled && primitiveValue->getValueID() == CSSValueAuto) 388 391 setValue(styleResolver->style(), Length()); 389 392 else if (primitiveValue->isLength()) { 390 Length length = primitiveValue->computeLength<Length>( styleResolver->state().cssToLengthConversionData());393 Length length = primitiveValue->computeLength<Length>(conversionData); 391 394 length.setHasQuirk(primitiveValue->isQuirkValue()); 392 395 setValue(styleResolver->style(), length); … … 394 397 setValue(styleResolver->style(), Length(primitiveValue->getDoubleValue(), Percent)); 395 398 else if (primitiveValue->isCalculatedPercentageWithLength()) 396 setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue( styleResolver->state().cssToLengthConversionData())));399 setValue(styleResolver->style(), Length(primitiveValue->cssCalcValue()->createCalculationValue(conversionData))); 397 400 } 398 401 -
trunk/Source/WebCore/css/StyleResolver.cpp
r171321 r171341 105 105 #include "SVGDocument.h" 106 106 #include "SVGDocumentExtensions.h" 107 #include "SVGElement.h"108 107 #include "SVGFontFaceElement.h" 109 108 #include "SVGNames.h" 109 #include "SVGSVGElement.h" 110 110 #include "SVGURIReference.h" 111 111 #include "SecurityOrigin.h" … … 1860 1860 { 1861 1861 return m_state.element() && m_state.element()->isSVGElement(); 1862 } 1863 1864 // Scale with/height properties on inline SVG root. 1865 bool StyleResolver::useSVGZoomRulesForLength() 1866 { 1867 return m_state.element() && m_state.element()->isSVGElement() && !(isSVGSVGElement(m_state.element()) && m_state.element()->parentNode()); 1862 1868 } 1863 1869 -
trunk/Source/WebCore/css/StyleResolver.h
r171138 r171341 207 207 public: 208 208 bool useSVGZoomRules(); 209 bool useSVGZoomRulesForLength(); 209 210 210 211 static bool colorFromPrimitiveValueIsDerivedFromElement(CSSPrimitiveValue*); -
trunk/Source/WebCore/rendering/svg/RenderSVGRect.cpp
r171046 r171341 57 57 58 58 SVGLengthContext lengthContext(&rectElement()); 59 FloatSize boundingBoxSize( rectElement().width().value(lengthContext), rectElement().height().value(lengthContext));59 FloatSize boundingBoxSize(lengthContext.valueForLength(style().width(), LengthModeWidth), lengthContext.valueForLength(style().height(), LengthModeHeight)); 60 60 61 61 // Element is invalid if either dimension is negative. -
trunk/Source/WebCore/rendering/svg/SVGPathData.cpp
r163440 r171341 22 22 23 23 #include "Path.h" 24 #include "RenderElement.h" 25 #include "RenderStyle.h" 24 26 #include "SVGCircleElement.h" 25 27 #include "SVGEllipseElement.h" 28 #include "SVGLengthContext.h" 26 29 #include "SVGLineElement.h" 27 30 #include "SVGNames.h" … … 105 108 { 106 109 SVGRectElement* rect = toSVGRectElement(element); 110 RenderElement* renderer = rect->renderer(); 111 if (!renderer) 112 return; 107 113 114 RenderStyle& style = renderer->style(); 108 115 SVGLengthContext lengthContext(element); 109 float width = rect->width().value(lengthContext);116 float width = lengthContext.valueForLength(style.width(), LengthModeWidth); 110 117 if (width <= 0) 111 118 return; 112 float height = rect->height().value(lengthContext);119 float height = lengthContext.valueForLength(style.height(), LengthModeHeight); 113 120 if (height <= 0) 114 121 return; -
trunk/Source/WebCore/svg/SVGAnimateElement.cpp
r163440 r171341 207 207 return; 208 208 209 if (shouldApply == ApplyXMLAnimation ) {209 if (shouldApply == ApplyXMLAnimation || shouldApply == ApplyXMLandCSSAnimation) { 210 210 // SVG DOM animVal animation code-path. 211 211 m_animatedProperties = animator->findAnimatedPropertiesForAttributeName(targetElement, attributeName); … … 335 335 } 336 336 337 ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName()); 338 if (shouldApply == ApplyXMLandCSSAnimation) 339 removeCSSPropertyFromTargetAndInstances(targetElement, attributeName()); 340 337 341 // SVG DOM animVal animation code-path. 338 342 if (m_animator) { … … 355 359 return; 356 360 361 SVGElement* targetElement = this->targetElement(); 362 const QualifiedName& attributeName = this->attributeName(); 357 363 if (m_animatedProperties.isEmpty()) { 358 364 // CSS properties animation code-path. 359 365 // Convert the result of the animation to a String and apply it as CSS property on the target & all instances. 360 applyCSSPropertyToTargetAndInstances(targetElement(), attributeName(), m_animatedType->valueAsString()); 361 return; 362 } 366 applyCSSPropertyToTargetAndInstances(targetElement, attributeName, m_animatedType->valueAsString()); 367 return; 368 } 369 370 // We do update the style and the animation property independent of each other. 371 ShouldApplyAnimation shouldApply = shouldApplyAnimation(targetElement, attributeName); 372 if (shouldApply == ApplyXMLandCSSAnimation) 373 applyCSSPropertyToTargetAndInstances(targetElement, attributeName, m_animatedType->valueAsString()); 363 374 364 375 // SVG DOM animVal animation code-path. … … 366 377 // We only have to trigger update notifications here. 367 378 m_animator->animValDidChange(m_animatedProperties); 368 notifyTargetAndInstancesAboutAnimValChange(targetElement (), attributeName());379 notifyTargetAndInstancesAboutAnimValChange(targetElement, attributeName); 369 380 } 370 381 -
trunk/Source/WebCore/svg/SVGAnimationElement.cpp
r168469 r171341 354 354 } 355 355 356 bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement*, const QualifiedName& attributeName) 357 { 356 bool SVGAnimationElement::isTargetAttributeCSSProperty(SVGElement* element, const QualifiedName& attributeName) 357 { 358 // FIXME: Must be isSVGTextPositioningElement(element) instead. 359 if (isSVGTextElement(element) 360 && (attributeName == SVGNames::xAttr || attributeName == SVGNames::yAttr)) 361 return false; 362 358 363 return SVGElement::isAnimatableCSSProperty(attributeName); 359 364 } … … 365 370 366 371 // Always animate CSS properties, using the ApplyCSSAnimation code path, regardless of the attributeType value. 367 if (isTargetAttributeCSSProperty(targetElement, attributeName)) 372 if (isTargetAttributeCSSProperty(targetElement, attributeName)) { 373 if (targetElement->isPresentationAttributeWithSVGDOM(attributeName)) 374 return ApplyXMLandCSSAnimation; 368 375 return ApplyCSSAnimation; 376 } 377 369 378 370 379 // If attributeType="CSS" and attributeName doesn't point to a CSS property, ignore the animation. -
trunk/Source/WebCore/svg/SVGAnimationElement.h
r163440 r171341 88 88 DontApplyAnimation, 89 89 ApplyCSSAnimation, 90 ApplyXMLAnimation 90 ApplyXMLAnimation, 91 ApplyXMLandCSSAnimation // For presentation attributes with SVG DOM properties. 91 92 }; 92 93 -
trunk/Source/WebCore/svg/SVGElement.cpp
r168921 r171341 112 112 &glyph_orientation_verticalAttr, 113 113 &image_renderingAttr, 114 &SVGNames::heightAttr, 114 115 &kerningAttr, 115 116 &letter_spacingAttr, … … 141 142 &vector_effectAttr, 142 143 &visibilityAttr, 144 &SVGNames::widthAttr, 143 145 &word_spacingAttr, 144 146 &writing_modeAttr, … … 233 235 } 234 236 237 static NEVER_INLINE void populateCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap(HashMap<QualifiedName::QualifiedNameImpl*, AnimatedPropertyType>& map) 238 { 239 struct TableEntry { 240 const QualifiedName& attributeName; 241 AnimatedPropertyType type; 242 }; 243 244 static const TableEntry table[] = { 245 { SVGNames::heightAttr, AnimatedLength }, 246 { SVGNames::widthAttr, AnimatedLength }, 247 }; 248 249 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(table); ++i) 250 map.add(table[i].attributeName.impl(), table[i].type); 251 } 252 253 static inline HashMap<QualifiedName::QualifiedNameImpl*, AnimatedPropertyType>& cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap() 254 { 255 static NeverDestroyed<HashMap<QualifiedName::QualifiedNameImpl*, AnimatedPropertyType>> map; 256 if (map.get().isEmpty()) 257 populateCSSPropertyWithSVGDOMNameToAnimatedPropertyTypeMap(map); 258 return map; 259 } 260 235 261 SVGElement::SVGElement(const QualifiedName& tagName, Document& document) 236 262 : StyledElement(tagName, document, CreateSVGElement) … … 509 535 auto& map = attributeNameToAnimatedPropertyTypeMap(); 510 536 auto it = map.find(attributeName.impl()); 511 if (it != map.end()) 537 if (it != map.end()) { 512 538 propertyTypes.append(it->value); 539 return; 540 } 541 542 auto& cssPropertyWithSVGDOMMap = cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap(); 543 auto svgPropertyIterator = cssPropertyWithSVGDOMMap.find(attributeName.impl()); 544 if (svgPropertyIterator != cssPropertyWithSVGDOMMap.end()) 545 propertyTypes.append(svgPropertyIterator->value); 513 546 } 514 547 … … 966 999 bool SVGElement::isAnimatableCSSProperty(const QualifiedName& attributeName) 967 1000 { 968 return attributeNameToAnimatedPropertyTypeMap().contains(attributeName.impl()); 1001 return attributeNameToAnimatedPropertyTypeMap().contains(attributeName.impl()) 1002 || cssPropertyWithSVGDOMNameToAnimatedPropertyTypeMap().contains(attributeName.impl()); 1003 } 1004 1005 bool SVGElement::isPresentationAttributeWithSVGDOM(const QualifiedName& attributeName) 1006 { 1007 Vector<AnimatedPropertyType> propertyTypes; 1008 localAttributeToPropertyMap().animatedPropertyTypeForAttribute(attributeName, propertyTypes); 1009 return !propertyTypes.isEmpty(); 969 1010 } 970 1011 -
trunk/Source/WebCore/svg/SVGElement.h
r168921 r171341 65 65 virtual String title() const override; 66 66 static bool isAnimatableCSSProperty(const QualifiedName&); 67 bool isPresentationAttributeWithSVGDOM(const QualifiedName&); 67 68 bool isKnownAttribute(const QualifiedName&); 68 69 PassRefPtr<CSSValue> getPresentationAttribute(const String& name); … … 87 88 virtual void svgAttributeChanged(const QualifiedName&); 88 89 89 v irtual void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&);90 void animatedPropertyTypeForAttribute(const QualifiedName&, Vector<AnimatedPropertyType>&); 90 91 91 92 void sendSVGLoadEventIfPossible(bool sendParentLoadEvents = false); … … 97 98 98 99 void invalidateSVGAttributes() { ensureUniqueElementData().setAnimatedSVGAttributesAreDirty(true); } 99 void invalidateSVGPresentationAttributeStyle() { ensureUniqueElementData().setPresentationAttributeStyleIsDirty(true); } 100 void invalidateSVGPresentationAttributeStyle() 101 { 102 ensureUniqueElementData().setPresentationAttributeStyleIsDirty(true); 103 // Trigger style recalculation for "elements as resource" (e.g. referenced by feImage). 104 setNeedsStyleRecalc(InlineStyleChange); 105 } 100 106 101 107 const HashSet<SVGElementInstance*>& instancesForElement() const; -
trunk/Source/WebCore/svg/SVGFilterElement.cpp
r170774 r171341 168 168 169 169 SVGElementInstance::InvalidationGuard invalidationGuard(this); 170 170 171 if (attrName == SVGNames::widthAttr 172 || attrName == SVGNames::heightAttr) { 173 invalidateSVGPresentationAttributeStyle(); 174 return; 175 } 176 171 177 if (attrName == SVGNames::xAttr 172 || attrName == SVGNames::yAttr 173 || attrName == SVGNames::widthAttr 174 || attrName == SVGNames::heightAttr) 178 || attrName == SVGNames::yAttr) 175 179 updateRelativeLengthsInformation(); 176 180 … … 234 238 } 235 239 236 bool SVGFilterElement::selfHasRelativeLengths() const237 {238 return x().isRelative()239 || y().isRelative()240 || width().isRelative()241 || height().isRelative();242 }243 244 240 } 245 241 -
trunk/Source/WebCore/svg/SVGFilterElement.h
r163440 r171341 58 58 virtual bool childShouldCreateRenderer(const Node&) const override; 59 59 60 virtual bool selfHasRelativeLengths() const override ;60 virtual bool selfHasRelativeLengths() const override { return true; } 61 61 62 62 static const AtomicString& filterResXIdentifier(); -
trunk/Source/WebCore/svg/SVGForeignObjectElement.cpp
r170774 r171341 113 113 114 114 SVGElementInstance::InvalidationGuard invalidationGuard(this); 115 116 bool isLengthAttribute = attrName == SVGNames::xAttr117 || attrName == SVGNames::yAttr118 || attrName == SVGNames::widthAttr119 || attrName == SVGNames::heightAttr;120 115 121 if (isLengthAttribute) 116 if (attrName == SVGNames::widthAttr 117 || attrName == SVGNames::heightAttr) { 118 invalidateSVGPresentationAttributeStyle(); 119 return; 120 } 121 122 if (attrName == SVGNames::xAttr || attrName == SVGNames::yAttr) 122 123 updateRelativeLengthsInformation(); 123 124 … … 159 160 } 160 161 161 bool SVGForeignObjectElement::selfHasRelativeLengths() const162 {163 return x().isRelative()164 || y().isRelative()165 || width().isRelative()166 || height().isRelative();167 162 } 168 169 } -
trunk/Source/WebCore/svg/SVGForeignObjectElement.h
r163440 r171341 47 47 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 48 48 49 virtual bool selfHasRelativeLengths() const override ;49 virtual bool selfHasRelativeLengths() const override { return true; } 50 50 51 51 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGForeignObjectElement) -
trunk/Source/WebCore/svg/SVGImageElement.cpp
r170774 r171341 88 88 } 89 89 90 bool SVGImageElement::isPresentationAttribute(const QualifiedName& name) const91 {92 if (name == SVGNames::widthAttr || name == SVGNames::heightAttr)93 return true;94 return SVGGraphicsElement::isPresentationAttribute(name);95 }96 97 void SVGImageElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)98 {99 if (!isSupportedAttribute(name))100 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, style);101 else if (name == SVGNames::widthAttr)102 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);103 else if (name == SVGNames::heightAttr)104 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value);105 }106 107 90 void SVGImageElement::parseAttribute(const QualifiedName& name, const AtomicString& value) 108 91 { … … 140 123 141 124 SVGElementInstance::InvalidationGuard invalidationGuard(this); 142 125 126 if (attrName == SVGNames::widthAttr 127 || attrName == SVGNames::heightAttr) { 128 invalidateSVGPresentationAttributeStyle(); 129 return; 130 } 131 143 132 bool isLengthAttribute = attrName == SVGNames::xAttr 144 133 || attrName == SVGNames::yAttr … … 172 161 173 162 ASSERT_NOT_REACHED(); 174 }175 176 bool SVGImageElement::selfHasRelativeLengths() const177 {178 return x().isRelative()179 || y().isRelative()180 || width().isRelative()181 || height().isRelative();182 163 } 183 164 -
trunk/Source/WebCore/svg/SVGImageElement.h
r168313 r171341 45 45 bool isSupportedAttribute(const QualifiedName&); 46 46 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 47 virtual bool isPresentationAttribute(const QualifiedName&) const override;48 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;49 47 virtual void svgAttributeChanged(const QualifiedName&) override; 50 48 … … 59 57 virtual bool haveLoadedRequiredResources() override; 60 58 61 virtual bool selfHasRelativeLengths() const override ;59 virtual bool selfHasRelativeLengths() const override { return true; } 62 60 virtual void didMoveToNewDocument(Document* oldDocument) override; 63 61 -
trunk/Source/WebCore/svg/SVGLength.h
r163440 r171341 57 57 }; 58 58 59 // FIXME: Once all SVGLength users use Length internally, we make this a wrapper for Length. 59 60 SVGLength(SVGLengthMode = LengthModeOther, const String& valueAsString = String()); 60 61 SVGLength(const SVGLengthContext&, float, SVGLengthMode = LengthModeOther, SVGLengthType = LengthTypeNumber); -
trunk/Source/WebCore/svg/SVGLengthContext.cpp
r163440 r171341 28 28 #include "FontMetrics.h" 29 29 #include "Frame.h" 30 #include "LengthFunctions.h" 30 31 #include "RenderSVGRoot.h" 31 32 #include "RenderSVGViewportContainer.h" … … 84 85 // FIXME: valueAsPercentage() won't be correct for eg. cm units. They need to be resolved in user space and then be considered in objectBoundingBox space. 85 86 return x.valueAsPercentage(); 87 } 88 89 float SVGLengthContext::valueForLength(const Length& length, SVGLengthMode mode) 90 { 91 if (length.isPercent()) 92 return convertValueFromPercentageToUserUnits(length.value() / 100, mode, IGNORE_EXCEPTION); 93 if (length.isAuto()) 94 return 0; 95 96 FloatSize viewportSize; 97 determineViewport(viewportSize); 98 99 switch (mode) { 100 case LengthModeWidth: 101 return floatValueForLength(length, viewportSize.width()); 102 case LengthModeHeight: 103 return floatValueForLength(length, viewportSize.height()); 104 case LengthModeOther: 105 return floatValueForLength(length, sqrtf(viewportSize.diagonalLengthSquared() / 2)); 106 }; 107 return 0; 86 108 } 87 109 -
trunk/Source/WebCore/svg/SVGLengthContext.h
r163440 r171341 28 28 class SVGElement; 29 29 class SVGLength; 30 struct Length; 30 31 31 32 typedef int ExceptionCode; … … 65 66 static float resolveLength(const SVGElement*, SVGUnitTypes::SVGUnitType, const SVGLength&); 66 67 68 float valueForLength(const Length&, SVGLengthMode = LengthModeOther); 67 69 float convertValueToUserUnits(float, SVGLengthMode, SVGLengthType fromUnit, ExceptionCode&) const; 68 70 float convertValueFromUserUnits(float, SVGLengthMode, SVGLengthType toUnit, ExceptionCode&) const; -
trunk/Source/WebCore/svg/SVGMaskElement.cpp
r170774 r171341 135 135 136 136 SVGElementInstance::InvalidationGuard invalidationGuard(this); 137 137 138 if (attrName == SVGNames::widthAttr 139 || attrName == SVGNames::heightAttr) { 140 invalidateSVGPresentationAttributeStyle(); 141 return; 142 } 143 138 144 if (attrName == SVGNames::xAttr 139 || attrName == SVGNames::yAttr 140 || attrName == SVGNames::widthAttr 141 || attrName == SVGNames::heightAttr) 145 || attrName == SVGNames::yAttr) 142 146 updateRelativeLengthsInformation(); 143 147 … … 162 166 } 163 167 164 bool SVGMaskElement::selfHasRelativeLengths() const165 {166 return x().isRelative()167 || y().isRelative()168 || width().isRelative()169 || height().isRelative();170 168 } 171 172 } -
trunk/Source/WebCore/svg/SVGMaskElement.h
r163440 r171341 51 51 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 52 52 53 virtual bool selfHasRelativeLengths() const override ;53 virtual bool selfHasRelativeLengths() const override { return true; } 54 54 55 55 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGMaskElement) -
trunk/Source/WebCore/svg/SVGPatternElement.cpp
r170774 r171341 160 160 161 161 SVGElementInstance::InvalidationGuard invalidationGuard(this); 162 162 163 if (attrName == SVGNames::widthAttr 164 || attrName == SVGNames::heightAttr) { 165 invalidateSVGPresentationAttributeStyle(); 166 return; 167 } 168 163 169 if (attrName == SVGNames::xAttr 164 || attrName == SVGNames::yAttr 165 || attrName == SVGNames::widthAttr 166 || attrName == SVGNames::heightAttr) 170 || attrName == SVGNames::yAttr) 167 171 updateRelativeLengthsInformation(); 168 172 … … 253 257 } 254 258 255 bool SVGPatternElement::selfHasRelativeLengths() const 256 { 257 return x().isRelative() 258 || y().isRelative() 259 || width().isRelative() 260 || height().isRelative(); 261 } 262 263 } 259 } -
trunk/Source/WebCore/svg/SVGPatternElement.h
r163440 r171341 65 65 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; 66 66 67 virtual bool selfHasRelativeLengths() const override ;67 virtual bool selfHasRelativeLengths() const override { return true; } 68 68 69 69 BEGIN_DECLARE_ANIMATED_PROPERTIES(SVGPatternElement) -
trunk/Source/WebCore/svg/SVGRectElement.cpp
r170774 r171341 121 121 122 122 SVGElementInstance::InvalidationGuard invalidationGuard(this); 123 123 124 if (attrName == SVGNames::widthAttr 125 || attrName == SVGNames::heightAttr) { 126 invalidateSVGPresentationAttributeStyle(); 127 return; 128 } 129 124 130 bool isLengthAttribute = attrName == SVGNames::xAttr 125 131 || attrName == SVGNames::yAttr 126 || attrName == SVGNames::widthAttr127 || attrName == SVGNames::heightAttr128 132 || attrName == SVGNames::rxAttr 129 133 || attrName == SVGNames::ryAttr; … … 150 154 } 151 155 152 bool SVGRectElement::selfHasRelativeLengths() const153 {154 return x().isRelative()155 || y().isRelative()156 || width().isRelative()157 || height().isRelative()158 || rx().isRelative()159 || ry().isRelative();160 }161 162 156 RenderPtr<RenderElement> SVGRectElement::createElementRenderer(PassRef<RenderStyle> style) 163 157 { -
trunk/Source/WebCore/svg/SVGRectElement.h
r168313 r171341 44 44 virtual void svgAttributeChanged(const QualifiedName&) override; 45 45 46 virtual bool selfHasRelativeLengths() const override ;46 virtual bool selfHasRelativeLengths() const override { return true; } 47 47 48 48 virtual RenderPtr<RenderElement> createElementRenderer(PassRef<RenderStyle>) override; -
trunk/Source/WebCore/svg/SVGSVGElement.cpp
r170774 r171341 271 271 } 272 272 273 bool SVGSVGElement::isPresentationAttribute(const QualifiedName& name) const274 {275 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SVGNames::heightAttr))276 return true;277 return SVGGraphicsElement::isPresentationAttribute(name);278 }279 280 void SVGSVGElement::collectStyleForPresentationAttribute(const QualifiedName& name, const AtomicString& value, MutableStyleProperties& style)281 {282 if (isOutermostSVGSVGElement() && (name == SVGNames::widthAttr || name == SVGNames::heightAttr)) {283 if (name == SVGNames::widthAttr)284 addPropertyToPresentationAttributeStyle(style, CSSPropertyWidth, value);285 else if (name == SVGNames::heightAttr)286 addPropertyToPresentationAttributeStyle(style, CSSPropertyHeight, value);287 } else288 SVGGraphicsElement::collectStyleForPresentationAttribute(name, value, style);289 }290 291 273 void SVGSVGElement::svgAttributeChanged(const QualifiedName& attrName) 292 274 { 293 275 bool updateRelativeLengthsOrViewBox = false; 294 bool widthChanged = attrName == SVGNames::widthAttr; 295 bool heightChanged = attrName == SVGNames::heightAttr; 296 if (widthChanged || heightChanged 276 if (attrName == SVGNames::widthAttr 277 || attrName == SVGNames::heightAttr 297 278 || attrName == SVGNames::xAttr 298 279 || attrName == SVGNames::yAttr) { 280 invalidateSVGPresentationAttributeStyle(); 299 281 updateRelativeLengthsOrViewBox = true; 300 updateRelativeLengthsInformation();301 302 // At the SVG/HTML boundary (aka RenderSVGRoot), the width and303 // height attributes can affect the replaced size so we need304 // to mark it for updating.305 if (widthChanged || heightChanged) {306 // FIXME: This is a hack to synchronize changes from SVG DOM earlier in the307 // run. We need these changes in the style calculation process earlier than308 // usual.309 synchronizeAllAttributes();310 RenderObject* renderObject = renderer();311 if (renderObject && renderObject->isSVGRoot()) {312 invalidateSVGPresentationAttributeStyle();313 setNeedsStyleRecalc();314 }315 }316 282 } 317 283 -
trunk/Source/WebCore/svg/SVGSVGElement.h
r171147 r171341 134 134 135 135 virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; 136 virtual bool isPresentationAttribute(const QualifiedName&) const override;137 virtual void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) override;138 136 139 137 virtual bool rendererIsNeeded(const RenderStyle&) override; -
trunk/Source/WebCore/svg/properties/SVGAnimatedProperty.cpp
r163440 r171341 56 56 m_contextElement->invalidateSVGAttributes(); 57 57 m_contextElement->svgAttributeChanged(m_attributeName); 58 // Needed to synchronize with CSSOM for presentation attributes with SVG DOM. 59 m_contextElement->synchronizeAnimatedSVGAttribute(m_attributeName); 58 60 } 59 61
Note: See TracChangeset
for help on using the changeset viewer.