getComputedStyle returns "auto" for zIndex property even after it has been set, on...
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2019 01:48:28 +0000 (01:48 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Nov 2019 01:48:28 +0000 (01:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=15562

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

More passing tests.

* web-platform-tests/css/css-position/inheritance-expected.txt:
* web-platform-tests/css/css-values/calc-integer-expected.txt:
* web-platform-tests/css/css-values/calc-z-index-fractions-001-expected.txt:
* web-platform-tests/css/css-values/minmax-integer-computed-expected.txt:

Source/WebCore:

The computed value of z-index should be the specified value, but Style::Adjuster::adjust() set z-index
to auto on non-positioned elements, so we reported the incorrect computed value.

Fix by storing the specified value in RenderStyle as "zIndex", and the used value as "effectiveZIndex", and
converting all rendering code to use the "effective" variants. getComputedStyle reads "zIndex".

Style::Adjuster::adjust() copies zIndex to effectiveZIndex for positioned elements.

Tests: fast/css/getComputedStyle/getComputedStyle-zIndex-auto.html

* animation/KeyframeEffect.cpp:
(WebCore::KeyframeEffect::apply):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSProperties.json:
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::createInnerTextStyle):
* page/animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::animate):
* rendering/RenderBox.cpp:
(WebCore::isCandidateForOpaquenessTest):
* rendering/RenderBox.h:
* rendering/RenderElement.cpp:
(WebCore::RenderElement::styleWillChange):
* rendering/RenderFullScreen.cpp:
(WebCore::createFullScreenStyle):
* rendering/RenderLayer.cpp:
(WebCore::canCreateStackingContext):
(WebCore::RenderLayer::shouldBeCSSStackingContext const):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::logLayerInfo):
* rendering/RenderLayerModelObject.cpp:
(WebCore::RenderLayerModelObject::styleWillChange):
* rendering/RenderTreeAsText.cpp:
(WebCore::RenderTreeAsText::writeRenderObject):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayerRepaint const):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::specifiedZIndex const):
(WebCore::RenderStyle::hasAutoSpecifiedZIndex const):
(WebCore::RenderStyle::setSpecifiedZIndex):
(WebCore::RenderStyle::setHasAutoSpecifiedZIndex):
(WebCore::RenderStyle::usedZIndex const):
(WebCore::RenderStyle::hasAutoUsedZIndex const):
(WebCore::RenderStyle::setUsedZIndex):
(WebCore::RenderStyle::setHasAutoUsedZIndex):
(WebCore::RenderStyle::hasAutoZIndex const): Deleted.
(WebCore::RenderStyle::setHasAutoZIndex): Deleted.
(WebCore::RenderStyle::zIndex const): Deleted.
(WebCore::RenderStyle::setZIndex): Deleted.
* rendering/style/StyleBoxData.cpp:
(WebCore::StyleBoxData::StyleBoxData):
(WebCore::StyleBoxData::operator== const):
* rendering/style/StyleBoxData.h:
(WebCore::StyleBoxData::specifiedZIndex const):
(WebCore::StyleBoxData::hasAutoSpecifiedZIndex const):
(WebCore::StyleBoxData::usedZIndex const):
(WebCore::StyleBoxData::hasAutoUsedZIndex const):
(WebCore::StyleBoxData::zIndex const): Deleted.
(WebCore::StyleBoxData::hasAutoZIndex const): Deleted.
* style/StyleAdjuster.cpp:
(WebCore::Style::Adjuster::adjust const):

LayoutTests:

* fast/css-grid-layout/grid-item-z-index-support-expected.txt:
* fast/css-grid-layout/grid-item-z-index-support.html:
* fast/css/getComputedStyle/getComputedStyle-zIndex-auto-expected.txt:
* fast/css/getComputedStyle/getComputedStyle-zIndex-auto.html:

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

31 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css-grid-layout/grid-item-z-index-support-expected.txt
LayoutTests/fast/css-grid-layout/grid-item-z-index-support.html
LayoutTests/fast/css/getComputedStyle/getComputedStyle-zIndex-auto-expected.txt
LayoutTests/fast/css/getComputedStyle/getComputedStyle-zIndex-auto.html
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/css/css-position/inheritance-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-integer-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-values/calc-z-index-fractions-001-expected.txt
LayoutTests/imported/w3c/web-platform-tests/css/css-values/minmax-integer-computed-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/animation/KeyframeEffect.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSProperties.json
Source/WebCore/html/HTMLInputElement.cpp
Source/WebCore/page/animation/CSSPropertyAnimation.cpp
Source/WebCore/page/animation/CompositeAnimation.cpp
Source/WebCore/rendering/RenderBox.cpp
Source/WebCore/rendering/RenderBox.h
Source/WebCore/rendering/RenderElement.cpp
Source/WebCore/rendering/RenderFullScreen.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/RenderLayer.h
Source/WebCore/rendering/RenderLayerCompositor.cpp
Source/WebCore/rendering/RenderLayerModelObject.cpp
Source/WebCore/rendering/RenderTreeAsText.cpp
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleBoxData.cpp
Source/WebCore/rendering/style/StyleBoxData.h
Source/WebCore/style/StyleAdjuster.cpp

