Title: [276661] branches/safari-611-branch
Revision
276661
Author
[email protected]
Date
2021-04-27 14:07:04 -0700 (Tue, 27 Apr 2021)

Log Message

Cherry-pick r274170. rdar://problem/77194450

    REGRESSION (r273003): Animated style may lose original display property value
    https://bugs.webkit.org/show_bug.cgi?id=222979
    rdar://75056684

    Reviewed by Zalan Bujtas.

    Source/WebCore:

    Test: fast/animation/animation-display-style-adjustment.html

    The original (non-blockified) display property value is saved in the beginning of Style::Adjuster::adjust.
    It is needed to implement absolute positioning correctly in some situations. However with animations
    the style adjustment code may run twice on the same style and the second run will clobber the saved original value.

    * rendering/RenderTheme.cpp:
    (WebCore::RenderTheme::adjustStyle):
    * rendering/style/RenderStyle.h:
    (WebCore::RenderStyle::setDisplay):

    Always save the original value when setting the property normally.

    (WebCore::RenderStyle::setEffectiveDisplay):
    (WebCore::RenderStyle::setOriginalDisplay): Deleted.

    Add setEffectiveDisplay that doesn't affect the original value for adjuster use.

    * style/StyleAdjuster.cpp:
    (WebCore::Style::Adjuster::adjust const):

    Remove the saving of the original value.
    Use setEffectiveDisplay in all adjuster code, preserving the original value.

    (WebCore::Style::Adjuster::adjustDisplayContentsStyle const):
    (WebCore::Style::Adjuster::adjustSVGElementStyle):
    (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const):

    LayoutTests:

    * fast/animation/animation-display-style-adjustment-expected.html: Added.
    * fast/animation/animation-display-style-adjustment.html: Added.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-611-branch/LayoutTests/ChangeLog (276660 => 276661)


--- branches/safari-611-branch/LayoutTests/ChangeLog	2021-04-27 20:56:19 UTC (rev 276660)
+++ branches/safari-611-branch/LayoutTests/ChangeLog	2021-04-27 21:07:04 UTC (rev 276661)
@@ -1,3 +1,62 @@
+2021-04-27  Russell Epstein  <[email protected]>
+
+        Cherry-pick r274170. rdar://problem/77194450
+
+    REGRESSION (r273003): Animated style may lose original display property value
+    https://bugs.webkit.org/show_bug.cgi?id=222979
+    rdar://75056684
+    
+    Reviewed by Zalan Bujtas.
+    
+    Source/WebCore:
+    
+    Test: fast/animation/animation-display-style-adjustment.html
+    
+    The original (non-blockified) display property value is saved in the beginning of Style::Adjuster::adjust.
+    It is needed to implement absolute positioning correctly in some situations. However with animations
+    the style adjustment code may run twice on the same style and the second run will clobber the saved original value.
+    
+    * rendering/RenderTheme.cpp:
+    (WebCore::RenderTheme::adjustStyle):
+    * rendering/style/RenderStyle.h:
+    (WebCore::RenderStyle::setDisplay):
+    
+    Always save the original value when setting the property normally.
+    
+    (WebCore::RenderStyle::setEffectiveDisplay):
+    (WebCore::RenderStyle::setOriginalDisplay): Deleted.
+    
+    Add setEffectiveDisplay that doesn't affect the original value for adjuster use.
+    
+    * style/StyleAdjuster.cpp:
+    (WebCore::Style::Adjuster::adjust const):
+    
+    Remove the saving of the original value.
+    Use setEffectiveDisplay in all adjuster code, preserving the original value.
+    
+    (WebCore::Style::Adjuster::adjustDisplayContentsStyle const):
+    (WebCore::Style::Adjuster::adjustSVGElementStyle):
+    (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const):
+    
+    LayoutTests:
+    
+    * fast/animation/animation-display-style-adjustment-expected.html: Added.
+    * fast/animation/animation-display-style-adjustment.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-03-09  Antti Koivisto  <[email protected]>
+
+            REGRESSION (r273003): Animated style may lose original display property value
+            https://bugs.webkit.org/show_bug.cgi?id=222979
+            rdar://75056684
+
+            Reviewed by Zalan Bujtas.
+
+            * fast/animation/animation-display-style-adjustment-expected.html: Added.
+            * fast/animation/animation-display-style-adjustment.html: Added.
+
 2021-04-21  Ruben Turcios  <[email protected]>
 
         Cherry-pick r276193. rdar://problem/76962916

