Title: [107119] trunk/Source/WebCore
Revision
107119
Author
ander...@apple.com
Date
2012-02-08 12:24:57 -0800 (Wed, 08 Feb 2012)

Log Message

Add a content shadow layer to the render layer compositor
https://bugs.webkit.org/show_bug.cgi?id=78133
<rdar://problem/10797742>

Reviewed by Beth Dakin.

Have the render layer compositor optionally create a content shadow layer,
and add a ScrollbarTheme::setUpContentShadowLayer member function that subclasses
can use to set content shadow properties.

* platform/mac/ScrollbarThemeMac.mm:
(WebCore::ScrollbarThemeMac::setUpContentShadowLayer):
Set the layer properties once, and set the shadow path on every call, since we know that this
function will be called every time the size of the content shadow layer changes.

* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateRootLayerPosition):
Reposition the content shadow layer, and call ScrollbarTheme::setUpContentShadowLayer if the size changes.

(WebCore::RenderLayerCompositor::requiresContentShadowLayer):
Add new helper function.

(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
Create a content shadow layer if needed.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (107118 => 107119)


--- trunk/Source/WebCore/ChangeLog	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/ChangeLog	2012-02-08 20:24:57 UTC (rev 107119)
@@ -1,3 +1,30 @@
+2012-02-08  Anders Carlsson  <ander...@apple.com>
+
+        Add a content shadow layer to the render layer compositor
+        https://bugs.webkit.org/show_bug.cgi?id=78133
+        <rdar://problem/10797742>
+
+        Reviewed by Beth Dakin.
+
+        Have the render layer compositor optionally create a content shadow layer,
+        and add a ScrollbarTheme::setUpContentShadowLayer member function that subclasses
+        can use to set content shadow properties.
+
+        * platform/mac/ScrollbarThemeMac.mm:
+        (WebCore::ScrollbarThemeMac::setUpContentShadowLayer):
+        Set the layer properties once, and set the shadow path on every call, since we know that this
+        function will be called every time the size of the content shadow layer changes.
+
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
+        Reposition the content shadow layer, and call ScrollbarTheme::setUpContentShadowLayer if the size changes.
+
+        (WebCore::RenderLayerCompositor::requiresContentShadowLayer):
+        Add new helper function.
+
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+        Create a content shadow layer if needed.
+
 2012-02-07  Andy Estes  <aes...@apple.com>
 
         REGRESSION (r102983): ClicktoFlash drawing of old style youtube embeds missing until resize

Modified: trunk/Source/WebCore/platform/ScrollbarTheme.h (107118 => 107119)


--- trunk/Source/WebCore/platform/ScrollbarTheme.h	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/platform/ScrollbarTheme.h	2012-02-08 20:24:57 UTC (rev 107119)
@@ -90,6 +90,7 @@
 
 #if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
     virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) { }
+    virtual void setUpContentShadowLayer(GraphicsLayer*) { }
 #endif
 
     virtual bool shouldCenterOnThumb(Scrollbar*, const PlatformMouseEvent&) { return false; }

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h (107118 => 107119)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h	2012-02-08 20:24:57 UTC (rev 107119)
@@ -83,6 +83,7 @@
 
 #if !PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
     virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) OVERRIDE;
+    virtual void setUpContentShadowLayer(GraphicsLayer*) OVERRIDE;
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm (107118 => 107119)


--- trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm	2012-02-08 20:24:57 UTC (rev 107119)
@@ -624,6 +624,27 @@
     graphicsLayer->platformLayer().backgroundColor = cachedLinenBackgroundColor;
 }
 
