Title: [169046] trunk/Source/WebCore
Revision
169046
Author
[email protected]
Date
2014-05-19 08:53:37 -0700 (Mon, 19 May 2014)

Log Message

Use RenderStyle& in more places in RenderLayerBacking
https://bugs.webkit.org/show_bug.cgi?id=133061

Reviewed by Andreas Kling.

Convert several member functions to use references to RenderStyle rather
than pointers. Move canCreateTiledImage() higher in the file (no code
changes). Other minor cleanup.

* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
(WebCore::RenderLayerBacking::updateOpacity):
(WebCore::RenderLayerBacking::updateTransform):
(WebCore::RenderLayerBacking::updateFilters):
(WebCore::RenderLayerBacking::updateBlendMode):
(WebCore::RenderLayerBacking::updateGeometry):
(WebCore::hasBoxDecorations):
(WebCore::canCreateTiledImage):
(WebCore::hasBoxDecorationsOrBackgroundImage):
(WebCore::hasPerspectiveOrPreserves3D):
(WebCore::supportsDirectBoxDecorationsComposition):
(WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
(WebCore::RenderLayerBacking::contentChanged):
(WebCore::RenderLayerBacking::startTransition):
* rendering/RenderLayerBacking.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (169045 => 169046)


--- trunk/Source/WebCore/ChangeLog	2014-05-19 15:53:32 UTC (rev 169045)
+++ trunk/Source/WebCore/ChangeLog	2014-05-19 15:53:37 UTC (rev 169046)
@@ -1,3 +1,31 @@
+2014-05-18  Simon Fraser  <[email protected]>
+
+        Use RenderStyle& in more places in RenderLayerBacking
+        https://bugs.webkit.org/show_bug.cgi?id=133061
+
+        Reviewed by Andreas Kling.
+
+        Convert several member functions to use references to RenderStyle rather
+        than pointers. Move canCreateTiledImage() higher in the file (no code
+        changes). Other minor cleanup.
+
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::createPrimaryGraphicsLayer):
+        (WebCore::RenderLayerBacking::updateOpacity):
+        (WebCore::RenderLayerBacking::updateTransform):
+        (WebCore::RenderLayerBacking::updateFilters):
+        (WebCore::RenderLayerBacking::updateBlendMode):
+        (WebCore::RenderLayerBacking::updateGeometry):
+        (WebCore::hasBoxDecorations):
+        (WebCore::canCreateTiledImage):
+        (WebCore::hasBoxDecorationsOrBackgroundImage):
+        (WebCore::hasPerspectiveOrPreserves3D):
+        (WebCore::supportsDirectBoxDecorationsComposition):
+        (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer):
+        (WebCore::RenderLayerBacking::contentChanged):
+        (WebCore::RenderLayerBacking::startTransition):
+        * rendering/RenderLayerBacking.h:
+
 2014-05-17  Simon Fraser  <[email protected]>
 
         Rename some RenderLayerBacking member functions

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (169045 => 169046)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-05-19 15:53:32 UTC (rev 169045)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2014-05-19 15:53:37 UTC (rev 169046)
@@ -73,9 +73,6 @@
 
 using namespace HTMLNames;
 
-static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*);
-static LayoutRect clipBox(RenderBox& renderer);
-
 CanvasCompositingStrategy canvasCompositingStrategy(const RenderObject& renderer)
 {
     ASSERT(renderer.isCanvas());
@@ -316,13 +313,13 @@
     }
 #endif    
     
-    updateOpacity(&renderer().style());
-    updateTransform(&renderer().style());
+    updateOpacity(renderer().style());
+    updateTransform(renderer().style());
 #if ENABLE(CSS_FILTERS)
-    updateFilters(&renderer().style());
+    updateFilters(renderer().style());
 #endif
 #if ENABLE(CSS_COMPOSITING)
-    updateBlendMode(&renderer().style());
+    updateBlendMode(renderer().style());
 #endif
 }
 
@@ -357,19 +354,19 @@
     m_scrollingContentsLayer = nullptr;
 }
 
-void RenderLayerBacking::updateOpacity(const RenderStyle* style)
+void RenderLayerBacking::updateOpacity(const RenderStyle& style)
 {
-    m_graphicsLayer->setOpacity(compositingOpacity(style->opacity()));
+    m_graphicsLayer->setOpacity(compositingOpacity(style.opacity()));
 }
 
