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

Unified Diff: Source/core/rendering/svg/RenderSVGResource.cpp

Issue 658333003: Make RenderSVGResource::requestPaintingResource an implementation detail (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Drop SolidColorResourceType. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/svg/RenderSVGResource.cpp
diff --git a/Source/core/rendering/svg/RenderSVGResource.cpp b/Source/core/rendering/svg/RenderSVGResource.cpp
index 1e300a8c55c4e89df7855fa0a1daf46fab245f1c..15174a4b60e48dcff3aa99c04246223b96afe45a 100644
--- a/Source/core/rendering/svg/RenderSVGResource.cpp
+++ b/Source/core/rendering/svg/RenderSVGResource.cpp
@@ -26,8 +26,6 @@
#include "core/rendering/svg/RenderSVGResourceClipper.h"
#include "core/rendering/svg/RenderSVGResourceFilter.h"
#include "core/rendering/svg/RenderSVGResourceMasker.h"
-#include "core/rendering/svg/RenderSVGResourceSolidColor.h"
-#include "core/rendering/svg/SVGRenderSupport.h"
#include "core/rendering/svg/SVGResources.h"
#include "core/rendering/svg/SVGResourcesCache.h"
#include "platform/graphics/GraphicsContext.h"
@@ -89,16 +87,16 @@ SVGPaintServer SVGPaintServer::requestForRenderer(const RenderObject& renderer,
ASSERT(style);
ASSERT(resourceMode == ApplyToFillMode || resourceMode == ApplyToStrokeMode);
- bool hasFallback = false;
- RenderSVGResource* paintingResource = RenderSVGResource::requestPaintingResource(resourceMode, renderer, style, hasFallback);
- if (!paintingResource)
+ RenderSVGResource::PaintDescription paintDescription = RenderSVGResource::requestPaint(resourceMode, renderer, style);
+ if (!paintDescription.isValid)
return invalid();
-
- SVGPaintServer paintServer = paintingResource->preparePaintServer(renderer);
+ if (!paintDescription.resource)
+ return SVGPaintServer(paintDescription.color);
+ SVGPaintServer paintServer = paintDescription.resource->preparePaintServer(renderer);
if (paintServer.isValid())
return paintServer;
- if (hasFallback)
- return SVGPaintServer(RenderSVGResource::sharedSolidPaintingResource()->color());
+ if (paintDescription.hasFallback)
+ return SVGPaintServer(paintDescription.color);
return invalid();
}
@@ -108,22 +106,20 @@ SVGPaintServer RenderSVGResource::preparePaintServer(const RenderObject&)
return SVGPaintServer::invalid();
}
-RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceMode mode, const RenderObject& object, const RenderStyle* style, bool& hasFallback)
+RenderSVGResource::PaintDescription RenderSVGResource::requestPaint(RenderSVGResourceMode mode, const RenderObject& object, const RenderStyle* style)
{
ASSERT(style);
- hasFallback = false;
-
// If we have no style at all, ignore it.
const SVGRenderStyle& svgStyle = style->svgStyle();
// If we have no fill/stroke, return 0.
if (mode == ApplyToFillMode) {
if (!svgStyle.hasFill())
- return 0;
+ return PaintDescription();
} else {
if (!svgStyle.hasStroke())
- return 0;
+ return PaintDescription();
}
bool applyToFill = mode == ApplyToFillMode;
@@ -156,12 +152,10 @@ RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM
}
// If the primary resource is just a color, return immediately.
- RenderSVGResourceSolidColor* colorResource = RenderSVGResource::sharedSolidPaintingResource();
if (paintType < SVG_PAINTTYPE_URI_NONE) {
// |paintType| will be either <current-color> or <rgb-color> here - both of which will have a color.
ASSERT(hasColor);
- colorResource->setColor(color);
- return colorResource;
+ return PaintDescription(color);
}
RenderSVGResource* uriResource = 0;
@@ -172,27 +166,18 @@ RenderSVGResource* RenderSVGResource::requestPaintingResource(RenderSVGResourceM
if (!uriResource) {
// The fallback is 'none'. (SVG2 say 'none' is implied when no fallback is specified.)
if (paintType == SVG_PAINTTYPE_URI_NONE || !hasColor)
- return 0;
+ return PaintDescription();
- colorResource->setColor(color);
- return colorResource;
+ return PaintDescription(color);
}
- // The paint server resource exists, though it may be invalid (pattern with width/height=0). Pass the fallback color to our caller
- // via sharedSolidPaintingResource so it can use the solid color painting resource, if applyResource() on the URI resource failed.
- if (hasColor) {
- colorResource->setColor(color);
- hasFallback = true;
- }
- return uriResource;
-}
+ // The paint server resource exists, though it may be invalid (pattern with width/height=0).
+ // Return the fallback color to our caller so it can use it, if
+ // preparePaintServer() on the resource container failed.
+ if (hasColor)
+ return PaintDescription(uriResource, color);
-RenderSVGResourceSolidColor* RenderSVGResource::sharedSolidPaintingResource()
-{
- static RenderSVGResourceSolidColor* s_sharedSolidPaintingResource = 0;
- if (!s_sharedSolidPaintingResource)
- s_sharedSolidPaintingResource = new RenderSVGResourceSolidColor;
- return s_sharedSolidPaintingResource;
+ return PaintDescription(uriResource);
}
static inline void removeFromCacheAndInvalidateDependencies(RenderObject* object, bool needsLayout)

Powered by Google App Engine
This is Rietveld 408576698