Some RenderSVGResource cleanup
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Aug 2017 22:43:01 +0000 (22:43 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 11 Aug 2017 22:43:01 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175494

Reviewed by Zalan Bujtas.

Use more initializers. Remove spurious use of bitfields that didn't save any space at all.
0 -> nullptr.

No behavior change.

* rendering/svg/RenderSVGResourceContainer.cpp:
(WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer):
* rendering/svg/RenderSVGResourceContainer.h:
* rendering/svg/RenderSVGResourceGradient.cpp:
(WebCore::RenderSVGResourceGradient::RenderSVGResourceGradient):
(WebCore::RenderSVGResourceGradient::applyResource):
* rendering/svg/RenderSVGResourceGradient.h:
* rendering/svg/RenderSVGResourcePattern.cpp:
(WebCore::RenderSVGResourcePattern::RenderSVGResourcePattern):
* rendering/svg/RenderSVGResourcePattern.h:
* rendering/svg/RenderSVGShape.cpp:
(WebCore::RenderSVGShape::fillShape):
(WebCore::RenderSVGShape::strokeShape):
* rendering/svg/SVGRenderingContext.cpp:
(WebCore::SVGRenderingContext::~SVGRenderingContext):
(WebCore::SVGRenderingContext::prepareToRenderSVGContent):
* rendering/svg/SVGRenderingContext.h:
(WebCore::SVGRenderingContext::SVGRenderingContext):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220616 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/svg/RenderSVGResourceContainer.cpp
Source/WebCore/rendering/svg/RenderSVGResourceContainer.h
Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp
Source/WebCore/rendering/svg/RenderSVGResourceGradient.h
Source/WebCore/rendering/svg/RenderSVGResourcePattern.cpp
Source/WebCore/rendering/svg/RenderSVGResourcePattern.h
Source/WebCore/rendering/svg/RenderSVGShape.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.cpp
Source/WebCore/rendering/svg/SVGRenderingContext.h

index 97cade7..ec2b108 100644 (file)
@@ -1,3 +1,34 @@
+2017-08-11  Simon Fraser  <simon.fraser@apple.com>
+
+        Some RenderSVGResource cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=175494
+
+        Reviewed by Zalan Bujtas.
+
+        Use more initializers. Remove spurious use of bitfields that didn't save any space at all.
+        0 -> nullptr.
+
+        No behavior change.
+
+        * rendering/svg/RenderSVGResourceContainer.cpp:
+        (WebCore::RenderSVGResourceContainer::RenderSVGResourceContainer):
+        * rendering/svg/RenderSVGResourceContainer.h:
+        * rendering/svg/RenderSVGResourceGradient.cpp:
+        (WebCore::RenderSVGResourceGradient::RenderSVGResourceGradient):
+        (WebCore::RenderSVGResourceGradient::applyResource):
+        * rendering/svg/RenderSVGResourceGradient.h:
+        * rendering/svg/RenderSVGResourcePattern.cpp:
+        (WebCore::RenderSVGResourcePattern::RenderSVGResourcePattern):
+        * rendering/svg/RenderSVGResourcePattern.h:
+        * rendering/svg/RenderSVGShape.cpp:
+        (WebCore::RenderSVGShape::fillShape):
+        (WebCore::RenderSVGShape::strokeShape):
+        * rendering/svg/SVGRenderingContext.cpp:
+        (WebCore::SVGRenderingContext::~SVGRenderingContext):
+        (WebCore::SVGRenderingContext::prepareToRenderSVGContent):
+        * rendering/svg/SVGRenderingContext.h:
+        (WebCore::SVGRenderingContext::SVGRenderingContext):
+
 2017-08-11  Tim Horton  <timothy_horton@apple.com>
 
         Fix the build with modern Clang's -Wexpansion-to-defined
index 3d44c6a..1818603 100644 (file)
@@ -37,8 +37,6 @@ static inline SVGDocumentExtensions& svgExtensionsFromElement(SVGElement& elemen
 RenderSVGResourceContainer::RenderSVGResourceContainer(SVGElement& element, RenderStyle&& style)
     : RenderSVGHiddenContainer(element, WTFMove(style))
     , m_id(element.getIdAttribute())
-    , m_registered(false)
-    , m_isInvalidating(false)
 {
 }
 
index fbf35d9..680a9e1 100644 (file)
@@ -70,10 +70,10 @@ private:
     void registerResource();
 
     AtomicString m_id;
-    bool m_registered : 1;
-    bool m_isInvalidating : 1;
     HashSet<RenderElement*> m_clients;
     HashSet<RenderLayer*> m_clientLayers;
+    bool m_registered { false };
+    bool m_isInvalidating { false };
 };
 
 inline RenderSVGResourceContainer* getRenderSVGResourceContainerById(Document& document, const AtomicString& id)
index 0e1fba3..e55136d 100644 (file)
@@ -32,10 +32,6 @@ namespace WebCore {
 
 RenderSVGResourceGradient::RenderSVGResourceGradient(SVGGradientElement& node, RenderStyle&& style)
     : RenderSVGResourceContainer(node, WTFMove(style))
-    , m_shouldCollectGradientAttributes(true)
-#if USE(CG)
-    , m_savedContext(0)
-#endif
 {
 }
 
@@ -200,7 +196,7 @@ void RenderSVGResourceGradient::postApplyResource(RenderElement& renderer, Graph
         if (m_savedContext && (gradientData = m_gradientMap.get(&renderer))) {
             // Restore on-screen drawing context
             context = m_savedContext;
-            m_savedContext = 0;
+            m_savedContext = nullptr;
 
             AffineTransform gradientTransform;
             calculateGradientTransform(gradientTransform);
index d60795c..ee8522a 100644 (file)
@@ -65,13 +65,14 @@ protected:
     GradientSpreadMethod platformSpreadMethodFromSVGType(SVGSpreadMethodType) const;
 
 private:
-    bool m_shouldCollectGradientAttributes : 1;
     HashMap<RenderObject*, std::unique_ptr<GradientData>> m_gradientMap;
 
 #if USE(CG)
-    GraphicsContext* m_savedContext;
+    GraphicsContext* m_savedContext { nullptr };
     std::unique_ptr<ImageBuffer> m_imageBuffer;
 #endif
+
+    bool m_shouldCollectGradientAttributes { true };
 };
 
 } // namespace WebCore
index 2c3d4eb..d3a1e3c 100644 (file)
@@ -34,7 +34,6 @@ namespace WebCore {
 
 RenderSVGResourcePattern::RenderSVGResourcePattern(SVGPatternElement& element, RenderStyle&& style)
     : RenderSVGResourceContainer(element, WTFMove(style))
-    , m_shouldCollectPatternAttributes(true)
 {
 }
 
index 3a82ab1..fda0048 100644 (file)
@@ -63,9 +63,9 @@ private:
 
     PatternData* buildPattern(RenderElement&, OptionSet<RenderSVGResourceMode>, GraphicsContext&);
 
-    bool m_shouldCollectPatternAttributes : 1;
     PatternAttributes m_attributes;
     HashMap<RenderElement*, std::unique_ptr<PatternData>> m_patternMap;
+    bool m_shouldCollectPatternAttributes { true };
 };
 
 } // namespace WebCore
index d86e78f..143b5ce 100644 (file)
@@ -236,12 +236,12 @@ void RenderSVGShape::fillShape(const RenderStyle& style, GraphicsContext& origin
     Color fallbackColor;
     if (RenderSVGResource* fillPaintingResource = RenderSVGResource::fillPaintingResource(*this, style, fallbackColor)) {
         if (fillPaintingResource->applyResource(*this, style, context, RenderSVGResourceMode::ApplyToFill))
-            fillPaintingResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToFill, 0, this);
+            fillPaintingResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToFill, nullptr, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
             fallbackResource->setColor(fallbackColor);
             if (fallbackResource->applyResource(*this, style, context, RenderSVGResourceMode::ApplyToFill))
-                fallbackResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToFill, 0, this);
+                fallbackResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToFill, nullptr, this);
         }
     }
 }