-void RenderLayerBacking::updateTransform(const RenderStyle* style)
+void RenderLayerBacking::updateTransform(const RenderStyle& style)
 {
     // FIXME: This could use m_owningLayer.transform(), but that currently has transform-origin
     // baked into it, and we don't want that.
     TransformationMatrix t;
     if (m_owningLayer.hasTransform()) {
         RenderBox& renderBox = toRenderBox(renderer());
-        style->applyTransform(t, pixelSnappedForPainting(renderBox.borderBoxRect(), renderBox.document().deviceScaleFactor()), RenderStyle::ExcludeTransformOrigin);
+        style.applyTransform(t, pixelSnappedForPainting(renderBox.borderBoxRect(), renderBox.document().deviceScaleFactor()), RenderStyle::ExcludeTransformOrigin);
         makeMatrixRenderable(t, compositor().canRender3DTransforms());
     }
     
@@ -381,20 +378,21 @@
 }
 
 #if ENABLE(CSS_FILTERS)
-void RenderLayerBacking::updateFilters(const RenderStyle* style)
+void RenderLayerBacking::updateFilters(const RenderStyle& style)
 {
-    m_canCompositeFilters = m_graphicsLayer->setFilters(style->filter());
+    m_canCompositeFilters = m_graphicsLayer->setFilters(style.filter());
 }
 #endif
 
 #if ENABLE(CSS_COMPOSITING)
-void RenderLayerBacking::updateBlendMode(const RenderStyle* style)
+void RenderLayerBacking::updateBlendMode(const RenderStyle& style)
 {
+    // FIXME: where is the blend mode updated when m_ancestorClippingLayers come and go?
     if (m_ancestorClippingLayer) {
-        m_ancestorClippingLayer->setBlendMode(style->blendMode());
+        m_ancestorClippingLayer->setBlendMode(style.blendMode());
         m_graphicsLayer->setBlendMode(BlendModeNormal);
     } else
-        m_graphicsLayer->setBlendMode(style->blendMode());
+        m_graphicsLayer->setBlendMode(style.blendMode());
 }
 #endif
 
@@ -653,21 +651,23 @@
     if (m_owningLayer.isStackingContainer() && m_owningLayer.m_zOrderListsDirty)
         return;
 
+    const RenderStyle& style = renderer().style();
+
     // Set transform property, if it is not animating. We have to do this here because the transform
     // is affected by the layer dimensions.
     if (!renderer().animation().isRunningAcceleratedAnimationOnRenderer(&renderer(), CSSPropertyWebkitTransform, AnimationBase::Running | AnimationBase::Paused | AnimationBase::FillingFowards))
-        updateTransform(&renderer().style());
+        updateTransform(style);
 
     // Set opacity, if it is not animating.
     if (!renderer().animation().isRunningAcceleratedAnimationOnRenderer(&renderer(), CSSPropertyOpacity, AnimationBase::Running | AnimationBase::Paused | AnimationBase::FillingFowards))
-        updateOpacity(&renderer().style());
+        updateOpacity(style);
         
 #if ENABLE(CSS_FILTERS)
-    updateFilters(&renderer().style());
+    updateFilters(style);
 #endif
 
 #if ENABLE(CSS_COMPOSITING)
-    updateBlendMode(&renderer().style());
+    updateBlendMode(style);
 #endif
 
     bool isSimpleContainer = isSimpleContainerCompositingLayer();
@@ -679,7 +679,6 @@
     // non-compositing visible layers.
     m_graphicsLayer->setContentsVisible(m_owningLayer.hasVisibleContent() || hasVisibleNonCompositingDescendantLayers());
 
-    const RenderStyle& style = renderer().style();
     // FIXME: reflections should force transform-style to be flat in the style: https://bugs.webkit.org/show_bug.cgi?id=106959
     bool preserves3D = style.transformStyle3D() == TransformStyle3DPreserve3D && !renderer().hasReflection();
     m_graphicsLayer->setPreserves3D(preserves3D);
@@ -844,7 +843,6 @@
         else
             m_graphicsLayer->setAnchorPoint(anchor);
 
