Bug 1520138 - Fix border-style conflict resolution in border-collapsed tables. r=dholbert, a=RyanVM
authorEmilio Cobos Álvarez <emilio@crisal.io>
Wed, 16 Jan 2019 19:40:08 +0000
changeset 509534 01bd5daff7e0667df22541e13dc1c8b125124d66
parent 509533 f69157ba349ee9c70f1a05571541a8011872a126
child 509535 e71504cbe594bbda84395ce67c323adc0b855b23
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, RyanVM
bugs1520138, 1509717
milestone65.0
Bug 1520138 - Fix border-style conflict resolution in border-collapsed tables. r=dholbert, a=RyanVM 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
@@ -4667,32 +4667,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
@@ -4805,21 +4789,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>