Bug695538 - Make sure that trailing spaces don't get dropped by nsCSSFrameConstructor::CreateNeededTablePseudos in certain cases. r=bz
authorKang-Hao (Kenny) Lu <kennyluck@csail.mit.edu>
Thu, 20 Oct 2011 10:09:33 +0200
changeset 80358 95a89a2a8e7a2305b94fc6e0ec73a48fa8997c16
parent 80357 991504bc6f4ff110e1cef6b495a227de98339f5c
child 80359 a99d60858d8645243986ca70fd9a452224645d55
push id434
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 12:10:54 +0000
treeherdermozilla-beta@bddb6ed8dd47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs695538
milestone10.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
Bug695538 - Make sure that trailing spaces don't get dropped by nsCSSFrameConstructor::CreateNeededTablePseudos in certain cases. r=bz
layout/base/nsCSSFrameConstructor.cpp
layout/reftests/table-anonymous-boxes/695538-1-ref.html
layout/reftests/table-anonymous-boxes/695538-1.html
layout/reftests/table-anonymous-boxes/reftest.list
--- a/layout/base/nsCSSFrameConstructor.cpp
+++ b/layout/base/nsCSSFrameConstructor.cpp
@@ -9283,19 +9283,25 @@ nsCSSFrameConstructor::CreateNeededTable
       do {
         /* Walk an iterator past any whitespace that we might be able to drop from the list */
         FCItemIterator spaceEndIter(endIter);
         if (prevParentType != eTypeBlock &&
             !aParentFrame->IsGeneratedContentFrame() &&
             spaceEndIter.item().IsWhitespace(aState)) {
           bool trailingSpaces = spaceEndIter.SkipWhitespace(aState);
 
-          // See whether we can drop the whitespace
-          if (trailingSpaces ||
-              spaceEndIter.item().DesiredParentType() != eTypeBlock) {
+          // We drop the whitespace if these are not trailing spaces and the next item
+          // does not want a block parent (see case 2 above)
+          // if these are trailing spaces and aParentFrame is a tabular container
+          // according to rule 1.3 of CSS 2.1 Sec 17.2.1. (Being a tabular container
+          // pretty much means ourParentType != eTypeBlock besides the eTypeColGroup case,
+          // which won't reach here.)
+          if ((trailingSpaces && ourParentType != eTypeBlock) ||
+              (!trailingSpaces && spaceEndIter.item().DesiredParentType() != 
+               eTypeBlock)) {
             bool updateStart = (iter == endIter);
             endIter.DeleteItemsTo(spaceEndIter);
             NS_ASSERTION(trailingSpaces == endIter.IsDone(), "These should match");
 
             if (updateStart) {
               iter = endIter;
             }
 
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-anonymous-boxes/695538-1-ref.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<style>
+:root {
+     border-collapse: collapse;
+     border-spacing: 1px;
+}
+.cell {
+     display: table-cell;
+     border: solid black;
+}
+.pre {
+     white-space: pre;
+     border: solid blue;
+}
+.table {
+     display: table;
+}
+</style>
+<span class="pre"> <span cless="table"><span class="cell">A</span>
+<span class="cell">B</span></span> </span>
+
new file mode 100644
--- /dev/null
+++ b/layout/reftests/table-anonymous-boxes/695538-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<style>
+:root {
+     border-collapse: collapse;
+     border-spacing: 1px;
+}
+.cell {
+     display: table-cell;
+     border: solid black;
+}
+.pre {
+     white-space: pre;
+     border: solid blue;
+}
+</style>
+<span class="pre"> <span class="cell">A</span> <span class="cell">B</span> </span>
+
--- a/layout/reftests/table-anonymous-boxes/reftest.list
+++ b/layout/reftests/table-anonymous-boxes/reftest.list
@@ -30,16 +30,17 @@
 random-if(d2d) == 394402-1a.html 394402-1-ref.html # bug 586833
 == 394402-1b.html 394402-1-ref.html # bug 586833
 == 398095-1.html 398095-1-ref.html
 == 407115-1.html 407115-1-ref.html
 == 443616-1a.xhtml 443616-1-ref.html
 == 443616-1b.html 443616-1-ref.html
 == 448111-1.html 448111-1-ref.html
 == 490174-1.html 490174-1-ref.html
+== 695538-1.html 695538-1-ref.html
 == infer-first-row.html 3x3-ref.html
 == infer-first-row-and-table.html 3x3-ref.html
 == infer-second-row.html 3x3-ref.html
 == infer-second-row-and-table.html 3x3-ref.html
 == infer-table-around-headers-footers-1.html 3x3-ref.html
 == infer-table-around-headers-footers-2.html 3x3-ref.html
 == infer-table-around-headers-footers-3.html 3x3-ref.html
 == infer-rows-inside-rowgroups.html 3x3-ref.html