2011-03-01 Nikolas Zimmermann <nzimmermann@rim.com>
authorzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2011 10:52:51 +0000 (10:52 +0000)
committerzimmermann@webkit.org <zimmermann@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 1 Mar 2011 10:52:51 +0000 (10:52 +0000)
commitdfe7e81f9ff1a83ce24d41fcb9bb70521a4b406c
tree0ff30d934523a3e28cce597e3dfe1152a0e74e18
parent2fe1c5f5fcbc07ec7958316b4fc438f97cb560d9
2011-03-01  Nikolas Zimmermann  <nzimmermann@rim.com>

        Reviewed by Antti Koivisto.

        SVG 1.1 2nd Edition color-prop-05-t.svg exposes bug in 'currentColor' handling
        https://bugs.webkit.org/show_bug.cgi?id=54800

        Add new layout test from the SVG 1.1 2nd Edition test suite, covering currentColor handling.
        Add tests ensuring that mutating a previously shared SVGPaint object makes it unique, so that
        mutations take affect, but don't affect other renderers which shared the SVGPaint object before.

        * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.checksum: Added.
        * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.png: Added.
        * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.txt: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.checksum: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.png: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.txt: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.checksum: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.png: Added.
        * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.txt: Added.
        * svg/W3C-SVG-1.1-SE/color-prop-05-t.svg: Added.
        * svg/animations/animate-color-fill-currentColor-expected.txt: Added.
        * svg/animations/animate-color-fill-currentColor.html: Added.
        * svg/animations/script-tests/animate-color-fill-currentColor.js: Added.
        * svg/custom/SVGPaint-mutate-attribute.svg: Added.
        * svg/custom/SVGPaint-mutate-inline-style.svg: Added.
        * svg/dom/SVGColor-expected.txt: SVGColor mutations now reflected in style/computed style.
        * svg/dom/SVGPaint-expected.txt: Same for SVGPaint.
