Changeset 160672 in webkit


Ignore:
Timestamp:
Dec 16, 2013 4:13:38 PM (10 years ago)
Author:
Simon Fraser
Message:

Apply overhang shadow and linen to UI-side layers
https://bugs.webkit.org/show_bug.cgi?id=125807

Source/WebCore:

Reviewed by Tim Horton.

With UI-side compositing, we need to apply the overhang shadow and linen
background to layers in the UI process. Achieve this by setting a "custom
appearance" flag on layers that need a shadow or linen background, and
migrating this flag to the UI process. Static functions on ScrollbarThemeMac
are exposed to do the actual setting.

  • WebCore.exp.in: Export ScrollbarThemeMac and GraphicsLayerCA functions.
  • WebCore.xcodeproj/project.pbxproj: ScrollbarThemeMac.h and ScrollbarThemeComposite.h

need to be Private.

  • platform/graphics/GraphicsLayer.cpp: Initialize m_customAppearance.

(WebCore::GraphicsLayer::GraphicsLayer):

  • platform/graphics/GraphicsLayer.h: Getter/setter for CustomAppearance.

(WebCore::GraphicsLayer::setCustomAppearance):
(WebCore::GraphicsLayer::customAppearance):

  • platform/graphics/ca/GraphicsLayerCA.cpp: Update CustomAppearanceChanged as

we do other properties.
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateCustomAppearance):
(WebCore::GraphicsLayerCA::setCustomAppearance):

  • platform/graphics/ca/GraphicsLayerCA.h:
  • platform/graphics/ca/PlatformCALayer.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.h:
  • platform/graphics/ca/mac/PlatformCALayerMac.mm: When we have a custom

appearance, use ScrollbarThemeMac functions to update the layer. Ensure
that if the bounds change, we update the shadow (whose path depends on the bounds).
(PlatformCALayerMac::PlatformCALayerMac):
(PlatformCALayerMac::clone):
(PlatformCALayerMac::setBounds):
(PlatformCALayerMac::requiresCustomAppearanceUpdateOnBoundsChange):
(PlatformCALayerMac::updateCustomAppearance):

  • platform/mac/ScrollbarThemeMac.h: Export some static functions.
  • platform/mac/ScrollbarThemeMac.mm: Change code to use static functions.

(WebCore::ScrollbarThemeMac::setUpOverhangAreaBackground):
(WebCore::ScrollbarThemeMac::removeOverhangAreaBackground):
(WebCore::ScrollbarThemeMac::setUpOverhangAreaShadow):
(WebCore::ScrollbarThemeMac::removeOverhangAreaShadow):
(WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
(WebCore::ScrollbarThemeMac::setUpContentShadowLayer):

  • rendering/RenderLayerCompositor.cpp:

(WebCore::RenderLayerCompositor::updateRootLayerPosition): No need to call
setUpContentShadowLayer() now when size changes; PlatformCALayer takes
care of that.
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers): Now set
custom appearance via GraphicsLayer.

Source/WebKit2:

Reviewed by Tim Horton.

With UI-side compositing, we need to apply the overhang shadow and linen
background to layers in the UI process. Achieve this by setting a "custom
appearance" flag on layers that need a shadow or linen background, and
migrating this flag to the UI process. Static functions on ScrollbarThemeMac
are exposed to do the actual setting.

  • Shared/mac/RemoteLayerTreePropertyApplier.mm:

(WebKit::updateCustomAppearance): Use ScrollbarThemeMac to update the
appearance.
(WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):

  • Shared/mac/RemoteLayerTreeTransaction.h:
  • Shared/mac/RemoteLayerTreeTransaction.mm:

(WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
(WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
(WebKit::dumpChangedLayers):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:

(PlatformCALayerRemote::setBounds): If the bounds change, also set the
CustomAppearanceChanged bit so that the UI side updates the shadow bounds
(done here because the UI side is not stateful).
(PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange):
(PlatformCALayerRemote::customAppearance):
(PlatformCALayerRemote::updateCustomAppearance):

  • WebProcess/WebPage/mac/PlatformCALayerRemote.h:
Location:
trunk/Source
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r160671 r160672  
     12013-12-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Apply overhang shadow and linen to UI-side layers
     4        https://bugs.webkit.org/show_bug.cgi?id=125807
     5
     6        Reviewed by Tim Horton.
     7       
     8        With UI-side compositing, we need to apply the overhang shadow and linen
     9        background to layers in the UI process. Achieve this by setting a "custom
     10        appearance" flag on layers that need a shadow or linen background, and
     11        migrating this flag to the UI process. Static functions on ScrollbarThemeMac
     12        are exposed to do the actual setting.
     13
     14        * WebCore.exp.in: Export ScrollbarThemeMac and GraphicsLayerCA functions.
     15        * WebCore.xcodeproj/project.pbxproj: ScrollbarThemeMac.h and ScrollbarThemeComposite.h
     16        need to be Private.
     17        * platform/graphics/GraphicsLayer.cpp: Initialize m_customAppearance.
     18        (WebCore::GraphicsLayer::GraphicsLayer):
     19        * platform/graphics/GraphicsLayer.h: Getter/setter for CustomAppearance.
     20        (WebCore::GraphicsLayer::setCustomAppearance):
     21        (WebCore::GraphicsLayer::customAppearance):
     22        * platform/graphics/ca/GraphicsLayerCA.cpp: Update CustomAppearanceChanged as
     23        we do other properties.
     24        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
     25        (WebCore::GraphicsLayerCA::updateCustomAppearance):
     26        (WebCore::GraphicsLayerCA::setCustomAppearance):
     27        * platform/graphics/ca/GraphicsLayerCA.h:
     28        * platform/graphics/ca/PlatformCALayer.h:
     29        * platform/graphics/ca/mac/PlatformCALayerMac.h:
     30        * platform/graphics/ca/mac/PlatformCALayerMac.mm: When we have a custom
     31        appearance, use ScrollbarThemeMac functions to update the layer. Ensure
     32        that if the bounds change, we update the shadow (whose path depends on the bounds).
     33        (PlatformCALayerMac::PlatformCALayerMac):
     34        (PlatformCALayerMac::clone):
     35        (PlatformCALayerMac::setBounds):
     36        (PlatformCALayerMac::requiresCustomAppearanceUpdateOnBoundsChange):
     37        (PlatformCALayerMac::updateCustomAppearance):
     38        * platform/mac/ScrollbarThemeMac.h: Export some static functions.
     39        * platform/mac/ScrollbarThemeMac.mm: Change code to use static functions.
     40        (WebCore::ScrollbarThemeMac::setUpOverhangAreaBackground):
     41        (WebCore::ScrollbarThemeMac::removeOverhangAreaBackground):
     42        (WebCore::ScrollbarThemeMac::setUpOverhangAreaShadow):
     43        (WebCore::ScrollbarThemeMac::removeOverhangAreaShadow):
     44        (WebCore::ScrollbarThemeMac::setUpOverhangAreasLayerContents):
     45        (WebCore::ScrollbarThemeMac::setUpContentShadowLayer):
     46        * rendering/RenderLayerCompositor.cpp:
     47        (WebCore::RenderLayerCompositor::updateRootLayerPosition): No need to call
     48        setUpContentShadowLayer() now when size changes; PlatformCALayer takes
     49        care of that.
     50        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers): Now set
     51        custom appearance via GraphicsLayer.
     52
    1532013-12-16  Brent Fulgham  <bfulgham@apple.com>
    254
  • trunk/Source/WebCore/WebCore.exp.in

    r160520 r160672  
    404404__ZN7WebCore14ScrollableAreaD2Ev
    405405__ZN7WebCore14ScrollbarTheme5themeEv
     406__ZN7WebCore17ScrollbarThemeMac28removeOverhangAreaBackgroundEP7CALayer
     407__ZN7WebCore17ScrollbarThemeMac24removeOverhangAreaShadowEP7CALayer
     408__ZN7WebCore17ScrollbarThemeMac27setUpOverhangAreaBackgroundEP7CALayerRKNS_5ColorE
     409__ZN7WebCore17ScrollbarThemeMac23setUpOverhangAreaShadowEP7CALayer
    406410__ZN7WebCore14SecurityOrigin16createFromStringERKN3WTF6StringE
    407411__ZN7WebCore14SecurityOrigin28createFromDatabaseIdentifierERKN3WTF6StringE
     
    567571__ZN7WebCore15GraphicsLayerCAC2EPNS_19GraphicsLayerClientE
    568572__ZN7WebCore15GraphicsLayerCAD2Ev
     573__ZN7WebCore15GraphicsLayerCA19setCustomAppearanceENS_13GraphicsLayer16CustomAppearanceE
    569574__ZN7WebCore15HitTestLocation12rectForPointERKNS_11LayoutPointEjjjj
    570575__ZN7WebCore15JSDOMWindowBase8commonVMEv
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r160606 r160672  
    47554755                BC128B01137C8D4600CAC845 /* RenderGrid.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC128B00137C8D4600CAC845 /* RenderGrid.cpp */; };
    47564756                BC14028A0E83680800319717 /* ScrollbarThemeComposite.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC1402880E83680800319717 /* ScrollbarThemeComposite.cpp */; };
    4757                 BC14028B0E83680800319717 /* ScrollbarThemeComposite.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1402890E83680800319717 /* ScrollbarThemeComposite.h */; };
     4757                BC14028B0E83680800319717 /* ScrollbarThemeComposite.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1402890E83680800319717 /* ScrollbarThemeComposite.h */; settings = {ATTRIBUTES = (Private, ); }; };
    47584758                BC17F9660B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */; };
    47594759                BC1A37AD097C715F0019F3D8 /* DOM.h in Headers */ = {isa = PBXBuildFile; fileRef = BC1A3797097C715F0019F3D8 /* DOM.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    49774977                BC8AE34E12EA096A00EB3AE6 /* ScrollableArea.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8AE34C12EA096A00EB3AE6 /* ScrollableArea.cpp */; };
    49784978                BC8AE34F12EA096A00EB3AE6 /* ScrollableArea.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8AE34D12EA096A00EB3AE6 /* ScrollableArea.h */; settings = {ATTRIBUTES = (Private, ); }; };
    4979                 BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */; };
     4979                BC8B853E0E7C7F1100AB6984 /* ScrollbarThemeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8B853C0E7C7F1100AB6984 /* ScrollbarThemeMac.h */; settings = {ATTRIBUTES = (Private, ); }; };
    49804980                BC8B854B0E7C7F5600AB6984 /* ScrollbarTheme.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8B854A0E7C7F5600AB6984 /* ScrollbarTheme.h */; settings = {ATTRIBUTES = (Private, ); }; };
    49814981                BC8BF151105813BF00A40A07 /* UserStyleSheet.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8BF150105813BF00A40A07 /* UserStyleSheet.h */; settings = {ATTRIBUTES = (Private, ); }; };
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp

    r158183 r160672  
    9898    , m_replicatedLayer(0)
    9999    , m_repaintCount(0)
     100    , m_customAppearance(NoCustomAppearance)
    100101{
    101102#ifndef NDEBUG
  • trunk/Source/WebCore/platform/graphics/GraphicsLayer.h

    r158183 r160672  
    422422    virtual void setDebugBorder(const Color&, float /*borderWidth*/) { }
    423423
     424    enum CustomAppearance { NoCustomAppearance, ScrollingOverhang, ScrollingShadow };
     425    virtual void setCustomAppearance(CustomAppearance customAppearance) { m_customAppearance = customAppearance; }
     426    CustomAppearance customAppearance() const { return m_customAppearance; }
     427
    424428    // z-position is the z-equivalent of position(). It's only used for debugging purposes.
    425429    virtual float zPosition() const { return m_zPosition; }
     
    578582
    579583    int m_repaintCount;
     584    CustomAppearance m_customAppearance;
    580585};
    581586
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp

    r159463 r160672  
    13661366        updateDebugBorder();
    13671367
     1368    if (m_uncommittedChanges & CustomAppearanceChanged)
     1369        updateCustomAppearance();
     1370
    13681371    if (m_uncommittedChanges & ChildrenChanged) {
    13691372        updateSublayerList();
     
    28442847}
    28452848
     2849void GraphicsLayerCA::updateCustomAppearance()
     2850{
     2851    m_layer->updateCustomAppearance(m_customAppearance);
     2852}
     2853
    28462854void GraphicsLayerCA::setShowDebugBorder(bool showBorder)
    28472855{
     
    29342942        m_layer->setBorderWidth(0);
    29352943    }
     2944}
     2945
     2946void GraphicsLayerCA::setCustomAppearance(CustomAppearance customAppearance)
     2947{
     2948    if (customAppearance == m_customAppearance)
     2949        return;
     2950
     2951    GraphicsLayer::setCustomAppearance(customAppearance);
     2952    noteLayerPropertyChanged(CustomAppearanceChanged);
    29362953}
    29372954
  • trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h

    r159463 r160672  
    131131    virtual void setDebugBorder(const Color&, float borderWidth);
    132132
     133    virtual void setCustomAppearance(CustomAppearance);
     134
    133135    virtual void layerDidDisplay(PlatformLayer*);
    134136
     
    367369    void updateTiles();
    368370    void updateContentsScale(float pageScaleFactor);
     371    void updateCustomAppearance();
    369372   
    370373    enum StructuralLayerPurpose {
     
    423426        TilingAreaChanged = 1 << 28,
    424427        TilesAdded = 1 < 29,
    425         DebugIndicatorsChanged = 1 << 30
     428        DebugIndicatorsChanged = 1 << 30,
     429        CustomAppearanceChanged = 1 << 31
    426430    };
    427431    typedef unsigned LayerChangeFlags;
  • trunk/Source/WebCore/platform/graphics/ca/PlatformCALayer.h

    r158982 r160672  
    187187
    188188    virtual void setEdgeAntialiasingMask(unsigned) = 0;
     189   
     190    virtual GraphicsLayer::CustomAppearance customAppearance() const = 0;
     191    virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) = 0;
    189192
    190193    virtual TiledBacking* tiledBacking() = 0;
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.h

    r158982 r160672  
    136136    virtual void setEdgeAntialiasingMask(unsigned) OVERRIDE;
    137137
     138    virtual GraphicsLayer::CustomAppearance customAppearance() const OVERRIDE { return m_customAppearance; }
     139    virtual void updateCustomAppearance(GraphicsLayer::CustomAppearance) OVERRIDE;
     140
    138141    virtual TiledBacking* tiledBacking() OVERRIDE;
    139142
     
    147150    PlatformCALayerMac(LayerType, PlatformLayer*, PlatformCALayerClient* owner);
    148151
     152    bool requiresCustomAppearanceUpdateOnBoundsChange() const;
     153
    149154    RetainPtr<NSObject> m_delegate;
    150155    OwnPtr<PlatformCALayerList> m_customSublayers;
     156    GraphicsLayer::CustomAppearance m_customAppearance;
    151157};
    152158
  • trunk/Source/WebCore/platform/graphics/ca/mac/PlatformCALayerMac.mm

    r158982 r160672  
    3636#import "LengthFunctions.h"
    3737#import "PlatformCAFilters.h"
     38#import "ScrollbarThemeMac.h"
    3839#import "SoftLinking.h"
    3940#import "TiledBacking.h"
     
    179180PlatformCALayerMac::PlatformCALayerMac(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
    180181    : PlatformCALayer(layer ? LayerTypeCustom : layerType, owner)
     182    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
    181183{
    182184    BEGIN_BLOCK_OBJC_EXCEPTIONS
     
    273275    newLayer->copyFiltersFrom(this);
    274276#endif
     277    newLayer->updateCustomAppearance(customAppearance());
    275278
    276279    if (type == LayerTypeAVPlayerLayer) {
     
    451454    BEGIN_BLOCK_OBJC_EXCEPTIONS
    452455    [m_layer.get() setBounds:value];
     456   
     457    if (requiresCustomAppearanceUpdateOnBoundsChange())
     458        updateCustomAppearance(m_customAppearance);
     459
    453460    END_BLOCK_OBJC_EXCEPTIONS
    454461}
     
    723730}
    724731
     732bool PlatformCALayerMac::requiresCustomAppearanceUpdateOnBoundsChange() const
     733{
     734    return m_customAppearance == GraphicsLayer::ScrollingShadow;
     735}
     736
     737void PlatformCALayerMac::updateCustomAppearance(GraphicsLayer::CustomAppearance appearance)
     738{
     739    m_customAppearance = appearance;
     740
     741    switch (appearance) {
     742    case GraphicsLayer::NoCustomAppearance:
     743        ScrollbarThemeMac::removeOverhangAreaBackground(platformLayer());
     744        ScrollbarThemeMac::removeOverhangAreaShadow(platformLayer());
     745        break;
     746    case GraphicsLayer::ScrollingOverhang:
     747        ScrollbarThemeMac::setUpOverhangAreaBackground(platformLayer());
     748        break;
     749    case GraphicsLayer::ScrollingShadow:
     750        ScrollbarThemeMac::setUpOverhangAreaShadow(platformLayer());
     751        break;
     752    }
     753}
     754
    725755TiledBacking* PlatformCALayerMac::tiledBacking()
    726756{
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.h

    r157253 r160672  
    6565    static void setIsCurrentlyDrawingIntoLayer(bool);
    6666
     67#if USE(ACCELERATED_COMPOSITING) && ENABLE(RUBBER_BANDING)
     68    static void setUpOverhangAreaBackground(CALayer *, const Color& customBackgroundColor = Color());
     69    static void removeOverhangAreaBackground(CALayer *);
     70
     71    static void setUpOverhangAreaShadow(CALayer *);
     72    static void removeOverhangAreaShadow(CALayer *);
     73#endif
     74
    6775protected:
    6876    virtual bool hasButtons(ScrollbarThemeClient*);
  • trunk/Source/WebCore/platform/mac/ScrollbarThemeMac.mm

    r160335 r160672  
    531531}
    532532
    533 void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer, const Color& backgroundColor)
     533void ScrollbarThemeMac::setUpOverhangAreaBackground(CALayer *layer, const Color& customBackgroundColor)
    534534{
    535535    static CGColorRef cachedLinenBackgroundColor = linenBackgroundColor().leakRef();
    536536    // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
    537537    // of pattern images, and we know that WebCore won't touch this layer.
    538     graphicsLayer->platformLayer().backgroundColor = backgroundColor.isValid() ? cachedCGColor(backgroundColor, ColorSpaceDeviceRGB) : cachedLinenBackgroundColor;
     538    layer.backgroundColor = customBackgroundColor.isValid() ? cachedCGColor(customBackgroundColor, ColorSpaceDeviceRGB) : cachedLinenBackgroundColor;
     539}
     540
     541void ScrollbarThemeMac::removeOverhangAreaBackground(CALayer *layer)
     542{
     543    layer.backgroundColor = nil;
     544}
     545
     546void ScrollbarThemeMac::setUpOverhangAreaShadow(CALayer *layer)
     547{
     548    static const CGFloat shadowOpacity = 0.66;
     549    static const CGFloat shadowRadius = 3;
     550
     551    // We only need to set these shadow properties once.
     552    if (!layer.shadowOpacity) {
     553        layer.shadowColor = CGColorGetConstantColor(kCGColorBlack);
     554        layer.shadowOffset = CGSizeZero;
     555        layer.shadowOpacity = shadowOpacity;
     556        layer.shadowRadius = shadowRadius;
     557    }
     558
     559    RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(layer.bounds, NULL));
     560    layer.shadowPath = shadowPath.get();
     561}
     562
     563void ScrollbarThemeMac::removeOverhangAreaShadow(CALayer *layer)
     564{
     565    layer.shadowPath = nil;
     566    layer.shadowOpacity = 0;
     567}
     568
     569void ScrollbarThemeMac::setUpOverhangAreasLayerContents(GraphicsLayer* graphicsLayer, const Color& customBackgroundColor)
     570{
     571    ScrollbarThemeMac::setUpOverhangAreaBackground(graphicsLayer->platformLayer(), customBackgroundColor);
    539572}
    540573
     
    543576    // We operate on the CALayer directly here, since GraphicsLayer doesn't have the concept
    544577    // of shadows, and we know that WebCore won't touch this layer.
    545     CALayer *contentShadowLayer = graphicsLayer->platformLayer();
    546 
    547     static const CGFloat shadowOpacity = 0.66;
    548     static const CGFloat shadowRadius = 3;
    549 
    550     // We only need to set these shadow properties once.
    551     if (!contentShadowLayer.shadowOpacity) {
    552         contentShadowLayer.shadowColor = CGColorGetConstantColor(kCGColorBlack);
    553         contentShadowLayer.shadowOffset = CGSizeZero;
    554         contentShadowLayer.shadowOpacity = shadowOpacity;
    555         contentShadowLayer.shadowRadius = shadowRadius;
    556     }
    557 
    558     RetainPtr<CGPathRef> shadowPath = adoptCF(CGPathCreateWithRect(CGRectMake(0, 0, graphicsLayer->size().width(), graphicsLayer->size().height()), NULL));
    559     contentShadowLayer.shadowPath = shadowPath.get();
     578    setUpOverhangAreaShadow(graphicsLayer->platformLayer());
    560579}
    561580
  • trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp

    r160236 r160672  
    5656#include "RenderVideo.h"
    5757#include "RenderView.h"
    58 #include "ScrollbarTheme.h"
    5958#include "ScrollingConstraints.h"
    6059#include "ScrollingCoordinator.h"
     
    18431842    if (m_contentShadowLayer) {
    18441843        m_contentShadowLayer->setPosition(m_rootContentLayer->position());
    1845 
    1846         FloatSize rootContentLayerSize = m_rootContentLayer->size();
    1847         if (m_contentShadowLayer->size() != rootContentLayerSize) {
    1848             m_contentShadowLayer->setSize(rootContentLayerSize);
    1849             ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
    1850         }
     1844        m_contentShadowLayer->setSize(m_rootContentLayer->size());
    18511845    }
    18521846
     
    29342928            m_layerForOverhangAreas->setDrawsContent(false);
    29352929            m_layerForOverhangAreas->setSize(m_renderView.frameView().frameRect().size());
    2936 
    2937             ScrollbarTheme::theme()->setUpOverhangAreasLayerContents(m_layerForOverhangAreas.get(), this->page()->chrome().client().underlayColor());
     2930            m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::ScrollingOverhang);
    29382931
    29392932            // We want the overhang areas layer to be positioned below the frame contents,
     
    29542947            m_contentShadowLayer->setSize(m_rootContentLayer->size());
    29552948            m_contentShadowLayer->setPosition(m_rootContentLayer->position());
    2956             ScrollbarTheme::theme()->setUpContentShadowLayer(m_contentShadowLayer.get());
     2949            m_contentShadowLayer->setCustomAppearance(GraphicsLayer::ScrollingShadow);
    29572950
    29582951            m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
  • trunk/Source/WebKit2/ChangeLog

    r160667 r160672  
     12013-12-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Apply overhang shadow and linen to UI-side layers
     4        https://bugs.webkit.org/show_bug.cgi?id=125807
     5
     6        Reviewed by Tim Horton.
     7
     8        With UI-side compositing, we need to apply the overhang shadow and linen
     9        background to layers in the UI process. Achieve this by setting a "custom
     10        appearance" flag on layers that need a shadow or linen background, and
     11        migrating this flag to the UI process. Static functions on ScrollbarThemeMac
     12        are exposed to do the actual setting.
     13
     14        * Shared/mac/RemoteLayerTreePropertyApplier.mm:
     15        (WebKit::updateCustomAppearance): Use ScrollbarThemeMac to update the
     16        appearance.
     17        (WebKit::RemoteLayerTreePropertyApplier::applyPropertiesToLayer):
     18        * Shared/mac/RemoteLayerTreeTransaction.h:
     19        * Shared/mac/RemoteLayerTreeTransaction.mm:
     20        (WebKit::RemoteLayerTreeTransaction::LayerProperties::encode):
     21        (WebKit::RemoteLayerTreeTransaction::LayerProperties::decode):
     22        (WebKit::dumpChangedLayers):
     23        * WebProcess/WebPage/mac/PlatformCALayerRemote.cpp:
     24        (PlatformCALayerRemote::setBounds): If the bounds change, also set the
     25        CustomAppearanceChanged bit so that the UI side updates the shadow bounds
     26        (done here because the UI side is not stateful).
     27        (PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange):
     28        (PlatformCALayerRemote::customAppearance):
     29        (PlatformCALayerRemote::updateCustomAppearance):
     30        * WebProcess/WebPage/mac/PlatformCALayerRemote.h:
     31
    1322013-12-16  Brady Eidson  <beidson@apple.com>
    233
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreePropertyApplier.mm

    r159985 r160672  
    3030#import <QuartzCore/CALayer.h>
    3131#import <WebCore/PlatformCAFilters.h>
     32#import <WebCore/ScrollbarThemeMac.h>
    3233
    3334using namespace WebCore;
     
    5960}
    6061
     62static void updateCustomAppearance(CALayer *layer, GraphicsLayer::CustomAppearance customAppearance)
     63{
     64    switch (customAppearance) {
     65    case GraphicsLayer::NoCustomAppearance:
     66        ScrollbarThemeMac::removeOverhangAreaBackground(layer);
     67        ScrollbarThemeMac::removeOverhangAreaShadow(layer);
     68        break;
     69    case GraphicsLayer::ScrollingOverhang:
     70        ScrollbarThemeMac::setUpOverhangAreaBackground(layer);
     71        break;
     72    case GraphicsLayer::ScrollingShadow:
     73        ScrollbarThemeMac::setUpOverhangAreaShadow(layer);
     74        break;
     75    }
     76}
     77
    6178void RemoteLayerTreePropertyApplier::applyPropertiesToLayer(CALayer *layer, RemoteLayerTreeTransaction::LayerProperties properties, RelatedLayerMap relatedLayers)
    6279{
     
    162179    if (properties.changedProperties & RemoteLayerTreeTransaction::EdgeAntialiasingMaskChanged)
    163180        layer.edgeAntialiasingMask = properties.edgeAntialiasingMask;
     181
     182    if (properties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
     183        updateCustomAppearance(layer, properties.customAppearance);
    164184}
    165185
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.h

    r159967 r160672  
    7777        BackingStoreChanged = 1 << 24,
    7878        FiltersChanged = 1 << 25,
    79         EdgeAntialiasingMaskChanged = 1 << 26
     79        EdgeAntialiasingMaskChanged = 1 << 26,
     80        CustomAppearanceChanged = 1 << 27
    8081    };
    8182
     
    133134        WebCore::FilterOperations filters;
    134135        unsigned edgeAntialiasingMask;
     136        WebCore::GraphicsLayer::CustomAppearance customAppearance;
    135137    };
    136138
  • trunk/Source/WebKit2/Shared/mac/RemoteLayerTreeTransaction.mm

    r159967 r160672  
    156156    if (changedProperties & EdgeAntialiasingMaskChanged)
    157157        encoder << edgeAntialiasingMask;
     158
     159    if (changedProperties & CustomAppearanceChanged)
     160        encoder.encodeEnum(customAppearance);
    158161}
    159162
     
    295298    if (result.changedProperties & EdgeAntialiasingMaskChanged) {
    296299        if (!decoder.decode(result.edgeAntialiasingMask))
     300            return false;
     301    }
     302
     303    if (result.changedProperties & CustomAppearanceChanged) {
     304        if (!decoder.decodeEnum(result.customAppearance))
    297305            return false;
    298306    }
     
    640648            dumpProperty<unsigned>(ts, "edgeAntialiasingMask", layerProperties.edgeAntialiasingMask);
    641649
     650        if (layerProperties.changedProperties & RemoteLayerTreeTransaction::CustomAppearanceChanged)
     651            dumpProperty<GraphicsLayer::CustomAppearance>(ts, "customAppearance", layerProperties.customAppearance);
     652
    642653        ts << ")";
    643654
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.cpp

    r159967 r160672  
    305305    m_properties.size = value.size();
    306306    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::SizeChanged);
     307   
     308    if (requiresCustomAppearanceUpdateOnBoundsChange())
     309        m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
    307310
    308311    ensureBackingStore();
     
    514517}
    515518
     519bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
     520{
     521    return m_properties.customAppearance == GraphicsLayer::ScrollingShadow;
     522}
     523
     524GraphicsLayer::CustomAppearance PlatformCALayerRemote::customAppearance() const
     525{
     526    return m_properties.customAppearance;
     527}
     528
     529void PlatformCALayerRemote::updateCustomAppearance(GraphicsLayer::CustomAppearance customAppearance)
     530{
     531    m_properties.customAppearance = customAppearance;
     532    m_properties.notePropertiesChanged(RemoteLayerTreeTransaction::CustomAppearanceChanged);
     533}
     534
    516535PassRefPtr<PlatformCALayer> PlatformCALayerRemote::createCompatibleLayer(PlatformCALayer::LayerType layerType, PlatformCALayerClient* client) const
    517536{
  • trunk/Source/WebKit2/WebProcess/WebPage/mac/PlatformCALayerRemote.h

    r159967 r160672  
    141141    virtual void setEdgeAntialiasingMask(unsigned) OVERRIDE;
    142142
     143    virtual WebCore::GraphicsLayer::CustomAppearance customAppearance() const OVERRIDE;
     144    virtual void updateCustomAppearance(WebCore::GraphicsLayer::CustomAppearance) OVERRIDE;
     145
    143146    virtual WebCore::TiledBacking* tiledBacking() OVERRIDE { return nullptr; }
    144147
     
    158161    void removeSublayer(PlatformCALayerRemote*);
    159162
     163    bool requiresCustomAppearanceUpdateOnBoundsChange() const;
     164
    160165    RemoteLayerTreeTransaction::LayerID m_layerID;
    161166    RemoteLayerTreeTransaction::LayerProperties m_properties;
Note: See TracChangeset for help on using the changeset viewer.