index b05bc08..7afc14e 100644 (file)
@@ -1,3 +1,15 @@
+2019-11-20  Simon Fraser  <simon.fraser@apple.com>
+
+        getComputedStyle returns "auto" for zIndex property even after it has been set, on non-positioned elements
+        https://bugs.webkit.org/show_bug.cgi?id=15562
+
+        Reviewed by Antti Koivisto.
+
+        * fast/css-grid-layout/grid-item-z-index-support-expected.txt:
+        * fast/css-grid-layout/grid-item-z-index-support.html:
+        * fast/css/getComputedStyle/getComputedStyle-zIndex-auto-expected.txt:
+        * fast/css/getComputedStyle/getComputedStyle-zIndex-auto.html:
+
 2019-11-20  Kate Cheney  <katherine_cheney@apple.com>
 
         [ Jazz ] http/tests/resourceLoadStatistics/cookie-deletion.html is timing out
index 8a27e8d..f5cc81b 100644 (file)
@@ -5,7 +5,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 Test z-index property for a regular element
 PASS getComputedStyle(item, '').getPropertyValue('z-index') is 'auto'
-PASS getComputedStyle(item, '').getPropertyValue('z-index') is 'auto'
+PASS getComputedStyle(item, '').getPropertyValue('z-index') is '-10'
 Test z-index property once the element becomes a grid item
 PASS getComputedStyle(item, '').getPropertyValue('z-index') is '-10'
 PASS getComputedStyle(item, '').getPropertyValue('z-index') is '10'
index 90b5c46..3695d90 100644 (file)
@@ -14,7 +14,7 @@ debug('Test z-index property for a regular element');
 var item = document.getElementById("item");
 shouldBe("getComputedStyle(item, '').getPropertyValue('z-index')", "'auto'");
 item.style.zIndex = "-10";
-shouldBe("getComputedStyle(item, '').getPropertyValue('z-index')", "'auto'");
+shouldBe("getComputedStyle(item, '').getPropertyValue('z-index')", "'-10'");
 
 debug('Test z-index property once the element becomes a grid item');
 var grid = document.getElementById("grid");
index 2a4e5a4..5c2e32c 100644 (file)
@@ -1,5 +1,5 @@
 Non-positioned Div:
-    Computed Style = auto (Should be auto)
+    Computed Style = 20 (Should be 20)
     element.style.zIndex = 20 (Should be 20)
 
 Positioned Div:
index d6a4e5d..c8bc542 100644 (file)
@@ -15,7 +15,7 @@
             var element = document.getElementById('nonPositionedDiv');
             var compStyle = element.ownerDocument.defaultView.getComputedStyle(element, null);
             log("Non-positioned Div:");
-            log("    Computed Style = " + compStyle.zIndex + " (Should be auto)");
+            log("    Computed Style = " + compStyle.zIndex + " (Should be 20)");
             log("    element.style.zIndex = " + element.style.zIndex + " (Should be 20)");
             log("");
 
index a693d57..941ff5a 100644 (file)
@@ -1,3 +1,17 @@
+2019-11-20  Simon Fraser  <simon.fraser@apple.com>
+
+        getComputedStyle returns "auto" for zIndex property even after it has been set, on non-positioned elements
+        https://bugs.webkit.org/show_bug.cgi?id=15562
+
+        Reviewed by Antti Koivisto.
+
+        More passing tests.
+
+        * web-platform-tests/css/css-position/inheritance-expected.txt:
+        * web-platform-tests/css/css-values/calc-integer-expected.txt:
+        * web-platform-tests/css/css-values/calc-z-index-fractions-001-expected.txt:
+        * web-platform-tests/css/css-values/minmax-integer-computed-expected.txt:
+
 2019-11-19  Youenn Fablet  <youenn@apple.com>
 
         getUserMedia echoCancellation constraint has no affect
index 33f0457..22b6660 100644 (file)
@@ -17,6 +17,6 @@ FAIL Property inset-start has initial value auto assert_true: inset-start doesn'
 FAIL Property inset-start does not inherit assert_true: expected true got false
 FAIL Property inset-end has initial value auto assert_true: inset-end doesn't seem to be supported in the computed style expected true got false
 FAIL Property inset-end does not inherit assert_true: expected true got false
-FAIL Property z-index has initial value auto assert_equals: expected "auto" but got "0"
+PASS Property z-index has initial value auto 
 PASS Property z-index does not inherit 
 
index f87ba34..c795953 100644 (file)
@@ -1,9 +1,9 @@
 
