Bug 1520138 - Fix border-style conflict resolution in border-collapsed tables. r=dholbert
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 16 Jan 2019 19:40:08 +0000
changeset 514128 9b2f212b3947b9511b0b6bc2b0256d5239a7d045
parent 514127 0b3a6c7175ca027b27db5943f178f36c2c1e0672
child 514129 d0e6b3cbbd16bce6ab704eb708464ab238d8ded3
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1520138, 1509717
milestone66.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 1520138 - Fix border-style conflict resolution in border-collapsed tables. r=dholbert Bug 1509717 removed Gecko's definition of StyleBorderStyle to use the Rust one. The Rust version was ordered in a different way, and the table code relied on the order in order to build the mapping for border conflict resolution. Simplify this mapping now that border constants are ordered in terms of priority, see the comment on top of `enum BorderStyle`. Differential Revision: https://phabricator.services.mozilla.com/D16565
layout/tables/nsTableFrame.cpp
testing/web-platform/tests/css/css-tables/border-conflict-resolution-ref.html
testing/web-platform/tests/css/css-tables/border-conflict-resolution.html
--- a/layout/tables/nsTableFrame.cpp
+++ b/layout/tables/nsTableFrame.cpp
@@ -4668,32 +4668,16 @@ void BCMapCellIterator::PeekBEnd(BCMapCe
   if (cellData->IsColSpan()) {
     aColIndex -= cellData->GetColSpanOffset();
     cellData =
         static_cast<BCCellData*>(cellMap->GetDataAt(rgRowIndex, aColIndex));
   }
   aAjaInfo.SetInfo(nextRow, aColIndex, cellData, this, cellMap);
 }
 
-// Assign priorities to border styles. For example,
-// styleToPriority(StyleBorderStyle::Solid) will return the priority of
-// StyleBorderStyle::Solid.
-static uint8_t styleToPriority[13] = {0,   // StyleBorderStyle::None
-                                      2,   // StyleBorderStyle::Groove
-                                      4,   // StyleBorderStyle::Ridge
-                                      5,   // StyleBorderStyle::Dotted
-                                      6,   // StyleBorderStyle::Dashed
-                                      7,   // StyleBorderStyle::Solid
-                                      8,   // StyleBorderStyle::Double
-                                      1,   // StyleBorderStyle::Inset
-                                      3,   // StyleBorderStyle::Outset
-                                      9};  // StyleBorderStyle::Hidden
-// priority rules follow CSS 2.1 spec
-// 'hidden', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove',
-// and the lowest: 'inset'. none is even weaker
 #define CELL_CORNER true
 
 /** return the border style, border color and optionally the width in
  * pixel for a given frame and side
  * @param aFrame           - query the info for this frame
  * @param aTableWM         - the writing-mode of the frame
  * @param aSide            - the side of the frame
  * @param aStyle           - the border style
@@ -4806,21 +4790,20 @@ static const BCCellBorder& CompareBorder
 
   if (StyleBorderStyle::Hidden == aBorder1.style) {
     firstDominates = (aIsCorner) ? false : true;
   } else if (StyleBorderStyle::Hidden == aBorder2.style) {
     firstDominates = (aIsCorner) ? true : false;
   } else if (aBorder1.width < aBorder2.width) {
     firstDominates = false;
   } else if (aBorder1.width == aBorder2.width) {
-    if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] <
-        styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
+    if (static_cast<uint8_t>(aBorder1.style) <
+        static_cast<uint8_t>(aBorder2.style)) {
       firstDominates = false;
-    } else if (styleToPriority[static_cast<uint8_t>(aBorder1.style)] ==
-               styleToPriority[static_cast<uint8_t>(aBorder2.style)]) {
+    } else if (aBorder1.style == aBorder2.style) {
       if (aBorder1.owner == aBorder2.owner) {
         firstDominates = !aSecondIsInlineDir;
       } else if (aBorder1.owner < aBorder2.owner) {
         firstDominates = false;
       }
     }
   }
 
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-tables/border-conflict-resolution-ref.html
@@ -0,0 +1,25 @@
+<!doctype html>
+<title>CSS Test Reference</title>
+<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
+<link rel="author" href="https://mozilla.org" title="Mozilla">
+<style>
+  table {
+    font-size: 2em;
+    border-collapse: collapse;
+    border: 5px solid green;
+  }
+</style>
+
+<p>You should see no non-solid borders and no red.</p>
+
+<table>
+  <tr>
+    <td colspan="4" style="border: 5px solid purple;">hello</td>
+  </tr>
+  <tr>
+    <td style="border-right: 5px solid blue; border-bottom: 9px hidden red;">one</td>
+    <td style="border-right: 5px solid blue;">two</td>
+    <td>three</td>
+    <td style="border-left: 5px solid blue">four</td>
+  </tr>
+</table>
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/tests/css/css-tables/border-conflict-resolution.html
@@ -0,0 +1,28 @@
+<!doctype html>
+<title>CSS Test: Table border resolution rules</title>
+<link rel="author" href="mailto:emilio@crisal.io" title="Emilio Cobos Álvarez">
+<link rel="author" href="https://mozilla.org" title="Mozilla">
+<link rel="help" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1520138">
+<link rel="help" href="https://drafts.csswg.org/css2/tables.html#border-conflict-resolution">
+<link rel="match" href="border-conflict-resolution-ref.html">
+<style>
+  table {
+    font-size: 2em;
+    border-collapse: collapse;
+    border: 5px solid green;
+  }
+</style>
+
+<p>You should see no non-solid borders and no red.</p>
+
+<table>
+  <tr>
+    <td colspan="4" style="border: 5px solid purple;">hello</td>
+  </tr>
+  <tr>
+    <td style="border-top: 5px solid blue; border-right: 5px solid blue; border-bottom: 9px hidden red; border-left: 9px none;">one</td>
+    <td style="border-top: 5px dashed blue; border-right: 5px solid blue; border-bottom: 5px outset red;">two</td>
+    <td style="border-top: 5px ridge blue; border-right: 5px ridge red; border-bottom: 5px inset red;">three</td>
+    <td style="border-left: 5px solid blue; border-bottom: 5px dotted red;">four</td>
+  </tr>
+</table>