Bug 1179288. Make position:fixed induce a stacking context. r=heycam
authorRobert O'Callahan <robert@ocallahan.org>
Mon, 17 Aug 2015 11:02:54 +1200
changeset 258118 89a5b5c8ce17eaefdea8178171567ee309bbf447
parent 258117 4b1fccda7a74443b3093efe8d224dad547f0f36b
child 258119 0e3dbc9c729c2f71a92d3b45aa521fe7c0576eae
push id63824
push userrocallahan@mozilla.com
push dateTue, 18 Aug 2015 05:58:49 +0000
treeherdermozilla-inbound@89a5b5c8ce17 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1179288
milestone43.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1179288. Make position:fixed induce a stacking context. r=heycam
layout/generic/nsFrame.cpp
layout/reftests/bugs/1179288-1-ref.html
layout/reftests/bugs/1179288-1.html
layout/reftests/bugs/reftest.list
layout/style/nsCSSPropList.h
layout/style/nsStyleStruct.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2363,17 +2363,17 @@ nsIFrame::BuildDisplayListForChild(nsDis
     // but the spec says it acts like the rest of these
     || disp->mChildPerspective.GetUnit() == eStyleUnit_Coord
     || disp->mMixBlendMode != NS_STYLE_BLEND_NORMAL
     || nsSVGIntegrationUtils::UsingEffectsForFrame(child)
     || (child->GetStateBits() & NS_FRAME_HAS_VR_CONTENT);
 
   bool isPositioned = disp->IsAbsPosContainingBlock(child);
   bool isStackingContext =
-    (isPositioned && (disp->mPosition == NS_STYLE_POSITION_STICKY ||
+    (isPositioned && (disp->IsPositionForcingStackingContext() ||
                       pos->mZIndex.GetUnit() == eStyleUnit_Integer)) ||
      (disp->mWillChangeBitField & NS_STYLE_WILL_CHANGE_STACKING_CONTEXT) ||
      disp->mIsolation != NS_STYLE_ISOLATION_AUTO ||
      isVisuallyAtomic || (aFlags & DISPLAY_CHILD_FORCE_STACKING_CONTEXT);
 
   if (isVisuallyAtomic || isPositioned || (!isSVG && disp->IsFloating(child)) ||
       ((disp->mClipFlags & NS_STYLE_CLIP_RECT) &&
        IsSVGContentWithCSSClip(child)) ||
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1179288-1-ref.html
@@ -0,0 +1,3 @@
+<!DOCTYPE HTML>
+<body>
+<div style="position:absolute; left:0; top:0; width:100px; height:100px; background:lime"></div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1179288-1.html
@@ -0,0 +1,6 @@
+<!DOCTYPE HTML>
+<body>
+<div style="position:fixed; left:0; top:0">
+  <div style="position:absolute; z-index:2; left:0; top:0; width:100px; height:100px; background:red"></div>
+</div>
+<div style="position:absolute; z-index:1; left:0; top:0; width:100px; height:100px; background:lime"></div>
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -1924,11 +1924,12 @@ skip-if(!B2G) fuzzy-if(B2G,102,577) == 1
 skip-if(!B2G) fuzzy-if(B2G,101,887) == 1133905-6-vh-rtl.html 1133905-ref-vh-rtl.html
 skip-if(B2G||Mulet) == 1150021-1.xul 1150021-1-ref.xul
 == 1151145-1.html 1151145-1-ref.html
 == 1151306-1.html 1151306-1-ref.html
 == 1153845-1.html 1153845-1-ref.html
 == 1155828-1.html 1155828-1-ref.html
 == 1156129-1.html 1156129-1-ref.html
 == 1169331-1.html 1169331-1-ref.html
+fuzzy(1,74) fuzzy-if(gtkWidget,6,79) == 1174332-1.html 1174332-1-ref.html
 == 1179078-1.html 1179078-1-ref.html
-fuzzy(1,74) fuzzy-if(gtkWidget,6,79) == 1174332-1.html 1174332-1-ref.html
+== 1179288-1.html 1179288-1-ref.html
 == 1190635-1.html 1190635-1-ref.html
--- a/layout/style/nsCSSPropList.h
+++ b/layout/style/nsCSSPropList.h
@@ -2994,17 +2994,17 @@ CSS_PROP_VISIBILITY(
     kPointerEventsKTable,
     offsetof(nsStyleVisibility, mPointerEvents),
     eStyleAnimType_EnumU8)
 CSS_PROP_DISPLAY(
     position,
     position,
     Position,
     CSS_PROPERTY_PARSE_VALUE |
-        // For position: sticky
+        // For position: sticky/fixed
         CSS_PROPERTY_CREATES_STACKING_CONTEXT,
     "",
     VARIANT_HK,
     kPositionKTable,
     CSS_PROP_NO_OFFSET,
     eStyleAnimType_None)
 CSS_PROP_QUOTES(
     quotes,
--- a/layout/style/nsStyleStruct.h
+++ b/layout/style/nsStyleStruct.h
@@ -2218,16 +2218,20 @@ struct nsStyleDisplay {
     return NS_STYLE_POSITION_ABSOLUTE == mPosition ||
            NS_STYLE_POSITION_FIXED == mPosition;
   }
 
   bool IsRelativelyPositionedStyle() const {
     return NS_STYLE_POSITION_RELATIVE == mPosition ||
            NS_STYLE_POSITION_STICKY == mPosition;
   }
+  bool IsPositionForcingStackingContext() const {
+    return NS_STYLE_POSITION_STICKY == mPosition ||
+           NS_STYLE_POSITION_FIXED == mPosition;
+  }
 
   static bool IsRubyDisplayType(uint8_t aDisplay) {
     return NS_STYLE_DISPLAY_RUBY == aDisplay ||
            NS_STYLE_DISPLAY_RUBY_BASE == aDisplay ||
            NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER == aDisplay ||
            NS_STYLE_DISPLAY_RUBY_TEXT == aDisplay ||
            NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER == aDisplay;
   }