@@ -252,12 +252,12 @@ void RenderSVGShape::strokeShape(const RenderStyle& style, GraphicsContext& orig
     Color fallbackColor;
     if (RenderSVGResource* strokePaintingResource = RenderSVGResource::strokePaintingResource(*this, style, fallbackColor)) {
         if (strokePaintingResource->applyResource(*this, style, context, RenderSVGResourceMode::ApplyToStroke))
-            strokePaintingResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToStroke, 0, this);
+            strokePaintingResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToStroke, nullptr, this);
         else if (fallbackColor.isValid()) {
             RenderSVGResourceSolidColor* fallbackResource = RenderSVGResource::sharedSolidPaintingResource();
             fallbackResource->setColor(fallbackColor);
             if (fallbackResource->applyResource(*this, style, context, RenderSVGResourceMode::ApplyToStroke))
-                fallbackResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToStroke, 0, this);
+                fallbackResource->postApplyResource(*this, context, RenderSVGResourceMode::ApplyToStroke, nullptr, this);
         }
     }
 }
index 33a40b2..c9b0f5e 100644 (file)
@@ -56,7 +56,7 @@ SVGRenderingContext::~SVGRenderingContext()
     if (m_renderingFlags & EndFilterLayer) {
         ASSERT(m_filter);
         GraphicsContext* contextPtr = &m_paintInfo->context();
-        m_filter->postApplyResource(*m_renderer, contextPtr, RenderSVGResourceMode::ApplyToDefault, 0, 0);
+        m_filter->postApplyResource(*m_renderer, contextPtr, RenderSVGResourceMode::ApplyToDefault, nullptr, nullptr);
         m_paintInfo->setContext(*m_savedContext);
         m_paintInfo->rect = m_savedPaintRect;
     }
