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

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

Issue 361543002: Remove SVGPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch for landing Created 6 years, 5 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
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 22 matching lines...) Expand all
33 #include "core/rendering/svg/SVGResources.h" 33 #include "core/rendering/svg/SVGResources.h"
34 #include "core/rendering/svg/SVGResourcesCache.h" 34 #include "core/rendering/svg/SVGResourcesCache.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 static inline bool inheritColorFromParentStyle(RenderObject* object, bool applyT oFill, Color& color) 38 static inline bool inheritColorFromParentStyle(RenderObject* object, bool applyT oFill, Color& color)
39 { 39 {
40 if (!object->parent() || !object->parent()->style()) 40 if (!object->parent() || !object->parent()->style())
41 return false; 41 return false;
42 const SVGRenderStyle* parentSVGStyle = object->parent()->style()->svgStyle() ; 42 const SVGRenderStyle* parentSVGStyle = object->parent()->style()->svgStyle() ;
43 SVGPaint::SVGPaintType paintType = applyToFill ? parentSVGStyle->fillPaintTy pe() : parentSVGStyle->strokePaintType(); 43 SVGPaintType paintType = applyToFill ? parentSVGStyle->fillPaintType() : par entSVGStyle->strokePaintType();
44 if (paintType != SVGPaint::SVG_PAINTTYPE_RGBCOLOR && paintType != SVGPaint:: SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR) 44 if (paintType != SVG_PAINTTYPE_RGBCOLOR && paintType != SVG_PAINTTYPE_RGBCOL OR_ICCCOLOR)
45 return false; 45 return false;
46 color = applyToFill ? parentSVGStyle->fillPaintColor() : parentSVGStyle->str okePaintColor(); 46 color = applyToFill ? parentSVGStyle->fillPaintColor() : parentSVGStyle->str okePaintColor();
47 return true; 47 return true;
48 } 48 }
49 49
50 static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode m ode, RenderObject* object, const RenderStyle* style, bool& hasFallback) 50 static inline RenderSVGResource* requestPaintingResource(RenderSVGResourceMode m ode, RenderObject* object, const RenderStyle* style, bool& hasFallback)
51 { 51 {
52 ASSERT(object); 52 ASSERT(object);
53 ASSERT(style); 53 ASSERT(style);
54 54
(...skipping 18 matching lines...) Expand all
73 } 73 }
74 74
75 if (!svgStyle->hasFill()) 75 if (!svgStyle->hasFill())
76 return 0; 76 return 0;
77 } else { 77 } else {
78 if (!svgStyle->hasStroke() || isRenderingMask) 78 if (!svgStyle->hasStroke() || isRenderingMask)
79 return 0; 79 return 0;
80 } 80 }
81 81
82 bool applyToFill = mode == ApplyToFillMode; 82 bool applyToFill = mode == ApplyToFillMode;
83 SVGPaint::SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle->strokePaintType(); 83 SVGPaintType paintType = applyToFill ? svgStyle->fillPaintType() : svgStyle- >strokePaintType();
84 ASSERT(paintType != SVGPaint::SVG_PAINTTYPE_NONE); 84 ASSERT(paintType != SVG_PAINTTYPE_NONE);
85 85
86 Color color; 86 Color color;
87 bool hasColor = false; 87 bool hasColor = false;
88 switch (paintType) { 88 switch (paintType) {
89 case SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR: 89 case SVG_PAINTTYPE_CURRENTCOLOR:
90 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR: 90 case SVG_PAINTTYPE_RGBCOLOR:
91 case SVGPaint::SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR: 91 case SVG_PAINTTYPE_RGBCOLOR_ICCCOLOR:
92 case SVGPaint::SVG_PAINTTYPE_URI_CURRENTCOLOR: 92 case SVG_PAINTTYPE_URI_CURRENTCOLOR:
93 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR: 93 case SVG_PAINTTYPE_URI_RGBCOLOR:
94 case SVGPaint::SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR: 94 case SVG_PAINTTYPE_URI_RGBCOLOR_ICCCOLOR:
95 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaint Color(); 95 color = applyToFill ? svgStyle->fillPaintColor() : svgStyle->strokePaint Color();
96 hasColor = true; 96 hasColor = true;
97 default: 97 default:
98 break; 98 break;
99 } 99 }
100 100
101 if (style->insideLink() == InsideVisitedLink) { 101 if (style->insideLink() == InsideVisitedLink) {
102 // FIXME: This code doesn't support the uri component of the visited lin k paint, https://bugs.webkit.org/show_bug.cgi?id=70006 102 // FIXME: This code doesn't support the uri component of the visited lin k paint, https://bugs.webkit.org/show_bug.cgi?id=70006
103 SVGPaint::SVGPaintType visitedPaintType = applyToFill ? svgStyle->visite dLinkFillPaintType() : svgStyle->visitedLinkStrokePaintType(); 103 SVGPaintType visitedPaintType = applyToFill ? svgStyle->visitedLinkFillP aintType() : svgStyle->visitedLinkStrokePaintType();
104 104
105 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visited Color'. 105 // For SVG_PAINTTYPE_CURRENTCOLOR, 'color' already contains the 'visited Color'.
106 if (visitedPaintType < SVGPaint::SVG_PAINTTYPE_URI_NONE && visitedPaintT ype != SVGPaint::SVG_PAINTTYPE_CURRENTCOLOR) { 106 if (visitedPaintType < SVG_PAINTTYPE_URI_NONE && visitedPaintType != SVG _PAINTTYPE_CURRENTCOLOR) {
107 const Color& visitedColor = applyToFill ? svgStyle->visitedLinkFillP aintColor() : svgStyle->visitedLinkStrokePaintColor(); 107 const Color& visitedColor = applyToFill ? svgStyle->visitedLinkFillP aintColor() : svgStyle->visitedLinkStrokePaintColor();
108 color = Color(visitedColor.red(), visitedColor.green(), visitedColor .blue(), color.alpha()); 108 color = Color(visitedColor.red(), visitedColor.green(), visitedColor .blue(), color.alpha());
109 hasColor = true; 109 hasColor = true;
110 } 110 }
111 } 111 }
112 112
113 // If the primary resource is just a color, return immediately. 113 // If the primary resource is just a color, return immediately.
114 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP aintingResource(); 114 RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidP aintingResource();
115 if (paintType < SVGPaint::SVG_PAINTTYPE_URI_NONE) { 115 if (paintType < SVG_PAINTTYPE_URI_NONE) {
116 if (!hasColor && !inheritColorFromParentStyle(object, applyToFill, color )) 116 if (!hasColor && !inheritColorFromParentStyle(object, applyToFill, color ))
117 return 0; 117 return 0;
118 118
119 colorResource->setColor(color); 119 colorResource->setColor(color);
120 return colorResource; 120 return colorResource;
121 } 121 }
122 122
123 // If no resources are associated with the given renderer, return the color resource. 123 // If no resources are associated with the given renderer, return the color resource.
124 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( object); 124 SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObject( object);
125 if (!resources) { 125 if (!resources) {
126 if (paintType == SVGPaint::SVG_PAINTTYPE_URI_NONE || (!hasColor && !inhe ritColorFromParentStyle(object, applyToFill, color))) 126 if (paintType == SVG_PAINTTYPE_URI_NONE || (!hasColor && !inheritColorFr omParentStyle(object, applyToFill, color)))
127 return 0; 127 return 0;
128 128
129 colorResource->setColor(color); 129 colorResource->setColor(color);
130 return colorResource; 130 return colorResource;
131 } 131 }
132 132
133 // If the requested resource is not available, return the color resource. 133 // If the requested resource is not available, return the color resource.
134 RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke(); 134 RenderSVGResource* uriResource = mode == ApplyToFillMode ? resources->fill() : resources->stroke();
135 if (!uriResource) { 135 if (!uriResource) {
136 if (!hasColor && !inheritColorFromParentStyle(object, applyToFill, color )) 136 if (!hasColor && !inheritColorFromParentStyle(object, applyToFill, color ))
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 // This will process the rest of the ancestors. 227 // This will process the rest of the ancestors.
228 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); 228 toRenderSVGResourceContainer(current)->removeAllClientsFromCache();
229 break; 229 break;
230 } 230 }
231 231
232 current = current->parent(); 232 current = current->parent();
233 } 233 }
234 } 234 }
235 235
236 } 236 }
OLDNEW
« no previous file with comments | « Source/core/rendering/style/SVGRenderStyleDefs.h ('k') | Source/core/rendering/svg/SVGResources.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698