Title: [234393] trunk/Source
Revision
234393
Author
[email protected]
Date
2018-07-30 16:07:17 -0700 (Mon, 30 Jul 2018)

Log Message

Shrink GraphicsLayerCA
https://bugs.webkit.org/show_bug.cgi?id=188141

Reviewed by Zalan Bujtas.
Source/WebCore:

Shrink GraphicsLayerCA from 1040 to 880 bytes by:
* moving all the clone-related stuff into the lazily-allocated m_layerClones
* moving all the animation-related stuff into the lazily-allocated m_animations
* making enums be 8-bit
* re-ordering data members

* page/cocoa/ResourceUsageOverlayCocoa.mm:
(WebCore::ResourceUsageOverlay::platformInitialize):
* platform/graphics/GraphicsLayer.cpp:
(WebCore::GraphicsLayer::GraphicsLayer):
(WebCore::operator<<):
* platform/graphics/GraphicsLayer.h:
* platform/graphics/GraphicsLayerClient.h:
* platform/graphics/WindRule.h:
* platform/graphics/ca/GraphicsLayerCA.cpp:
(WebCore::GraphicsLayerCA::GraphicsLayerCA):
(WebCore::GraphicsLayerCA::moveOrCopyAnimations):
(WebCore::GraphicsLayerCA::addProcessingActionForAnimation):
(WebCore::GraphicsLayerCA::setContentsToSolidColor):
(WebCore::GraphicsLayerCA::setContentsToImage):
(WebCore::GraphicsLayerCA::setContentsToPlatformLayer):
(WebCore::GraphicsLayerCA::contentsLayerForMedia const):
(WebCore::GraphicsLayerCA::layerDidDisplay):
(WebCore::layerTypeForCustomBackdropAppearance):
(WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
(WebCore::GraphicsLayerCA::updateGeometry):
(WebCore::GraphicsLayerCA::updateMasksToBounds):
(WebCore::GraphicsLayerCA::updateContentsVisibility):
(WebCore::GraphicsLayerCA::updateContentsOpaque):
(WebCore::GraphicsLayerCA::updateBackfaceVisibility):
(WebCore::GraphicsLayerCA::updateFilters):
(WebCore::GraphicsLayerCA::updateBackdropFilters):
(WebCore::GraphicsLayerCA::updateBackdropFiltersRect):
(WebCore::GraphicsLayerCA::ensureStructuralLayer):
(WebCore::GraphicsLayerCA::updateDrawsContent):
(WebCore::GraphicsLayerCA::updateCoverage):
(WebCore::GraphicsLayerCA::updateDebugIndicators):
(WebCore::GraphicsLayerCA::updateContentsImage):
(WebCore::GraphicsLayerCA::updateContentsPlatformLayer):
(WebCore::GraphicsLayerCA::updateContentsColorLayer):
(WebCore::GraphicsLayerCA::updateContentsRects):
(WebCore::GraphicsLayerCA::updateMasksToBoundsRect):
(WebCore::GraphicsLayerCA::updateMaskLayer):
(WebCore::GraphicsLayerCA::updateAnimations):
(WebCore::GraphicsLayerCA::isRunningTransformAnimation const):
(WebCore::GraphicsLayerCA::ensureLayerAnimations):
(WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
* platform/graphics/ca/GraphicsLayerCA.h:
(WebCore::GraphicsLayerCA::animationIsRunning const):
(WebCore::GraphicsLayerCA::primaryLayerClones const): Deleted.
* platform/graphics/ca/PlatformCALayerClient.h:
(WebCore::PlatformCALayerClient::platformCALayerContentsOrientation const):
* platform/graphics/ca/TileCoverageMap.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
* platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
(PlatformCALayerCocoa::PlatformCALayerCocoa):
(PlatformCALayerCocoa::requiresCustomAppearanceUpdateOnBoundsChange const):
(PlatformCALayerCocoa::updateCustomAppearance):
(PlatformCALayer::drawLayerContents):
* rendering/RenderLayerBacking.cpp:
(WebCore::RenderLayerBacking::updateCustomAppearance):
(WebCore::RenderLayerBacking::updateConfiguration):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::rootBackgroundColorOrTransparencyChanged):
(WebCore::RenderLayerCompositor::updateOverflowControlsLayers):

Source/WebKit:

Shrink GraphicsLayerCA from 1040 to 880 bytes by:
* moving all the clone-related stuff into the lazily-allocated m_layerClones
* moving all the animation-related stuff into the lazily-allocated m_animations
* making enums be 8-bit
* re-ordering data members

* Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
(WebKit::updateCustomAppearance):
(WebKit::RemoteLayerTreePropertyApplier::applyProperties):
* Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
(WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
* WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
(WebKit::PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange const):

Source/WebKitLegacy/mac:

Shrink GraphicsLayerCA from 1040 to 880 bytes by:
* moving all the clone-related stuff into the lazily-allocated m_layerClones
* moving all the animation-related stuff into the lazily-allocated m_animations
* making enums be 8-bit
* re-ordering data members

* WebView/WebView.mm:
(-[WebView _setMediaLayer:forPluginView:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234392 => 234393)


--- trunk/Source/WebCore/ChangeLog	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/ChangeLog	2018-07-30 23:07:17 UTC (rev 234393)
@@ -1,3 +1,76 @@
+2018-07-30  Simon Fraser  <[email protected]>
+
+        Shrink GraphicsLayerCA
+        https://bugs.webkit.org/show_bug.cgi?id=188141
+
+        Reviewed by Zalan Bujtas.
+        
+        Shrink GraphicsLayerCA from 1040 to 880 bytes by:
+        * moving all the clone-related stuff into the lazily-allocated m_layerClones
+        * moving all the animation-related stuff into the lazily-allocated m_animations
+        * making enums be 8-bit
+        * re-ordering data members
+
+        * page/cocoa/ResourceUsageOverlayCocoa.mm:
+        (WebCore::ResourceUsageOverlay::platformInitialize):
+        * platform/graphics/GraphicsLayer.cpp:
+        (WebCore::GraphicsLayer::GraphicsLayer):
+        (WebCore::operator<<):
+        * platform/graphics/GraphicsLayer.h:
+        * platform/graphics/GraphicsLayerClient.h:
+        * platform/graphics/WindRule.h:
+        * platform/graphics/ca/GraphicsLayerCA.cpp:
+        (WebCore::GraphicsLayerCA::GraphicsLayerCA):
+        (WebCore::GraphicsLayerCA::moveOrCopyAnimations):
+        (WebCore::GraphicsLayerCA::addProcessingActionForAnimation):
+        (WebCore::GraphicsLayerCA::setContentsToSolidColor):
+        (WebCore::GraphicsLayerCA::setContentsToImage):
+        (WebCore::GraphicsLayerCA::setContentsToPlatformLayer):
+        (WebCore::GraphicsLayerCA::contentsLayerForMedia const):
+        (WebCore::GraphicsLayerCA::layerDidDisplay):
+        (WebCore::layerTypeForCustomBackdropAppearance):
+        (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers):
+        (WebCore::GraphicsLayerCA::updateGeometry):
+        (WebCore::GraphicsLayerCA::updateMasksToBounds):
+        (WebCore::GraphicsLayerCA::updateContentsVisibility):
+        (WebCore::GraphicsLayerCA::updateContentsOpaque):
+        (WebCore::GraphicsLayerCA::updateBackfaceVisibility):
+        (WebCore::GraphicsLayerCA::updateFilters):
+        (WebCore::GraphicsLayerCA::updateBackdropFilters):
+        (WebCore::GraphicsLayerCA::updateBackdropFiltersRect):
+        (WebCore::GraphicsLayerCA::ensureStructuralLayer):
+        (WebCore::GraphicsLayerCA::updateDrawsContent):
+        (WebCore::GraphicsLayerCA::updateCoverage):
+        (WebCore::GraphicsLayerCA::updateDebugIndicators):
+        (WebCore::GraphicsLayerCA::updateContentsImage):
+        (WebCore::GraphicsLayerCA::updateContentsPlatformLayer):
+        (WebCore::GraphicsLayerCA::updateContentsColorLayer):
+        (WebCore::GraphicsLayerCA::updateContentsRects):
+        (WebCore::GraphicsLayerCA::updateMasksToBoundsRect):
+        (WebCore::GraphicsLayerCA::updateMaskLayer):
+        (WebCore::GraphicsLayerCA::updateAnimations):
+        (WebCore::GraphicsLayerCA::isRunningTransformAnimation const):
+        (WebCore::GraphicsLayerCA::ensureLayerAnimations):
+        (WebCore::GraphicsLayerCA::createTransformAnimationsFromKeyframes):
+        * platform/graphics/ca/GraphicsLayerCA.h:
+        (WebCore::GraphicsLayerCA::animationIsRunning const):
+        (WebCore::GraphicsLayerCA::primaryLayerClones const): Deleted.
+        * platform/graphics/ca/PlatformCALayerClient.h:
+        (WebCore::PlatformCALayerClient::platformCALayerContentsOrientation const):
+        * platform/graphics/ca/TileCoverageMap.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.h:
+        * platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm:
+        (PlatformCALayerCocoa::PlatformCALayerCocoa):
+        (PlatformCALayerCocoa::requiresCustomAppearanceUpdateOnBoundsChange const):
+        (PlatformCALayerCocoa::updateCustomAppearance):
+        (PlatformCALayer::drawLayerContents):
+        * rendering/RenderLayerBacking.cpp:
+        (WebCore::RenderLayerBacking::updateCustomAppearance):
+        (WebCore::RenderLayerBacking::updateConfiguration):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::rootBackgroundColorOrTransparencyChanged):
+        (WebCore::RenderLayerCompositor::updateOverflowControlsLayers):
+
 2018-07-30  Justin Fan  <[email protected]>
 
         [WebGL2] Support compilation of GLSL ES version 300 shaders

Modified: trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm (234392 => 234393)


--- trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm	2018-07-30 23:07:17 UTC (rev 234393)
@@ -226,7 +226,7 @@
     [m_layer.get() setBackgroundColor:adoptCF(createColor(0, 0, 0, 0.8)).get()];
     [m_layer.get() setBounds:CGRectMake(0, 0, normalWidth, normalHeight)];
 
-    overlay().layer().setContentsToPlatformLayer(m_layer.get(), GraphicsLayer::NoContentsLayer);
+    overlay().layer().setContentsToPlatformLayer(m_layer.get(), GraphicsLayer::ContentsLayerPurpose::None);
 
     ResourceUsageThread::addObserver(this, [this] (const ResourceUsageData& data) {
         appendDataToHistory(data);

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -112,12 +112,6 @@
 
 GraphicsLayer::GraphicsLayer(Type type, GraphicsLayerClient& client)
     : m_client(client)
-    , m_anchorPoint(0.5f, 0.5f, 0)
-    , m_opacity(1)
-    , m_zPosition(0)
-#if ENABLE(CSS_COMPOSITING)
-    , m_blendMode(BlendModeNormal)
-#endif
     , m_type(type)
     , m_contentsOpaque(false)
     , m_supportsSubpixelAntialiasedText(false)
@@ -135,14 +129,6 @@
     , m_isTrackingDisplayListReplay(false)
     , m_userInteractionEnabled(true)
     , m_canDetachBackingStore(true)
-    , m_paintingPhase(GraphicsLayerPaintAllWithOverflowClip)
-    , m_contentsOrientation(CompositingCoordinatesTopDown)
-    , m_parent(nullptr)
-    , m_maskLayer(nullptr)
-    , m_replicaLayer(nullptr)
-    , m_replicatedLayer(nullptr)
-    , m_repaintCount(0)
-    , m_customAppearance(NoCustomAppearance)
 {
 #ifndef NDEBUG
     m_client.verifyNotPainting();
@@ -938,11 +924,11 @@
 TextStream& operator<<(TextStream& ts, const WebCore::GraphicsLayer::CustomAppearance& customAppearance)
 {
     switch (customAppearance) {
-    case GraphicsLayer::CustomAppearance::NoCustomAppearance: ts << "none"; break;
+    case GraphicsLayer::CustomAppearance::None: ts << "none"; break;
     case GraphicsLayer::CustomAppearance::ScrollingOverhang: ts << "scrolling-overhang"; break;
     case GraphicsLayer::CustomAppearance::ScrollingShadow: ts << "scrolling-shadow"; break;
-    case GraphicsLayer::CustomAppearance::LightBackdropAppearance: ts << "light-backdrop"; break;
-    case GraphicsLayer::CustomAppearance::DarkBackdropAppearance: ts << "dark-backdrop"; break;
+    case GraphicsLayer::CustomAppearance::LightBackdrop: ts << "light-backdrop"; break;
+    case GraphicsLayer::CustomAppearance::DarkBackdrop: ts << "dark-backdrop"; break;
     }
     return ts;
 }

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayer.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayer.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -233,7 +233,7 @@
 class GraphicsLayer {
     WTF_MAKE_NONCOPYABLE(GraphicsLayer); WTF_MAKE_FAST_ALLOCATED;
 public:
-    enum class Type {
+    enum class Type : uint8_t {
         Normal,
         PageTiledBacking,
         Scrolling,
@@ -267,13 +267,13 @@
     // Returns true if the child list changed.
     WEBCORE_EXPORT virtual bool setChildren(const Vector<GraphicsLayer*>&);
 
-    enum ContentsLayerPurpose {
-        NoContentsLayer = 0,
-        ContentsLayerForImage,
-        ContentsLayerForMedia,
-        ContentsLayerForCanvas,
-        ContentsLayerForBackgroundColor,
-        ContentsLayerForPlugin
+    enum class ContentsLayerPurpose : uint8_t {
+        None = 0,
+        Image,
+        Media,
+        Canvas,
+        BackgroundColor,
+        Plugin
     };
 
     // Add child layers. If the child is already parented, it will be removed from its old parent.
@@ -477,7 +477,7 @@
     // For hosting this GraphicsLayer in a native layer hierarchy.
     virtual PlatformLayer* platformLayer() const { return 0; }
 
-    enum CompositingCoordinatesOrientation { CompositingCoordinatesTopDown, CompositingCoordinatesBottomUp };
+    enum class CompositingCoordinatesOrientation : uint8_t { TopDown, BottomUp };
 
     // Flippedness of the contents of this layer. Does not affect sublayer geometry.
     virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation) { m_contentsOrientation = orientation; }
@@ -498,7 +498,13 @@
     virtual void setDebugBackgroundColor(const Color&) { }
     virtual void setDebugBorder(const Color&, float /*borderWidth*/) { }
 
-    enum CustomAppearance { NoCustomAppearance, ScrollingOverhang, ScrollingShadow, LightBackdropAppearance, DarkBackdropAppearance };
+    enum class CustomAppearance : uint8_t {
+        None,
+        ScrollingOverhang,
+        ScrollingShadow,
+        LightBackdrop,
+        DarkBackdrop
+    };
     virtual void setCustomAppearance(CustomAppearance customAppearance) { m_customAppearance = customAppearance; }
     CustomAppearance customAppearance() const { return m_customAppearance; }
 
@@ -627,7 +633,7 @@
     // If set, overrides m_position. Only used for coverage computation.
     std::optional<FloatPoint> m_approximatePosition;
 
-    FloatPoint3D m_anchorPoint;
+    FloatPoint3D m_anchorPoint { 0.5f, 0.5f, 0 };
     FloatSize m_size;
     FloatPoint m_boundsOrigin;
 
@@ -635,17 +641,20 @@
     std::unique_ptr<TransformationMatrix> m_childrenTransform;
 
     Color m_backgroundColor;
-    float m_opacity;
-    float m_zPosition;
+    float m_opacity { 1 };
+    float m_zPosition { 0 };
     
     FilterOperations m_filters;
     FilterOperations m_backdropFilters;
 
 #if ENABLE(CSS_COMPOSITING)
-    BlendMode m_blendMode;
+    BlendMode m_blendMode { BlendModeNormal };
 #endif
 
     const Type m_type;
+    CustomAppearance m_customAppearance { CustomAppearance::None };
+    GraphicsLayerPaintingPhase m_paintingPhase { GraphicsLayerPaintAllWithOverflowClip };
+    CompositingCoordinatesOrientation m_contentsOrientation { CompositingCoordinatesOrientation::TopDown }; // affects orientation of layer contents
 
     bool m_contentsOpaque : 1;
     bool m_supportsSubpixelAntialiasedText : 1;
@@ -663,18 +672,17 @@
     bool m_isTrackingDisplayListReplay : 1;
     bool m_userInteractionEnabled : 1;
     bool m_canDetachBackingStore : 1;
-    
-    GraphicsLayerPaintingPhase m_paintingPhase;
-    CompositingCoordinatesOrientation m_contentsOrientation; // affects orientation of layer contents
 
+    int m_repaintCount { 0 };
+
     Vector<GraphicsLayer*> m_children;
-    GraphicsLayer* m_parent;
+    GraphicsLayer* m_parent { nullptr };
 
-    GraphicsLayer* m_maskLayer; // Reference to mask layer. We don't own this.
+    GraphicsLayer* m_maskLayer { nullptr }; // Reference to mask layer. We don't own this.
 
-    GraphicsLayer* m_replicaLayer; // A layer that replicates this layer. We only allow one, for now.
+    GraphicsLayer* m_replicaLayer { nullptr }; // A layer that replicates this layer. We only allow one, for now.
                                    // The replica is not parented; this is the primary reference to it.
-    GraphicsLayer* m_replicatedLayer; // For a replica layer, a reference to the original layer.
+    GraphicsLayer* m_replicatedLayer { nullptr }; // For a replica layer, a reference to the original layer.
     FloatPoint m_replicatedLayerPosition; // For a replica layer, the position of the replica.
 
     FloatRect m_contentsRect;
@@ -685,12 +693,9 @@
     FloatRoundedRect m_backdropFiltersRect;
     std::optional<FloatRect> m_animationExtent;
 
-    int m_repaintCount;
-    CustomAppearance m_customAppearance;
-
 #if USE(CA)
+    WindRule m_shapeLayerWindRule { WindRule::NonZero };
     Path m_shapeLayerPath;
-    WindRule m_shapeLayerWindRule { WindRule::NonZero };
 #endif
 };
 

Modified: trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/GraphicsLayerClient.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -48,7 +48,7 @@
     GraphicsLayerPaintChildClippingMask     = 1 << 6,
     GraphicsLayerPaintAllWithOverflowClip   = GraphicsLayerPaintBackground | GraphicsLayerPaintForeground
 };
-typedef unsigned GraphicsLayerPaintingPhase;
+typedef uint8_t GraphicsLayerPaintingPhase;
 
 enum AnimatedPropertyID {
     AnimatedPropertyInvalid,

Modified: trunk/Source/WebCore/platform/graphics/WindRule.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/WindRule.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/WindRule.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -29,7 +29,7 @@
 
 namespace WebCore {
 
-enum class WindRule {
+enum class WindRule : uint8_t {
     NonZero = 0,
     EvenOdd = 1
 };

Modified: trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -220,7 +220,7 @@
     virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
 
     virtual void platformCALayerAnimationStarted(MonotonicTime beginTime) { }
-    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesOrientation::TopDown; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) { }
     virtual bool platformCALayerShowDebugBorders() const { return false; }
     virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -403,6 +403,13 @@
 
 GraphicsLayerCA::GraphicsLayerCA(Type layerType, GraphicsLayerClient& client)
     : GraphicsLayer(layerType, client)
+    , m_needsFullRepaint(false)
+    , m_usingBackdropLayerType(false)
+    , m_isViewportConstrained(false)
+    , m_intersectsCoverageRect(false)
+    , m_hasEverPainted(false)
+    , m_hasDescendantsWithRunningTransformAnimations(false)
+    , m_hasDescendantsWithUncommittedChanges(false)
 {
 }
 
@@ -683,10 +690,12 @@
 
 void GraphicsLayerCA::moveOrCopyAnimations(MoveOrCopy operation, PlatformCALayer *fromLayer, PlatformCALayer *toLayer)
 {
+    if (!hasAnimations())
+        return;
+
     // Look for running animations affecting this property.
-    AnimationsMap::const_iterator end = m_runningAnimations.end();
-    for (AnimationsMap::const_iterator it = m_runningAnimations.begin(); it != end; ++it) {
-        const Vector<LayerPropertyAnimation>& propertyAnimations = it->value;
+    for (auto it : m_animations->runningAnimations) {
+        const auto& propertyAnimations = it.value;
         size_t numAnimations = propertyAnimations.size();
         for (size_t i = 0; i < numAnimations; ++i) {
             const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
@@ -1010,7 +1019,9 @@
 
 void GraphicsLayerCA::addProcessingActionForAnimation(const String& animationName, AnimationProcessingAction processingAction)
 {
-    auto& processingActions = m_animationsToProcess.ensure(animationName, [] {
+    ensureLayerAnimations();
+
+    auto& processingActions = m_animations->animationsToProcess.ensure(animationName, [] {
         return Vector<AnimationProcessingAction> { };
     }).iterator->value;
 
@@ -1104,8 +1115,8 @@
     bool contentsLayerChanged = false;
 
     if (m_contentsSolidColor.isVisible()) {
-        if (!m_contentsLayer || m_contentsLayerPurpose != ContentsLayerForBackgroundColor) {
-            m_contentsLayerPurpose = ContentsLayerForBackgroundColor;
+        if (!m_contentsLayer || m_contentsLayerPurpose != ContentsLayerPurpose::BackgroundColor) {
+            m_contentsLayerPurpose = ContentsLayerPurpose::BackgroundColor;
             m_contentsLayer = createPlatformCALayer(PlatformCALayer::LayerTypeLayer, this);
 #if ENABLE(TREE_DEBUGGING)
             m_contentsLayer->setName(String::format("contents color %llu", m_contentsLayer->layerID()));
@@ -1116,7 +1127,7 @@
         }
     } else {
         contentsLayerChanged = m_contentsLayer;
-        m_contentsLayerPurpose = NoContentsLayer;
+        m_contentsLayerPurpose = ContentsLayerPurpose::None;
         m_contentsLayer = nullptr;
     }
 
@@ -1140,13 +1151,13 @@
         m_uncorrectedContentsImage = WTFMove(newImage);
         m_pendingContentsImage = m_uncorrectedContentsImage;
 
-        m_contentsLayerPurpose = ContentsLayerForImage;
+        m_contentsLayerPurpose = ContentsLayerPurpose::Image;
         if (!m_contentsLayer)
             noteSublayersChanged();
     } else {
         m_uncorrectedContentsImage = nullptr;
         m_pendingContentsImage = nullptr;
-        m_contentsLayerPurpose = NoContentsLayer;
+        m_contentsLayerPurpose = ContentsLayerPurpose::None;
         if (m_contentsLayer)
             noteSublayersChanged();
     }
@@ -1171,7 +1182,7 @@
     // For now we don't support such a case.
     PlatformCALayer* platformCALayer = PlatformCALayer::platformCALayer(platformLayer);
     m_contentsLayer = platformLayer ? (platformCALayer ? platformCALayer : createPlatformCALayer(platformLayer, this).ptr()) : nullptr;
-    m_contentsLayerPurpose = platformLayer ? purpose : NoContentsLayer;
+    m_contentsLayerPurpose = platformLayer ? purpose : ContentsLayerPurpose::None;
 
     if (m_contentsClippingLayer && m_contentsLayer)
         m_contentsClippingLayer->appendSublayer(*m_contentsLayer);
@@ -1183,30 +1194,25 @@
 #if PLATFORM(IOS)
 PlatformLayer* GraphicsLayerCA::contentsLayerForMedia() const
 {
-    return m_contentsLayerPurpose == ContentsLayerForMedia ? m_contentsLayer->platformLayer() : nullptr;
+    return m_contentsLayerPurpose == ContentsLayerPurpose::Media ? m_contentsLayer->platformLayer() : nullptr;
 }
 #endif
 
 void GraphicsLayerCA::layerDidDisplay(PlatformCALayer* layer)
 {
-    LayerMap* layerCloneMap;
+    if (!m_layerClones)
+        return;
 
+    LayerMap* layerCloneMap = nullptr;
+
     if (layer == m_layer)
-        layerCloneMap = m_layerClones.get();
+        layerCloneMap = &m_layerClones->primaryLayerClones;
     else if (layer == m_contentsLayer)
-        layerCloneMap = m_contentsLayerClones.get();
-    else
-        return;
+        layerCloneMap = &m_layerClones->contentsLayerClones;
 
     if (layerCloneMap) {
-        LayerMap::const_iterator end = layerCloneMap->end();
-        for (LayerMap::const_iterator it = layerCloneMap->begin(); it != end; ++it) {
-            PlatformCALayer* currClone = it->value.get();
-            if (!currClone)
-                continue;
-
-            currClone->copyContentsFromLayer(layer);
-        }
+        for (auto& platformLayerClone : layerCloneMap->values())
+            platformLayerClone->copyContentsFromLayer(layer);
     }
 }
 
@@ -1687,7 +1693,7 @@
 
 static PlatformCALayer::LayerType layerTypeForCustomBackdropAppearance(GraphicsLayer::CustomAppearance appearance)
 {
-    return appearance == GraphicsLayer::LightBackdropAppearance ? PlatformCALayer::LayerTypeLightSystemBackdropLayer : PlatformCALayer::LayerTypeDarkSystemBackdropLayer;
+    return appearance == GraphicsLayer::CustomAppearance::LightBackdrop ? PlatformCALayer::LayerTypeLightSystemBackdropLayer : PlatformCALayer::LayerTypeDarkSystemBackdropLayer;
 }
 
 static bool isCustomBackdropLayerType(PlatformCALayer::LayerType layerType)
@@ -1710,7 +1716,7 @@
     }
 
     bool needTiledLayer = requiresTiledLayer(pageScaleFactor);
-    bool needBackdropLayerType = (customAppearance() == LightBackdropAppearance || customAppearance() == DarkBackdropAppearance);
+    bool needBackdropLayerType = (customAppearance() == CustomAppearance::LightBackdrop || customAppearance() == CustomAppearance::DarkBackdrop);
 
     PlatformCALayer::LayerType currentLayerType = m_layer->layerType();
     PlatformCALayer::LayerType neededLayerType = currentLayerType;
@@ -1964,8 +1970,8 @@
         m_structuralLayer->setBounds(layerBounds);
         m_structuralLayer->setAnchorPoint(m_anchorPoint);
 
-        if (LayerMap* layerCloneMap = m_structuralLayerClones.get()) {
-            for (auto& clone : *layerCloneMap) {
+        if (m_layerClones) {
+            for (auto& clone : m_layerClones->structuralLayerClones) {
                 PlatformCALayer* cloneLayer = clone.value.get();
                 FloatPoint clonePosition = layerPosition;
 
@@ -1994,8 +2000,8 @@
     m_layer->setBounds(adjustedBounds);
     m_layer->setAnchorPoint(scaledAnchorPoint);
 
-    if (LayerMap* layerCloneMap = m_layerClones.get()) {
-        for (auto& clone : *layerCloneMap) {
+    if (m_layerClones) {
+        for (auto& clone : m_layerClones->primaryLayerClones) {
             PlatformCALayer* cloneLayer = clone.value.get();
             FloatPoint clonePosition = adjustedPosition;
 
@@ -2043,8 +2049,8 @@
 {
     m_layer->setMasksToBounds(m_masksToBounds);
 
-    if (LayerMap* layerCloneMap = m_layerClones.get()) {
-        for (auto& layer : layerCloneMap->values())
+    if (m_layerClones) {
+        for (auto& layer : m_layerClones->primaryLayerClones.values())
             layer->setMasksToBounds(m_masksToBounds);
     }
 }
@@ -2061,8 +2067,8 @@
     } else {
         m_layer->setContents(nullptr);
 
-        if (LayerMap* layerCloneMap = m_layerClones.get()) {
-            for (auto& layer : layerCloneMap->values())
+        if (m_layerClones) {
+            for (auto& layer : m_layerClones->primaryLayerClones.values())
                 layer->setContents(nullptr);
         }
 
@@ -2089,8 +2095,8 @@
     
     m_layer->setOpaque(contentsOpaque);
 
-    if (LayerMap* layerCloneMap = m_layerClones.get()) {
-        for (auto& layer : layerCloneMap->values())
+    if (m_layerClones) {
+        for (auto& layer : m_layerClones->primaryLayerClones.values())
             layer->setOpaque(contentsOpaque);
     }
 }
@@ -2100,8 +2106,8 @@
     if (m_structuralLayer && structuralLayerPurpose() == StructuralLayerForReplicaFlattening) {
         m_structuralLayer->setDoubleSided(m_backfaceVisibility);
 
-        if (LayerMap* layerCloneMap = m_structuralLayerClones.get()) {
-            for (auto& layer : layerCloneMap->values())
+        if (m_layerClones) {
+            for (auto& layer : m_layerClones->structuralLayerClones.values())
                 layer->setDoubleSided(m_backfaceVisibility);
         }
     }
@@ -2108,8 +2114,8 @@
 
     m_layer->setDoubleSided(m_backfaceVisibility);
 
-    if (LayerMap* layerCloneMap = m_layerClones.get()) {
-        for (auto& layer : layerCloneMap->values())
+    if (m_layerClones) {
+        for (auto& layer : m_layerClones->primaryLayerClones.values())
             layer->setDoubleSided(m_backfaceVisibility);
     }
 }
@@ -2118,8 +2124,8 @@
 {
     m_layer->setFilters(m_filters);
 
-    if (LayerMap* layerCloneMap = m_layerClones.get()) {
-        for (auto& clone : *layerCloneMap) {
+    if (m_layerClones) {
+        for (auto& clone : m_layerClones->primaryLayerClones) {
             if (m_replicaLayer && isReplicatedRootClone(clone.key))
                 continue;
 
@@ -2150,8 +2156,8 @@
     m_backdropLayer->setHidden(!m_contentsVisible);
     m_backdropLayer->setFilters(m_backdropFilters);
 
-    if (LayerMap* layerCloneMap = m_backdropLayerClones.get()) {
-        for (auto& clone : *layerCloneMap) {
+    if (m_layerClones) {
+        for (auto& clone : m_layerClones->backdropLayerClones) {
             PlatformCALayer* cloneLayer = clone.value.get();
             cloneLayer->setHidden(!m_contentsVisible);
             cloneLayer->setFilters(m_backdropFilters);
@@ -2173,24 +2179,22 @@
 
     updateClippingStrategy(*m_backdropLayer, m_backdropClippingLayer, m_backdropFiltersRect);
 
-    if (m_backdropLayerClones) {
-        for (auto& clone : *m_backdropLayerClones) {
+    if (m_layerClones) {
+        for (auto& clone : m_layerClones->backdropLayerClones) {
             PlatformCALayer* backdropCloneLayer = clone.value.get();
             backdropCloneLayer->setBounds(contentBounds);
             backdropCloneLayer->setPosition(m_backdropFiltersRect.rect().location());
 
             CloneID cloneID = clone.key;
-            RefPtr<PlatformCALayer> backdropClippingLayerClone;
-            if (m_backdropClippingLayerClones)
-                backdropClippingLayerClone = m_backdropClippingLayerClones->get(cloneID);
+            RefPtr<PlatformCALayer> backdropClippingLayerClone = m_layerClones->backdropLayerClones.get(cloneID);
 
             bool hadBackdropClippingLayer = backdropClippingLayerClone;
             updateClippingStrategy(*backdropCloneLayer, backdropClippingLayerClone, m_backdropFiltersRect);
 
-            if (!backdropClippingLayerClone && m_backdropClippingLayerClones)
-                m_backdropClippingLayerClones->remove(cloneID);
+            if (!backdropClippingLayerClone)
+                m_layerClones->backdropLayerClones.remove(cloneID);
             else if (backdropClippingLayerClone && !hadBackdropClippingLayer)
-                m_backdropClippingLayerClones->add(cloneID, backdropClippingLayerClone);
+                m_layerClones->backdropLayerClones.add(cloneID, backdropClippingLayerClone);
         }
     }
 }
@@ -2300,13 +2304,11 @@
     m_layer->setTransform(TransformationMatrix());
     m_layer->setOpacity(1);
     if (m_layerClones) {
-        LayerMap::const_iterator end = m_layerClones->end();
-        for (LayerMap::const_iterator it = m_layerClones->begin(); it != end; ++it) {
-            PlatformCALayer* currLayer = it->value.get();
-            currLayer->setPosition(point);
-            currLayer->setAnchorPoint(anchorPoint);
-            currLayer->setTransform(TransformationMatrix());
-            currLayer->setOpacity(1);
+        for (auto& layer : m_layerClones->primaryLayerClones.values()) {
+            layer->setPosition(point);
+            layer->setAnchorPoint(anchorPoint);
+            layer->setTransform(TransformationMatrix());
+            layer->setOpacity(1);
         }
     }
 
@@ -2333,11 +2335,10 @@
         m_layer->setNeedsDisplay();
         m_hasEverPainted = false;
     } else {
-        m_layer->setContents(0);
+        m_layer->setContents(nullptr);
         if (m_layerClones) {
-            LayerMap::const_iterator end = m_layerClones->end();
-            for (LayerMap::const_iterator it = m_layerClones->begin(); it != end; ++it)
-                it->value->setContents(0);
+            for (auto& layer : m_layerClones->primaryLayerClones.values())
+                layer->setContents(nullptr);
         }
     }
 }
@@ -2372,8 +2373,8 @@
 
         m_layer->setBackingStoreAttached(requiresBacking);
         if (m_layerClones) {
-            for (auto& it : *m_layerClones)
-                it.value->setBackingStoreAttached(requiresBacking);
+            for (auto& layer : m_layerClones->primaryLayerClones.values())
+                layer->setBackingStoreAttached(requiresBacking);
         }
     }
 
@@ -2425,20 +2426,16 @@
         setLayerDebugBorder(*m_contentsLayer, contentsLayerDebugBorderColor(showDebugBorders), contentsLayerBorderWidth);
 
     if (m_layerClones) {
-        for (auto& clone : m_layerClones->values())
-            setLayerDebugBorder(*clone, borderColor, width);
-    }
+        for (auto& layer : m_layerClones->primaryLayerClones.values())
+            setLayerDebugBorder(*layer, borderColor, width);
 
-    if (m_structuralLayerClones) {
         Color cloneLayerBorderColor = cloneLayerDebugBorderColor(showDebugBorders);
-        for (auto& clone : m_structuralLayerClones->values())
-            setLayerDebugBorder(*clone, cloneLayerBorderColor, cloneLayerBorderWidth);
-    }
+        for (auto& layer : m_layerClones->structuralLayerClones.values())
+            setLayerDebugBorder(*layer, cloneLayerBorderColor, cloneLayerBorderWidth);
 
-    if (m_contentsLayerClones) {
         Color contentsLayerBorderColor = contentsLayerDebugBorderColor(showDebugBorders);
-        for (auto& contentsLayerClone : m_contentsLayerClones->values())
-            setLayerDebugBorder(*contentsLayerClone, contentsLayerBorderColor, contentsLayerBorderWidth);
+        for (auto& layer : m_layerClones->contentsLayerClones.values())
+            setLayerDebugBorder(*layer, contentsLayerBorderColor, contentsLayerBorderWidth);
     }
 }
 
@@ -2539,10 +2536,9 @@
         m_contentsLayer->setContents(m_pendingContentsImage.get());
         m_pendingContentsImage = nullptr;
 
-        if (m_contentsLayerClones) {
-            LayerMap::const_iterator end = m_contentsLayerClones->end();
-            for (LayerMap::const_iterator it = m_contentsLayerClones->begin(); it != end; ++it)
-                it->value->setContents(m_contentsLayer->contents());
+        if (m_layerClones) {
+            for (auto& layer : m_layerClones->contentsLayerClones.values())
+                layer->setContents(m_contentsLayer->contents());
         }
         
         updateContentsRects();
@@ -2561,7 +2557,7 @@
     // Platform layer was set as m_contentsLayer, and will get parented in updateSublayerList().
     setupContentsLayer(m_contentsLayer.get());
 
-    if (m_contentsLayerPurpose == ContentsLayerForCanvas)
+    if (m_contentsLayerPurpose == ContentsLayerPurpose::Canvas)
         m_contentsLayer->setNeedsDisplay();
 
     updateContentsRects();
@@ -2570,7 +2566,7 @@
 void GraphicsLayerCA::updateContentsColorLayer()
 {
     // Color layer was set as m_contentsLayer, and will get parented in updateSublayerList().
-    if (!m_contentsLayer || m_contentsLayerPurpose != ContentsLayerForBackgroundColor)
+    if (!m_contentsLayer || m_contentsLayerPurpose != ContentsLayerPurpose::BackgroundColor)
         return;
 
     setupContentsLayer(m_contentsLayer.get());
@@ -2578,10 +2574,9 @@
     ASSERT(m_contentsSolidColor.isValid());
     m_contentsLayer->setBackgroundColor(m_contentsSolidColor);
 
-    if (m_contentsLayerClones) {
-        LayerMap::const_iterator end = m_contentsLayerClones->end();
-        for (LayerMap::const_iterator it = m_contentsLayerClones->begin(); it != end; ++it)
-            it->value->setBackgroundColor(m_contentsSolidColor);
+    if (m_layerClones) {
+        for (auto& layer : m_layerClones->contentsLayerClones.values())
+            layer->setBackgroundColor(m_contentsSolidColor);
     }
 }
 
@@ -2676,30 +2671,23 @@
     m_contentsLayer->setPosition(contentOrigin);
     m_contentsLayer->setBounds(contentBounds);
 
-    if (m_contentsLayerClones) {
-        for (auto& layer : m_contentsLayerClones->values()) {
+    if (m_layerClones) {
+        for (auto& layer : m_layerClones->contentsLayerClones.values()) {
             layer->setPosition(contentOrigin);
             layer->setBounds(contentBounds);
         }
-    }
 
-    if (m_contentsClippingLayerClones) {
-        if (!m_contentsShapeMaskLayerClones && m_contentsShapeMaskLayer)
-            m_contentsShapeMaskLayerClones = std::make_unique<LayerMap>();
-
-        for (auto& clone : *m_contentsClippingLayerClones) {
+        for (auto& clone : m_layerClones->contentsClippingLayerClones) {
             CloneID cloneID = clone.key;
-            RefPtr<PlatformCALayer> shapeMaskLayerClone;
-            if (m_contentsShapeMaskLayerClones)
-                shapeMaskLayerClone = m_contentsShapeMaskLayerClones->get(cloneID);
+            RefPtr<PlatformCALayer> shapeMaskLayerClone = m_layerClones->contentsShapeMaskLayerClones.get(cloneID);
 
             bool hadShapeMask = shapeMaskLayerClone;
             updateClippingStrategy(*clone.value, shapeMaskLayerClone, m_contentsClippingRect);
 
-            if (!shapeMaskLayerClone && m_contentsShapeMaskLayerClones)
-                m_contentsShapeMaskLayerClones->remove(cloneID);
+            if (!shapeMaskLayerClone)
+                m_layerClones->contentsShapeMaskLayerClones.remove(cloneID);
             else if (shapeMaskLayerClone && !hadShapeMask)
-                m_contentsShapeMaskLayerClones->add(cloneID, shapeMaskLayerClone);
+                m_layerClones->contentsShapeMaskLayerClones.add(cloneID, shapeMaskLayerClone);
         }
     }
 }
@@ -2709,19 +2697,17 @@
     updateClippingStrategy(*m_layer, m_shapeMaskLayer, m_masksToBoundsRect);
 
     if (m_layerClones) {
-        for (auto& clone : *m_layerClones) {
+        for (auto& clone : m_layerClones->primaryLayerClones) {
             CloneID cloneID = clone.key;
-            RefPtr<PlatformCALayer> shapeMaskLayerClone;
-            if (m_shapeMaskLayerClones)
-                shapeMaskLayerClone = m_shapeMaskLayerClones->get(cloneID);
+            RefPtr<PlatformCALayer> shapeMaskLayerClone = m_layerClones->shapeMaskLayerClones.get(cloneID);
 
             bool hadShapeMask = shapeMaskLayerClone;
             updateClippingStrategy(*clone.value, shapeMaskLayerClone, m_masksToBoundsRect);
 
-            if (!shapeMaskLayerClone && m_shapeMaskLayerClones)
-                m_shapeMaskLayerClones->remove(cloneID);
-            else if (shapeMaskLayerClone && !hadShapeMask)
-                m_shapeMaskLayerClones->add(cloneID, shapeMaskLayerClone);
+            if (!shapeMaskLayerClone)
+                m_layerClones->shapeMaskLayerClones.remove(cloneID);
+            else if (!hadShapeMask && shapeMaskLayerClone)
+                m_layerClones->shapeMaskLayerClones.add(cloneID, shapeMaskLayerClone);
         }
     }
 }
@@ -2733,10 +2719,10 @@
     LayerMap* layerCloneMap;
     if (m_structuralLayer && structuralLayerPurpose() == StructuralLayerForBackdrop) {
         m_structuralLayer->setMask(maskCALayer);
-        layerCloneMap = m_structuralLayerClones.get();
+        layerCloneMap = m_layerClones ? &m_layerClones->structuralLayerClones : nullptr;
     } else {
         m_layer->setMask(maskCALayer);
-        layerCloneMap = m_layerClones.get();
+        layerCloneMap = m_layerClones ? &m_layerClones->primaryLayerClones : nullptr;
     }
 
     LayerMap* maskLayerCloneMap = m_maskLayer ? downcast<GraphicsLayerCA>(*m_maskLayer).primaryLayerClones() : nullptr;
@@ -2804,34 +2790,36 @@
 
 void GraphicsLayerCA::updateAnimations()
 {
+    if (!hasAnimations())
+        return;
+
     size_t numAnimations;
-    if ((numAnimations = m_uncomittedAnimations.size())) {
+    if ((numAnimations = m_animations->uncomittedAnimations.size())) {
         for (size_t i = 0; i < numAnimations; ++i) {
-            const LayerPropertyAnimation& pendingAnimation = m_uncomittedAnimations[i];
+            const LayerPropertyAnimation& pendingAnimation = m_animations->uncomittedAnimations[i];
             setAnimationOnLayer(*pendingAnimation.m_animation, pendingAnimation.m_property, pendingAnimation.m_name, pendingAnimation.m_index, pendingAnimation.m_subIndex, pendingAnimation.m_timeOffset);
 
-            AnimationsMap::iterator it = m_runningAnimations.find(pendingAnimation.m_name);
-            if (it == m_runningAnimations.end()) {
+            AnimationsMap::iterator it = m_animations->runningAnimations.find(pendingAnimation.m_name);
+            if (it == m_animations->runningAnimations.end()) {
                 Vector<LayerPropertyAnimation> animations;
                 animations.append(pendingAnimation);
-                m_runningAnimations.add(pendingAnimation.m_name, animations);
+                m_animations->runningAnimations.add(pendingAnimation.m_name, animations);
             } else {
                 Vector<LayerPropertyAnimation>& animations = it->value;
                 animations.append(pendingAnimation);
             }
         }
-        m_uncomittedAnimations.clear();
+        m_animations->uncomittedAnimations.clear();
     }
 
-    if (m_animationsToProcess.size()) {
-        AnimationsToProcessMap::const_iterator end = m_animationsToProcess.end();
-        for (AnimationsToProcessMap::const_iterator it = m_animationsToProcess.begin(); it != end; ++it) {
-            const String& currentAnimationName = it->key;
-            auto animationIterator = m_runningAnimations.find(currentAnimationName);
-            if (animationIterator == m_runningAnimations.end())
+    if (m_animations->animationsToProcess.size()) {
+        for (auto it : m_animations->animationsToProcess) {
+            const String& currentAnimationName = it.key;
+            auto animationIterator = m_animations->runningAnimations.find(currentAnimationName);
+            if (animationIterator == m_animations->runningAnimations.end())
                 continue;
 
-            for (const auto& processingInfo : it->value) {
+            for (const auto& processingInfo : it.value) {
                 const Vector<LayerPropertyAnimation>& animations = animationIterator->value;
                 for (const auto& currentAnimation : animations) {
                     switch (processingInfo.action) {
@@ -2848,20 +2836,21 @@
                 }
 
                 if (processingInfo.action == Remove)
-                    m_runningAnimations.remove(currentAnimationName);
+                    m_animations->runningAnimations.remove(currentAnimationName);
             }
-
         }
 
-        m_animationsToProcess.clear();
+        m_animations->animationsToProcess.clear();
     }
 }
 
 bool GraphicsLayerCA::isRunningTransformAnimation() const
 {
-    AnimationsMap::const_iterator end = m_runningAnimations.end();
-    for (AnimationsMap::const_iterator it = m_runningAnimations.begin(); it != end; ++it) {
-        const Vector<LayerPropertyAnimation>& propertyAnimations = it->value;
+    if (!hasAnimations())
+        return false;
+
+    for (auto it : m_animations->runningAnimations) {
+        const auto& propertyAnimations = it.value;
         size_t numAnimations = propertyAnimations.size();
         for (size_t i = 0; i < numAnimations; ++i) {
             const LayerPropertyAnimation& currAnimation = propertyAnimations[i];
@@ -2872,6 +2861,12 @@
     return false;
 }
 
+void GraphicsLayerCA::ensureLayerAnimations()
+{
+    if (!m_animations)
+        m_animations = std::make_unique<LayerAnimations>();
+}
+
 void GraphicsLayerCA::setAnimationOnLayer(PlatformCAAnimation& caAnim, AnimatedPropertyID property, const String& animationName, int index, int subIndex, Seconds timeOffset)
 {
     PlatformCALayer* layer = animatedLayer(property);
@@ -3136,11 +3131,13 @@
 
 void GraphicsLayerCA::appendToUncommittedAnimations(LayerPropertyAnimation&& animation)
 {
+    ensureLayerAnimations();
+
     // Since we're adding a new animation, make sure we clear any pending AnimationProcessingAction for this animation
     // as these are applied after we've committed new animations.
-    m_animationsToProcess.remove(animation.m_name);
+    m_animations->animationsToProcess.remove(animation.m_name);
 
-    m_uncomittedAnimations.append(WTFMove(animation));
+    m_animations->uncomittedAnimations.append(WTFMove(animation));
 }
 
 bool GraphicsLayerCA::createFilterAnimationsFromKeyframes(const KeyframeValueList& valueList, const Animation* animation, const String& animationName, Seconds timeOffset)
@@ -3557,9 +3554,20 @@
     }
 }
 
+GraphicsLayerCA::LayerMap* GraphicsLayerCA::primaryLayerClones() const
+{
+    if (!m_layerClones)
+        return nullptr;
+
+    return m_structuralLayer ? &m_layerClones->structuralLayerClones : &m_layerClones->primaryLayerClones;
+}
+
 GraphicsLayerCA::LayerMap* GraphicsLayerCA::animatedLayerClones(AnimatedPropertyID property) const
 {
-    return (property == AnimatedPropertyBackgroundColor) ? m_contentsLayerClones.get() : primaryLayerClones();
+    if (!m_layerClones)
+        return nullptr;
+
+    return (property == AnimatedPropertyBackgroundColor) ? &m_layerClones->contentsLayerClones : primaryLayerClones();
 }
 
 void GraphicsLayerCA::updateContentsScale(float pageScaleFactor)
@@ -3576,7 +3584,7 @@
 
     m_layer->setContentsScale(contentsScale);
 
-    if (m_contentsLayer && m_contentsLayerPurpose == ContentsLayerForMedia)
+    if (m_contentsLayer && m_contentsLayerPurpose == ContentsLayerPurpose::Media)
         m_contentsLayer->setContentsScale(contentsScale);
 
     if (tiledBacking()) {
@@ -3820,7 +3828,7 @@
 
 GraphicsLayer::CompositingCoordinatesOrientation GraphicsLayerCA::defaultContentsOrientation() const
 {
-    return CompositingCoordinatesTopDown;
+    return CompositingCoordinatesOrientation::TopDown;
 }
 
 void GraphicsLayerCA::setupContentsLayer(PlatformCALayer* contentsLayer)
@@ -3830,7 +3838,7 @@
     contentsLayer->setMasksToBounds(true);
 #endif
 
-    if (defaultContentsOrientation() == CompositingCoordinatesBottomUp) {
+    if (defaultContentsOrientation() == CompositingCoordinatesOrientation::BottomUp) {
         TransformationMatrix flipper(
             1.0f, 0.0f, 0.0f, 0.0f,
             0.0f, -1.0f, 0.0f, 0.0f,
@@ -3844,7 +3852,7 @@
     setLayerDebugBorder(*contentsLayer, contentsLayerDebugBorderColor(isShowingDebugBorder()), contentsLayerBorderWidth);
 }
 
-RefPtr<PlatformCALayer> GraphicsLayerCA::findOrMakeClone(CloneID cloneID, PlatformCALayer *sourceLayer, LayerMap* clones, CloneLevel cloneLevel)
+RefPtr<PlatformCALayer> GraphicsLayerCA::findOrMakeClone(CloneID cloneID, PlatformCALayer *sourceLayer, LayerMap& clones, CloneLevel cloneLevel)
 {
     if (!sourceLayer)
         return nullptr;
@@ -3854,7 +3862,7 @@
     // Add with a dummy value to get an iterator for the insertion position, and a boolean that tells
     // us whether there's an item there. This technique avoids two hash lookups.
     RefPtr<PlatformCALayer> dummy;
-    LayerMap::AddResult addResult = clones->add(cloneID, dummy);
+    LayerMap::AddResult addResult = clones.add(cloneID, dummy);
     if (!addResult.isNewEntry) {
         // Value was not added, so it exists already.
         resultLayer = addResult.iterator->value.get();
@@ -3878,60 +3886,39 @@
     contentsLayer = nullptr;
 
     if (!m_layerClones)
-        m_layerClones = std::make_unique<LayerMap>();
+        m_layerClones = std::make_unique<LayerClones>();
 
-    if (!m_structuralLayerClones && m_structuralLayer)
-        m_structuralLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_contentsLayerClones && m_contentsLayer)
-        m_contentsLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_contentsClippingLayerClones && m_contentsClippingLayer)
-        m_contentsClippingLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_contentsShapeMaskLayerClones && m_contentsShapeMaskLayer)
-        m_contentsShapeMaskLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_shapeMaskLayerClones && m_shapeMaskLayer)
-        m_shapeMaskLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_backdropLayerClones && m_backdropLayer)
-        m_backdropLayerClones = std::make_unique<LayerMap>();
-
-    if (!m_backdropClippingLayerClones && m_backdropClippingLayer)
-        m_backdropClippingLayerClones = std::make_unique<LayerMap>();
-
-    primaryLayer = findOrMakeClone(cloneID, m_layer.get(), m_layerClones.get(), cloneLevel);
-    structuralLayer = findOrMakeClone(cloneID, m_structuralLayer.get(), m_structuralLayerClones.get(), cloneLevel);
-    contentsLayer = findOrMakeClone(cloneID, m_contentsLayer.get(), m_contentsLayerClones.get(), cloneLevel);
-    contentsClippingLayer = findOrMakeClone(cloneID, m_contentsClippingLayer.get(), m_contentsClippingLayerClones.get(), cloneLevel);
-    contentsShapeMaskLayer = findOrMakeClone(cloneID, m_contentsShapeMaskLayer.get(), m_contentsShapeMaskLayerClones.get(), cloneLevel);
-    shapeMaskLayer = findOrMakeClone(cloneID, m_shapeMaskLayer.get(), m_shapeMaskLayerClones.get(), cloneLevel);
-    backdropLayer = findOrMakeClone(cloneID, m_backdropLayer.get(), m_backdropLayerClones.get(), cloneLevel);
-    backdropClippingLayer = findOrMakeClone(cloneID, m_backdropClippingLayer.get(), m_backdropClippingLayerClones.get(), cloneLevel);
+    primaryLayer = findOrMakeClone(cloneID, m_layer.get(), m_layerClones->primaryLayerClones, cloneLevel);
+    structuralLayer = findOrMakeClone(cloneID, m_structuralLayer.get(), m_layerClones->structuralLayerClones, cloneLevel);
+    contentsLayer = findOrMakeClone(cloneID, m_contentsLayer.get(), m_layerClones->contentsLayerClones, cloneLevel);
+    contentsClippingLayer = findOrMakeClone(cloneID, m_contentsClippingLayer.get(), m_layerClones->contentsClippingLayerClones, cloneLevel);
+    contentsShapeMaskLayer = findOrMakeClone(cloneID, m_contentsShapeMaskLayer.get(), m_layerClones->contentsShapeMaskLayerClones, cloneLevel);
+    shapeMaskLayer = findOrMakeClone(cloneID, m_shapeMaskLayer.get(), m_layerClones->shapeMaskLayerClones, cloneLevel);
+    backdropLayer = findOrMakeClone(cloneID, m_backdropLayer.get(), m_layerClones->backdropLayerClones, cloneLevel);
+    backdropClippingLayer = findOrMakeClone(cloneID, m_backdropClippingLayer.get(), m_layerClones->backdropClippingLayerClones, cloneLevel);
 }
 
-void GraphicsLayerCA::clearClones(std::unique_ptr<LayerMap>& layerMap)
+void GraphicsLayerCA::clearClones(LayerMap& layerMap)
 {
-    if (!layerMap)
-        return;
-
-    for (auto& layer : layerMap->values())
+    for (auto& layer : layerMap.values())
         layer->setOwner(nullptr);
-    
-    layerMap = nullptr;
 }
 
 void GraphicsLayerCA::removeCloneLayers()
 {
-    clearClones(m_layerClones);
-    clearClones(m_structuralLayerClones);
-    clearClones(m_contentsLayerClones);
-    clearClones(m_contentsClippingLayerClones);
-    clearClones(m_contentsShapeMaskLayerClones);
-    clearClones(m_shapeMaskLayerClones);
-    clearClones(m_backdropLayerClones);
-    clearClones(m_backdropClippingLayerClones);
+    if (!m_layerClones)
+        return;
+
+    clearClones(m_layerClones->primaryLayerClones);
+    clearClones(m_layerClones->structuralLayerClones);
+    clearClones(m_layerClones->contentsLayerClones);
+    clearClones(m_layerClones->contentsClippingLayerClones);
+    clearClones(m_layerClones->contentsShapeMaskLayerClones);
+    clearClones(m_layerClones->shapeMaskLayerClones);
+    clearClones(m_layerClones->backdropLayerClones);
+    clearClones(m_layerClones->backdropClippingLayerClones);
+    
+    m_layerClones = nullptr;
 }
 
 FloatPoint GraphicsLayerCA::positionForCloneRootLayer() const
@@ -4091,7 +4078,7 @@
     
     if (preserves3D()) {
         m_layer->setOpacity(accumulatedOpacity);
-        layerCloneMap = m_layerClones.get();
+        layerCloneMap = m_layerClones ? &m_layerClones->primaryLayerClones : nullptr;
     } else {
         primaryLayer()->setOpacity(accumulatedOpacity);
         layerCloneMap = primaryLayerClones();

Modified: trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/GraphicsLayerCA.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -140,7 +140,7 @@
     WEBCORE_EXPORT void setContentsToPlatformLayer(PlatformLayer*, ContentsLayerPurpose) override;
     WEBCORE_EXPORT void setContentsToSolidColor(const Color&) override;
 
-    bool usesContentsLayer() const override { return m_contentsLayerPurpose != NoContentsLayer; }
+    bool usesContentsLayer() const override { return m_contentsLayerPurpose != ContentsLayerPurpose::None; }
     
     WEBCORE_EXPORT void setShowDebugBorder(bool) override;
     WEBCORE_EXPORT void setShowRepaintCounter(bool) override;
@@ -237,8 +237,9 @@
     static bool isReplicatedRootClone(const CloneID& cloneID) { return cloneID[0U] & 1; }
 
     typedef HashMap<CloneID, RefPtr<PlatformCALayer>> LayerMap;
-    LayerMap* primaryLayerClones() const { return m_structuralLayer.get() ? m_structuralLayerClones.get() : m_layerClones.get(); }
+    LayerMap* primaryLayerClones() const;
     LayerMap* animatedLayerClones(AnimatedPropertyID) const;
+    static void clearClones(LayerMap&);
 
     bool createAnimationFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset);
     bool createTransformAnimationsFromKeyframes(const KeyframeValueList&, const Animation*, const String& animationName, Seconds timeOffset, const FloatSize& boxSize);
@@ -266,9 +267,10 @@
     WEBCORE_EXPORT bool backingStoreAttached() const override;
     WEBCORE_EXPORT bool backingStoreAttachedForTesting() const override;
 
+    bool hasAnimations() const { return m_animations.get(); }
     bool animationIsRunning(const String& animationName) const
     {
-        return m_runningAnimations.find(animationName) != m_runningAnimations.end();
+        return m_animations && m_animations->runningAnimations.contains(animationName);
     }
 
     void commitLayerChangesBeforeSublayers(CommitState&, float pageScaleFactor, const FloatPoint& positionRelativeToBase);
@@ -375,7 +377,7 @@
     RefPtr<PlatformCALayer> fetchCloneLayers(GraphicsLayer* replicaRoot, ReplicaState&, CloneLevel);
     
     Ref<PlatformCALayer> cloneLayer(PlatformCALayer *, CloneLevel);
-    RefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap*, CloneLevel);
+    RefPtr<PlatformCALayer> findOrMakeClone(CloneID, PlatformCALayer *, LayerMap&, CloneLevel);
 
     void ensureCloneLayers(CloneID, RefPtr<PlatformCALayer>& primaryLayer, RefPtr<PlatformCALayer>& structuralLayer,
         RefPtr<PlatformCALayer>& contentsLayer, RefPtr<PlatformCALayer>& contentsClippingLayer, RefPtr<PlatformCALayer>& contentsShapeMaskLayer,
@@ -382,8 +384,6 @@
         RefPtr<PlatformCALayer>& shapeMaskLayer, RefPtr<PlatformCALayer>& backdropLayer, RefPtr<PlatformCALayer>& backdropClippingLayer,
         CloneLevel);
 
-    static void clearClones(std::unique_ptr<LayerMap>&);
-
     bool hasCloneLayers() const { return !!m_layerClones; }
     void removeCloneLayers();
     FloatPoint positionForCloneRootLayer() const;
@@ -441,6 +441,8 @@
     };
     void ensureStructuralLayer(StructuralLayerPurpose);
     StructuralLayerPurpose structuralLayerPurpose() const;
+    
+    void ensureLayerAnimations();
 
     void setAnimationOnLayer(PlatformCAAnimation&, AnimatedPropertyID, const String& animationName, int index, int subIndex, Seconds timeOffset);
     bool removeCAAnimationFromLayer(AnimatedPropertyID, const String& animationName, int index, int subINdex);
@@ -554,6 +556,13 @@
     };
     void addProcessingActionForAnimation(const String&, AnimationProcessingAction);
 
+#if PLATFORM(WIN)
+    // FIXME: when initializing m_uncommittedChanges to a non-zero value, nothing is painted on Windows, see https://bugs.webkit.org/show_bug.cgi?id=168666.
+    LayerChangeFlags m_uncommittedChanges { 0 };
+#else
+    LayerChangeFlags m_uncommittedChanges { CoverageRectChanged };
+#endif
+
     RefPtr<PlatformCALayer> m_layer; // The main layer
     RefPtr<PlatformCALayer> m_structuralLayer; // A layer used for structural reasons, like preserves-3d or replica-flattening. Is the parent of m_layer.
     RefPtr<PlatformCALayer> m_contentsClippingLayer; // A layer used to clip inner content
@@ -564,62 +573,57 @@
     RefPtr<PlatformCALayer> m_backdropLayer; // The layer used for backdrop rendering, if necessary.
 
     // References to clones of our layers, for replicated layers.
-    std::unique_ptr<LayerMap> m_layerClones;
-    std::unique_ptr<LayerMap> m_structuralLayerClones;
-    std::unique_ptr<LayerMap> m_contentsLayerClones;
-    std::unique_ptr<LayerMap> m_contentsClippingLayerClones;
-    std::unique_ptr<LayerMap> m_contentsShapeMaskLayerClones;
-    std::unique_ptr<LayerMap> m_shapeMaskLayerClones;
-    std::unique_ptr<LayerMap> m_backdropLayerClones;
-    std::unique_ptr<LayerMap> m_backdropClippingLayerClones;
+    struct LayerClones {
+        LayerMap primaryLayerClones;
+        LayerMap structuralLayerClones;
+        LayerMap contentsLayerClones;
+        LayerMap contentsClippingLayerClones;
+        LayerMap contentsShapeMaskLayerClones;
+        LayerMap shapeMaskLayerClones;
+        LayerMap backdropLayerClones;
+        LayerMap backdropClippingLayerClones;
+    };
 
+    std::unique_ptr<LayerClones> m_layerClones;
+
 #ifdef VISIBLE_TILE_WASH
     RefPtr<PlatformCALayer> m_visibleTileWashLayer;
 #endif
     FloatRect m_visibleRect;
+    FloatRect m_previousCommittedVisibleRect;
+    FloatRect m_coverageRect; // Area for which we should maintain backing store, in the coordinate space of this layer.
     FloatSize m_sizeAtLastCoverageRectUpdate;
+    FloatSize m_pixelAlignmentOffset;
 
-    FloatRect m_coverageRect; // Area for which we should maintain backing store, in the coordinate space of this layer.
-    
-    ContentsLayerPurpose m_contentsLayerPurpose { NoContentsLayer };
-    bool m_needsFullRepaint { false };
-    bool m_usingBackdropLayerType { false };
-    bool m_isViewportConstrained { false };
-    bool m_intersectsCoverageRect { false };
-    bool m_hasEverPainted { false };
-    bool m_hasDescendantsWithRunningTransformAnimations { false };
-
     Color m_contentsSolidColor;
 
     RetainPtr<CGImageRef> m_uncorrectedContentsImage;
     RetainPtr<CGImageRef> m_pendingContentsImage;
     
-    // Uncommitted transitions and animations.
-    Vector<LayerPropertyAnimation> m_uncomittedAnimations;
-    
     typedef HashMap<String, Vector<AnimationProcessingAction>> AnimationsToProcessMap;
-    AnimationsToProcessMap m_animationsToProcess;
-
-    // Map of animation names to their associated lists of property animations, so we can remove/pause them.
     typedef HashMap<String, Vector<LayerPropertyAnimation>> AnimationsMap;
-    AnimationsMap m_runningAnimations;
+    struct LayerAnimations {
+        Vector<LayerPropertyAnimation> uncomittedAnimations;
+        AnimationsToProcessMap animationsToProcess;
+        AnimationsMap runningAnimations;
+    };
+    
+    std::unique_ptr<LayerAnimations> m_animations;
 
     Vector<FloatRect> m_dirtyRects;
 
     std::unique_ptr<DisplayList::DisplayList> m_displayList;
 
-    FloatSize m_pixelAlignmentOffset;
+    ContentsLayerPurpose m_contentsLayerPurpose { ContentsLayerPurpose::None };
+    bool m_isCommittingChanges { false };
 
-#if PLATFORM(WIN)
-    // FIXME: when initializing m_uncommittedChanges to a non-zero value, nothing is painted on Windows, see https://bugs.webkit.org/show_bug.cgi?id=168666.
-    LayerChangeFlags m_uncommittedChanges { 0 };
-#else
-    LayerChangeFlags m_uncommittedChanges { CoverageRectChanged };
-#endif
-    bool m_hasDescendantsWithUncommittedChanges { false };
-
-    bool m_isCommittingChanges { false };
-    FloatRect m_previousCommittedVisibleRect;
+    bool m_needsFullRepaint : 1;
+    bool m_usingBackdropLayerType : 1;
+    bool m_isViewportConstrained : 1;
+    bool m_intersectsCoverageRect : 1;
+    bool m_hasEverPainted : 1;
+    bool m_hasDescendantsWithRunningTransformAnimations : 1;
+    bool m_hasDescendantsWithUncommittedChanges : 1;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/PlatformCALayerClient.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -42,7 +42,7 @@
 
     virtual void platformCALayerAnimationStarted(const String& /*animationKey*/, MonotonicTime) { }
     virtual void platformCALayerAnimationEnded(const String& /*animationKey*/) { }
-    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesTopDown; }
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesOrientation::TopDown; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect& inClip, GraphicsLayerPaintBehavior) = 0;
     virtual bool platformCALayerShowDebugBorders() const { return false; }
     virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }

Modified: trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/TileCoverageMap.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -58,7 +58,7 @@
 
 private:
     // PlatformCALayerClient
-    GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return GraphicsLayer::CompositingCoordinatesTopDown; }
+    GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const override { return GraphicsLayer::CompositingCoordinatesOrientation::TopDown; }
     bool platformCALayerContentsOpaque() const override { return true; }
     bool platformCALayerDrawsContent() const override { return true; }
     void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) override;

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -194,7 +194,7 @@
 
     RetainPtr<NSObject> m_delegate;
     std::unique_ptr<PlatformCALayerList> m_customSublayers;
-    GraphicsLayer::CustomAppearance m_customAppearance;
+    GraphicsLayer::CustomAppearance m_customAppearance { GraphicsLayer::CustomAppearance::None };
     std::unique_ptr<FloatRoundedRect> m_shapeRoundedRect;
     bool m_wantsDeepColorBackingStore { false };
     bool m_supportsSubpixelAntialiasedText { false };

Modified: trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/cocoa/PlatformCALayerCocoa.mm	2018-07-30 23:07:17 UTC (rev 234393)
@@ -207,7 +207,6 @@
 
 PlatformCALayerCocoa::PlatformCALayerCocoa(LayerType layerType, PlatformCALayerClient* owner)
     : PlatformCALayer(layerType, owner)
-    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
 {
     Class layerClass = Nil;
     switch (layerType) {
@@ -278,7 +277,6 @@
 
 PlatformCALayerCocoa::PlatformCALayerCocoa(PlatformLayer* layer, PlatformCALayerClient* owner)
     : PlatformCALayer(layerTypeForPlatformLayer(layer), owner)
-    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
 {
     m_layer = layer;
     commonInit();
@@ -992,7 +990,7 @@
 
 bool PlatformCALayerCocoa::requiresCustomAppearanceUpdateOnBoundsChange() const
 {
-    return m_customAppearance == GraphicsLayer::ScrollingShadow;
+    return m_customAppearance == GraphicsLayer::CustomAppearance::ScrollingShadow;
 }
 
 void PlatformCALayerCocoa::updateCustomAppearance(GraphicsLayer::CustomAppearance appearance)
@@ -1004,16 +1002,16 @@
 
 #if ENABLE(RUBBER_BANDING)
     switch (appearance) {
-    case GraphicsLayer::NoCustomAppearance:
-    case GraphicsLayer::LightBackdropAppearance:
-    case GraphicsLayer::DarkBackdropAppearance:
+    case GraphicsLayer::CustomAppearance::None:
+    case GraphicsLayer::CustomAppearance::LightBackdrop:
+    case GraphicsLayer::CustomAppearance::DarkBackdrop:
         ScrollbarThemeMac::removeOverhangAreaBackground(platformLayer());
         ScrollbarThemeMac::removeOverhangAreaShadow(platformLayer());
         break;
-    case GraphicsLayer::ScrollingOverhang:
+    case GraphicsLayer::CustomAppearance::ScrollingOverhang:
         ScrollbarThemeMac::setUpOverhangAreaBackground(platformLayer());
         break;
-    case GraphicsLayer::ScrollingShadow:
+    case GraphicsLayer::CustomAppearance::ScrollingShadow:
         ScrollbarThemeMac::setUpOverhangAreaShadow(platformLayer());
         break;
     }
@@ -1141,8 +1139,8 @@
     
     CGContextSaveGState(context);
     
-    // We never use CompositingCoordinatesBottomUp on Mac.
-    ASSERT(layerContents->platformCALayerContentsOrientation() == GraphicsLayer::CompositingCoordinatesTopDown);
+    // We never use CompositingCoordinatesOrientation::BottomUp on Mac.
+    ASSERT(layerContents->platformCALayerContentsOrientation() == GraphicsLayer::CompositingCoordinatesOrientation::TopDown);
     
 #if PLATFORM(IOS)
     FontAntialiasingStateSaver fontAntialiasingState(context, [platformCALayer->platformLayer() isOpaque]);

Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -132,7 +132,6 @@
 
 PlatformCALayerWin::PlatformCALayerWin(LayerType layerType, PlatformLayer* layer, PlatformCALayerClient* owner)
     : PlatformCALayer(layer ? LayerTypeCustom : layerType, owner)
-    , m_customAppearance(GraphicsLayer::NoCustomAppearance)
 {
     if (layer) {
         m_layer = layer;

Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWin.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -175,7 +175,7 @@
 
     HashMap<String, RefPtr<PlatformCAAnimation>> m_animations;
     std::unique_ptr<PlatformCALayerList> m_customSublayers;
-    GraphicsLayer::CustomAppearance m_customAppearance;
+    GraphicsLayer::CustomAppearance m_customAppearance { GraphicsLayer::CustomAppearance::None };
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/ca/win/PlatformCALayerWinInternal.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -161,11 +161,11 @@
             // We assume a maximum of 4 digits and a font size of 18.
             repaintCounterRect.setWidth(80);
             repaintCounterRect.setHeight(22);
-            if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown)
+            if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesOrientation::TopDown)
                 repaintCounterRect.setY(layerBounds.height() - (layerBounds.y() + repaintCounterRect.height()));
             internalSetNeedsDisplay(&repaintCounterRect);
         }
-        if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesTopDown) {
+        if (owner()->owner()->platformCALayerContentsOrientation() == WebCore::GraphicsLayer::CompositingCoordinatesOrientation::TopDown) {
             FloatRect flippedDirtyRect = dirtyRect;
             flippedDirtyRect.setY(owner()->bounds().height() - (flippedDirtyRect.y() + flippedDirtyRect.height()));
             internalSetNeedsDisplay(&flippedDirtyRect);

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -302,7 +302,7 @@
         m_compositedImage = nullptr;
     }
 
-    setContentsToPlatformLayer(m_compositedImage.get(), ContentsLayerForImage);
+    setContentsToPlatformLayer(m_compositedImage.get(), ContentsLayerPurpose::Image);
     notifyChange(ContentChange);
     GraphicsLayer::setContentsToImage(image);
 }

Modified: trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h (234392 => 234393)


--- trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/platform/graphics/texmap/GraphicsLayerTextureMapper.h	2018-07-30 23:07:17 UTC (rev 234393)
@@ -96,7 +96,7 @@
     bool isGraphicsLayerTextureMapper() const override { return true; }
 
     // TextureMapperPlatformLayer::Client
-    void platformLayerWillBeDestroyed() override { setContentsToPlatformLayer(0, NoContentsLayer); }
+    void platformLayerWillBeDestroyed() override { setContentsToPlatformLayer(0, ContentsLayerPurpose::None); }
     void setPlatformLayerNeedsDisplay() override { setContentsNeedsDisplay(); }
 
     void commitLayerChanges();

Modified: trunk/Source/WebCore/rendering/RenderLayerBacking.cpp (234392 => 234393)


--- trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/rendering/RenderLayerBacking.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -550,11 +550,11 @@
 {
     ControlPart appearance = style.appearance();
     if (appearance == MediaControlsLightBarBackgroundPart)
-        m_graphicsLayer->setCustomAppearance(GraphicsLayer::LightBackdropAppearance);
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::LightBackdrop);
     else if (appearance == MediaControlsDarkBarBackgroundPart)
-        m_graphicsLayer->setCustomAppearance(GraphicsLayer::DarkBackdropAppearance);
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::DarkBackdrop);
     else
-        m_graphicsLayer->setCustomAppearance(GraphicsLayer::NoCustomAppearance);
+        m_graphicsLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::None);
 }
 
 static bool layerOrAncestorIsTransformedOrUsingCompositedScrolling(RenderLayer& layer)
@@ -745,13 +745,13 @@
         }
 #else
         if (!pluginViewBase->shouldNotAddLayer())
-            m_graphicsLayer->setContentsToPlatformLayer(pluginViewBase->platformLayer(), GraphicsLayer::ContentsLayerForPlugin);
+            m_graphicsLayer->setContentsToPlatformLayer(pluginViewBase->platformLayer(), GraphicsLayer::ContentsLayerPurpose::Plugin);
 #endif
     }
 #if ENABLE(VIDEO)
     else if (is<RenderVideo>(renderer()) && downcast<RenderVideo>(renderer()).shouldDisplayVideo()) {
         auto* mediaElement = downcast<HTMLMediaElement>(renderer().element());
-        m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(), GraphicsLayer::ContentsLayerForMedia);
+        m_graphicsLayer->setContentsToPlatformLayer(mediaElement->platformLayer(), GraphicsLayer::ContentsLayerPurpose::Media);
         resetContentsRect();
     }
 #endif
@@ -759,7 +759,7 @@
     else if (renderer().isCanvas() && canvasCompositingStrategy(renderer()) == CanvasAsLayerContents) {
         const HTMLCanvasElement* canvas = downcast<HTMLCanvasElement>(renderer().element());
         if (auto* context = canvas->renderingContext())
-            m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer(), GraphicsLayer::ContentsLayerForCanvas);
+            m_graphicsLayer->setContentsToPlatformLayer(context->platformLayer(), GraphicsLayer::ContentsLayerPurpose::Canvas);
         layerConfigChanged = true;
     }
 #endif

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (234392 => 234393)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -3224,7 +3224,7 @@
         m_layerForOverhangAreas->setBackgroundColor(m_rootExtendedBackgroundColor);
         
         if (!m_rootExtendedBackgroundColor.isValid())
-            m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::ScrollingOverhang);
+            m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingOverhang);
 #endif
     }
     
@@ -3251,7 +3251,7 @@
             if (m_renderView.settings().backgroundShouldExtendBeyondPage())
                 m_layerForOverhangAreas->setBackgroundColor(m_renderView.frameView().documentBackgroundColor());
             else
-                m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::ScrollingOverhang);
+                m_layerForOverhangAreas->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingOverhang);
 
             // We want the overhang areas layer to be positioned below the frame contents,
             // so insert it below the clip layer.
@@ -3269,7 +3269,7 @@
             m_contentShadowLayer->setSize(m_rootContentLayer->size());
             m_contentShadowLayer->setPosition(m_rootContentLayer->position());
             m_contentShadowLayer->setAnchorPoint(FloatPoint3D());
-            m_contentShadowLayer->setCustomAppearance(GraphicsLayer::ScrollingShadow);
+            m_contentShadowLayer->setCustomAppearance(GraphicsLayer::CustomAppearance::ScrollingShadow);
 
             m_scrollLayer->addChildBelow(m_contentShadowLayer.get(), m_rootContentLayer.get());
         }

Modified: trunk/Source/WebKit/ChangeLog (234392 => 234393)


--- trunk/Source/WebKit/ChangeLog	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKit/ChangeLog	2018-07-30 23:07:17 UTC (rev 234393)
@@ -1,3 +1,24 @@
+2018-07-30  Simon Fraser  <[email protected]>
+
+        Shrink GraphicsLayerCA
+        https://bugs.webkit.org/show_bug.cgi?id=188141
+
+        Reviewed by Zalan Bujtas.
+
+        Shrink GraphicsLayerCA from 1040 to 880 bytes by:
+        * moving all the clone-related stuff into the lazily-allocated m_layerClones
+        * moving all the animation-related stuff into the lazily-allocated m_animations
+        * making enums be 8-bit
+        * re-ordering data members
+
+        * Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm:
+        (WebKit::updateCustomAppearance):
+        (WebKit::RemoteLayerTreePropertyApplier::applyProperties):
+        * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm:
+        (WebKit::RemoteLayerTreeTransaction::LayerProperties::LayerProperties):
+        * WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp:
+        (WebKit::PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange const):
+
 2018-07-30  Wenson Hsieh  <[email protected]>
 
         REGRESSION (r230817): Terrible performance when selecting text on Stash code review

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm (234392 => 234393)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreePropertyApplier.mm	2018-07-30 23:07:17 UTC (rev 234393)
@@ -108,16 +108,16 @@
 {
 #if ENABLE(RUBBER_BANDING)
     switch (customAppearance) {
-    case GraphicsLayer::NoCustomAppearance:
-    case GraphicsLayer::DarkBackdropAppearance:
-    case GraphicsLayer::LightBackdropAppearance:
+    case GraphicsLayer::CustomAppearance::None:
+    case GraphicsLayer::CustomAppearance::DarkBackdrop:
+    case GraphicsLayer::CustomAppearance::LightBackdrop:
         ScrollbarThemeMac::removeOverhangAreaBackground(layer);
         ScrollbarThemeMac::removeOverhangAreaShadow(layer);
         break;
-    case GraphicsLayer::ScrollingOverhang:
+    case GraphicsLayer::CustomAppearance::ScrollingOverhang:
         ScrollbarThemeMac::setUpOverhangAreaBackground(layer);
         break;
-    case GraphicsLayer::ScrollingShadow:
+    case GraphicsLayer::CustomAppearance::ScrollingShadow:
         ScrollbarThemeMac::setUpOverhangAreaShadow(layer);
         break;
     }
@@ -303,7 +303,7 @@
             [children addObject:relatedLayers.get(child)];
         }
 
-        if (properties.customAppearance == GraphicsLayer::LightBackdropAppearance || properties.customAppearance == GraphicsLayer::DarkBackdropAppearance) {
+        if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
             // This is a UIBackdropView, which should have children attached to
             // its content view, not directly on its layers.
             [[(_UIBackdropView*)view contentView] _web_setSubviews:children.get()];
@@ -314,7 +314,7 @@
     if (properties.changedProperties & RemoteLayerTreeTransaction::MaskLayerChanged) {
         CALayer *maskOwnerLayer = view.layer;
 
-        if (properties.customAppearance == GraphicsLayer::LightBackdropAppearance || properties.customAppearance == GraphicsLayer::DarkBackdropAppearance) {
+        if (properties.customAppearance == GraphicsLayer::CustomAppearance::LightBackdrop || properties.customAppearance == GraphicsLayer::CustomAppearance::DarkBackdrop) {
             // This is a UIBackdropView, which means any mask must be applied to the CABackdropLayer rather
             // that the view's layer. The backdrop is the first layer child.
             if (view.layer.sublayers.count && [view.layer.sublayers[0] isKindOfClass:[CABackdropLayer class]])

Modified: trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm (234392 => 234393)


--- trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm	2018-07-30 23:07:17 UTC (rev 234393)
@@ -90,7 +90,7 @@
     , backgroundColor(Color::transparent)
     , borderColor(Color::black)
     , edgeAntialiasingMask(kCALayerLeftEdge | kCALayerRightEdge | kCALayerBottomEdge | kCALayerTopEdge)
-    , customAppearance(GraphicsLayer::NoCustomAppearance)
+    , customAppearance(GraphicsLayer::CustomAppearance::None)
     , minificationFilter(PlatformCALayer::FilterType::Linear)
     , magnificationFilter(PlatformCALayer::FilterType::Linear)
     , blendMode(BlendModeNormal)

Modified: trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp (234392 => 234393)


--- trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/PlatformCALayerRemote.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -832,7 +832,7 @@
 
 bool PlatformCALayerRemote::requiresCustomAppearanceUpdateOnBoundsChange() const
 {
-    return m_properties.customAppearance == GraphicsLayer::ScrollingShadow;
+    return m_properties.customAppearance == GraphicsLayer::CustomAppearance::ScrollingShadow;
 }
 
 GraphicsLayer::CustomAppearance PlatformCALayerRemote::customAppearance() const

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (234392 => 234393)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2018-07-30 23:07:17 UTC (rev 234393)
@@ -1,3 +1,19 @@
+2018-07-30  Simon Fraser  <[email protected]>
+
+        Shrink GraphicsLayerCA
+        https://bugs.webkit.org/show_bug.cgi?id=188141
+
+        Reviewed by Zalan Bujtas.
+
+        Shrink GraphicsLayerCA from 1040 to 880 bytes by:
+        * moving all the clone-related stuff into the lazily-allocated m_layerClones
+        * moving all the animation-related stuff into the lazily-allocated m_animations
+        * making enums be 8-bit
+        * re-ordering data members
+
+        * WebView/WebView.mm:
+        (-[WebView _setMediaLayer:forPluginView:]):
+
 2018-07-30  Rob Buis  <[email protected]>
 
         Merge PlatformCookieJar functions into NetworkStorageSession

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebView.mm (234392 => 234393)


--- trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebView.mm	2018-07-30 23:07:17 UTC (rev 234393)
@@ -4170,7 +4170,7 @@
             continue;
         
         if (layerForWidget->contentsLayerForMedia() != layer) {
-            layerForWidget->setContentsToPlatformLayer(layer, GraphicsLayer::ContentsLayerForMedia);
+            layerForWidget->setContentsToPlatformLayer(layer, GraphicsLayer::ContentsLayerPurpose::Media);
             // We need to make sure the layer hierachy change is applied immediately.
             if (mainCoreFrame->view())
                 mainCoreFrame->view()->flushCompositingStateIncludingSubframes();

Modified: trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp (234392 => 234393)


--- trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp	2018-07-30 22:01:45 UTC (rev 234392)
+++ trunk/Source/WebKitLegacy/win/FullscreenVideoController.cpp	2018-07-30 23:07:17 UTC (rev 234393)
@@ -185,7 +185,7 @@
     virtual bool platformCALayerRespondsToLayoutChanges() const { return true; }
 
     virtual void platformCALayerAnimationStarted(MonotonicTime beginTime) { }
-    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesBottomUp; }
+    virtual GraphicsLayer::CompositingCoordinatesOrientation platformCALayerContentsOrientation() const { return GraphicsLayer::CompositingCoordinatesOrientation::BottomUp; }
     virtual void platformCALayerPaintContents(PlatformCALayer*, GraphicsContext&, const FloatRect&, GraphicsLayerPaintBehavior) { }
     virtual bool platformCALayerShowDebugBorders() const { return false; }
     virtual bool platformCALayerShowRepaintCounter(PlatformCALayer*) const { return false; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to