@@ -81,7 +81,7 @@ void SVGRenderingContext::prepareToRenderSVGContent(RenderElement& renderer, Pai
 
     m_renderer = &renderer;
     m_paintInfo = &paintInfo;
-    m_filter = 0;
+    m_filter = nullptr;
 
     // We need to save / restore the context even if the initialization failed.
     if (needsGraphicsContextSave == SaveGraphicsContext) {
index fb6c29c..8b9b74a 100644 (file)
@@ -45,20 +45,10 @@ public:
 
     // Does not start rendering.
     SVGRenderingContext()
-        : m_renderingFlags(0)
-        , m_renderer(nullptr)
-        , m_paintInfo(nullptr)
-        , m_savedContext(nullptr)
-        , m_filter(nullptr)
     {
     }
 
     SVGRenderingContext(RenderElement& object, PaintInfo& paintinfo, NeedsGraphicsContextSave needsGraphicsContextSave = DontSaveGraphicsContext)
-        : m_renderingFlags(0)
-        , m_renderer(nullptr)
-        , m_paintInfo(nullptr)
-        , m_savedContext(nullptr)
-        , m_filter(nullptr)
     {
         prepareToRenderSVGContent(object, paintinfo, needsGraphicsContextSave);
     }
@@ -102,12 +92,12 @@ private:
     // List of those flags which require actions during the destructor.
     const static int ActionsNeeded = RestoreGraphicsContext | EndOpacityLayer | EndShadowLayer | EndFilterLayer;
 
-    int m_renderingFlags;
-    RenderElement* m_renderer;
-    PaintInfo* m_paintInfo;
-    GraphicsContext* m_savedContext;
+    RenderElement* m_renderer { nullptr };
+    PaintInfo* m_paintInfo { nullptr };
+    GraphicsContext* m_savedContext  { nullptr };
+    RenderSVGResourceFilter* m_filter  { nullptr };
     LayoutRect m_savedPaintRect;
-    RenderSVGResourceFilter* m_filter;
+    int m_renderingFlags { 0 };
 };
 
 } // namespace WebCore