-        const RenderStyle& style = renderer().style();
         GraphicsLayer* clipLayer = clippingLayer();
         if (style.hasPerspective()) {
             TransformationMatrix t = owningLayer().perspectiveTransform();
@@ -1511,27 +1509,57 @@
     return finalOpacity;
 }
 
-static bool hasBoxDecorations(const RenderStyle* style)
+static inline bool hasBoxDecorations(const RenderStyle& style)
 {
-    return style->hasBorder() || style->hasBorderRadius() || style->hasOutline() || style->hasAppearance() || style->boxShadow() || style->hasFilter();
+    return style.hasBorder() || style.hasBorderRadius() || style.hasOutline() || style.hasAppearance() || style.boxShadow() || style.hasFilter();
 }
 
-static bool canCreateTiledImage(const RenderStyle*);
+static bool canCreateTiledImage(const RenderStyle& style)
+{
+    const FillLayer* fillLayer = style.backgroundLayers();
+    if (fillLayer->next())
+        return false;
 
-static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle* style)
+    if (!fillLayer->imagesAreLoaded())
+        return false;
+
+    if (fillLayer->attachment() != ScrollBackgroundAttachment)
+        return false;
+
+    Color color = style.visitedDependentColor(CSSPropertyBackgroundColor);
+
+    // FIXME: Allow color+image compositing when it makes sense.
+    // For now bailing out.
+    if (color.isValid() && color.alpha())
+        return false;
+
+    StyleImage* styleImage = fillLayer->image();
+
+    // FIXME: support gradients with isGeneratedImage.
+    if (!styleImage->isCachedImage())
+        return false;
+
+    Image* image = styleImage->cachedImage()->image();
+    if (!image->isBitmapImage())
+        return false;
+
+    return true;
+}
+
+static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle& style)
 {
     if (hasBoxDecorations(style))
         return true;
 
-    if (!style->hasBackgroundImage())
+    if (!style.hasBackgroundImage())
         return false;
 
     return !GraphicsLayer::supportsContentsTiling() || !canCreateTiledImage(style);
 }
 
-static bool hasPerspectiveOrPreserves3D(const RenderStyle* style)
+static inline bool hasPerspectiveOrPreserves3D(const RenderStyle& style)
 {
-    return style->hasPerspective() || style->preserves3D();
+    return style.hasPerspective() || style.preserves3D();
 }
 
 Color RenderLayerBacking::rendererBackgroundColor() const
@@ -1557,38 +1585,6 @@
     didUpdateContentsRect = true;
 }
 
-bool canCreateTiledImage(const RenderStyle* style)
-{
-    const FillLayer* fillLayer = style->backgroundLayers();
-    if (fillLayer->next())
-        return false;
-
-    if (!fillLayer->imagesAreLoaded())
-        return false;
-
-    if (fillLayer->attachment() != ScrollBackgroundAttachment)
-        return false;
-
-    Color color = style->visitedDependentColor(CSSPropertyBackgroundColor);
-
-    // FIXME: Allow color+image compositing when it makes sense.
-    // For now bailing out.
-    if (color.isValid() && color.alpha())
-        return false;
-
-    StyleImage* styleImage = fillLayer->image();
-
-    // FIXME: support gradients with isGeneratedImage.
-    if (!styleImage->isCachedImage())
-        return false;
-
-    Image* image = styleImage->cachedImage()->image();
-    if (!image->isBitmapImage())
-        return false;
-
-    return true;
-}
-
 void RenderLayerBacking::updateDirectlyCompositedBackgroundImage(bool isSimpleContainer, bool& didUpdateContentsRect)
 {
     if (!GraphicsLayer::supportsContentsTiling())
@@ -1643,10 +1639,11 @@
     if (!GraphicsLayer::supportsBackgroundColorContent())
         return false;
 
+    const RenderStyle& style = renderer.style();
     if (renderer.hasClip())
         return false;
 
-    if (hasBoxDecorationsOrBackgroundImage(&renderer.style()))
+    if (hasBoxDecorationsOrBackgroundImage(style))
         return false;
 
     // FIXME: We can't create a directly composited background if this
@@ -1654,14 +1651,14 @@
     // A better solution might be to introduce a flattening layer if
     // we do direct box decoration composition.
     // https://bugs.webkit.org/show_bug.cgi?id=119461
-    if (hasPerspectiveOrPreserves3D(&renderer.style()))
+    if (hasPerspectiveOrPreserves3D(style))
         return false;
 
     // FIXME: we should be able to allow backgroundComposite; However since this is not a common use case it has been deferred for now.
-    if (renderer.style().backgroundComposite() != CompositeSourceOver)
+    if (style.backgroundComposite() != CompositeSourceOver)
         return false;
 
-    if (renderer.style().backgroundClip() == TextFillBox)
+    if (style.backgroundClip() == TextFillBox)
         return false;
 
     return true;
@@ -1729,11 +1726,9 @@
         if (!rootObject)
             return false;
         
-        RenderStyle* style = &rootObject->style();
-        
         // Reject anything that has a border, a border-radius or outline,
         // or is not a simple background (no background, or solid color).
-        if (hasBoxDecorationsOrBackgroundImage(style))
+        if (hasBoxDecorationsOrBackgroundImage(rootObject->style()))
             return false;
         
         // Now look at the body's renderer.
@@ -1742,9 +1737,7 @@
         if (!bodyObject)
             return false;
         
-        style = &bodyObject->style();
-        
-        if (hasBoxDecorationsOrBackgroundImage(style))
+        if (hasBoxDecorationsOrBackgroundImage(bodyObject->style()))
             return false;
     }
 
