Bug 1394226 - Correct z-ordering for some table parts. r=dbaron draft
authorMorris Tseng <mtseng@mozilla.com>
Tue, 29 Aug 2017 16:30:06 +0800
changeset 667456 464063553f86880fa98eba71032848262a9d62df
parent 667303 a0eb21bf55e1c1ae0ba311e6f2273da05c712799
child 667457 17d50d85b7c21d6738b8b29c44bfd7bcd418fa55
push id80712
push userbmo:mtseng@mozilla.com
push dateWed, 20 Sep 2017 03:56:27 +0000
reviewersdbaron
bugs1394226
milestone57.0a1
Bug 1394226 - Correct z-ordering for some table parts. r=dbaron MozReview-Commit-ID: IdLhMGDmQag
layout/tables/nsTableFrame.cpp
layout/tables/nsTableWrapperFrame.cpp
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -1603,16 +1603,18 @@ nsTableFrame::DisplayGenericTablePart(ns
 
     // Paint the inset box-shadows for the table frames
     if (aFrame->StyleEffects()->mBoxShadow) {
       aLists.BorderBackground()->AppendNewToTop(
         new (aBuilder) nsDisplayBoxShadowInner(aBuilder, aFrame));
     }
   }
 
+  aFrame->DisplayOutline(aBuilder, aLists);
+
   aTraversal(aBuilder, aFrame, aLists);
 
   if (isVisible) {
     if (isTable) {
       nsTableFrame* table = static_cast<nsTableFrame*>(aFrame);
       // In the collapsed border model, overlay all collapsed borders.
       if (table->IsBorderCollapse()) {
         if (table->HasBCBorders()) {
@@ -1623,18 +1625,16 @@ nsTableFrame::DisplayGenericTablePart(ns
         const nsStyleBorder* borderStyle = aFrame->StyleBorder();
         if (borderStyle->HasBorder()) {
           aLists.BorderBackground()->AppendNewToTop(
             new (aBuilder) nsDisplayBorder(aBuilder, table));
         }
       }
     }
   }
-
-  aFrame->DisplayOutline(aBuilder, aLists);
 }
 
 // table paint code is concerned primarily with borders and bg color
 // SEC: TODO: adjust the rect for captions
 void
 nsTableFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                const nsDisplayListSet& aLists)
 {
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -182,18 +182,21 @@ nsTableWrapperFrame::BuildDisplayList(ns
 
   nsDisplayListCollection set;
   BuildDisplayListForInnerTable(aBuilder, set);
 
   nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds());
   BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(), captionSet);
 
   // Now we have to sort everything by content order, since the caption
-  // may be somewhere inside the table
-  set.BlockBorderBackgrounds()->SortByContentOrder(GetContent());
+  // may be somewhere inside the table.
+  // We don't sort BlockBorderBackgrounds and BorderBackgrounds because the
+  // display items in those lists should stay out of content order in order to
+  // follow the rules in https://www.w3.org/TR/CSS21/zindex.html#painting-order
+  // and paint the caption background after all of the rest.
   set.Floats()->SortByContentOrder(GetContent());
   set.Content()->SortByContentOrder(GetContent());
   set.PositionedDescendants()->SortByContentOrder(GetContent());
   set.Outlines()->SortByContentOrder(GetContent());
   set.MoveTo(aLists);
 }
 
 void