+void ScrollbarThemeMac::setUpContentShadowLayer(GraphicsLayer* graphicsLayer)
+{
+    // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
+    // of shadows, and we know that WebCore won't touch this layer.
+    CALayer *contentShadowLayer = graphicsLayer->platformLayer();
+
+    static const CGFloat shadowOpacity = 0.66;
+    static const CGFloat shadowRadius = 3;
+
+    // We only need to set these shadow properties once.
+    if (!contentShadowLayer.shadowOpacity) {
+        contentShadowLayer.shadowColor = CGColorGetConstantColor(kCGColorBlack);
+        contentShadowLayer.shadowOffset = CGSizeZero;
+        contentShadowLayer.shadowOpacity = shadowOpacity;
+        contentShadowLayer.shadowRadius = shadowRadius;
+    }
+
+    RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, graphicsLayer->size().width(), graphicsLayer->size().height()), NULL));
+    contentShadowLayer.shadowPath = shadowPath.get();
+}
+
 #endif
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (107118 => 107119)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-02-08 20:24:57 UTC (rev 107119)
@@ -1231,6 +1231,18 @@
         FrameView* frameView = m_renderView->frameView();
         m_clipLayer->setSize(frameView->visibleContentRect(false /* exclude scrollbars */).size());
     }
+
+#if ENABLE(RUBBER_BANDING)
+    if (m_contentShadowLayer) {
+        m_contentShadowLayer->setPosition(m_rootContentLayer->position());
+
+        FloatSize rootContentLayerSize = m_rootContentLayer->size();
+        if (m_contentShadowLayer->size() != rootContentLayerSize) {
+            m_contentShadowLayer->setSize(rootContentLayerSize);
+            ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
+        }
+    }
+#endif
 }
 
 void RenderLayerCompositor::didStartAcceleratedAnimation(CSSPropertyID property)
@@ -1722,8 +1734,23 @@
 
     return false;
 }
+
+bool RenderLayerCompositor::requiresContentShadowLayer() const
+{
+    // We don't want a layer if this is a subframe.
+    if (m_renderView->document()->ownerElement())
+        return false;
+
+#if PLATFORM(MAC) && ENABLE(THREADED_SCROLLING)
+    // On Mac, we want a content shadow layer if we have a scrolling coordinator.
+    if (scrollingCoordinator())
+        return true;
 #endif
 
+    return false;
+}
+#endif
+
 void RenderLayerCompositor::updateOverflowControlsLayers()
 {
 #if ENABLE(RUBBER_BANDING)
@@ -1746,8 +1773,25 @@
         m_layerForOverhangAreas->removeFromParent();
         m_layerForOverhangAreas = nullptr;
     }
+
+    if (requiresContentShadowLayer()) {
+        if (!m_contentShadowLayer) {
+            m_contentShadowLayer = GraphicsLayer::create(this);
+#ifndef NDEBUG
+            m_contentShadowLayer->setName("content shadow");
 #endif
+            m_contentShadowLayer->setSize(m_rootContentLayer->size());
+            m_contentShadowLayer->setPosition(m_rootContentLayer->position());
+            ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
 
+            m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
+        }
+    } else if (m_contentShadowLayer) {
+        m_contentShadowLayer->removeFromParent();
+        m_contentShadowLayer = nullptr;
+    }
+#endif
+
     if (requiresHorizontalScrollbarLayer()) {
         if (!m_layerForHorizontalScrollbar) {
             m_layerForHorizontalScrollbar = GraphicsLayer::create(this);

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.h (107118 => 107119)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2012-02-08 20:20:41 UTC (rev 107118)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.h	2012-02-08 20:24:57 UTC (rev 107119)
@@ -291,6 +291,7 @@
     bool requiresScrollCornerLayer() const;
 #if ENABLE(RUBBER_BANDING)
     bool requiresOverhangAreasLayer() const;
+    bool requiresContentShadowLayer() const;
 #endif
 
 #if ENABLE(THREADED_SCROLLING)
@@ -337,6 +338,7 @@
     OwnPtr<GraphicsLayer> m_layerForScrollCorner;
 #if ENABLE(RUBBER_BANDING)
     OwnPtr<GraphicsLayer> m_layerForOverhangAreas;
+    OwnPtr<GraphicsLayer> m_contentShadowLayer;
 #endif
 #if PROFILE_LAYER_REBUILD
     int m_rootLayerUpdateCount;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to