Changeset 79985 in webkit
- Timestamp:
- Mar 1, 2011 2:52:51 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 16 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r79980 r79985 1 2011-03-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Antti Koivisto. 4 5 SVG 1.1 2nd Edition color-prop-05-t.svg exposes bug in 'currentColor' handling 6 https://bugs.webkit.org/show_bug.cgi?id=54800 7 8 Add new layout test from the SVG 1.1 2nd Edition test suite, covering currentColor handling. 9 Add tests ensuring that mutating a previously shared SVGPaint object makes it unique, so that 10 mutations take affect, but don't affect other renderers which shared the SVGPaint object before. 11 12 * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.checksum: Added. 13 * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.png: Added. 14 * platform/mac/svg/W3C-SVG-1.1-SE/color-prop-05-t-expected.txt: Added. 15 * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.checksum: Added. 16 * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.png: Added. 17 * platform/mac/svg/custom/SVGPaint-mutate-attribute-expected.txt: Added. 18 * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.checksum: Added. 19 * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.png: Added. 20 * platform/mac/svg/custom/SVGPaint-mutate-inline-style-expected.txt: Added. 21 * svg/W3C-SVG-1.1-SE/color-prop-05-t.svg: Added. 22 * svg/animations/animate-color-fill-currentColor-expected.txt: Added. 23 * svg/animations/animate-color-fill-currentColor.html: Added. 24 * svg/animations/script-tests/animate-color-fill-currentColor.js: Added. 25 * svg/custom/SVGPaint-mutate-attribute.svg: Added. 26 * svg/custom/SVGPaint-mutate-inline-style.svg: Added. 27 * svg/dom/SVGColor-expected.txt: SVGColor mutations now reflected in style/computed style. 28 * svg/dom/SVGPaint-expected.txt: Same for SVGPaint. 29 1 30 2011-03-01 Pavel Feldman <pfeldman@chromium.org> 2 31 … … 408 437 https://bugs.webkit.org/show_bug.cgi?id=55121 409 438 410 411 412 413 414 439 [chromium] Recently, French Academy changed the sorting 440 rules for French in such a way that accents are not weighted 441 from the end of a word any more. ICU 4.6 / CLDR 1.9 442 incorporated the change. Canadian French hasn't adopted the 443 change, yet. 415 444 416 445 Chrome is the only port that uses new rules with ICU 4.6. So, -
trunk/LayoutTests/svg/dom/SVGColor-expected.txt
r79675 r79985 44 44 PASS rgbColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 77 45 45 PASS stopElement.style.stopColor is "#4d004d" 46 FAIL document.defaultView.getComputedStyle(stopElement).stopColor should be rgb(77, 0, 77). Was rgb(255, 0, 0). 46 PASS document.defaultView.getComputedStyle(stopElement).stopColor is "rgb(77, 0, 77)" 47 47 48 48 Test using setColor() and SVG_COLORTYPE_CURRENTCOLOR … … 55 55 PASS rgbColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 56 56 PASS stopElement.style.stopColor is "currentColor" 57 FAIL document.defaultView.getComputedStyle(stopElement).stopColor should be rgb(0, 128, 0). Was rgb(255, 0, 0). 57 PASS document.defaultView.getComputedStyle(stopElement).stopColor is "rgb(0, 128, 0)" 58 58 59 59 Test using setColor() and SVG_COLORTYPE_RGBCOLOR … … 65 65 PASS rgbColor.green.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 77 66 66 PASS rgbColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 67 FAIL document.defaultView.getComputedStyle(stopElement).stopColor should be rgb(0, 77, 0). Was rgb(255, 0, 0). 67 PASS document.defaultView.getComputedStyle(stopElement).stopColor is "rgb(0, 77, 0)" 68 68 PASS successfullyParsed is true 69 69 -
trunk/LayoutTests/svg/dom/SVGPaint-expected.txt
r79675 r79985 166 166 PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 167 167 PASS rectElement.style.fill is "url(#foo) currentColor" 168 FAIL document.defaultView.getComputedStyle(rectElement).fill should be url(#foo) #00ff00. Was url(#foo) currentColor. 168 PASS document.defaultView.getComputedStyle(rectElement).fill is "url(#foo) #00ff00" 169 169 170 170 Test using setPaint() and SVG_PAINTTYPE_URI_RGBCOLOR … … 214 214 PASS fillColor.blue.getFloatValue(CSSPrimitiveValue.CSS_NUMBER) is 0 215 215 PASS rectElement.style.fill is "currentColor" 216 FAIL document.defaultView.getComputedStyle(rectElement).fill should be #00ff00. Was currentColor. 216 PASS document.defaultView.getComputedStyle(rectElement).fill is "#00ff00" 217 217 218 218 Test using setPaint() and SVG_PAINTTYPE_RGBCOLOR -
trunk/Source/WebCore/ChangeLog
r79984 r79985 1 2011-03-01 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Antti Koivisto. 4 5 SVG 1.1 2nd Edition color-prop-05-t.svg exposes bug in 'currentColor' handling 6 https://bugs.webkit.org/show_bug.cgi?id=54800 7 8 Wrong handling of currentColor on inherit 9 https://bugs.webkit.org/show_bug.cgi?id=38102 10 11 Stop storing RefPtr<SVGPaint> objects in the SVGRenderStyle for fill/stroke. These are the last 12 two objects that held references to CSSValues, they're all gone now, aligning better with RenderStyle. 13 It's also dangerous, as a SVGPaint object can be shared by multiple SVGRenderStyles (MappedAttribute will 14 once create a CSSStyleDeclaration for fill="red" and reuse it where possible), and it was easy to 15 accidently mutate the object, affecting multiple styles. Instead store a Color, an URI and a paint 16 type in SVGRenderStyle, enough to create a SVGPaint object, if needed (eg for computed styles). 17 18 <g color="green"><rect fill="currentColor"/> already worked fine in trunk, but 19 <g fill="currentColor" color="green"><rect color="red"/> procuded a red rectangle. 20 21 In order to fix to bug we have to resolve all currentColor values for SVGPaint objects, in SVGCSSStyleSelector, 22 as it's already done for SVGColor objects (stop-color, flood-color, etc.) instead of in RenderSVGResource::fill/strokePaintingResource, 23 when trying to use the paint server. The correct "color" value that should be used from the RenderStyle, is directly 24 available in CSSStyleSelector: in applyProperty m_style->color() gives the desired value. In CSSStyleSelector it's handled 25 exactly this way for non-SVG currentColor properties. Also fix computed styles, which did not resolve currentColor for SVGPaint/SVGColor. 26 27 A previous patch implemented the SVGPaint/SVGColor API. SVG demands these CSSValues to be mutable. Introduce 28 CSSMutableValue, which extends CSSValue by a Node pointer, and let SVGPaint/SVGColor inherit from it. 29 Mutating a SVGPaint/SVGColor object now takes immediate effect, which is reflected in the inline style / computed style. 30 (Note that getPresentationAttribute() already takes care of removing the CSSValue from the mapped attribute cache, so that it's no longer shared.) 31 32 Add several new tests covering the patch. 33 34 Tests: svg/W3C-SVG-1.1-SE/color-prop-05-t.svg 35 svg/animations/animate-color-fill-currentColor.html 36 svg/custom/SVGPaint-mutate-attribute.svg 37 svg/custom/SVGPaint-mutate-inline-style.svg 38 39 * GNUMakefile.am: Add CSSMutableValue.h 40 * WebCore.gypi: Ditto. 41 * WebCore.xcodeproj/project.pbxproj: Ditto. 42 * css/CSSMutableStyleDeclaration.cpp: Reset the Node pointer in all CSSMutableValues belonging to this style declaration. 43 (WebCore::CSSMutableStyleDeclaration::~CSSMutableStyleDeclaration): 44 * css/CSSMutableStyleDeclaration.h: Add destructor. 45 * css/CSSMutableValue.h: Added. 46 (WebCore::CSSMutableValue::CSSMutableValue): 47 (WebCore::CSSMutableValue::~CSSMutableValue): 48 (WebCore::CSSMutableValue::isMutableValue): 49 (WebCore::CSSMutableValue::node): 50 (WebCore::CSSMutableValue::setNode): 51 (WebCore::CSSMutableValue::setNeedsStyleRecalc): 52 * css/CSSStyleDeclaration.cpp: 53 (WebCore::CSSStyleDeclaration::getPropertyCSSValue): Set the Node object of a CSSMutableValue to the Node, this style declaration belongs to. 54 * css/CSSValue.h: 55 (WebCore::CSSValue::isMutableValue): Return false, default. 56 * css/SVGCSSComputedStyleDeclaration.cpp: 57 (WebCore::CSSComputedStyleDeclaration::adjustSVGPaintForCurrentColor): Add helper function, resolving currentColor values for SVGPaint objects. 58 (WebCore::CSSComputedStyleDeclaration::getSVGPropertyCSSValue): Use currentColorOrValidColor/adjustSVGPaintForCurrentColor to resolve SVGColor/SVGPaint values. 59 * css/SVGCSSStyleSelector.cpp: 60 (WebCore::CSSStyleSelector::applySVGProperty): Store fill/stroke uri, color, paint type seperated in SVGRenderStyle, don't store the full SVGPaint object anymore. 61 * rendering/style/SVGRenderStyle.cpp: 62 (WebCore::SVGRenderStyle::diff): Adapt to SVGPaint changes. 63 * rendering/style/SVGRenderStyle.h: Ditto. 64 (WebCore::SVGRenderStyle::initialFillOpacity): 65 (WebCore::SVGRenderStyle::initialFillPaintType): 66 (WebCore::SVGRenderStyle::initialFillPaintColor): 67 (WebCore::SVGRenderStyle::initialFillPaintUri): 68 (WebCore::SVGRenderStyle::initialStrokeOpacity): 69 (WebCore::SVGRenderStyle::initialStrokePaintType): 70 (WebCore::SVGRenderStyle::initialStrokePaintColor): 71 (WebCore::SVGRenderStyle::initialStrokePaintUri): 72 (WebCore::SVGRenderStyle::initialStrokeMiterLimit): 73 (WebCore::SVGRenderStyle::initialStopOpacity): 74 (WebCore::SVGRenderStyle::initialFloodOpacity): 75 (WebCore::SVGRenderStyle::setFillPaint): 76 (WebCore::SVGRenderStyle::setStrokePaint): 77 (WebCore::SVGRenderStyle::fillPaintType): 78 (WebCore::SVGRenderStyle::fillPaintColor): 79 (WebCore::SVGRenderStyle::fillPaintUri): 80 (WebCore::SVGRenderStyle::strokePaintType): 81 (WebCore::SVGRenderStyle::strokePaintColor): 82 (WebCore::SVGRenderStyle::strokePaintUri): 83 (WebCore::SVGRenderStyle::hasStroke): 84 (WebCore::SVGRenderStyle::hasFill): 85 * rendering/style/SVGRenderStyleDefs.cpp: Ditto. 86 (WebCore::StyleFillData::StyleFillData): 87 (WebCore::StyleFillData::operator==): 88 (WebCore::StyleStrokeData::StyleStrokeData): 89 (WebCore::StyleStrokeData::operator==): 90 * rendering/style/SVGRenderStyleDefs.h: Ditto. 91 * rendering/svg/RenderSVGResource.cpp: Ditto. 92 (WebCore::requestPaintingResource): 93 * rendering/svg/RenderSVGResourceClipper.cpp: Ditto. 94 (WebCore::RenderSVGResourceClipper::drawContentIntoMaskImage): 95 * rendering/svg/SVGResources.cpp: Ditto. 96 (WebCore::paintingResourceFromSVGPaint): 97 (WebCore::SVGResources::buildCachedResources): 98 * svg/SVGColor.cpp: Call setNeedsStyleRecalc() after mutating the object. 99 (WebCore::SVGColor::setRGBColor): 100 (WebCore::SVGColor::setRGBColorICCColor): 101 (WebCore::SVGColor::setColor): 102 * svg/SVGColor.h: 103 * svg/SVGPaint.cpp: Ditto. 104 (WebCore::SVGPaint::setUri): 105 (WebCore::SVGPaint::setPaint): 106 * svg/SVGPaint.h: 107 1 108 2011-03-01 Andrey Adaikin <aandrey@google.com> 2 109 -
trunk/Source/WebCore/GNUmakefile.am
r79983 r79985 1004 1004 Source/WebCore/css/CSSMutableStyleDeclaration.cpp \ 1005 1005 Source/WebCore/css/CSSMutableStyleDeclaration.h \ 1006 Source/WebCore/css/CSSMutableValue.h \ 1006 1007 Source/WebCore/css/CSSNamespace.h \ 1007 1008 Source/WebCore/css/CSSOMUtils.cpp \ -
trunk/Source/WebCore/WebCore.gypi
r79978 r79985 1045 1045 'css/CSSMutableStyleDeclaration.cpp', 1046 1046 'css/CSSMutableStyleDeclaration.h', 1047 'css/CSSMutableValue.h', 1047 1048 'css/CSSNamespace.h', 1048 1049 'css/CSSOMUtils.cpp', -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r79978 r79985 186 186 0897D97B0F007A4600411BB3 /* WMLMetaElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 0897D9790F007A4600411BB3 /* WMLMetaElement.h */; }; 187 187 089A8E07128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h in Headers */ = {isa = PBXBuildFile; fileRef = 089A8E06128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h */; }; 188 089F0D511316CE93005877AD /* CSSMutableValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 089F0D501316CE93005877AD /* CSSMutableValue.h */; settings = {ATTRIBUTES = (Private, ); }; }; 188 189 08A484770E5272C500C3FE76 /* ScriptElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 08A484750E5272C500C3FE76 /* ScriptElement.cpp */; }; 189 190 08A484780E5272C500C3FE76 /* ScriptElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 08A484760E5272C500C3FE76 /* ScriptElement.h */; }; … … 6473 6474 0897D9790F007A4600411BB3 /* WMLMetaElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMLMetaElement.h; sourceTree = "<group>"; }; 6474 6475 089A8E06128D8B3D00E7A534 /* SVGAnimatedPathSegListPropertyTearOff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimatedPathSegListPropertyTearOff.h; sourceTree = "<group>"; }; 6476 089F0D501316CE93005877AD /* CSSMutableValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSMutableValue.h; sourceTree = "<group>"; }; 6475 6477 08A484750E5272C500C3FE76 /* ScriptElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptElement.cpp; sourceTree = "<group>"; }; 6476 6478 08A484760E5272C500C3FE76 /* ScriptElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptElement.h; sourceTree = "<group>"; }; … … 18565 18567 A80E6DF90A199067007FB8C5 /* CSSMutableStyleDeclaration.cpp */, 18566 18568 A80E6DFA0A199067007FB8C5 /* CSSMutableStyleDeclaration.h */, 18569 089F0D501316CE93005877AD /* CSSMutableValue.h */, 18567 18570 A80E73470A199C77007FB8C5 /* CSSNamespace.h */, 18568 18571 F98FFF4211A2676200F548E8 /* CSSOMUtils.cpp */, … … 22483 22486 E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */, 22484 22487 977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */, 22488 089F0D511316CE93005877AD /* CSSMutableValue.h in Headers */, 22485 22489 ); 22486 22490 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h
r67568 r79985 23 23 24 24 #include "CSSStyleDeclaration.h" 25 #include "PlatformString.h"26 25 #include "RenderStyleConstants.h" 27 26 #include <wtf/RefPtr.h> 27 #include <wtf/text/WTFString.h> 28 28 29 29 namespace WebCore { … … 35 35 class RenderStyle; 36 36 class ShadowData; 37 class SVGPaint; 37 38 38 39 enum EUpdateLayout { DoNotUpdateLayout = false, UpdateLayout = true }; … … 77 78 PassRefPtr<CSSValue> valueForShadow(const ShadowData*, int, RenderStyle*) const; 78 79 PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle*, const Color&) const; 79 80 #if ENABLE(SVG) 81 PassRefPtr<SVGPaint> adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint>, RenderStyle*) const; 82 #endif 83 80 84 RefPtr<Node> m_node; 81 85 PseudoId m_pseudoElementSpecifier; -
trunk/Source/WebCore/css/CSSMutableStyleDeclaration.cpp
r79009 r79985 23 23 24 24 #include "CSSImageValue.h" 25 #include "CSSMutableValue.h" 25 26 #include "CSSParser.h" 26 27 #include "CSSPropertyLonghand.h" … … 92 93 } 93 94 95 CSSMutableStyleDeclaration::~CSSMutableStyleDeclaration() 96 { 97 const CSSMutableStyleDeclarationConstIterator end = this->end(); 98 for (CSSMutableStyleDeclarationConstIterator it = begin(); it != end; ++it) { 99 CSSValue* value = it->value(); 100 if (!value || !value->isMutableValue()) 101 continue; 102 static_cast<CSSMutableValue*>(value)->setNode(0); 103 } 104 } 105 94 106 CSSMutableStyleDeclaration& CSSMutableStyleDeclaration::operator=(const CSSMutableStyleDeclaration& other) 95 107 { -
trunk/Source/WebCore/css/CSSMutableStyleDeclaration.h
r76012 r79985 58 58 class CSSMutableStyleDeclaration : public CSSStyleDeclaration { 59 59 public: 60 virtual ~CSSMutableStyleDeclaration(); 61 60 62 static PassRefPtr<CSSMutableStyleDeclaration> create() 61 63 { -
trunk/Source/WebCore/css/CSSStyleDeclaration.cpp
r72116 r79985 23 23 24 24 #include "CSSMutableStyleDeclaration.h" 25 #include "CSSMutableValue.h" 25 26 #include "CSSParser.h" 26 27 #include "CSSProperty.h" 27 28 #include "CSSPropertyNames.h" 28 29 #include "CSSRule.h" 30 #include "Node.h" 31 #include "SVGElement.h" 29 32 #include <wtf/ASCIICType.h> 30 33 … … 43 46 if (!propID) 44 47 return 0; 45 return getPropertyCSSValue(propID); 48 49 // Short-cut, not involving any change to the refcount. 50 if (!isMutableStyleDeclaration()) 51 return getPropertyCSSValue(propID); 52 53 // Slow path. 54 RefPtr<CSSValue> value = getPropertyCSSValue(propID); 55 if (!value || !value->isMutableValue()) 56 return value.release(); 57 58 Node* node = static_cast<CSSMutableStyleDeclaration*>(this)->node(); 59 if (!node || !node->isStyledElement()) 60 return value.release(); 61 62 Node* associatedNode = static_cast<CSSMutableValue*>(value.get())->node(); 63 if (associatedNode) { 64 ASSERT(associatedNode == node); 65 return value.release(); 66 } 67 68 static_cast<CSSMutableValue*>(value.get())->setNode(node); 69 return value.release(); 46 70 } 47 71 -
trunk/Source/WebCore/css/CSSValue.h
r76966 r79985 51 51 void setCssText(const String&, ExceptionCode&) { } // FIXME: Not implemented. 52 52 53 virtual bool isMutableValue() const { return false; } 54 53 55 virtual bool isBorderImageValue() const { return false; } 54 56 virtual bool isCursorImageValue() const { return false; } -
trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
r67568 r79985 28 28 #include "Document.h" 29 29 #include "RenderStyle.h" 30 #include "SVGPaint.h" 30 31 31 32 namespace WebCore { … … 58 59 59 60 return list.release(); 61 } 62 63 PassRefPtr<SVGPaint> CSSComputedStyleDeclaration::adjustSVGPaintForCurrentColor(PassRefPtr<SVGPaint> newPaint, RenderStyle* style) const 64 { 65 RefPtr<SVGPaint> paint = newPaint; 66 if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) 67 paint->setColor(style->color()); 68 return paint.release(); 60 69 } 61 70 … … 128 137 return CSSPrimitiveValue::createIdentifier(CSSValueNone); 129 138 case CSSPropertyFloodColor: 130 return CSSPrimitiveValue::createColor(svgStyle->floodColor().rgb());139 return currentColorOrValidColor(style, svgStyle->floodColor()); 131 140 case CSSPropertyLightingColor: 132 return CSSPrimitiveValue::createColor(svgStyle->lightingColor().rgb());141 return currentColorOrValidColor(style, svgStyle->lightingColor()); 133 142 case CSSPropertyStopColor: 134 return CSSPrimitiveValue::createColor(svgStyle->stopColor().rgb());143 return currentColorOrValidColor(style, svgStyle->stopColor()); 135 144 case CSSPropertyFill: 136 return svgStyle->fillPaint();145 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->fillPaintType(), svgStyle->fillPaintUri(), svgStyle->fillPaintColor()), style); 137 146 case CSSPropertyKerning: 138 147 return SVGLength::toCSSPrimitiveValue(svgStyle->kerning()); … … 150 159 return CSSPrimitiveValue::createIdentifier(CSSValueNone); 151 160 case CSSPropertyStroke: 152 return svgStyle->strokePaint();161 return adjustSVGPaintForCurrentColor(SVGPaint::create(svgStyle->strokePaintType(), svgStyle->strokePaintUri(), svgStyle->strokePaintColor()), style); 153 162 case CSSPropertyStrokeDasharray: 154 163 return strokeDashArrayToCSSValueList(svgStyle->strokeDashArray()); -
trunk/Source/WebCore/css/SVGCSSStyleSelector.cpp
r74538 r79985 232 232 case CSSPropertyFill: 233 233 { 234 HANDLE_INHERIT_AND_INITIAL(fillPaint, FillPaint) 235 if (value->isSVGPaint()) 236 svgstyle->setFillPaint(static_cast<SVGPaint*>(value)); 234 if (isInherit) { 235 const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); 236 svgstyle->setFillPaint(svgParentStyle->fillPaintType(), svgParentStyle->fillPaintColor(), svgParentStyle->fillPaintUri()); 237 return; 238 } 239 if (isInitial) { 240 svgstyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri()); 241 return; 242 } 243 if (value->isSVGPaint()) { 244 SVGPaint* svgPaint = static_cast<SVGPaint*>(value); 245 svgstyle->setFillPaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri()); 246 } 237 247 break; 238 248 } 239 249 case CSSPropertyStroke: 240 250 { 241 HANDLE_INHERIT_AND_INITIAL(strokePaint, StrokePaint) 242 if (value->isSVGPaint()) 243 svgstyle->setStrokePaint(static_cast<SVGPaint*>(value)); 244 251 if (isInherit) { 252 const SVGRenderStyle* svgParentStyle = m_parentStyle->svgStyle(); 253 svgstyle->setStrokePaint(svgParentStyle->strokePaintType(), svgParentStyle->strokePaintColor(), svgParentStyle->strokePaintUri()); 254 return; 255 } 256 if (isInitial) { 257 svgstyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri()); 258 return; 259 } 260 if (value->isSVGPaint()) { 261 SVGPaint* svgPaint = static_cast<SVGPaint*>(value); 262 svgstyle->setStrokePaint(svgPaint->paintType(), colorFromSVGColorCSSValue(svgPaint, m_style->color()), svgPaint->uri()); 263 } 245 264 break; 246 265 } -
trunk/Source/WebCore/rendering/style/SVGRenderStyle.cpp
r69279 r79985 170 170 if (stroke != other->stroke) { 171 171 if (stroke->width != other->stroke->width 172 || stroke->paint != other->stroke->paint 172 || stroke->paintType != other->stroke->paintType 173 || stroke->paintColor != other->stroke->paintColor 174 || stroke->paintUri != other->stroke->paintUri 173 175 || stroke->miterLimit != other->stroke->miterLimit 174 176 || stroke->dashArray != other->stroke->dashArray … … 192 194 193 195 // If fill changes, we just need to repaint. Fill boundaries are not influenced by this, only by the Path, that RenderSVGPath contains. 194 if (fill != other->fill)196 if (fill->paintType != other->fill->paintType || fill->paintColor != other->fill->paintColor || fill->paintUri != other->fill->paintUri) 195 197 return StyleDifferenceRepaint; 196 198 -
trunk/Source/WebCore/rendering/style/SVGRenderStyle.h
r71014 r79985 71 71 static EGlyphOrientation initialGlyphOrientationHorizontal() { return GO_0DEG; } 72 72 static EGlyphOrientation initialGlyphOrientationVertical() { return GO_AUTO; } 73 static float initialFillOpacity() { return 1.0f; } 74 static SVGPaint* initialFillPaint() { return SVGPaint::defaultFill(); } 75 static float initialStrokeOpacity() { return 1.0f; } 76 static SVGPaint* initialStrokePaint() { return SVGPaint::defaultStroke(); } 73 static float initialFillOpacity() { return 1; } 74 static SVGPaint::SVGPaintType initialFillPaintType() { return SVGPaint::SVG_PAINTTYPE_RGBCOLOR; } 75 static Color initialFillPaintColor() { return Color::black; } 76 static String initialFillPaintUri() { return String(); } 77 static float initialStrokeOpacity() { return 1; } 78 static SVGPaint::SVGPaintType initialStrokePaintType() { return SVGPaint::SVG_PAINTTYPE_NONE; } 79 static Color initialStrokePaintColor() { return Color(); } 80 static String initialStrokePaintUri() { return String(); } 77 81 static Vector<SVGLength> initialStrokeDashArray() { return Vector<SVGLength>(); } 78 static float initialStrokeMiterLimit() { return 4 .0f; }79 static float initialStopOpacity() { return 1 .0f; }82 static float initialStrokeMiterLimit() { return 4; } 83 static float initialStopOpacity() { return 1; } 80 84 static Color initialStopColor() { return Color(0, 0, 0); } 81 static float initialFloodOpacity() { return 1 .0f; }85 static float initialFloodOpacity() { return 1; } 82 86 static Color initialFloodColor() { return Color(0, 0, 0); } 83 87 static Color initialLightingColor() { return Color(255, 255, 255); } … … 151 155 } 152 156 153 void setFillPaint(PassRefPtr<SVGPaint> obj) 154 { 155 if (!(fill->paint == obj)) 156 fill.access()->paint = obj; 157 void setFillPaint(SVGPaint::SVGPaintType type, const Color& color, const String& uri) 158 { 159 if (!(fill->paintType == type)) 160 fill.access()->paintType = type; 161 if (!(fill->paintColor == color)) 162 fill.access()->paintColor = color; 163 if (!(fill->paintUri == uri)) 164 fill.access()->paintUri = uri; 157 165 } 158 166 … … 163 171 } 164 172 165 void setStrokePaint(PassRefPtr<SVGPaint> obj) 166 { 167 if (!(stroke->paint == obj)) 168 stroke.access()->paint = obj; 173 void setStrokePaint(SVGPaint::SVGPaintType type, const Color& color, const String& uri) 174 { 175 if (!(stroke->paintType == type)) 176 stroke.access()->paintType = type; 177 if (!(stroke->paintColor == color)) 178 stroke.access()->paintColor = color; 179 if (!(stroke->paintUri == uri)) 180 stroke.access()->paintUri = uri; 169 181 } 170 182 … … 294 306 EGlyphOrientation glyphOrientationVertical() const { return (EGlyphOrientation) svg_inherited_flags._glyphOrientationVertical; } 295 307 float fillOpacity() const { return fill->opacity; } 296 SVGPaint* fillPaint() const { return fill->paint.get(); } 308 const SVGPaint::SVGPaintType& fillPaintType() const { return fill->paintType; } 309 const Color& fillPaintColor() const { return fill->paintColor; } 310 const String& fillPaintUri() const { return fill->paintUri; } 297 311 float strokeOpacity() const { return stroke->opacity; } 298 SVGPaint* strokePaint() const { return stroke->paint.get(); } 312 const SVGPaint::SVGPaintType& strokePaintType() const { return stroke->paintType; } 313 const Color& strokePaintColor() const { return stroke->paintColor; } 314 const String& strokePaintUri() const { return stroke->paintUri; } 299 315 Vector<SVGLength> strokeDashArray() const { return stroke->dashArray; } 300 316 float strokeMiterLimit() const { return stroke->miterLimit; } … … 321 337 bool hasFilter() const { return !filterResource().isEmpty(); } 322 338 bool hasMarkers() const { return !markerStartResource().isEmpty() || !markerMidResource().isEmpty() || !markerEndResource().isEmpty(); } 323 bool hasStroke() const { return strokePaint ()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; }324 bool hasFill() const { return fillPaint ()->paintType() != SVGPaint::SVG_PAINTTYPE_NONE; }339 bool hasStroke() const { return strokePaintType() != SVGPaint::SVG_PAINTTYPE_NONE; } 340 bool hasFill() const { return fillPaintType() != SVGPaint::SVG_PAINTTYPE_NONE; } 325 341 bool isVerticalWritingMode() const { return writingMode() == WM_TBRL || writingMode() == WM_TB; } 326 342 -
trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.cpp
r64830 r79985 38 38 StyleFillData::StyleFillData() 39 39 : opacity(SVGRenderStyle::initialFillOpacity()) 40 , paint(SVGRenderStyle::initialFillPaint()) 40 , paintType(SVGRenderStyle::initialFillPaintType()) 41 , paintColor(SVGRenderStyle::initialFillPaintColor()) 42 , paintUri(SVGRenderStyle::initialFillPaintUri()) 41 43 { 42 44 } … … 45 47 : RefCounted<StyleFillData>() 46 48 , opacity(other.opacity) 47 , paint(other.paint) 49 , paintType(other.paintType) 50 , paintColor(other.paintColor) 51 , paintUri(other.paintUri) 48 52 { 49 53 } … … 51 55 bool StyleFillData::operator==(const StyleFillData& other) const 52 56 { 53 if (opacity != other.opacity) 54 return false; 55 56 if (!paint || !other.paint) 57 return paint == other.paint; 58 59 if (paint->paintType() != other.paint->paintType()) 60 return false; 61 62 if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_URI) 63 return paint->uri() == other.paint->uri(); 64 65 if (paint->paintType() == SVGPaint::SVG_PAINTTYPE_RGBCOLOR) 66 return paint->color() == other.paint->color(); 67 68 return paint == other.paint; 57 return opacity == other.opacity 58 && paintType == other.paintType 59 && paintColor == other.paintColor 60 && paintUri == other.paintUri; 69 61 } 70 62 … … 75 67 , dashOffset(SVGRenderStyle::initialStrokeDashOffset()) 76 68 , dashArray(SVGRenderStyle::initialStrokeDashArray()) 77 , paint(SVGRenderStyle::initialStrokePaint()) 69 , paintType(SVGRenderStyle::initialStrokePaintType()) 70 , paintColor(SVGRenderStyle::initialStrokePaintColor()) 71 , paintUri(SVGRenderStyle::initialStrokePaintUri()) 78 72 { 79 73 } … … 86 80 , dashOffset(other.dashOffset) 87 81 , dashArray(other.dashArray) 88 , paint(other.paint) 82 , paintType(other.paintType) 83 , paintColor(other.paintColor) 84 , paintUri(other.paintUri) 89 85 { 90 86 } … … 92 88 bool StyleStrokeData::operator==(const StyleStrokeData& other) const 93 89 { 94 return paint == other.paint 95 && width == other.width 90 return width == other.width 96 91 && opacity == other.opacity 97 92 && miterLimit == other.miterLimit 98 93 && dashOffset == other.dashOffset 99 && dashArray == other.dashArray; 94 && dashArray == other.dashArray 95 && paintType == other.paintType 96 && paintColor == other.paintColor 97 && paintUri == other.paintUri; 100 98 } 101 99 -
trunk/Source/WebCore/rendering/style/SVGRenderStyleDefs.h
r69220 r79985 30 30 31 31 #if ENABLE(SVG) 32 #include "Color.h"33 #include "PlatformString.h"34 32 #include "SVGLength.h" 33 #include "SVGPaint.h" 35 34 #include "ShadowData.h" 36 35 #include <wtf/OwnPtr.h> … … 99 98 static PassRefPtr<StyleFillData> create() { return adoptRef(new StyleFillData); } 100 99 PassRefPtr<StyleFillData> copy() const { return adoptRef(new StyleFillData(*this)); } 101 100 102 101 bool operator==(const StyleFillData&) const; 103 102 bool operator!=(const StyleFillData& other) const … … 107 106 108 107 float opacity; 109 RefPtr<SVGPaint> paint; 108 SVGPaint::SVGPaintType paintType; 109 Color paintColor; 110 String paintUri; 110 111 111 112 private: … … 132 133 Vector<SVGLength> dashArray; 133 134 134 RefPtr<SVGPaint> paint; 135 SVGPaint::SVGPaintType paintType; 136 Color paintColor; 137 String paintUri; 135 138 136 139 private: … … 263 266 264 267 #endif // ENABLE(SVG) 265 266 268 #endif // SVGRenderStyleDefs_h -
trunk/Source/WebCore/rendering/svg/RenderSVGResource.cpp
r75350 r79985 52 52 } 53 53 54 SVGPaint* paint = mode == ApplyToFillMode ? svgStyle->fillPaint() : svgStyle->strokePaint(); 55 ASSERT(paint); 56 57 SVGPaint::SVGPaintType paintType = paint->paintType(); 54 bool applyToFill = mode == ApplyToFillMode; 55 SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle->strokePaintType(); 58 56 if (paintType == SVGPaint::SVG_PAINTTYPE_NONE) 59 57 return 0; 60 58 61 59 Color color; 62 if (paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR 63 || paintType == SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR 64 || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR 65 || paintType == SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR) 66 color = paint->color(); 67 else if (paintType == SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR || paintType == SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR) 68 color = style->visitedDependentColor(CSSPropertyColor); 60 switch (paintType) { 61 case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR: 62 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR: 63 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 64 case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR: 65 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR: 66 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 67 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaintColor(); 68 default: 69 break; 70 } 69 71 70 72 if (style->insideLink() == InsideVisitedLink) { … … 72 74 ASSERT(visitedStyle); 73 75 74 if (SVGPaint* visitedPaint = mode == ApplyToFillMode ? visitedStyle->svgStyle()->fillPaint() : visitedStyle->svgStyle()->strokePaint()) { 75 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visitedColor'. 76 if (visitedPaint->paintType() < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaint->paintType() != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { 77 const Color& visitedColor = visitedPaint->color(); 78 if (visitedColor.isValid()) 79 color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha()); 80 } 76 const SVGRenderStyle* svgVisitedStyle = visitedStyle->svgStyle(); 77 SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgVisitedStyle->fillPaintType() : svgVisitedStyle->strokePaintType(); 78 79 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visitedColor'. 80 if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintType != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { 81 const Color& visitedColor = applyToFill ? svgVisitedStyle->fillPaintColor() : svgVisitedStyle->strokePaintColor(); 82 if (visitedColor.isValid()) 83 color = Color(visitedColor.red(), visitedColor.green(), visitedColor.blue(), color.alpha()); 81 84 } 82 85 } -
trunk/Source/WebCore/rendering/svg/RenderSVGResourceClipper.cpp
r75350 r79985 255 255 RefPtr<RenderStyle> newRenderStyle = RenderStyle::clone(oldRenderStyle.get()); 256 256 SVGRenderStyle* svgStyle = newRenderStyle.get()->accessSVGStyle(); 257 svgStyle->setFillPaint(SVG Paint::defaultFill());258 svgStyle->setStrokePaint(SVG Paint::defaultStroke());257 svgStyle->setFillPaint(SVGRenderStyle::initialFillPaintType(), SVGRenderStyle::initialFillPaintColor(), SVGRenderStyle::initialFillPaintUri()); 258 svgStyle->setStrokePaint(SVGRenderStyle::initialStrokePaintType(), SVGRenderStyle::initialStrokePaintColor(), SVGRenderStyle::initialStrokePaintUri()); 259 259 svgStyle->setFillRule(newClipRule); 260 260 newRenderStyle.get()->setOpacity(1.0f); -
trunk/Source/WebCore/rendering/svg/SVGResources.cpp
r75350 r79985 153 153 } 154 154 155 static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, SVGPaint* paint, AtomicString& id, bool& hasPendingResource) 156 { 157 ASSERT(paint); 158 159 SVGPaint::SVGPaintType paintType = paint->paintType(); 155 static inline RenderSVGResourceContainer* paintingResourceFromSVGPaint(Document* document, const SVGPaint::SVGPaintType& paintType, const String& paintUri, AtomicString& id, bool& hasPendingResource) 156 { 160 157 if (paintType != SVGPaint::SVG_PAINTTYPE_URI && paintType != SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR) 161 158 return 0; 162 159 163 id = SVGURIReference::getTarget(paint ->uri());160 id = SVGURIReference::getTarget(paintUri); 164 161 RenderSVGResourceContainer* container = getRenderSVGResourceContainerById(document, id); 165 162 if (!container) { … … 260 257 bool hasPendingResource = false; 261 258 AtomicString id; 262 if (setFill(paintingResourceFromSVGPaint(document, style->fillPaint (), id, hasPendingResource)))259 if (setFill(paintingResourceFromSVGPaint(document, style->fillPaintType(), style->fillPaintUri(), id, hasPendingResource))) 263 260 foundResources = true; 264 261 else if (hasPendingResource) … … 269 266 bool hasPendingResource = false; 270 267 AtomicString id; 271 if (setStroke(paintingResourceFromSVGPaint(document, style->strokePaint (), id, hasPendingResource)))268 if (setStroke(paintingResourceFromSVGPaint(document, style->strokePaintType(), style->strokePaintUri(), id, hasPendingResource))) 272 269 foundResources = true; 273 270 else if (hasPendingResource) -
trunk/Source/WebCore/svg/SVGColor.cpp
r79675 r79985 51 51 m_color = color; 52 52 m_colorType = SVG_COLORTYPE_RGBCOLOR; 53 // FIXME: A follow up patch will call valueChanged() here.53 setNeedsStyleRecalc(); 54 54 } 55 55 … … 76 76 77 77 m_colorType = SVG_COLORTYPE_RGBCOLOR_ICCCOLOR; 78 // FIXME: A follow up patch will call valueChanged() here.78 setNeedsStyleRecalc(); 79 79 } 80 80 … … 116 116 } 117 117 118 // FIXME: A follow up patch will call valueChanged() here.118 setNeedsStyleRecalc(); 119 119 m_colorType = type; 120 120 if (!requiresRGBColor) { -
trunk/Source/WebCore/svg/SVGColor.h
r79675 r79985 24 24 25 25 #if ENABLE(SVG) 26 #include "CSS Value.h"26 #include "CSSMutableValue.h" 27 27 #include "Color.h" 28 28 #include <wtf/PassRefPtr.h> … … 32 32 class RGBColor; 33 33 34 class SVGColor : public CSS Value {34 class SVGColor : public CSSMutableValue { 35 35 public: 36 36 enum SVGColorType { -
trunk/Source/WebCore/svg/SVGPaint.cpp
r79675 r79985 68 68 setColor(Color()); 69 69 setColorType(colorTypeForPaintType(m_paintType)); 70 // FIXME: A follow up patch will call valueChanged() here. 71 } 72 73 SVGPaint* SVGPaint::defaultFill() 74 { 75 static SVGPaint* staticDefaultFill = createColor(Color::black).releaseRef(); 76 return staticDefaultFill; 77 } 78 79 SVGPaint* SVGPaint::defaultStroke() 80 { 81 static SVGPaint* staticDefaultStroke = createNone().releaseRef(); 82 return staticDefaultStroke; 70 setNeedsStyleRecalc(); 83 71 } 84 72 … … 133 121 m_paintType = type; 134 122 m_uri = requiresURI ? uri : String(); 135 // FIXME: A follow up patch will call valueChanged() here.123 setNeedsStyleRecalc(); 136 124 } 137 125 -
trunk/Source/WebCore/svg/SVGPaint.h
r79675 r79985 88 88 bool matchesTargetURI(const String& referenceId); 89 89 90 static SVGPaint* defaultFill();91 static SVGPaint* defaultStroke();92 93 90 private: 94 91 friend class CSSComputedStyleDeclaration;
Note: See TracChangeset
for help on using the changeset viewer.