Added: branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment-expected.html (0 => 276661)


--- branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment-expected.html	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment-expected.html	2021-04-27 21:07:04 UTC (rev 276661)
@@ -0,0 +1,18 @@
+<style>
+.test {
+    text-align: center;
+    border: 2px solid green;
+    height:100px;
+}
+.test > span {
+    top: 40px;
+    position: absolute;
+    width: 64px;
+    height: 64px;
+    background-color: #ff4500;
+    border-radius: 100%;
+}
+</style>
+<body>
+<div class=test><span></span>centered</div>
+</body>

Added: branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment.html (0 => 276661)


--- branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment.html	                        (rev 0)
+++ branches/safari-611-branch/LayoutTests/fast/animation/animation-display-style-adjustment.html	2021-04-27 21:07:04 UTC (rev 276661)
@@ -0,0 +1,25 @@
+<style>
+@keyframes scaleout {
+    0% {
+    }
+    to {
+    }
+}
+.test {
+    text-align: center;
+    border: 2px solid green;
+    height:100px;
+}
+.test > span {
+    top: 40px;
+    position: absolute;
+    width: 64px;
+    height: 64px;
+    background-color: #ff4500;
+    border-radius: 100%;
+    animation:scaleout 1.5s infinite ease-in-out
+}
+</style>
+<body>
+<div class=test><span></span>centered</div>
+</body>

Modified: branches/safari-611-branch/Source/WebCore/ChangeLog (276660 => 276661)


--- branches/safari-611-branch/Source/WebCore/ChangeLog	2021-04-27 20:56:19 UTC (rev 276660)
+++ branches/safari-611-branch/Source/WebCore/ChangeLog	2021-04-27 21:07:04 UTC (rev 276661)
@@ -1,3 +1,87 @@
+2021-04-27  Russell Epstein  <[email protected]>
+
+        Cherry-pick r274170. rdar://problem/77194450
+
+    REGRESSION (r273003): Animated style may lose original display property value
+    https://bugs.webkit.org/show_bug.cgi?id=222979
+    rdar://75056684
+    
+    Reviewed by Zalan Bujtas.
+    
+    Source/WebCore:
+    
+    Test: fast/animation/animation-display-style-adjustment.html
+    
+    The original (non-blockified) display property value is saved in the beginning of Style::Adjuster::adjust.
+    It is needed to implement absolute positioning correctly in some situations. However with animations
+    the style adjustment code may run twice on the same style and the second run will clobber the saved original value.
+    
+    * rendering/RenderTheme.cpp:
+    (WebCore::RenderTheme::adjustStyle):
+    * rendering/style/RenderStyle.h:
+    (WebCore::RenderStyle::setDisplay):
+    
+    Always save the original value when setting the property normally.
+    
+    (WebCore::RenderStyle::setEffectiveDisplay):
+    (WebCore::RenderStyle::setOriginalDisplay): Deleted.
+    
+    Add setEffectiveDisplay that doesn't affect the original value for adjuster use.
+    
+    * style/StyleAdjuster.cpp:
+    (WebCore::Style::Adjuster::adjust const):
+    
+    Remove the saving of the original value.
+    Use setEffectiveDisplay in all adjuster code, preserving the original value.
+    
+    (WebCore::Style::Adjuster::adjustDisplayContentsStyle const):
+    (WebCore::Style::Adjuster::adjustSVGElementStyle):
+    (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const):
+    
+    LayoutTests:
+    
+    * fast/animation/animation-display-style-adjustment-expected.html: Added.
+    * fast/animation/animation-display-style-adjustment.html: Added.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@274170 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2021-03-09  Antti Koivisto  <[email protected]>
+
+            REGRESSION (r273003): Animated style may lose original display property value
+            https://bugs.webkit.org/show_bug.cgi?id=222979
+            rdar://75056684
+
+            Reviewed by Zalan Bujtas.
+
+            Test: fast/animation/animation-display-style-adjustment.html
+
+            The original (non-blockified) display property value is saved in the beginning of Style::Adjuster::adjust.
+            It is needed to implement absolute positioning correctly in some situations. However with animations
+            the style adjustment code may run twice on the same style and the second run will clobber the saved original value.
+
+            * rendering/RenderTheme.cpp:
+            (WebCore::RenderTheme::adjustStyle):
+            * rendering/style/RenderStyle.h:
+            (WebCore::RenderStyle::setDisplay):
+
+            Always save the original value when setting the property normally.
+
+            (WebCore::RenderStyle::setEffectiveDisplay):
+            (WebCore::RenderStyle::setOriginalDisplay): Deleted.
+
+            Add setEffectiveDisplay that doesn't affect the original value for adjuster use.
+
+            * style/StyleAdjuster.cpp:
+            (WebCore::Style::Adjuster::adjust const):
+
+            Remove the saving of the original value.
+            Use setEffectiveDisplay in all adjuster code, preserving the original value.
+
+            (WebCore::Style::Adjuster::adjustDisplayContentsStyle const):
+            (WebCore::Style::Adjuster::adjustSVGElementStyle):
+            (WebCore::Style::Adjuster::adjustForSiteSpecificQuirks const):
+
 2021-04-21  Ruben Turcios  <[email protected]>
 
         Cherry-pick r276010. rdar://problem/76962988

