Title: [267259] branches/safari-610-branch/Source/WebCore
Revision
267259
Author
[email protected]
Date
2020-09-18 12:35:43 -0700 (Fri, 18 Sep 2020)

Log Message

Cherry-pick r266344. rdar://problem/69101085

    Make StyleRareNonInheritedData::mask and StyleBackgroundData::background DataRefs
    https://bugs.webkit.org/show_bug.cgi?id=215942

    Reviewed by Darin Adler.

    A significant amount of time in MotionMark's Multiply subtest is spent underneath the copy constructor
    `StyleRareNonInheritedData`, and a significant amount of time underneath this copy constructor is spent copying
    the rare non-inherited data's mask (a `FillLayer`).

    This `FillLayer` is currently inline data in `StyleRareNonInheritedData`; to reduce the cost of copying rare
    non-inherited data, we can instead make this a `DataRef<FillLayer>`, such that copying rare data will only copy
    the reference to the `FillLayer` rather than the `FillLayer` itself.

    Upon mutating the `FillLayer`, we now use `DataRef::access()` to ensure that these `FillLayer`s are copied
    before writing. See below for more details.

    * css/makeprop.pl:
    (generateFillLayerPropertyInheritValueSetter):
    (generateFillLayerPropertyValueSetter):
    * rendering/style/FillLayer.cpp:
    (WebCore::FillLayer::create):
    (WebCore::FillLayer::FillLayer):

    Deeply copy the `FillLayer`'s linked list of `FillLayer`s. This preserves existing behavior, which currently
    uses `std::unique_ptr` to store the pointer to the next `FillLayer` (and therefore, requires a deep copy of the
    linked list when copying `FillLayer`).

    In a future patch, we could probably further optimize this as well to behave in a copy-on-write way, by turning
    the `RefPtr<FillLayer> m_next;` into an `Optional<DataRef<FillLayer>>` instead (and then use `access()` to copy
    the next `FillLayer` prior to writing).

    (WebCore::FillLayer::~FillLayer):
    (WebCore::FillLayer::operator=):
    * rendering/style/FillLayer.h:

    Make `FillLayer` ref-counted, and introduce new `create` methods for constructing `FillLayer`s. Use these
    methods in several places where we currently call the constructors directly, via `makeUnique`.

    (WebCore::FillLayer::copy const):
    (WebCore::FillLayer::setNext):
    * rendering/style/RenderStyle.h:
    (WebCore::RenderStyle::hasBackgroundImage const):
    (WebCore::RenderStyle::hasFixedBackgroundImage const):
    (WebCore::RenderStyle::backgroundRepeatX const):
    (WebCore::RenderStyle::backgroundRepeatY const):
    (WebCore::RenderStyle::backgroundComposite const):
    (WebCore::RenderStyle::backgroundAttachment const):
    (WebCore::RenderStyle::backgroundClip const):
    (WebCore::RenderStyle::backgroundOrigin const):
    (WebCore::RenderStyle::backgroundXPosition const):
    (WebCore::RenderStyle::backgroundYPosition const):
    (WebCore::RenderStyle::backgroundSizeType const):
    (WebCore::RenderStyle::backgroundSizeLength const):
    (WebCore::RenderStyle::ensureBackgroundLayers):
    (WebCore::RenderStyle::maskImage const):
    (WebCore::RenderStyle::maskRepeatX const):
    (WebCore::RenderStyle::maskRepeatY const):
    (WebCore::RenderStyle::maskComposite const):
    (WebCore::RenderStyle::maskClip const):
    (WebCore::RenderStyle::maskOrigin const):
    (WebCore::RenderStyle::maskXPosition const):
    (WebCore::RenderStyle::maskYPosition const):
    (WebCore::RenderStyle::maskSizeType const):
    (WebCore::RenderStyle::maskSizeLength const):
    (WebCore::RenderStyle::ensureMaskLayers):
    (WebCore::RenderStyle::hasMask const):
    (WebCore::RenderStyle::setBackgroundXPosition):
    (WebCore::RenderStyle::setBackgroundYPosition):
    (WebCore::RenderStyle::setBackgroundSize):
    (WebCore::RenderStyle::setBackgroundSizeLength):
    (WebCore::RenderStyle::clearBackgroundLayers):
    (WebCore::RenderStyle::inheritBackgroundLayers):
    (WebCore::RenderStyle::clearMaskLayers):
    (WebCore::RenderStyle::inheritMaskLayers):
    (WebCore::RenderStyle::setMaskImage):
    (WebCore::RenderStyle::setMaskXPosition):
    (WebCore::RenderStyle::setMaskYPosition):
    (WebCore::RenderStyle::setMaskSize):
    * rendering/style/StyleBackgroundData.cpp:
    (WebCore::StyleBackgroundData::StyleBackgroundData):
    (WebCore::StyleBackgroundData::dump const):
    * rendering/style/StyleBackgroundData.h:

    Since `FillLayer` is now ref-counted, `StyleBackgroundData::background` needs to be a `DataRef` as well.

    * rendering/style/StyleRareNonInheritedData.cpp:
    (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
    * rendering/style/StyleRareNonInheritedData.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266344 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610-branch/Source/WebCore/ChangeLog (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/ChangeLog	2020-09-18 19:35:43 UTC (rev 267259)
@@ -1,5 +1,192 @@
 2020-09-17  Alan Coon  <[email protected]>
 
+        Cherry-pick r266344. rdar://problem/69101085
+
+    Make StyleRareNonInheritedData::mask and StyleBackgroundData::background DataRefs
+    https://bugs.webkit.org/show_bug.cgi?id=215942
+    
+    Reviewed by Darin Adler.
+    
+    A significant amount of time in MotionMark's Multiply subtest is spent underneath the copy constructor
+    `StyleRareNonInheritedData`, and a significant amount of time underneath this copy constructor is spent copying
+    the rare non-inherited data's mask (a `FillLayer`).
+    
+    This `FillLayer` is currently inline data in `StyleRareNonInheritedData`; to reduce the cost of copying rare
+    non-inherited data, we can instead make this a `DataRef<FillLayer>`, such that copying rare data will only copy
+    the reference to the `FillLayer` rather than the `FillLayer` itself.
+    
+    Upon mutating the `FillLayer`, we now use `DataRef::access()` to ensure that these `FillLayer`s are copied
+    before writing. See below for more details.
+    
+    * css/makeprop.pl:
+    (generateFillLayerPropertyInheritValueSetter):
+    (generateFillLayerPropertyValueSetter):
+    * rendering/style/FillLayer.cpp:
+    (WebCore::FillLayer::create):
+    (WebCore::FillLayer::FillLayer):
+    
+    Deeply copy the `FillLayer`'s linked list of `FillLayer`s. This preserves existing behavior, which currently
+    uses `std::unique_ptr` to store the pointer to the next `FillLayer` (and therefore, requires a deep copy of the
+    linked list when copying `FillLayer`).
+    
+    In a future patch, we could probably further optimize this as well to behave in a copy-on-write way, by turning
+    the `RefPtr<FillLayer> m_next;` into an `Optional<DataRef<FillLayer>>` instead (and then use `access()` to copy
+    the next `FillLayer` prior to writing).
+    
+    (WebCore::FillLayer::~FillLayer):
+    (WebCore::FillLayer::operator=):
+    * rendering/style/FillLayer.h:
+    
+    Make `FillLayer` ref-counted, and introduce new `create` methods for constructing `FillLayer`s. Use these
+    methods in several places where we currently call the constructors directly, via `makeUnique`.
+    
+    (WebCore::FillLayer::copy const):
+    (WebCore::FillLayer::setNext):
+    * rendering/style/RenderStyle.h:
+    (WebCore::RenderStyle::hasBackgroundImage const):
+    (WebCore::RenderStyle::hasFixedBackgroundImage const):
+    (WebCore::RenderStyle::backgroundRepeatX const):
+    (WebCore::RenderStyle::backgroundRepeatY const):
+    (WebCore::RenderStyle::backgroundComposite const):
+    (WebCore::RenderStyle::backgroundAttachment const):
+    (WebCore::RenderStyle::backgroundClip const):
+    (WebCore::RenderStyle::backgroundOrigin const):
+    (WebCore::RenderStyle::backgroundXPosition const):
+    (WebCore::RenderStyle::backgroundYPosition const):
+    (WebCore::RenderStyle::backgroundSizeType const):
+    (WebCore::RenderStyle::backgroundSizeLength const):
+    (WebCore::RenderStyle::ensureBackgroundLayers):
+    (WebCore::RenderStyle::maskImage const):
+    (WebCore::RenderStyle::maskRepeatX const):
+    (WebCore::RenderStyle::maskRepeatY const):
+    (WebCore::RenderStyle::maskComposite const):
+    (WebCore::RenderStyle::maskClip const):
+    (WebCore::RenderStyle::maskOrigin const):
+    (WebCore::RenderStyle::maskXPosition const):
+    (WebCore::RenderStyle::maskYPosition const):
+    (WebCore::RenderStyle::maskSizeType const):
+    (WebCore::RenderStyle::maskSizeLength const):
+    (WebCore::RenderStyle::ensureMaskLayers):
+    (WebCore::RenderStyle::hasMask const):
+    (WebCore::RenderStyle::setBackgroundXPosition):
+    (WebCore::RenderStyle::setBackgroundYPosition):
+    (WebCore::RenderStyle::setBackgroundSize):
+    (WebCore::RenderStyle::setBackgroundSizeLength):
+    (WebCore::RenderStyle::clearBackgroundLayers):
+    (WebCore::RenderStyle::inheritBackgroundLayers):
+    (WebCore::RenderStyle::clearMaskLayers):
+    (WebCore::RenderStyle::inheritMaskLayers):
+    (WebCore::RenderStyle::setMaskImage):
+    (WebCore::RenderStyle::setMaskXPosition):
+    (WebCore::RenderStyle::setMaskYPosition):
+    (WebCore::RenderStyle::setMaskSize):
+    * rendering/style/StyleBackgroundData.cpp:
+    (WebCore::StyleBackgroundData::StyleBackgroundData):
+    (WebCore::StyleBackgroundData::dump const):
+    * rendering/style/StyleBackgroundData.h:
+    
+    Since `FillLayer` is now ref-counted, `StyleBackgroundData::background` needs to be a `DataRef` as well.
+    
+    * rendering/style/StyleRareNonInheritedData.cpp:
+    (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+    * rendering/style/StyleRareNonInheritedData.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@266344 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-30  Wenson Hsieh  <[email protected]>
+
+            Make StyleRareNonInheritedData::mask and StyleBackgroundData::background DataRefs
+            https://bugs.webkit.org/show_bug.cgi?id=215942
+
+            Reviewed by Darin Adler.
+
+            A significant amount of time in MotionMark's Multiply subtest is spent underneath the copy constructor
+            `StyleRareNonInheritedData`, and a significant amount of time underneath this copy constructor is spent copying
+            the rare non-inherited data's mask (a `FillLayer`).
+
+            This `FillLayer` is currently inline data in `StyleRareNonInheritedData`; to reduce the cost of copying rare
+            non-inherited data, we can instead make this a `DataRef<FillLayer>`, such that copying rare data will only copy
+            the reference to the `FillLayer` rather than the `FillLayer` itself.
+
+            Upon mutating the `FillLayer`, we now use `DataRef::access()` to ensure that these `FillLayer`s are copied
+            before writing. See below for more details.
+
+            * css/makeprop.pl:
+            (generateFillLayerPropertyInheritValueSetter):
+            (generateFillLayerPropertyValueSetter):
+            * rendering/style/FillLayer.cpp:
+            (WebCore::FillLayer::create):
+            (WebCore::FillLayer::FillLayer):
+
+            Deeply copy the `FillLayer`'s linked list of `FillLayer`s. This preserves existing behavior, which currently
+            uses `std::unique_ptr` to store the pointer to the next `FillLayer` (and therefore, requires a deep copy of the
+            linked list when copying `FillLayer`).
+
+            In a future patch, we could probably further optimize this as well to behave in a copy-on-write way, by turning
+            the `RefPtr<FillLayer> m_next;` into an `Optional<DataRef<FillLayer>>` instead (and then use `access()` to copy
+            the next `FillLayer` prior to writing).
+
+            (WebCore::FillLayer::~FillLayer):
+            (WebCore::FillLayer::operator=):
+            * rendering/style/FillLayer.h:
+
+            Make `FillLayer` ref-counted, and introduce new `create` methods for constructing `FillLayer`s. Use these
+            methods in several places where we currently call the constructors directly, via `makeUnique`.
+
+            (WebCore::FillLayer::copy const):
+            (WebCore::FillLayer::setNext):
+            * rendering/style/RenderStyle.h:
+            (WebCore::RenderStyle::hasBackgroundImage const):
+            (WebCore::RenderStyle::hasFixedBackgroundImage const):
+            (WebCore::RenderStyle::backgroundRepeatX const):
+            (WebCore::RenderStyle::backgroundRepeatY const):
+            (WebCore::RenderStyle::backgroundComposite const):
+            (WebCore::RenderStyle::backgroundAttachment const):
+            (WebCore::RenderStyle::backgroundClip const):
+            (WebCore::RenderStyle::backgroundOrigin const):
+            (WebCore::RenderStyle::backgroundXPosition const):
+            (WebCore::RenderStyle::backgroundYPosition const):
+            (WebCore::RenderStyle::backgroundSizeType const):
+            (WebCore::RenderStyle::backgroundSizeLength const):
+            (WebCore::RenderStyle::ensureBackgroundLayers):
+            (WebCore::RenderStyle::maskImage const):
+            (WebCore::RenderStyle::maskRepeatX const):
+            (WebCore::RenderStyle::maskRepeatY const):
+            (WebCore::RenderStyle::maskComposite const):
+            (WebCore::RenderStyle::maskClip const):
+            (WebCore::RenderStyle::maskOrigin const):
+            (WebCore::RenderStyle::maskXPosition const):
+            (WebCore::RenderStyle::maskYPosition const):
+            (WebCore::RenderStyle::maskSizeType const):
+            (WebCore::RenderStyle::maskSizeLength const):
+            (WebCore::RenderStyle::ensureMaskLayers):
+            (WebCore::RenderStyle::hasMask const):
+            (WebCore::RenderStyle::setBackgroundXPosition):
+            (WebCore::RenderStyle::setBackgroundYPosition):
+            (WebCore::RenderStyle::setBackgroundSize):
+            (WebCore::RenderStyle::setBackgroundSizeLength):
+            (WebCore::RenderStyle::clearBackgroundLayers):
+            (WebCore::RenderStyle::inheritBackgroundLayers):
+            (WebCore::RenderStyle::clearMaskLayers):
+            (WebCore::RenderStyle::inheritMaskLayers):
+            (WebCore::RenderStyle::setMaskImage):
+            (WebCore::RenderStyle::setMaskXPosition):
+            (WebCore::RenderStyle::setMaskYPosition):
+            (WebCore::RenderStyle::setMaskSize):
+            * rendering/style/StyleBackgroundData.cpp:
+            (WebCore::StyleBackgroundData::StyleBackgroundData):
+            (WebCore::StyleBackgroundData::dump const):
+            * rendering/style/StyleBackgroundData.h:
+
+            Since `FillLayer` is now ref-counted, `StyleBackgroundData::background` needs to be a `DataRef` as well.
+
+            * rendering/style/StyleRareNonInheritedData.cpp:
+            (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData):
+            * rendering/style/StyleRareNonInheritedData.h:
+
+2020-09-17  Alan Coon  <[email protected]>
+
         Cherry-pick r266290. rdar://problem/69101142
 
     [iOS] Vertical text's logical width calculation is stale from the previous height of the WKWebView

Modified: branches/safari-610-branch/Source/WebCore/css/makeprop.pl (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/css/makeprop.pl	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/css/makeprop.pl	2020-09-18 19:35:43 UTC (rev 267259)
@@ -925,7 +925,7 @@
   $setterContent .= $indent . "FillLayer* previousChild = nullptr;\n";
   $setterContent .= $indent . "for (auto* parent = &builderState.parentStyle()." . getLayersFunction($name) . "(); parent && parent->" . $testFunction . "(); parent = parent->next()) {\n";
   $setterContent .= $indent . "    if (!child) {\n";
-  $setterContent .= $indent . "        previousChild->setNext(makeUnique<FillLayer>(" . getFillLayerType($name) . "));\n";
+  $setterContent .= $indent . "        previousChild->setNext(FillLayer::create(" . getFillLayerType($name) . "));\n";
   $setterContent .= $indent . "        child = previousChild->next();\n";
   $setterContent .= $indent . "    }\n";
   $setterContent .= $indent . "    child->" . $setter . "(parent->" . $getter . "());\n";
@@ -951,7 +951,7 @@
   $setterContent .= $indent . "    // Walk each value and put it into a layer, creating new layers as needed.\n";
   $setterContent .= $indent . "    for (auto& item : downcast<CSSValueList>(value)) {\n";
   $setterContent .= $indent . "        if (!child) {\n";
-  $setterContent .= $indent . "            previousChild->setNext(makeUnique<FillLayer>(" . getFillLayerType($name) . "));\n";
+  $setterContent .= $indent . "            previousChild->setNext(FillLayer::create(" . getFillLayerType($name) . "));\n";
   $setterContent .= $indent . "            child = previousChild->next();\n";
   $setterContent .= $indent . "        }\n";
   $setterContent .= $indent . "        builderState.styleMap()." . getFillLayerMapfunction($name) . "(" . $CSSPropertyId . ", *child, item);\n";

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.cpp (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.cpp	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.cpp	2020-09-18 19:35:43 UTC (rev 267259)
@@ -27,7 +27,7 @@
 
 namespace WebCore {
 
-struct SameSizeAsFillLayer {
+struct SameSizeAsFillLayer : RefCounted<SameSizeAsFillLayer> {
     FillLayer* next;
 
     RefPtr<StyleImage> image;
@@ -43,6 +43,16 @@
 
 COMPILE_ASSERT(sizeof(FillLayer) == sizeof(SameSizeAsFillLayer), FillLayer_should_stay_small);
 
+Ref<FillLayer> FillLayer::create(FillLayerType type)
+{
+    return adoptRef(*new FillLayer(type));
+}
+
+Ref<FillLayer> FillLayer::create(const FillLayer& layer)
+{
+    return adoptRef(*new FillLayer(layer));
+}
+
 FillLayer::FillLayer(FillLayerType type)
     : m_image(FillLayer::initialFillImage(type))
     , m_xPosition(FillLayer::initialFillXPosition(type))
@@ -76,8 +86,7 @@
 }
 
 FillLayer::FillLayer(const FillLayer& o)
-    : m_next(o.m_next ? makeUnique<FillLayer>(*o.m_next) : nullptr)
-    , m_image(o.m_image)
+    : m_image(o.m_image)
     , m_xPosition(o.m_xPosition)
     , m_yPosition(o.m_yPosition)
     , m_sizeLength(o.m_sizeLength)
@@ -107,18 +116,22 @@
     , m_maskSourceTypeSet(o.m_maskSourceTypeSet)
     , m_type(o.m_type)
 {
+    if (o.m_next)
+        m_next = create(*o.m_next);
 }
 
 FillLayer::~FillLayer()
 {
     // Delete the layers in a loop rather than allowing recursive calls to the destructors.
-    for (std::unique_ptr<FillLayer> next = WTFMove(m_next); next; next = WTFMove(next->m_next)) { }
+    for (auto next = WTFMove(m_next); next; next = WTFMove(next->m_next)) { }
 }
 
 FillLayer& FillLayer::operator=(const FillLayer& o)
 {
-    m_next = o.m_next ? makeUnique<FillLayer>(*o.m_next) : nullptr;
-
+    if (o.m_next)
+        m_next = create(*o.m_next);
+    else
+        m_next = nullptr;
     m_image = o.m_image;
     m_xPosition = o.m_xPosition;
     m_yPosition = o.m_yPosition;

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.h (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.h	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/FillLayer.h	2020-09-18 19:35:43 UTC (rev 267259)
@@ -60,10 +60,14 @@
     return !(a == b);
 }
 
-class FillLayer {
+class FillLayer : public RefCounted<FillLayer> {
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    explicit FillLayer(FillLayerType);
+    static Ref<FillLayer> create(FillLayerType);
+    static Ref<FillLayer> create(const FillLayer&);
+
+    Ref<FillLayer> copy() const { return create(*this); }
+
     ~FillLayer();
 
     StyleImage* image() const { return m_image.get(); }
@@ -135,10 +139,9 @@
     void clearSize() { m_sizeType = static_cast<unsigned>(FillSizeType::None); }
     void clearMaskSourceType() { m_maskSourceTypeSet = false; }
 
-    void setNext(std::unique_ptr<FillLayer> next) { m_next = WTFMove(next); }
+    void setNext(RefPtr<FillLayer>&& next) { m_next = WTFMove(next); }
 
     FillLayer& operator=(const FillLayer&);
-    FillLayer(const FillLayer&);
 
     bool operator==(const FillLayer&) const;
     bool operator!=(const FillLayer& other) const { return !(*this == other); }
@@ -174,11 +177,14 @@
 private:
     friend class RenderStyle;
 
+    explicit FillLayer(FillLayerType);
+    FillLayer(const FillLayer&);
+
     void computeClipMax() const;
 
     bool hasImageInAnyLayer() const;
 
-    std::unique_ptr<FillLayer> m_next;
+    RefPtr<FillLayer> m_next;
 
     RefPtr<StyleImage> m_image;
 

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/RenderStyle.h (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/RenderStyle.h	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/RenderStyle.h	2020-09-18 19:35:43 UTC (rev 267259)
@@ -206,8 +206,8 @@
     bool hasMarginBeforeQuirk() const { return marginBefore().hasQuirk(); }
     bool hasMarginAfterQuirk() const { return marginAfter().hasQuirk(); }
 
-    bool hasBackgroundImage() const { return m_backgroundData->background.hasImage(); }
-    bool hasFixedBackgroundImage() const { return m_backgroundData->background.hasFixedImage(); }
+    bool hasBackgroundImage() const { return m_backgroundData->background->hasImage(); }
+    bool hasFixedBackgroundImage() const { return m_backgroundData->background->hasFixedImage(); }
 
     bool hasEntirelyFixedBackground() const;
 
@@ -406,30 +406,30 @@
     bool breakOnlyAfterWhiteSpace() const;
     bool breakWords() const;
 
-    FillRepeat backgroundRepeatX() const { return static_cast<FillRepeat>(m_backgroundData->background.repeatX()); }
-    FillRepeat backgroundRepeatY() const { return static_cast<FillRepeat>(m_backgroundData->background.repeatY()); }
-    CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(m_backgroundData->background.composite()); }
-    FillAttachment backgroundAttachment() const { return static_cast<FillAttachment>(m_backgroundData->background.attachment()); }
-    FillBox backgroundClip() const { return static_cast<FillBox>(m_backgroundData->background.clip()); }
-    FillBox backgroundOrigin() const { return static_cast<FillBox>(m_backgroundData->background.origin()); }
-    const Length& backgroundXPosition() const { return m_backgroundData->background.xPosition(); }
-    const Length& backgroundYPosition() const { return m_backgroundData->background.yPosition(); }
-    FillSizeType backgroundSizeType() const { return m_backgroundData->background.sizeType(); }
-    const LengthSize& backgroundSizeLength() const { return m_backgroundData->background.sizeLength(); }
-    FillLayer& ensureBackgroundLayers() { return m_backgroundData.access().background; }
+    FillRepeat backgroundRepeatX() const { return static_cast<FillRepeat>(m_backgroundData->background->repeatX()); }
+    FillRepeat backgroundRepeatY() const { return static_cast<FillRepeat>(m_backgroundData->background->repeatY()); }
+    CompositeOperator backgroundComposite() const { return static_cast<CompositeOperator>(m_backgroundData->background->composite()); }
+    FillAttachment backgroundAttachment() const { return static_cast<FillAttachment>(m_backgroundData->background->attachment()); }
+    FillBox backgroundClip() const { return static_cast<FillBox>(m_backgroundData->background->clip()); }
+    FillBox backgroundOrigin() const { return static_cast<FillBox>(m_backgroundData->background->origin()); }
+    const Length& backgroundXPosition() const { return m_backgroundData->background->xPosition(); }
+    const Length& backgroundYPosition() const { return m_backgroundData->background->yPosition(); }
+    FillSizeType backgroundSizeType() const { return m_backgroundData->background->sizeType(); }
+    const LengthSize& backgroundSizeLength() const { return m_backgroundData->background->sizeLength(); }
+    FillLayer& ensureBackgroundLayers() { return m_backgroundData.access().background.access(); }
     const FillLayer& backgroundLayers() const { return m_backgroundData->background; }
 
-    StyleImage* maskImage() const { return m_rareNonInheritedData->mask.image(); }
-    FillRepeat maskRepeatX() const { return static_cast<FillRepeat>(m_rareNonInheritedData->mask.repeatX()); }
-    FillRepeat maskRepeatY() const { return static_cast<FillRepeat>(m_rareNonInheritedData->mask.repeatY()); }
-    CompositeOperator maskComposite() const { return static_cast<CompositeOperator>(m_rareNonInheritedData->mask.composite()); }
-    FillBox maskClip() const { return static_cast<FillBox>(m_rareNonInheritedData->mask.clip()); }
-    FillBox maskOrigin() const { return static_cast<FillBox>(m_rareNonInheritedData->mask.origin()); }
-    const Length& maskXPosition() const { return m_rareNonInheritedData->mask.xPosition(); }
-    const Length& maskYPosition() const { return m_rareNonInheritedData->mask.yPosition(); }
-    FillSizeType maskSizeType() const { return m_rareNonInheritedData->mask.sizeType(); }
-    const LengthSize& maskSizeLength() const { return m_rareNonInheritedData->mask.sizeLength(); }
-    FillLayer& ensureMaskLayers() { return m_rareNonInheritedData.access().mask; }
+    StyleImage* maskImage() const { return m_rareNonInheritedData->mask->image(); }
+    FillRepeat maskRepeatX() const { return static_cast<FillRepeat>(m_rareNonInheritedData->mask->repeatX()); }
+    FillRepeat maskRepeatY() const { return static_cast<FillRepeat>(m_rareNonInheritedData->mask->repeatY()); }
+    CompositeOperator maskComposite() const { return static_cast<CompositeOperator>(m_rareNonInheritedData->mask->composite()); }
+    FillBox maskClip() const { return static_cast<FillBox>(m_rareNonInheritedData->mask->clip()); }
+    FillBox maskOrigin() const { return static_cast<FillBox>(m_rareNonInheritedData->mask->origin()); }
+    const Length& maskXPosition() const { return m_rareNonInheritedData->mask->xPosition(); }
+    const Length& maskYPosition() const { return m_rareNonInheritedData->mask->yPosition(); }
+    FillSizeType maskSizeType() const { return m_rareNonInheritedData->mask->sizeType(); }
+    const LengthSize& maskSizeLength() const { return m_rareNonInheritedData->mask->sizeLength(); }
+    FillLayer& ensureMaskLayers() { return m_rareNonInheritedData.access().mask.access(); }
     const FillLayer& maskLayers() const { return m_rareNonInheritedData->mask; }
     const NinePieceImage& maskBoxImage() const { return m_rareNonInheritedData->maskBoxImage; }
     StyleImage* maskBoxImageSource() const { return m_rareNonInheritedData->maskBoxImage.image(); }
@@ -650,7 +650,7 @@
     void applyTransform(TransformationMatrix&, const FloatRect& boundingBox, ApplyTransformOrigin = IncludeTransformOrigin) const;
     void setPageScaleTransform(float);
 
-    bool hasMask() const { return m_rareNonInheritedData->mask.hasImage() || m_rareNonInheritedData->maskBoxImage.hasImage(); }
+    bool hasMask() const { return m_rareNonInheritedData->mask->hasImage() || m_rareNonInheritedData->maskBoxImage.hasImage(); }
 
     TextCombine textCombine() const { return static_cast<TextCombine>(m_rareNonInheritedData->textCombine); }
     bool hasTextCombine() const { return textCombine() != TextCombine::None; }
@@ -846,10 +846,10 @@
 
     void setBackgroundColor(const Color& v) { SET_VAR(m_backgroundData, color, v); }
 
-    void setBackgroundXPosition(Length&& length) { SET_VAR(m_backgroundData, background.m_xPosition, WTFMove(length)); }
-    void setBackgroundYPosition(Length&& length) { SET_VAR(m_backgroundData, background.m_yPosition, WTFMove(length)); }
-    void setBackgroundSize(FillSizeType b) { SET_VAR(m_backgroundData, background.m_sizeType, static_cast<unsigned>(b)); }
-    void setBackgroundSizeLength(LengthSize&& size) { SET_VAR(m_backgroundData, background.m_sizeLength, WTFMove(size)); }
+    void setBackgroundXPosition(Length&& length) { SET_NESTED_VAR(m_backgroundData, background, m_xPosition, WTFMove(length)); }
+    void setBackgroundYPosition(Length&& length) { SET_NESTED_VAR(m_backgroundData, background, m_yPosition, WTFMove(length)); }
+    void setBackgroundSize(FillSizeType b) { SET_NESTED_VAR(m_backgroundData, background, m_sizeType, static_cast<unsigned>(b)); }
+    void setBackgroundSizeLength(LengthSize&& size) { SET_NESTED_VAR(m_backgroundData, background, m_sizeLength, WTFMove(size)); }
     
     void setBorderImage(const NinePieceImage& b) { SET_VAR(m_surroundData, border.m_image, b); }
     void setBorderImageSource(RefPtr<StyleImage>&&);
@@ -966,23 +966,23 @@
     void setWordSpacing(Length&&);
     void setLetterSpacing(float);
 
-    void clearBackgroundLayers() { m_backgroundData.access().background = "" }
-    void inheritBackgroundLayers(const FillLayer& parent) { m_backgroundData.access().background = "" }
+    void clearBackgroundLayers() { m_backgroundData.access().background = "" }
+    void inheritBackgroundLayers(const FillLayer& parent) { m_backgroundData.access().background = "" }
 
     void adjustBackgroundLayers();
 
-    void clearMaskLayers() { m_rareNonInheritedData.access().mask = FillLayer(FillLayerType::Mask); }
-    void inheritMaskLayers(const FillLayer& parent) { m_rareNonInheritedData.access().mask = parent; }
+    void clearMaskLayers() { m_rareNonInheritedData.access().mask = FillLayer::create(FillLayerType::Mask); }
+    void inheritMaskLayers(const FillLayer& parent) { m_rareNonInheritedData.access().mask = FillLayer::create(parent); }
 
     void adjustMaskLayers();
 
-    void setMaskImage(RefPtr<StyleImage>&& v) { m_rareNonInheritedData.access().mask.setImage(WTFMove(v)); }
+    void setMaskImage(RefPtr<StyleImage>&& v) { m_rareNonInheritedData.access().mask.access().setImage(WTFMove(v)); }
 
     void setMaskBoxImage(const NinePieceImage& b) { SET_VAR(m_rareNonInheritedData, maskBoxImage, b); }
     void setMaskBoxImageSource(RefPtr<StyleImage>&& v) { m_rareNonInheritedData.access().maskBoxImage.setImage(WTFMove(v)); }
-    void setMaskXPosition(Length&& length) { SET_VAR(m_rareNonInheritedData, mask.m_xPosition, WTFMove(length)); }
-    void setMaskYPosition(Length&& length) { SET_VAR(m_rareNonInheritedData, mask.m_yPosition, WTFMove(length)); }
-    void setMaskSize(LengthSize size) { SET_VAR(m_rareNonInheritedData, mask.m_sizeLength, WTFMove(size)); }
+    void setMaskXPosition(Length&& length) { SET_NESTED_VAR(m_rareNonInheritedData, mask, m_xPosition, WTFMove(length)); }
+    void setMaskYPosition(Length&& length) { SET_NESTED_VAR(m_rareNonInheritedData, mask, m_yPosition, WTFMove(length)); }
+    void setMaskSize(LengthSize size) { SET_NESTED_VAR(m_rareNonInheritedData, mask, m_sizeLength, WTFMove(size)); }
 
     void setBorderCollapse(BorderCollapse collapse) { m_inheritedFlags.borderCollapse = static_cast<unsigned>(collapse); }
     void setHorizontalBorderSpacing(float);

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.cpp (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.cpp	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.cpp	2020-09-18 19:35:43 UTC (rev 267259)
@@ -28,7 +28,7 @@
 namespace WebCore {
 
 StyleBackgroundData::StyleBackgroundData()
-    : background(FillLayerType::Background)
+    : background(FillLayer::create(FillLayerType::Background))
     , color(RenderStyle::initialBackgroundColor())
 {
 }
@@ -62,7 +62,7 @@
 
 void StyleBackgroundData::dump(TextStream& ts, DumpStyleValues behavior) const
 {
-    if (behavior == DumpStyleValues::All || background != FillLayer(FillLayerType::Background))
+    if (behavior == DumpStyleValues::All || *background != FillLayer::create(FillLayerType::Background).get())
         ts.dumpProperty("background-image", background);
     if (behavior == DumpStyleValues::All || color != RenderStyle::initialBackgroundColor())
         ts.dumpProperty("background-color", color);

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.h (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.h	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/StyleBackgroundData.h	2020-09-18 19:35:43 UTC (rev 267259)
@@ -27,6 +27,7 @@
 #include "Color.h"
 #include "FillLayer.h"
 #include "OutlineValue.h"
+#include <wtf/DataRef.h>
 #include <wtf/RefCounted.h>
 #include <wtf/Ref.h>
 
@@ -42,7 +43,7 @@
 
     bool isEquivalentForPainting(const StyleBackgroundData&) const;
 
-    FillLayer background;
+    DataRef<FillLayer> background;
     Color color;
     OutlineValue outline;
 

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2020-09-18 19:35:43 UTC (rev 267259)
@@ -65,7 +65,7 @@
     , scrollSnapArea(StyleScrollSnapArea::create())
 #endif
     , willChange(RenderStyle::initialWillChange())
-    , mask(FillLayerType::Mask)
+    , mask(FillLayer::create(FillLayerType::Mask))
     , maskBoxImage(NinePieceImage::Type::Mask)
     , objectPosition(RenderStyle::initialObjectPosition())
     , shapeOutside(RenderStyle::initialShapeOutside())

Modified: branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (267258 => 267259)


--- branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-09-18 19:35:39 UTC (rev 267258)
+++ branches/safari-610-branch/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2020-09-18 19:35:43 UTC (rev 267259)
@@ -144,7 +144,7 @@
     RefPtr<AnimationList> animations;
     RefPtr<AnimationList> transitions;
 
-    FillLayer mask;
+    DataRef<FillLayer> mask;
     NinePieceImage maskBoxImage;
 
     LengthSize pageSize;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to