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

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

Issue 593173002: Change SVG paint server fallback for a non-existent URL (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Adjust tests. Created 6 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
« no previous file with comments | « LayoutTests/svg/hixie/error/003-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 17 matching lines...) Expand all
28 #include "core/frame/LocalFrame.h" 28 #include "core/frame/LocalFrame.h"
29 #include "core/rendering/svg/RenderSVGResourceClipper.h" 29 #include "core/rendering/svg/RenderSVGResourceClipper.h"
30 #include "core/rendering/svg/RenderSVGResourceFilter.h" 30 #include "core/rendering/svg/RenderSVGResourceFilter.h"
31 #include "core/rendering/svg/RenderSVGResourceMasker.h" 31 #include "core/rendering/svg/RenderSVGResourceMasker.h"
32 #include "core/rendering/svg/RenderSVGResourceSolidColor.h" 32 #include "core/rendering/svg/RenderSVGResourceSolidColor.h"
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 blink { 36 namespace blink {
37 37
38 static inline bool inheritColorFromParentStyle(RenderObject* object, bool applyT oFill, Color& color)
39 {
40 if (!object->parent() || !object->parent()->style())
41 return false;
42 const SVGRenderStyle& parentSVGStyle = object->parent()->style()->svgStyle() ;
43 SVGPaintType paintType = applyToFill ? parentSVGStyle.fillPaintType() : pare ntSVGStyle.strokePaintType();
44 if (paintType != SVG_PAINTTYPE_RGBCOLOR)
45 return false;
46 color = applyToFill ? parentSVGStyle.fillPaintColor() : parentSVGStyle.strok ePaintColor();
47 return true;
48 }
49
50 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback) 38 RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM ode mode, RenderObject* object, const RenderStyle* style, bool& hasFallback)
51 { 39 {
52 ASSERT(object); 40 ASSERT(object);
53 ASSERT(style); 41 ASSERT(style);
54 42
55 hasFallback = false; 43 hasFallback = false;
56 44
57 // If we have no style at all, ignore it. 45 // If we have no style at all, ignore it.
58 const SVGRenderStyle& svgStyle = style->svgStyle(); 46 const SVGRenderStyle& svgStyle = style->svgStyle();
59 47
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 colorResource->setColor(color); 102 colorResource->setColor(color);
115 return colorResource; 103 return colorResource;
116 } 104 }
117 105
118 RenderSVGResource* uriResource = 0; 106 RenderSVGResource* uriResource = 0;
119 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(object)) 107 if (SVGResources* resources = SVGResourcesCache::cachedResourcesForRenderObj ect(object))
120 uriResource = applyToFill ? resources->fill() : resources->stroke(); 108 uriResource = applyToFill ? resources->fill() : resources->stroke();
121 109
122 // If the requested resource is not available, return the color resource or 'none'. 110 // If the requested resource is not available, return the color resource or 'none'.
123 if (!uriResource) { 111 if (!uriResource) {
124 // The fallback is 'none'. 112 // The fallback is 'none'. (SVG2 say 'none' is implied when no fallback is specified.)
125 if (paintType == SVG_PAINTTYPE_URI_NONE) 113 if (paintType == SVG_PAINTTYPE_URI_NONE || !hasColor)
126 return 0;
127 // If there's no fallback color, attempt to use the the parents paint
128 // server if it's a simple <color>.
129 if (!hasColor && !inheritColorFromParentStyle(object, applyToFill, color ))
130 return 0; 114 return 0;
131 115
132 colorResource->setColor(color); 116 colorResource->setColor(color);
133 return colorResource; 117 return colorResource;
134 } 118 }
135 119
136 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller 120 // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller
137 // via sharedSolidPaintingResource so it can use the solid color painting re source, if applyResource() on the URI resource failed. 121 // via sharedSolidPaintingResource so it can use the solid color painting re source, if applyResource() on the URI resource failed.
138 if (hasColor) { 122 if (hasColor) {
139 colorResource->setColor(color); 123 colorResource->setColor(color);
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // This will process the rest of the ancestors. 194 // This will process the rest of the ancestors.
211 toRenderSVGResourceContainer(current)->removeAllClientsFromCache(); 195 toRenderSVGResourceContainer(current)->removeAllClientsFromCache();
212 break; 196 break;
213 } 197 }
214 198
215 current = current->parent(); 199 current = current->parent();
216 } 200 }
217 } 201 }
218 202
219 } 203 }
OLDNEW
« no previous file with comments | « LayoutTests/svg/hixie/error/003-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698