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

Side by Side Diff: Source/core/rendering/svg/RenderSVGResource.cpp

Issue 23581008: Revert r154797: "Move isValid/isCurrentColor from Color to StyleColor" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2006 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2007 Rob Buis <buis@kde.org>
4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> 4 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org>
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 16 matching lines...) Expand all
27 #include "core/page/FrameView.h" 27 #include "core/page/FrameView.h"
28 #include "core/rendering/svg/RenderSVGResourceClipper.h" 28 #include "core/rendering/svg/RenderSVGResourceClipper.h"
29 #include "core/rendering/svg/RenderSVGResourceFilter.h" 29 #include "core/rendering/svg/RenderSVGResourceFilter.h"
30 #include "core/rendering/svg/RenderSVGResourceMasker.h" 30 #include "core/rendering/svg/RenderSVGResourceMasker.h"
31 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" 31 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
32 #include "core/rendering/svg/SVGResources.h" 32 #include "core/rendering/svg/SVGResources.h"
33 #include "core/rendering/svg/SVGResourcesCache.h" 33 #include "core/rendering/svg/SVGResourcesCache.h"
34 34
35 namespace WebCore { 35 namespace WebCore {
36 36
37 static inline bool inheritColorFromParentStyleIfNeeded(RenderObject* object, boo l applyToFill, StyleColor& color) 37 static inline bool inheritColorFromParentStyleIfNeeded(RenderObject* object, boo l applyToFill, Color& color)
38 { 38 {
39 if (color.isValid()) 39 if (color.isValid())
40 return true; 40 return true;
41 if (!object->parent() || !object->parent()->style()) 41 if (!object->parent() || !object->parent()->style())
42 return false; 42 return false;
43 const SVGRenderStyle* parentSVGStyle = object->parent()->style()->svgStyle() ; 43 const SVGRenderStyle* parentSVGStyle = object->parent()->style()->svgStyle() ;
44 color = applyToFill ? parentSVGStyle->fillPaintColor() : parentSVGStyle->str okePaintColor(); 44 color = applyToFill ? parentSVGStyle->fillPaintColor() : parentSVGStyle->str okePaintColor();
45 return true; 45 return true;
46 } 46 }
47 47
48 static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode m ode, RenderObject* object, const RenderStyle* style, StyleColor& fallbackColor) 48 static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode m ode, RenderObject* object, const RenderStyle* style, Color& fallbackColor)
49 { 49 {
50 ASSERT(object); 50 ASSERT(object);
51 ASSERT(style); 51 ASSERT(style);
52 52
53 // If we have no style at all, ignore it. 53 // If we have no style at all, ignore it.
54 const SVGRenderStyle* svgStyle = style->svgStyle(); 54 const SVGRenderStyle* svgStyle = style->svgStyle();
55 if (!svgStyle) 55 if (!svgStyle)
56 return 0; 56 return 0;
57 57
58 bool isRenderingMask = false; 58 bool isRenderingMask = false;
(...skipping 14 matching lines...) Expand all
73 } else { 73 } else {
74 if (!svgStyle->hasStroke() || isRenderingMask) 74 if (!svgStyle->hasStroke() || isRenderingMask)
75 return 0; 75 return 0;
76 } 76 }
77 77
78 bool applyToFill = mode == ApplyToFillMode; 78 bool applyToFill = mode == ApplyToFillMode;
79 SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle->strokePaintType(); 79 SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle->strokePaintType();
80 if (paintType == SVGPaint::SVG_PAINTTYPE_NONE) 80 if (paintType == SVGPaint::SVG_PAINTTYPE_NONE)
81 return 0; 81 return 0;
82 82
83 StyleColor color; 83 Color color;
84 switch (paintType) { 84 switch (paintType) {
85 case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR: 85 case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR:
86 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR: 86 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR:
87 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 87 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
88 case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR: 88 case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR:
89 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR: 89 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR:
90 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 90 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
91 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaint Color(); 91 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaint Color();
92 default: 92 default:
93 break; 93 break;
94 } 94 }
95 95
96 if (style->insideLink() == InsideVisitedLink) { 96 if (style->insideLink() == InsideVisitedLink) {
97 // FIXME: This code doesn't support the uri component of the visited lin k paint, https://bugs.webkit.org/show_bug.cgi?id=70006 97 // FIXME: This code doesn't support the uri component of the visited lin k paint, https://bugs.webkit.org/show_bug.cgi?id=70006
98 SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgStyle->visite dLinkFillPaintType() : svgStyle->visitedLinkStrokePaintType(); 98 SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgStyle->visite dLinkFillPaintType() : svgStyle->visitedLinkStrokePaintType();
99 99
100 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visited Color'. 100 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visited Color'.
101 if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintT ype != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { 101 if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintT ype != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) {
102 const Color& visitedColor = applyToFill ? svgStyle->visitedLinkFillP aintColor() : svgStyle->visitedLinkStrokePaintColor(); 102 const Color& visitedColor = applyToFill ? svgStyle->visitedLinkFillP aintColor() : svgStyle->visitedLinkStrokePaintColor();
103 color = Color(visitedColor.red(), visitedColor.green(), visitedColor .blue(), color.alpha()); 103 if (visitedColor.isValid())
104 color = Color(visitedColor.red(), visitedColor.green(), visitedC olor.blue(), color.alpha());
104 } 105 }
105 } 106 }
106 107
107 // If the primary resource is just a color, return immediately. 108 // If the primary resource is just a color, return immediately.
108 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP aintingResource(); 109 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP aintingResource();
109 if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) { 110 if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) {
110 if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color)) 111 if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
111 return 0; 112 return 0;
112 113
113 colorResource->setColor(color.color()); 114 colorResource->setColor(color);
114 return colorResource; 115 return colorResource;
115 } 116 }
116 117
117 // If no resources are associated with the given renderer, return the color resource. 118 // If no resources are associated with the given renderer, return the color resource.
118 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( object); 119 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( object);
119 if (!resources) { 120 if (!resources) {
120 if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || !inheritColorFromPa rentStyleIfNeeded(object, applyToFill, color)) 121 if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || !inheritColorFromPa rentStyleIfNeeded(object, applyToFill, color))
121 return 0; 122 return 0;
122 123
123 colorResource->setColor(color.color()); 124 colorResource->setColor(color);
124 return colorResource; 125 return colorResource;
125 } 126 }
126 127
127 // If the requested resource is not available, return the color resource. 128 // If the requested resource is not available, return the color resource.
128 RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke(); 129 RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke();
129 if (!uriResource) { 130 if (!uriResource) {
130 if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color)) 131 if (!inheritColorFromParentStyleIfNeeded(object, applyToFill, color))
131 return 0; 132 return 0;
132 133
133 colorResource->setColor(color.color()); 134 colorResource->setColor(color);
134 return colorResource; 135 return colorResource;
135 } 136 }
136 137
137 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller 138 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller
138 // so it can use the solid color painting resource, if applyResource() on th e URI resource failed. 139 // so it can use the solid color painting resource, if applyResource() on th e URI resource failed.
139 fallbackColor = color; 140 fallbackColor = color;
140 return uriResource; 141 return uriResource;
141 } 142 }
142 143
143 RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderObject* object, const RenderStyle* style, StyleColor& fallbackColor) 144 RenderSVGResource* RenderSVGResource::fillPaintingResource(RenderObject* object, const RenderStyle* style, Color& fallbackColor)
144 { 145 {
145 return requestPaintingResource(ApplyToFillMode, object, style, fallbackColor ); 146 return requestPaintingResource(ApplyToFillMode, object, style, fallbackColor );
146 } 147 }
147 148
148 RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderObject* objec t, const RenderStyle* style, StyleColor& fallbackColor) 149 RenderSVGResource* RenderSVGResource::strokePaintingResource(RenderObject* objec t, const RenderStyle* style, Color& fallbackColor)
149 { 150 {
150 return requestPaintingResource(ApplyToStrokeMode, object, style, fallbackCol or); 151 return requestPaintingResource(ApplyToStrokeMode, object, style, fallbackCol or);
151 } 152 }
152 153
153 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource() 154 RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
154 { 155 {
155 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0; 156 static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0;
156 if (!s_sharedSolidPaintingResource) 157 if (!s_sharedSolidPaintingResource)
157 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor; 158 s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor;
158 return s_sharedSolidPaintingResource; 159 return s_sharedSolidPaintingResource;
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // This will process the rest of the ancestors. 204 // This will process the rest of the ancestors.
204 current->toRenderSVGResourceContainer()->removeAllClientsFromCache() ; 205 current->toRenderSVGResourceContainer()->removeAllClientsFromCache() ;
205 break; 206 break;
206 } 207 }
207 208
208 current = current->parent(); 209 current = current->parent();
209 } 210 }
210 } 211 }
211 212
212 } 213 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698