-FAIL Sanity assert_equals: expected "2" but got "auto"
-FAIL Basic division works assert_equals: expected "2" but got "auto"
-FAIL Rounds up if fractional part is >= 0.5 assert_equals: expected "1" but got "auto"
-FAIL Accepts numbers, and rounds assert_equals: expected "1" but got "auto"
-FAIL Operation between <integer> and <number> works assert_equals: expected "3" but got "auto"
-FAIL Rounds down if fractional part is < 0.5 assert_equals: expected "0" but got "auto"
-FAIL Only rounds at the end of the conversion assert_equals: expected "1" but got "auto"
+PASS Sanity 
+PASS Basic division works 
+PASS Rounds up if fractional part is >= 0.5 
+PASS Accepts numbers, and rounds 
+PASS Operation between <integer> and <number> works 
+PASS Rounds down if fractional part is < 0.5 
+PASS Only rounds at the end of the conversion 
 
index 995af08..360d994 100644 (file)
@@ -1,4 +1,4 @@
 
-FAIL testing z-index: calc(3 / 2) assert_equals: expected "2" but got "auto"
-FAIL testing z-index: calc(-3 / 2) assert_equals: expected "-1" but got "auto"
+PASS testing z-index: calc(3 / 2) 
+FAIL testing z-index: calc(-3 / 2) assert_equals: expected "-1" but got "-2"
 
index 0f653a0..395a238 100644 (file)
@@ -1,12 +1,12 @@
 
-PASS Property z-index value 'min(1)' computes to 'auto
-PASS Property z-index value 'max(1)' computes to 'auto
-PASS Property z-index value 'min(0.4)' computes to 'auto
-PASS Property z-index value 'min(0.6)' computes to 'auto
-PASS Property z-index value 'max(0.4)' computes to 'auto
-PASS Property z-index value 'max(0.6)' computes to 'auto
-PASS Property z-index value 'min(1.1, max(0.4, 0.6))' computes to 'auto
-PASS Property z-index value 'max(0.3, min(1.1, 0.4))' computes to 'auto
-PASS Property z-index value 'calc(min(0.3, 0.6) * 2)' computes to 'auto
-PASS Property z-index value 'calc(max(0.3, 0.6) / 2)' computes to 'auto
+PASS Property z-index value 'min(1)' computes to '1
+PASS Property z-index value 'max(1)' computes to '1
+PASS Property z-index value 'min(0.4)' computes to '0
+PASS Property z-index value 'min(0.6)' computes to '1
+PASS Property z-index value 'max(0.4)' computes to '0
+PASS Property z-index value 'max(0.6)' computes to '1
+PASS Property z-index value 'min(1.1, max(0.4, 0.6))' computes to '1
+PASS Property z-index value 'max(0.3, min(1.1, 0.4))' computes to '0
+PASS Property z-index value 'calc(min(0.3, 0.6) * 2)' computes to '1
+PASS Property z-index value 'calc(max(0.3, 0.6) / 2)' computes to '0
 
index 2d8efe7..15c7ad7 100644 (file)
@@ -1,3 +1,77 @@
+2019-11-20  Simon Fraser  <simon.fraser@apple.com>
+
+        getComputedStyle returns "auto" for zIndex property even after it has been set, on non-positioned elements
+        https://bugs.webkit.org/show_bug.cgi?id=15562
+
+        Reviewed by Antti Koivisto.
+
+        The computed value of z-index should be the specified value, but Style::Adjuster::adjust() set z-index
+        to auto on non-positioned elements, so we reported the incorrect computed value.
+
+        Fix by storing the specified value in RenderStyle as "zIndex", and the used value as "effectiveZIndex", and
+        converting all rendering code to use the "effective" variants. getComputedStyle reads "zIndex".
+
+        Style::Adjuster::adjust() copies zIndex to effectiveZIndex for positioned elements.
+
+        Tests: fast/css/getComputedStyle/getComputedStyle-zIndex-auto.html
+
+        * animation/KeyframeEffect.cpp:
+        (WebCore::KeyframeEffect::apply):
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+        * css/CSSProperties.json:
+        * html/HTMLInputElement.cpp:
+        (WebCore::HTMLInputElement::createInnerTextStyle):
+        * page/animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::animate):
+        * rendering/RenderBox.cpp:
+        (WebCore::isCandidateForOpaquenessTest):
+        * rendering/RenderBox.h:
+        * rendering/RenderElement.cpp:
+        (WebCore::RenderElement::styleWillChange):
+        * rendering/RenderFullScreen.cpp:
+        (WebCore::createFullScreenStyle):
+        * rendering/RenderLayer.cpp:
+        (WebCore::canCreateStackingContext):
+        (WebCore::RenderLayer::shouldBeCSSStackingContext const):
+        (WebCore::RenderLayer::calculateClipRects const):
+        * rendering/RenderLayer.h:
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::logLayerInfo):
+        * rendering/RenderLayerModelObject.cpp:
+        (WebCore::RenderLayerModelObject::styleWillChange):
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::RenderTreeAsText::writeRenderObject):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeRequiresLayerRepaint const):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::specifiedZIndex const):
+        (WebCore::RenderStyle::hasAutoSpecifiedZIndex const):
+        (WebCore::RenderStyle::setSpecifiedZIndex):
+        (WebCore::RenderStyle::setHasAutoSpecifiedZIndex):
+        (WebCore::RenderStyle::usedZIndex const):
+        (WebCore::RenderStyle::hasAutoUsedZIndex const):
+        (WebCore::RenderStyle::setUsedZIndex):
+        (WebCore::RenderStyle::setHasAutoUsedZIndex):
+        (WebCore::RenderStyle::hasAutoZIndex const): Deleted.
+        (WebCore::RenderStyle::setHasAutoZIndex): Deleted.
+        (WebCore::RenderStyle::zIndex const): Deleted.
+        (WebCore::RenderStyle::setZIndex): Deleted.
+        * rendering/style/StyleBoxData.cpp:
+        (WebCore::StyleBoxData::StyleBoxData):
+        (WebCore::StyleBoxData::operator== const):
+        * rendering/style/StyleBoxData.h:
+        (WebCore::StyleBoxData::specifiedZIndex const):
+        (WebCore::StyleBoxData::hasAutoSpecifiedZIndex const):
+        (WebCore::StyleBoxData::usedZIndex const):
+        (WebCore::StyleBoxData::hasAutoUsedZIndex const):
+        (WebCore::StyleBoxData::zIndex const): Deleted.
+        (WebCore::StyleBoxData::hasAutoZIndex const): Deleted.
+        * style/StyleAdjuster.cpp:
+        (WebCore::Style::Adjuster::adjust const):
+
 2019-11-19  Ryosuke Niwa  <rniwa@webkit.org>
 
         MicrotaskQueue should be accessed via EventLoop
