Bug 1463940 - Invalidate display items when we add a caption to a table, since it can change the ordering of the content. r?mstange draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 24 May 2018 16:54:50 +1200
changeset 799187 46cc736b94d83781e7c41bc92324777e6a0e4422
parent 799120 47e81ea1ef10189ef210867934bf36e14cf223dc
child 799635 75fd91bfeaeeef136fefc23b661f87b5ee2bd0c1
push id110957
push usermwoodrow@mozilla.com
push dateThu, 24 May 2018 04:55:11 +0000
reviewersmstange
bugs1463940
milestone62.0a1
Bug 1463940 - Invalidate display items when we add a caption to a table, since it can change the ordering of the content. r?mstange MozReview-Commit-ID: HQewY2vNEJm
layout/base/crashtests/1463940.html
layout/base/crashtests/crashtests.list
layout/tables/nsTableWrapperFrame.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1463940.html
@@ -0,0 +1,24 @@
+<style>
+#c {
+clip-path: url(undefined);
+}
+.cl {
+opacity: 0.29556127;
+}
+</style>
+<script>
+function eh1() {
+  a.createCaption();
+  b.vAlign = "top";
+}
+function eh2() {
+  c.deleteCell(0);
+  setTimeout(eh1, 0);
+}
+</script>
+<body onload="eh2()">
+<table id="a">
+<tr id="c">
+<th>
+<th id="b">
+<colgroup class="cl">
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -528,8 +528,9 @@ load 1443027-1.html
 load 1448841-1.html
 load 1452839.html
 load 1453702.html
 load 1453342.html
 load 1453196.html
 pref(dom.webcomponents.shadowdom.enabled,true) load 1414303.html
 load 1461812.html
 load 1462412.html
+load 1463940.html
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -118,16 +118,20 @@ nsTableWrapperFrame::AppendFrames(ChildL
              aFrameList.FirstChild()->IsTableCaption(),
              "appending non-caption frame to captionList");
   mCaptionFrames.AppendFrames(this, aFrameList);
 
   // Reflow the new caption frame. It's already marked dirty, so
   // just tell the pres shell.
   PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                                 NS_FRAME_HAS_DIRTY_CHILDREN);
+  // The presence of caption frames makes us sort our display
+  // list differently, so mark us as changed for the new
+  // ordering.
+  MarkNeedsDisplayItemRebuild();
 }
 
 void
 nsTableWrapperFrame::InsertFrames(ChildListID     aListID,
                                   nsIFrame*       aPrevFrame,
                                   nsFrameList&    aFrameList)
 {
   MOZ_ASSERT(kCaptionList == aListID, "unexpected child list");
@@ -137,16 +141,17 @@ nsTableWrapperFrame::InsertFrames(ChildL
   MOZ_ASSERT(!aPrevFrame || aPrevFrame->GetParent() == this,
              "inserting after sibling frame with different parent");
   mCaptionFrames.InsertFrames(nullptr, aPrevFrame, aFrameList);
 
   // Reflow the new caption frame. It's already marked dirty, so
   // just tell the pres shell.
   PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                                 NS_FRAME_HAS_DIRTY_CHILDREN);
+  MarkNeedsDisplayItemRebuild();
 }
 
 void
 nsTableWrapperFrame::RemoveFrame(ChildListID  aListID,
                                  nsIFrame*    aOldFrame)
 {
   // We only have two child frames: the inner table and one caption frame.
   // The inner frame can't be removed so this should be the caption
@@ -158,16 +163,17 @@ nsTableWrapperFrame::RemoveFrame(ChildLi
     InnerTableFrame()->AddStateBits(NS_FRAME_IS_DIRTY);
   }
 
   // Remove the frame and destroy it
   mCaptionFrames.DestroyFrame(aOldFrame);
 
   PresShell()->FrameNeedsReflow(this, nsIPresShell::eTreeChange,
                                 NS_FRAME_HAS_DIRTY_CHILDREN);
+  MarkNeedsDisplayItemRebuild();
 }
 
 void
 nsTableWrapperFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                       const nsDisplayListSet& aLists)
 {
   // No border, background or outline are painted because they all belong
   // to the inner table.