Changeset 107119 in webkit


Ignore:
Timestamp:
Feb 8, 2012 12:24:57 PM (12 years ago)
Author:
andersca@apple.com
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.

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r107118 r107119  
     12012-02-08  Anders Carlsson  <andersca@apple.com>
     2
     3        Add a content shadow layer to the render layer compositor
     4        https://bugs.webkit.org/show_bug.cgi?id=78133
     5        <rdar://problem/10797742>
     6
     7        Reviewed by Beth Dakin.
     8
     9        Have the render layer compositor optionally create a content shadow layer,
     10        and add a ScrollbarTheme::setUpContentShadowLayer member function that subclasses
     11        can use to set content shadow properties.
     12
     13        * platform/mac/ScrollbarThemeMac.mm:
     14        (WebCore::ScrollbarThemeMac::setUpContentShadowLayer):
     15        Set the layer properties once, and set the shadow path on every call, since we know that this
     16        function will be called every time the size of the content shadow layer changes.
     17
     18        * rendering/RenderLayerCompositor.cpp:
     19        (WebCore::RenderLayerCompositor::updateRootLayerPosition):
     20        Reposition the content shadow layer, and call ScrollbarTheme::setUpContentShadowLayer if the size changes.
     21
     22        (WebCore::RenderLayerCompositor::requiresContentShadowLayer):
     23        Add new helper function.
     24
     25        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
     26        Create a content shadow layer if needed.
     27
    1282012-02-07  Andy Estes  <aestes@apple.com>
    229
  • trunk/Source/WebCore/platform/ScrollbarTheme.h

    r106588 r107119  
    9191#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
    9292    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) { }
     93    virtual void setUpContentShadowLayer(GraphicsLayer*) { }
    9394#endif
    9495
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h

    r106588 r107119  
    8484#if !PLATFORM(CHROMIUM) && USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
    8585    virtual void setUpOverhangAreasLayerContents(GraphicsLayer*) OVERRIDE;
     86    virtual void setUpContentShadowLayer(GraphicsLayer*) OVERRIDE;
    8687#endif
    8788};
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm

    r106588 r107119  
    625625}
    626626
     627void ScrollbarThemeMac::setUpContentShadowLayer(GraphicsLayer* graphicsLayer)
     628{
     629    // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
     630    // of shadows, and we know that WebCore won't touch this layer.
     631    CALayer *contentShadowLayer = graphicsLayer->platformLayer();
     632
     633    static const CGFloat shadowOpacity = 0.66;
     634    static const CGFloat shadowRadius = 3;
     635
     636    // We only need to set these shadow properties once.
     637    if (!contentShadowLayer.shadowOpacity) {
     638        contentShadowLayer.shadowColor = CGColorGetConstantColor(kCGColorBlack);
     639        contentShadowLayer.shadowOffset = CGSizeZero;
     640        contentShadowLayer.shadowOpacity = shadowOpacity;
     641        contentShadowLayer.shadowRadius = shadowRadius;
     642    }
     643
     644    RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, graphicsLayer->size().width(), graphicsLayer->size().height()), NULL));
     645    contentShadowLayer.shadowPath = shadowPath.get();
     646}
     647
    627648#endif
    628649
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r107024 r107119  
    12321232        m_clipLayer->setSize(frameView->visibleContentRect(false /* exclude scrollbars */).size());
    12331233    }
     1234
     1235#if ENABLE(RUBBER_BANDING)
     1236    if (m_contentShadowLayer) {
     1237        m_contentShadowLayer->setPosition(m_rootContentLayer->position());
     1238
     1239        FloatSize rootContentLayerSize = m_rootContentLayer->size();
     1240        if (m_contentShadowLayer->size() != rootContentLayerSize) {
     1241            m_contentShadowLayer->setSize(rootContentLayerSize);
     1242            ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
     1243        }
     1244    }
     1245#endif
    12341246}
    12351247
     
    17231735    return false;
    17241736}
     1737
     1738bool RenderLayerCompositor::requiresContentShadowLayer() const
     1739{
     1740    // We don't want a layer if this is a subframe.
     1741    if (m_renderView->document()->ownerElement())
     1742        return false;
     1743
     1744#if PLATFORM(MAC) && ENABLE(THREADED_SCROLLING)
     1745    // On Mac, we want a content shadow layer if we have a scrolling coordinator.
     1746    if (scrollingCoordinator())
     1747        return true;
     1748#endif
     1749
     1750    return false;
     1751}
    17251752#endif
    17261753
     
    17461773        m_layerForOverhangAreas->removeFromParent();
    17471774        m_layerForOverhangAreas = nullptr;
     1775    }
     1776
     1777    if (requiresContentShadowLayer()) {
     1778        if (!m_contentShadowLayer) {
     1779            m_contentShadowLayer = GraphicsLayer::create(this);
     1780#ifndef NDEBUG
     1781            m_contentShadowLayer->setName("content shadow");
     1782#endif
     1783            m_contentShadowLayer->setSize(m_rootContentLayer->size());
     1784            m_contentShadowLayer->setPosition(m_rootContentLayer->position());
     1785            ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
     1786
     1787            m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
     1788        }
     1789    } else if (m_contentShadowLayer) {
     1790        m_contentShadowLayer->removeFromParent();
     1791        m_contentShadowLayer = nullptr;
    17481792    }
    17491793#endif
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.h

    r107024 r107119  
    292292#if ENABLE(RUBBER_BANDING)
    293293    bool requiresOverhangAreasLayer() const;
     294    bool requiresContentShadowLayer() const;
    294295#endif
    295296
     
    338339#if ENABLE(RUBBER_BANDING)
    339340    OwnPtr<GraphicsLayer> m_layerForOverhangAreas;
     341    OwnPtr<GraphicsLayer> m_contentShadowLayer;
    340342#endif
    341343#if PROFILE_LAYER_REBUILD
Note: See TracChangeset for help on using the changeset viewer.