Modified: branches/safari-611-branch/Source/WebCore/rendering/RenderTheme.cpp (276660 => 276661)


--- branches/safari-611-branch/Source/WebCore/rendering/RenderTheme.cpp	2021-04-27 20:56:19 UTC (rev 276660)
+++ branches/safari-611-branch/Source/WebCore/rendering/RenderTheme.cpp	2021-04-27 21:07:04 UTC (rev 276661)
@@ -83,9 +83,9 @@
         || style.display() == DisplayType::TableHeaderGroup || style.display() == DisplayType::TableFooterGroup
         || style.display() == DisplayType::TableRow || style.display() == DisplayType::TableColumnGroup || style.display() == DisplayType::TableColumn
         || style.display() == DisplayType::TableCell || style.display() == DisplayType::TableCaption)
-        style.setDisplay(DisplayType::InlineBlock);
+        style.setEffectiveDisplay(DisplayType::InlineBlock);
     else if (style.display() == DisplayType::ListItem || style.display() == DisplayType::Table)
-        style.setDisplay(DisplayType::Block);
+        style.setEffectiveDisplay(DisplayType::Block);
 
     if (userAgentAppearanceStyle && isControlStyled(style, *userAgentAppearanceStyle)) {
         switch (part) {

Modified: branches/safari-611-branch/Source/WebCore/rendering/style/RenderStyle.h (276660 => 276661)


--- branches/safari-611-branch/Source/WebCore/rendering/style/RenderStyle.h	2021-04-27 20:56:19 UTC (rev 276660)
+++ branches/safari-611-branch/Source/WebCore/rendering/style/RenderStyle.h	2021-04-27 21:07:04 UTC (rev 276661)
@@ -835,8 +835,12 @@
 
 // attribute setter methods
 
-    void setDisplay(DisplayType v) { m_nonInheritedFlags.effectiveDisplay = static_cast<unsigned>(v); }
-    void setOriginalDisplay(DisplayType v) { m_nonInheritedFlags.originalDisplay = static_cast<unsigned>(v); }
+    void setDisplay(DisplayType value)
+    {
+        m_nonInheritedFlags.originalDisplay = static_cast<unsigned>(value);
+        m_nonInheritedFlags.effectiveDisplay = m_nonInheritedFlags.originalDisplay;
+    }
+    void setEffectiveDisplay(DisplayType v) { m_nonInheritedFlags.effectiveDisplay = static_cast<unsigned>(v); }
     void setPosition(PositionType v) { m_nonInheritedFlags.position = static_cast<unsigned>(v); }
     void setFloating(Float v) { m_nonInheritedFlags.floating = static_cast<unsigned>(v); }
 

Modified: branches/safari-611-branch/Source/WebCore/style/StyleAdjuster.cpp (276660 => 276661)


--- branches/safari-611-branch/Source/WebCore/style/StyleAdjuster.cpp	2021-04-27 20:56:19 UTC (rev 276660)
+++ branches/safari-611-branch/Source/WebCore/style/StyleAdjuster.cpp	2021-04-27 21:07:04 UTC (rev 276661)
@@ -243,9 +243,6 @@
 
 void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearanceStyle) const
 {
-    // Cache our original display.
-    style.setOriginalDisplay(style.display());
-
     if (style.display() == DisplayType::Contents)
         adjustDisplayContentsStyle(style);
 
@@ -257,10 +254,10 @@
             // these tags to retain their display types.
             if (m_document.inQuirksMode()) {
                 if (m_element->hasTagName(tdTag)) {
-                    style.setDisplay(DisplayType::TableCell);
+                    style.setEffectiveDisplay(DisplayType::TableCell);
                     style.setFloating(Float::No);
                 } else if (is<HTMLTableElement>(*m_element))
-                    style.setDisplay(style.isDisplayInlineType() ? DisplayType::InlineTable : DisplayType::Table);
+                    style.setEffectiveDisplay(style.isDisplayInlineType() ? DisplayType::InlineTable : DisplayType::Table);
             }
 
             if (m_element->hasTagName(tdTag) || m_element->hasTagName(thTag)) {
@@ -283,7 +280,7 @@
             // fix a crash where a site tries to position these objects. They also never honor display.
             if (m_element->hasTagName(frameTag) || m_element->hasTagName(framesetTag)) {
                 style.setPosition(PositionType::Static);
-                style.setDisplay(DisplayType::Block);
+                style.setEffectiveDisplay(DisplayType::Block);
             }
 
             // Ruby text does not support float or position. This might change with evolution of the specification.
@@ -300,17 +297,17 @@
                 style.setTextAlign(TextAlignMode::Center);
 
             if (m_element->hasTagName(legendTag))
-                style.setDisplay(DisplayType::Block);
+                style.setEffectiveDisplay(DisplayType::Block);
         }
 
         // Absolute/fixed positioned elements, floating elements and the document element need block-like outside display.
         if (style.hasOutOfFlowPosition() || style.isFloating() || (m_element && m_document.documentElement() == m_element))
-            style.setDisplay(equivalentBlockDisplay(style, m_document));
+            style.setEffectiveDisplay(equivalentBlockDisplay(style, m_document));
 
         // FIXME: Don't support this mutation for pseudo styles like first-letter or first-line, since it's not completely
         // clear how that should work.
         if (style.display() == DisplayType::Inline && style.styleType() == PseudoId::None && style.writingMode() != m_parentStyle.writingMode())
-            style.setDisplay(DisplayType::InlineBlock);
+            style.setEffectiveDisplay(DisplayType::InlineBlock);
 
         // After performing the display mutation, check table rows. We do not honor position:relative or position:sticky on
         // table rows or cells. This has been established for position:relative in CSS2.1 (and caused a crash in containingBlock()
@@ -337,7 +334,7 @@
         // "A parent with a grid or flex display value blockifies the box’s display type."
         if (m_parentBoxStyle.isDisplayFlexibleOrGridBox()) {
             style.setFloating(Float::No);
-            style.setDisplay(equivalentBlockDisplay(style, m_document));
+            style.setEffectiveDisplay(equivalentBlockDisplay(style, m_document));
         }
     }
 
@@ -544,17 +541,17 @@
 {
     if (!m_element) {
         if (style.styleType() != PseudoId::Before && style.styleType() != PseudoId::After)
-            style.setDisplay(DisplayType::None);
+            style.setEffectiveDisplay(DisplayType::None);
         return;
     }
 
     if (m_document.documentElement() == m_element) {
-        style.setDisplay(DisplayType::Block);
+        style.setEffectiveDisplay(DisplayType::Block);
         return;
     }
 
     if (hasEffectiveDisplayNoneForDisplayContents(*m_element))
-        style.setDisplay(DisplayType::None);
+        style.setEffectiveDisplay(DisplayType::None);
 }
 
 void Adjuster::adjustSVGElementStyle(RenderStyle& style, const SVGElement& svgElement)
@@ -571,7 +568,7 @@
 
     // SVG text layout code expects us to be a block-level style element.
     if ((svgElement.hasTagName(SVGNames::foreignObjectTag) || svgElement.hasTagName(SVGNames::textTag)) && style.isDisplayInlineType())
-        style.setDisplay(DisplayType::Block);
+        style.setEffectiveDisplay(DisplayType::Block);
 }
 
 void Adjuster::adjustAnimatedStyle(RenderStyle& style, OptionSet<AnimationImpact> impact) const
@@ -630,7 +627,7 @@
             if (div.hasClass() && div.classNames().contains(instreamNativeVideoDivClass)) {
                 auto* video = div.treeScope().getElementById(videoElementID);
                 if (is<HTMLVideoElement>(video) && downcast<HTMLVideoElement>(*video).isFullscreen())
-                    style.setDisplay(DisplayType::Block);
+                    style.setEffectiveDisplay(DisplayType::Block);
             }
         }
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to