index 27ca94b..98b6168 100644 (file)
@@ -1060,8 +1060,8 @@ void KeyframeEffect::apply(RenderStyle& targetStyle)
     // https://w3c.github.io/web-animations/#side-effects-section
     // For every property targeted by at least one animation effect that is current or in effect, the user agent
     // must act as if the will-change property ([css-will-change-1]) on the target element includes the property.
-    if (m_triggersStackingContext && targetStyle.hasAutoZIndex())
-        targetStyle.setZIndex(0);
+    if (m_triggersStackingContext && targetStyle.hasAutoUsedZIndex())
+        targetStyle.setUsedZIndex(0);
 }
 
 void KeyframeEffect::invalidate()
index 9df1820..73596ee 100644 (file)
@@ -3226,9 +3226,9 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty
         case CSSPropertyFontVariantEastAsian:
             return fontVariantEastAsianPropertyValue(style.fontDescription().variantEastAsianVariant(), style.fontDescription().variantEastAsianWidth(), style.fontDescription().variantEastAsianRuby());
         case CSSPropertyZIndex:
-            if (style.hasAutoZIndex())
+            if (style.hasAutoSpecifiedZIndex())
                 return cssValuePool.createIdentifierValue(CSSValueAuto);
-            return cssValuePool.createValue(style.zIndex(), CSSUnitType::CSS_NUMBER);
+            return cssValuePool.createValue(style.specifiedZIndex(), CSSUnitType::CSS_NUMBER);
         case CSSPropertyZoom:
             return cssValuePool.createValue(style.zoom(), CSSUnitType::CSS_NUMBER);
         case CSSPropertyBoxSizing:
