Bug 1482778 - Include captions within table outlines. r=dbaron
authorCameron McCormack <cam@mcc.id.au>
Sun, 22 Sep 2019 23:42:04 +0000
changeset 494457 8d46f84b818dce78694859a991f328f2960cdc4e
parent 494456 88f20e24fa39cd939b5bf6003ec43014f722f8b7
child 494458 cb54e53665dec89e689176aa5100120747ba2408
push id36607
push usermalexandru@mozilla.com
push dateMon, 23 Sep 2019 09:48:00 +0000
treeherdermozilla-central@07eb2cc7e1c3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1482778
milestone71.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 1482778 - Include captions within table outlines. r=dbaron Differential Revision: https://phabricator.services.mozilla.com/D45802
layout/generic/nsFrame.cpp
layout/reftests/outline/outline-table-caption-invisible.html
layout/reftests/outline/outline-table-caption-ref.html
layout/reftests/outline/outline-table-caption.html
layout/reftests/outline/reftest.list
layout/style/res/ua.css
layout/tables/nsTableWrapperFrame.cpp
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -2405,16 +2405,21 @@ void nsFrame::DisplayOutlineUnconditiona
   // ignored, except when explicitly specified by this specification."
   // CSS outlines fall into this category, so we skip them on these boxes.
   MOZ_ASSERT(!IsTableColGroupFrame() && !IsTableColFrame());
 
   if (!StyleOutline()->ShouldPaintOutline()) {
     return;
   }
 
+  // Outlines are painted by the table wrapper frame.
+  if (IsTableFrame()) {
+    return;
+  }
+
   if (HasAnyStateBits(NS_FRAME_PART_OF_IBSPLIT) &&
       GetScrollableOverflowRect().IsEmpty()) {
     // Skip parts of IB-splits with an empty overflow rect, see bug 434301.
     // We may still want to fix some of the overflow area calculations over in
     // that bug.
     return;
   }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/outline/outline-table-caption-invisible.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<style>
+table { outline: 1px solid red; visibility: hidden; }
+</style>
+<table>
+  <caption>Caption</caption>
+  <tr><td>Cell</td></tr>
+</table>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/outline/outline-table-caption-ref.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+table { outline: 1px solid blue; border-collapse: collapse; }
+.caption, .cell { width: 100px; height: 100px; padding: 0; text-align: left; vertical-align: top; }
+.caption { background-color: yellow; }
+.cell { background-color: lime; }
+</style>
+<table>
+  <tr><td class="caption">Caption</td></tr>
+  <tr><td class="cell">Cell</td></tr>
+</table>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/outline/outline-table-caption.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<style>
+table { outline: 1px solid blue; border-collapse: collapse; }
+.caption, .cell { width: 100px; height: 100px; padding: 0; text-align: left; vertical-align: top; }
+.caption { background-color: yellow; }
+.cell { background-color: lime; }
+</style>
+<table>
+  <caption class="caption">Caption</caption>
+  <tr><td class="cell">Cell</td></tr>
+</table>
--- a/layout/reftests/outline/reftest.list
+++ b/layout/reftests/outline/reftest.list
@@ -8,8 +8,10 @@ fuzzy-if(gtkWidget,0-136,0-120) fuzzy-if
 == outline-overflow-block-float.html outline-overflow-block-ref.html
 == outline-overflow-inlineblock-abspos.html outline-overflow-inlineblock-ref.html
 == outline-overflow-inlineblock-float.html outline-overflow-inlineblock-ref.html
 pref(layout.css.outline-style-auto.enabled,true) skip-if(!gtkWidget&&!winWidget&&!cocoaWidget) == outline-auto-001.html outline-auto-001-ref.html # only works on platforms that supports NS_THEME_FOCUS_OUTLINE
 pref(layout.css.outline-style-auto.enabled,false) == outline-auto-001.html outline-auto-001-solid-ref.html
 == outline-initial-1a.html outline-initial-1-ref.html
 == outline-initial-1b.html outline-initial-1-ref.html
 == outline-on-table.html outline-on-table-ref.html
+== outline-table-caption.html outline-table-caption-ref.html
+== outline-table-caption-invisible.html about:blank
--- a/layout/style/res/ua.css
+++ b/layout/style/res/ua.css
@@ -55,16 +55,17 @@
   /* When the table wrapper is a Flex/Grid item we need these: */
   align-self: inherit;
   justify-self: inherit;
   grid-column-start: inherit;
   grid-column-end: inherit;
   grid-row-start: inherit;
   grid-row-end: inherit;
   order: inherit;
+  outline: inherit;
   column-span: inherit; /* needed if <table> has "column-span:all" */
   contain: inherit; /* needed if table has 'contain:layout' or 'paint' */
 }
 
 *|*::-moz-table-row {
   display: table-row;
 }
 
--- a/layout/tables/nsTableWrapperFrame.cpp
+++ b/layout/tables/nsTableWrapperFrame.cpp
@@ -161,23 +161,24 @@ void nsTableWrapperFrame::RemoveFrame(Ch
 
   PresShell()->FrameNeedsReflow(this, IntrinsicDirty::TreeChange,
                                 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.
+  // No border or background is painted because they belong to the inner table.
+  // The outline belongs to the wrapper frame so it can contain the caption.
 
   // If there's no caption, take a short cut to avoid having to create
   // the special display list set and then sort it.
   if (mCaptionFrames.IsEmpty()) {
     BuildDisplayListForInnerTable(aBuilder, aLists);
+    DisplayOutline(aBuilder, aLists);
     return;
   }
 
   nsDisplayListCollection set(aBuilder);
   BuildDisplayListForInnerTable(aBuilder, set);
 
   nsDisplayListSet captionSet(set, set.BlockBorderBackgrounds());
   BuildDisplayListForChild(aBuilder, mCaptionFrames.FirstChild(), captionSet);
@@ -188,16 +189,18 @@ void nsTableWrapperFrame::BuildDisplayLi
   // 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);
+
+  DisplayOutline(aBuilder, aLists);
 }
 
 void nsTableWrapperFrame::BuildDisplayListForInnerTable(
     nsDisplayListBuilder* aBuilder, const nsDisplayListSet& aLists) {
   // Just paint the regular children, but the children's background is our
   // true background (there should only be one, the real table)
   nsIFrame* kid = mFrames.FirstChild();
   // The children should be in content order