2011-03-01  Nikolas Zimmermann  <nzimmermann@rim.com>

        Reviewed by Antti Koivisto.

        SVG 1.1 2nd Edition color-prop-05-t.svg exposes bug in 'currentColor' handling
        https://bugs.webkit.org/show_bug.cgi?id=54800

        Wrong handling of currentColor on inherit
        https://bugs.webkit.org/show_bug.cgi?id=38102

        Stop storing RefPtr<SVGPaint> objects in the SVGRenderStyle for fill/stroke. These are the last
        two objects that held references to CSSValues, they're all gone now, aligning better with RenderStyle.
        It's also dangerous, as a SVGPaint object can be shared by multiple SVGRenderStyles (MappedAttribute will
        once create a CSSStyleDeclaration for fill="red" and reuse it where possible), and it was easy to
        accidently mutate the object, affecting multiple styles. Instead store a Color, an URI and a paint
        type in SVGRenderStyle, enough to create a SVGPaint object, if needed (eg for computed styles).

        <g color="green"><rect fill="currentColor"/> already worked fine in trunk, but
        <g fill="currentColor" color="green"><rect color="red"/> procuded a red rectangle.

        In order to fix to bug we have to resolve all currentColor values for SVGPaint objects, in SVGCSSStyleSelector,
        as it's already done for SVGColor objects (stop-color, flood-color, etc.) instead of in RenderSVGResource::fill/strokePaintingResource,
        when trying to use the paint server. The correct "color" value that should be used from the RenderStyle, is directly
        available in CSSStyleSelector: in applyProperty m_style->color() gives the desired value. In CSSStyleSelector it's handled
        exactly this way for non-SVG currentColor properties. Also fix computed styles, which did not resolve currentColor for SVGPaint/SVGColor.

        A previous patch implemented the SVGPaint/SVGColor API. SVG demands these CSSValues to be mutable. Introduce
        CSSMutableValue, which extends CSSValue by a Node pointer, and let SVGPaint/SVGColor inherit from it.
        Mutating a SVGPaint/SVGColor object now takes immediate effect, which is reflected in the inline style / computed style.
        (Note that getPresentationAttribute() already takes care of removing the CSSValue from the mapped attribute cache, so that it's no longer shared.)

        Add several new tests covering the patch.

        Tests: svg/W3C-SVG-1.1-SE/color-prop-05-t.svg
               svg/animations/animate-color-fill-currentColor.html
               svg/custom/SVGPaint-mutate-attribute.svg
               svg/custom/SVGPaint-mutate-inline-style.svg

        * GNUMakefile.am: Add CSSMutableValue.h
        * WebCore.gypi: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * css/CSSMutableStyleDeclaration.cpp: Reset the Node pointer in all CSSMutableValues belonging to this style declaration.
        (WebCore::CSSMutableStyleDeclaration::~CSSMutableStyleDeclaration):
        * css/CSSMutableStyleDeclaration.h: Add destructor.
        * css/CSSMutableValue.h: Added.
        (WebCore::CSSMutableValue::CSSMutableValue):
        (WebCore::CSSMutableValue::~CSSMutableValue):
        (WebCore::CSSMutableValue::isMutableValue):
        (WebCore::CSSMutableValue::node):
        (WebCore::CSSMutableValue::setNode):
        (WebCore::CSSMutableValue::setNeedsStyleRecalc):
        * css/CSSStyleDeclaration.cpp:
        (WebCore::CSSStyleDeclaration::getPropertyCSSValue): Set the Node object of a CSSMutableValue to the Node, this style declaration belongs to.
        * css/CSSValue.h:
        (WebCore::CSSValue::isMutableValue): Return false, default.
        * css/SVGCSSComputedStyleDeclaration.cpp:
        (WebCore::CSSComputedStyleDeclaration::adjustSVGPaintForCurrentColor): Add helper function, resolving currentColor values for SVGPaint objects.
        (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue): Use currentColorOrValidColor/adjustSVGPaintForCurrentColor to resolve SVGColor/SVGPaint values.
        * css/SVGCSSStyleSelector.cpp:
        (WebCore::CSSStyleSelector::applySVGProperty): Store fill/stroke uri, color, paint type seperated in SVGRenderStyle, don't store the full SVGPaint object anymore.
        * rendering/style/SVGRenderStyle.cpp:
        (WebCore::SVGRenderStyle::diff): Adapt to SVGPaint changes.
        * rendering/style/SVGRenderStyle.h: Ditto.
        (WebCore::SVGRenderStyle::initialFillOpacity):
        (WebCore::SVGRenderStyle::initialFillPaintType):
        (WebCore::SVGRenderStyle::initialFillPaintColor):
        (WebCore::SVGRenderStyle::initialFillPaintUri):
        (WebCore::SVGRenderStyle::initialStrokeOpacity):
        (WebCore::SVGRenderStyle::initialStrokePaintType):
        (WebCore::SVGRenderStyle::initialStrokePaintColor):
        (WebCore::SVGRenderStyle::initialStrokePaintUri):
        (WebCore::SVGRenderStyle::initialStrokeMiterLimit):
        (WebCore::SVGRenderStyle::initialStopOpacity):
        (WebCore::SVGRenderStyle::initialFloodOpacity):
        (WebCore::SVGRenderStyle::setFillPaint):
        (WebCore::SVGRenderStyle::setStrokePaint):
        (WebCore::SVGRenderStyle::fillPaintType):
        (WebCore::SVGRenderStyle::fillPaintColor):
        (WebCore::SVGRenderStyle::fillPaintUri):
        (WebCore::SVGRenderStyle::strokePaintType):
        (WebCore::SVGRenderStyle::strokePaintColor):
        (WebCore::SVGRenderStyle::strokePaintUri):
        (WebCore::SVGRenderStyle::hasStroke):
        (WebCore::SVGRenderStyle::hasFill):
        * rendering/style/SVGRenderStyleDefs.cpp: Ditto.
        (WebCore::StyleFillData::StyleFillData):
        (WebCore::StyleFillData::operator==):
        (WebCore::StyleStrokeData::StyleStrokeData):
        (WebCore::StyleStrokeData::operator==):
        * rendering/style/SVGRenderStyleDefs.h: Ditto.
        * rendering/svg/RenderSVGResource.cpp: Ditto.
        (WebCore::requestPaintingResource):
        * rendering/svg/RenderSVGResourceClipper.cpp: Ditto.
        (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage):
        * rendering/svg/SVGResources.cpp: Ditto.
        (WebCore::paintingResourceFromSVGPaint):
        (WebCore::SVGResources::buildCachedResources):
        * svg/SVGColor.cpp: Call setNeedsStyleRecalc() after mutating the object.
        (WebCore::SVGColor::setRGBColor):
        (WebCore::SVGColor::setRGBColorICCColor):
        (WebCore::SVGColor::setColor):
        * svg/SVGColor.h:
        * svg/SVGPaint.cpp: Ditto.
        (WebCore::SVGPaint::setUri):
        (WebCore::SVGPaint::setPaint):
        * svg/SVGPaint.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79985 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.txt [new file with mode: 0644]
LayoutTests/svg/W3C-SVG-1.1-SE/color-prop-05-t.svg [new file with mode: 0644]
LayoutTests/svg/animations/animate-color-fill-currentColor-expected.txt [new file with mode: 0644]
LayoutTests/svg/animations/animate-color-fill-currentColor.html [new file with mode: 0644]
LayoutTests/svg/animations/script-tests/animate-color-fill-currentColor.js [new file with mode: 0644]
LayoutTests/svg/custom/SVGPaint-mutate-attribute.svg [new file with mode: 0644]
LayoutTests/svg/custom/SVGPaint-mutate-inline-style.svg [new file with mode: 0644]
LayoutTests/svg/dom/SVGColor-expected.txt
LayoutTests/svg/dom/SVGPaint-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.h
Source/WebCore/css/CSSMutableStyleDeclaration.cpp
Source/WebCore/css/CSSMutableStyleDeclaration.h
Source/WebCore/css/CSSMutableValue.h [new file with mode: 0644]
Source/WebCore/css/CSSStyleDeclaration.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
Source/WebCore/css/SVGCSSStyleSelector.cpp
Source/WebCore/rendering/style/SVGRenderStyle.cpp
Source/WebCore/rendering/style/SVGRenderStyle.h
Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
Source/WebCore/rendering/style/SVGRenderStyleDefs.h
Source/WebCore/rendering/svg/RenderSVGResource.cpp
Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
Source/WebCore/rendering/svg/SVGResources.cpp
Source/WebCore/svg/SVGColor.cpp
Source/WebCore/svg/SVGColor.h
Source/WebCore/svg/SVGPaint.cpp
Source/WebCore/svg/SVGPaint.h