index bbc9bee..41578a9 100644 (file)
         },
         "z-index": {
             "codegen-properties": {
-                "auto-functions": true
+                "auto-functions": true,
+                "name-for-methods": "SpecifiedZIndex"
             },
             "specification": {
                 "category": "css-22",
index 9791deb..dfe190a 100644 (file)
@@ -2092,8 +2092,8 @@ RenderStyle HTMLInputElement::createInnerTextStyle(const RenderStyle& style)
         textBlockStyle.setTextOverflow(TextOverflow::Clip);
         textBlockStyle.setMaskImage(StyleGeneratedImage::create(autoFillStrongPasswordMaskImage()));
         // A stacking context is needed for the mask.
-        if (textBlockStyle.hasAutoZIndex())
-            textBlockStyle.setZIndex(0);
+        if (textBlockStyle.hasAutoUsedZIndex())
+            textBlockStyle.setUsedZIndex(0);
     }
 
     // Do not allow line-height to be smaller than our default.
index 161cba0..60b5f88 100644 (file)
@@ -1612,7 +1612,7 @@ CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap()
         new PropertyWrapper<float>(CSSPropertyColumnWidth, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth),
         new PropertyWrapper<float>(CSSPropertyWebkitBorderHorizontalSpacing, &RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing),
         new PropertyWrapper<float>(CSSPropertyWebkitBorderVerticalSpacing, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing),
-        new PropertyWrapper<int>(CSSPropertyZIndex, &RenderStyle::zIndex, &RenderStyle::setZIndex),
+        new PropertyWrapper<int>(CSSPropertyZIndex, &RenderStyle::specifiedZIndex, &RenderStyle::setSpecifiedZIndex),
         new PropertyWrapper<short>(CSSPropertyOrphans, &RenderStyle::orphans, &RenderStyle::setOrphans),
         new PropertyWrapper<short>(CSSPropertyWidows, &RenderStyle::widows, &RenderStyle::setWidows),
         new LengthPropertyWrapper(CSSPropertyLineHeight, &RenderStyle::specifiedLineHeight, &RenderStyle::setLineHeight),
index ad86915..0449470 100644 (file)
@@ -337,8 +337,8 @@ AnimationUpdate CompositeAnimation::animate(Element& element, const RenderStyle*
     // the user agent must act as if the will-change property ([css-will-change-1]) on the element additionally
     // includes all the properties animated by the animation.
     if (forceStackingContext && animatedStyle) {
-        if (animatedStyle->hasAutoZIndex())
-            animatedStyle->setZIndex(0);
+        if (animatedStyle->hasAutoUsedZIndex())
+            animatedStyle->setUsedZIndex(0);
     }
 
     return { WTFMove(animatedStyle), animationChangeRequiresRecomposite };
index 7ec2cf6..87ae762 100644 (file)
@@ -1482,7 +1482,7 @@ static bool isCandidateForOpaquenessTest(const RenderBox& childBox)
         if (childLayer->isComposited())
             return false;
         // FIXME: Deal with z-index.
-        if (!childStyle.hasAutoZIndex())
+        if (!childStyle.hasAutoUsedZIndex())
             return false;
         if (childLayer->hasTransform() || childLayer->isTransparent() || childLayer->hasFilter())
             return false;
index c5834fa..2bfce5f 100644 (file)
@@ -53,7 +53,7 @@ public:
     {
         return isDocumentElementRenderer() || isPositioned() || createsGroup() || hasClipPath() || hasOverflowClip()
             || hasTransformRelatedProperty() || hasHiddenBackface() || hasReflection() || style().specifiesColumns()
-            || !style().hasAutoZIndex() || hasRunningAcceleratedAnimations();
+            || !style().hasAutoUsedZIndex() || hasRunningAcceleratedAnimations();
     }
 
     bool backgroundIsKnownToBeOpaqueInRect(const LayoutRect& localRect) const final;
index bf6c2a7..e7f903a 100644 (file)
@@ -711,8 +711,8 @@ void RenderElement::styleWillChange(StyleDifference diff, const RenderStyle& new
         // If our z-index changes value or our visibility changes,
         // we need to dirty our stacking context's z-order list.
         bool visibilityChanged = m_style.visibility() != newStyle.visibility()
-            || m_style.zIndex() != newStyle.zIndex()
-            || m_style.hasAutoZIndex() != newStyle.hasAutoZIndex();
+            || m_style.usedZIndex() != newStyle.usedZIndex()
+            || m_style.hasAutoUsedZIndex() != newStyle.hasAutoUsedZIndex();
 
         if (visibilityChanged)
             document().invalidateRenderingDependentRegions();
index d3f4f64..d872deb 100644 (file)
@@ -67,7 +67,7 @@ static RenderStyle createFullScreenStyle()
     auto fullscreenStyle = RenderStyle::create();
 
     // Create a stacking context:
-    fullscreenStyle.setZIndex(INT_MAX);
+    fullscreenStyle.setUsedZIndex(INT_MAX);
 
     fullscreenStyle.setFontDescription({ });
     fullscreenStyle.fontCascade().update(nullptr);
index dc08f08..22876b7 100644 (file)
@@ -566,7 +566,7 @@ static bool canCreateStackingContext(const RenderLayer& layer)
         || renderer.isPositioned() // Note that this only creates stacking context in conjunction with explicit z-index.
         || renderer.hasReflection()
         || renderer.style().hasIsolation()
-        || !renderer.style().hasAutoZIndex()
+        || !renderer.style().hasAutoUsedZIndex()
         || (renderer.style().willChange() && renderer.style().willChange()->canCreateStackingContext());
 }
 
@@ -587,7 +587,7 @@ bool RenderLayer::shouldBeNormalFlowOnly() const
 
 bool RenderLayer::shouldBeCSSStackingContext() const
 {
-    return !renderer().style().hasAutoZIndex() || isRenderViewLayer();
+    return !renderer().style().hasAutoUsedZIndex() || isRenderViewLayer();
 }
 
 bool RenderLayer::setIsNormalFlowOnly(bool isNormalFlowOnly)
@@ -6601,7 +6601,7 @@ void RenderLayer::styleChanged(StyleDifference diff, const RenderStyle* oldStyle
     // FIXME: RenderLayer already handles visibility changes through our visibility dirty bits. This logic could
     // likely be folded along with the rest.
     if (oldStyle) {
-        if (oldStyle->zIndex() != renderer().style().zIndex() || oldStyle->visibility() != renderer().style().visibility()) {
+        if (oldStyle->usedZIndex() != renderer().style().usedZIndex() || oldStyle->visibility() != renderer().style().visibility()) {
             dirtyStackingContextZOrderLists();
             if (isStackingContext())
                 dirtyZOrderLists();
@@ -6810,9 +6810,9 @@ RenderStyle RenderLayer::createReflectionStyle()
 
     // Map in our mask.
     newStyle.setMaskBoxImage(renderer().style().boxReflect()->mask());
-    
+
     // Style has transform and mask, so needs to be stacking context.
-    newStyle.setZIndex(0);
+    newStyle.setUsedZIndex(0);
 
     return newStyle;
 }
index 5c8ca29..49ee9d4 100644 (file)
@@ -648,7 +648,7 @@ public:
     LayoutPoint convertToLayerCoords(const RenderLayer* ancestorLayer, const LayoutPoint&, ColumnOffsetAdjustment adjustForColumns = DontAdjustForColumns) const;
     LayoutSize offsetFromAncestor(const RenderLayer*, ColumnOffsetAdjustment = DontAdjustForColumns) const;
 
-    int zIndex() const { return renderer().style().zIndex(); }
+    int zIndex() const { return renderer().style().usedZIndex(); }
 
     enum PaintLayerFlag {
         PaintLayerHaveTransparency                      = 1 << 0,
index 9d45452..923261b 100644 (file)
@@ -1393,8 +1393,8 @@ void RenderLayerCompositor::logLayerInfo(const RenderLayer& layer, const char* p
     StringBuilder logString;
     logString.append(pad(' ', 12 + depth * 2, hex(reinterpret_cast<uintptr_t>(&layer), Lowercase)), " id ", backing->graphicsLayer()->primaryLayerID(), " (", FormattedNumber::fixedWidth(absoluteBounds.x().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.y().toFloat(), 3), '-', FormattedNumber::fixedWidth(absoluteBounds.maxX().toFloat(), 3), ',', FormattedNumber::fixedWidth(absoluteBounds.maxY().toFloat(), 3), ") ", FormattedNumber::fixedWidth(backing->backingStoreMemoryEstimate() / 1024, 2), "KB");
 
-    if (!layer.renderer().style().hasAutoZIndex())
-        logString.append(" z-index: ", layer.renderer().style().zIndex());
+    if (!layer.renderer().style().hasAutoUsedZIndex())
+        logString.append(" z-index: ", layer.renderer().style().usedZIndex());
 
     logString.append(" (", logReasonsForCompositing(layer), ") ");
 
index 1c537ec..ced7244 100644 (file)
@@ -132,8 +132,8 @@ void RenderLayerModelObject::styleWillChange(StyleDifference diff, const RenderS
             // When a layout hint happens, we do a repaint of the layer, since the layer could end up being destroyed.
             if (hasLayer()) {
                 if (oldStyle->position() != newStyle.position()
-                    || oldStyle->zIndex() != newStyle.zIndex()
-                    || oldStyle->hasAutoZIndex() != newStyle.hasAutoZIndex()
+                    || oldStyle->usedZIndex() != newStyle.usedZIndex()
+                    || oldStyle->hasAutoUsedZIndex() != newStyle.hasAutoUsedZIndex()
                     || !(oldStyle->clip() == newStyle.clip())
                     || oldStyle->hasClip() != newStyle.hasClip()
                     || oldStyle->opacity() != newStyle.opacity()
index 11b719e..2135a52 100644 (file)
@@ -176,8 +176,8 @@ void RenderTreeAsText::writeRenderObject(TextStream& ts, const RenderObject& o,
     if (behavior.contains(RenderAsTextFlag::ShowAddresses))
         ts << " " << static_cast<const void*>(&o);
 
-    if (o.style().zIndex())
-        ts << " zI: " << o.style().zIndex();
+    if (o.style().usedZIndex()) // FIXME: This should use !hasAutoUsedZIndex().
+        ts << " zI: " << o.style().usedZIndex();
 
     if (o.node()) {
         String tagName = getTagName(o.node());
index 9d83ef8..3368ef9 100644 (file)
@@ -982,7 +982,7 @@ static bool rareNonInheritedDataChangeRequiresLayerRepaint(const StyleRareNonInh
 bool RenderStyle::changeRequiresLayerRepaint(const RenderStyle& other, OptionSet<StyleDifferenceContextSensitiveProperty>& changedContextSensitiveProperties) const
 {
     // Style::Resolver has ensured that zIndex is non-auto only if it's applicable.
-    if (m_boxData->zIndex() != other.m_boxData->zIndex() || m_boxData->hasAutoZIndex() != other.m_boxData->hasAutoZIndex())
+    if (m_boxData->usedZIndex() != other.m_boxData->usedZIndex() || m_boxData->hasAutoUsedZIndex() != other.m_boxData->hasAutoUsedZIndex())
         return true;
 
     if (position() != PositionType::Static) {
index 58522bd..c2ec48e 100644 (file)
@@ -1029,10 +1029,31 @@ public:
     PrintColorAdjust printColorAdjust() const { return static_cast<PrintColorAdjust>(m_inheritedFlags.printColorAdjust); }
     void setPrintColorAdjust(PrintColorAdjust value) { m_inheritedFlags.printColorAdjust = static_cast<unsigned>(value); }
 
-    bool hasAutoZIndex() const { return m_boxData->hasAutoZIndex(); }
-    void setHasAutoZIndex() { SET_VAR(m_boxData, m_hasAutoZIndex, true); SET_VAR(m_boxData, m_zIndex, 0); }
-    int zIndex() const { return m_boxData->zIndex(); }
-    void setZIndex(int v) { SET_VAR(m_boxData, m_hasAutoZIndex, false); SET_VAR(m_boxData, m_zIndex, v); }
+    int specifiedZIndex() const { return m_boxData->specifiedZIndex(); }
+    bool hasAutoSpecifiedZIndex() const { return m_boxData->hasAutoSpecifiedZIndex(); }
+    void setSpecifiedZIndex(int v)
+    {
+        SET_VAR(m_boxData, m_hasAutoSpecifiedZIndex, false);
+        SET_VAR(m_boxData, m_specifiedZIndex, v);
+    }
+    void setHasAutoSpecifiedZIndex()
+    {
+        SET_VAR(m_boxData, m_hasAutoSpecifiedZIndex, true);
+        SET_VAR(m_boxData, m_specifiedZIndex, 0);
+    }
+
+    int usedZIndex() const { return m_boxData->usedZIndex(); }
+    bool hasAutoUsedZIndex() const { return m_boxData->hasAutoUsedZIndex(); }
+    void setUsedZIndex(int v)
+    {
+        SET_VAR(m_boxData, m_hasAutoUsedZIndex, false);
+        SET_VAR(m_boxData, m_usedZIndex, v);
+    }
+    void setHasAutoUsedZIndex()
+    {
+        SET_VAR(m_boxData, m_hasAutoUsedZIndex, true);
+        SET_VAR(m_boxData, m_usedZIndex, 0);
+    }
 
     void setHasAutoWidows() { SET_VAR(m_rareInheritedData, hasAutoWidows, true); SET_VAR(m_rareInheritedData, widows, initialWidows()); }
     void setWidows(short w) { SET_VAR(m_rareInheritedData, hasAutoWidows, false); SET_VAR(m_rareInheritedData, widows, w); }
index a8b35e1..b56c864 100644 (file)
@@ -29,7 +29,7 @@ namespace WebCore {
 
 struct SameSizeAsStyleBoxData : public RefCounted<SameSizeAsStyleBoxData> {
     Length length[7];
-    int m_zIndex;
+    int m_zIndex[2];
     uint32_t bitfields;
 };
 
@@ -40,8 +40,10 @@ StyleBoxData::StyleBoxData()
     , m_maxWidth(RenderStyle::initialMaxSize())
     , m_minHeight(RenderStyle::initialMinSize())
     , m_maxHeight(RenderStyle::initialMaxSize())
-    , m_zIndex(0)
-    , m_hasAutoZIndex(true)
+    , m_specifiedZIndex(0)
+    , m_usedZIndex(0)
+    , m_hasAutoSpecifiedZIndex(true)
+    , m_hasAutoUsedZIndex(true)
     , m_boxSizing(static_cast<unsigned>(BoxSizing::ContentBox))
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
     , m_boxDecorationBreak(static_cast<unsigned>(BoxDecorationBreak::Slice))
@@ -58,8 +60,10 @@ inline StyleBoxData::StyleBoxData(const StyleBoxData& o)
     , m_minHeight(o.m_minHeight)
     , m_maxHeight(o.m_maxHeight)
     , m_verticalAlign(o.m_verticalAlign)
-    , m_zIndex(o.m_zIndex)
-    , m_hasAutoZIndex(o.m_hasAutoZIndex)
+    , m_specifiedZIndex(o.m_specifiedZIndex)
+    , m_usedZIndex(o.m_usedZIndex)
+    , m_hasAutoSpecifiedZIndex(o.m_hasAutoSpecifiedZIndex)
+    , m_hasAutoUsedZIndex(o.m_hasAutoUsedZIndex)
     , m_boxSizing(o.m_boxSizing)
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
     , m_boxDecorationBreak(o.m_boxDecorationBreak)
@@ -75,19 +79,21 @@ Ref<StyleBoxData> StyleBoxData::copy() const
 bool StyleBoxData::operator==(const StyleBoxData& o) const
 {
     return m_width == o.m_width
-           && m_height == o.m_height
-           && m_minWidth == o.m_minWidth
-           && m_maxWidth == o.m_maxWidth
-           && m_minHeight == o.m_minHeight
-           && m_maxHeight == o.m_maxHeight
-           && m_verticalAlign == o.m_verticalAlign
-           && m_zIndex == o.m_zIndex
-           && m_hasAutoZIndex == o.m_hasAutoZIndex
-           && m_boxSizing == o.m_boxSizing
+        && m_height == o.m_height
+        && m_minWidth == o.m_minWidth
+        && m_maxWidth == o.m_maxWidth
+        && m_minHeight == o.m_minHeight
+        && m_maxHeight == o.m_maxHeight
+        && m_verticalAlign == o.m_verticalAlign
+        && m_specifiedZIndex == o.m_specifiedZIndex
+        && m_hasAutoSpecifiedZIndex == o.m_hasAutoSpecifiedZIndex
+        && m_usedZIndex == o.m_usedZIndex
+        && m_hasAutoUsedZIndex == o.m_hasAutoUsedZIndex
+        && m_boxSizing == o.m_boxSizing
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
-           && m_boxDecorationBreak == o.m_boxDecorationBreak
+        && m_boxDecorationBreak == o.m_boxDecorationBreak
 #endif
-            ;
+        ;
 }
 
 } // namespace WebCore
index 8917037..9da795e 100644 (file)
@@ -53,9 +53,12 @@ public:
     
     const Length& verticalAlign() const { return m_verticalAlign; }
     
-    int zIndex() const { return m_zIndex; }
-    bool hasAutoZIndex() const { return m_hasAutoZIndex; }
-    
+    int specifiedZIndex() const { return m_specifiedZIndex; }
+    bool hasAutoSpecifiedZIndex() const { return m_hasAutoSpecifiedZIndex; }
+
+    int usedZIndex() const { return m_usedZIndex; }
+    bool hasAutoUsedZIndex() const { return m_hasAutoUsedZIndex; }
+
     BoxSizing boxSizing() const { return static_cast<BoxSizing>(m_boxSizing); }
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
     BoxDecorationBreak boxDecorationBreak() const { return static_cast<BoxDecorationBreak>(m_boxDecorationBreak); }
@@ -78,8 +81,10 @@ private:
 
     Length m_verticalAlign;
 
-    int m_zIndex;
-    unsigned m_hasAutoZIndex : 1;
+    int m_specifiedZIndex;
+    int m_usedZIndex;
+    unsigned m_hasAutoSpecifiedZIndex : 1;
+    unsigned m_hasAutoUsedZIndex : 1;
     unsigned m_boxSizing : 1; // BoxSizing
 #if ENABLE(CSS_BOX_DECORATION_BREAK)
     unsigned m_boxDecorationBreak : 1; // BoxDecorationBreak
index aa676e5..c525cbd 100644 (file)
@@ -294,13 +294,15 @@ void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearance
     }
 
     // Make sure our z-index value is only applied if the object is positioned.
-    if (style.position() == PositionType::Static && !m_parentBoxStyle.isDisplayFlexibleOrGridBox())
-        style.setHasAutoZIndex();
+    if (style.hasAutoSpecifiedZIndex() || (style.position() == PositionType::Static && !m_parentBoxStyle.isDisplayFlexibleOrGridBox()))
+        style.setHasAutoUsedZIndex();
+    else
+        style.setUsedZIndex(style.specifiedZIndex());
 
     // Auto z-index becomes 0 for the root element and transparent objects. This prevents
     // cases where objects that should be blended as a single unit end up with a non-transparent
     // object wedged in between them. Auto z-index also becomes 0 for objects that specify transforms/masks/reflections.
-    if (style.hasAutoZIndex()) {
+    if (style.hasAutoUsedZIndex()) {
         if ((m_element && m_document.documentElement() == m_element)
             || style.opacity() < 1.0f
             || style.hasTransformRelatedProperty()
@@ -316,7 +318,7 @@ void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearance
             || style.position() == PositionType::Sticky
             || style.position() == PositionType::Fixed
             || style.willChangeCreatesStackingContext())
-            style.setZIndex(0);
+            style.setUsedZIndex(0);
     }
 
     if (m_element) {
@@ -385,8 +387,8 @@ void Adjuster::adjust(RenderStyle& style, const RenderStyle* userAgentAppearance
 
 #if ENABLE(OVERFLOW_SCROLLING_TOUCH)
     // Touch overflow scrolling creates a stacking context.
-    if (style.hasAutoZIndex() && style.useTouchOverflowScrolling() && (isScrollableOverflow(style.overflowX()) || isScrollableOverflow(style.overflowY())))
-        style.setZIndex(0);
+    if (style.hasAutoUsedZIndex() && style.useTouchOverflowScrolling() && (isScrollableOverflow(style.overflowX()) || isScrollableOverflow(style.overflowY())))
+        style.setUsedZIndex(0);
 #endif
 
     // Cull out any useless layers and also repeat patterns into additional layers.