@@ -1860,7 +1853,7 @@
         return;
     }
 
-    if ((changeType == BackgroundImageChanged) && canCreateTiledImage(&renderer().style()))
+    if ((changeType == BackgroundImageChanged) && canCreateTiledImage(renderer().style()))
         updateGeometry();
 
     if ((changeType == MaskImageChanged) && m_maskLayer) {
@@ -2416,7 +2409,7 @@
             // The boxSize param is only used for transform animations (which can only run on RenderBoxes), so we pass an empty size here.
             if (m_graphicsLayer->addAnimation(opacityVector, FloatSize(), opacityAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyOpacity), timeOffset)) {
                 // To ensure that the correct opacity is visible when the animation ends, also set the final opacity.
-                updateOpacity(toStyle);
+                updateOpacity(*toStyle);
                 didAnimate = true;
             }
         }
@@ -2430,7 +2423,7 @@
             transformVector.insert(TransformAnimationValue::create(1, toStyle->transform()));
             if (m_graphicsLayer->addAnimation(transformVector, toRenderBox(renderer()).pixelSnappedBorderBoxRect().size(), transformAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitTransform), timeOffset)) {
                 // To ensure that the correct transform is visible when the animation ends, also set the final transform.
-                updateTransform(toStyle);
+                updateTransform(*toStyle);
                 didAnimate = true;
             }
         }
@@ -2445,7 +2438,7 @@
             filterVector.insert(FilterAnimationValue::create(1, toStyle->filter()));
             if (m_graphicsLayer->addAnimation(filterVector, FloatSize(), filterAnim, GraphicsLayer::animationNameForTransition(AnimatedPropertyWebkitFilter), timeOffset)) {
                 // To ensure that the correct filter is visible when the animation ends, also set the final filter.
-                updateFilters(toStyle);
+                updateFilters(*toStyle);
                 didAnimate = true;
             }
         }

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.h (169045 => 169046)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.h	2014-05-19 15:53:32 UTC (rev 169045)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.h	2014-05-19 15:53:37 UTC (rev 169046)
@@ -251,13 +251,13 @@
     // Result is transform origin in device pixels.
     FloatPoint3D computeTransformOriginForPainting(const LayoutRect& borderBox) const;
 
-    void updateOpacity(const RenderStyle*);
-    void updateTransform(const RenderStyle*);
+    void updateOpacity(const RenderStyle&);
+    void updateTransform(const RenderStyle&);
 #if ENABLE(CSS_FILTERS)
-    void updateFilters(const RenderStyle*);
+    void updateFilters(const RenderStyle&);
 #endif
 #if ENABLE(CSS_COMPOSITING)
-    void updateBlendMode(const RenderStyle*);
+    void updateBlendMode(const RenderStyle&);
 #endif
     // Return the opacity value that this layer should use for compositing.
     float compositingOpacity(float rendererOpacity) const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to