Bug 1224669 - Clamp width to be non-negative during intrinsic width calculation. r=dholbert
authorJonathan Kew <jkew@mozilla.com>
Fri, 01 Jan 2016 10:29:27 +0000
changeset 300449 8d8d40c30f5bdc6187d60300b6a3cab4728cd043
parent 300448 68fbc021bdb4b84b84dbf3d7899cde7d165bc07a
child 300450 17576c804d39415c937c6cbeb2136f05d8299963
push id8978
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 14:05:32 +0000
treeherdermozilla-aurora@b9a803752a2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1224669
milestone46.0a1
Bug 1224669 - Clamp width to be non-negative during intrinsic width calculation. r=dholbert
layout/generic/nsTextFrame.cpp
layout/reftests/text/reftest.list
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -7867,30 +7867,35 @@ nsTextFrame::AddInlineMinISizeForFlow(ns
       {
         // we can't break here (and it's not the end of the flow)
         continue;
       }
     }
 
     if (i > wordStart) {
       nscoord width =
-        NSToCoordCeilClamped(textRun->GetAdvanceWidth(wordStart, i - wordStart, &provider));
+        NSToCoordCeilClamped(textRun->GetAdvanceWidth(wordStart, i - wordStart,
+                                                      &provider));
+      width = std::max(0, width);
       aData->currentLine = NSCoordSaturatingAdd(aData->currentLine, width);
       aData->atStartOfLine = false;
 
       if (collapseWhitespace) {
         uint32_t trimStart = GetEndOfTrimmedText(frag, textStyle, wordStart, i, &iter);
         if (trimStart == start) {
           // This is *all* trimmable whitespace, so whatever trailingWhitespace
           // we saw previously is still trailing...
           aData->trailingWhitespace += width;
         } else {
           // Some non-whitespace so the old trailingWhitespace is no longer trailing
-          aData->trailingWhitespace =
-            NSToCoordCeilClamped(textRun->GetAdvanceWidth(trimStart, i - trimStart, &provider));
+          nscoord wsWidth =
+            NSToCoordCeilClamped(textRun->GetAdvanceWidth(trimStart,
+                                                          i - trimStart,
+                                                          &provider));
+          aData->trailingWhitespace = std::max(0, wsWidth);
         }
       } else {
         aData->trailingWhitespace = 0;
       }
     }
 
     if (preformattedTab) {
       PropertyProvider::Spacing spacing;
@@ -8019,29 +8024,34 @@ nsTextFrame::AddInlinePrefISizeForFlow(n
       if (!preformattedNewline && !preformattedTab) {
         // we needn't break here (and it's not the end of the flow)
         continue;
       }
     }
 
     if (i > lineStart) {
       nscoord width =
-        NSToCoordCeilClamped(textRun->GetAdvanceWidth(lineStart, i - lineStart, &provider));
+        NSToCoordCeilClamped(textRun->GetAdvanceWidth(lineStart, i - lineStart,
+                                                      &provider));
+      width = std::max(0, width);
       aData->currentLine = NSCoordSaturatingAdd(aData->currentLine, width);
 
       if (collapseWhitespace) {
         uint32_t trimStart = GetEndOfTrimmedText(frag, textStyle, lineStart, i, &iter);
         if (trimStart == start) {
           // This is *all* trimmable whitespace, so whatever trailingWhitespace
           // we saw previously is still trailing...
           aData->trailingWhitespace += width;
         } else {
           // Some non-whitespace so the old trailingWhitespace is no longer trailing
-          aData->trailingWhitespace =
-            NSToCoordCeilClamped(textRun->GetAdvanceWidth(trimStart, i - trimStart, &provider));
+          nscoord wsWidth =
+            NSToCoordCeilClamped(textRun->GetAdvanceWidth(trimStart,
+                                                          i - trimStart,
+                                                          &provider));
+          aData->trailingWhitespace = std::max(0, wsWidth);
         }
       } else {
         aData->trailingWhitespace = 0;
       }
     }
 
     if (preformattedTab) {
       PropertyProvider::Spacing spacing;
--- a/layout/reftests/text/reftest.list
+++ b/layout/reftests/text/reftest.list
@@ -321,9 +321,9 @@ pref(layout.css.control-characters.visib
 pref(layout.css.control-characters.visible,true) != control-chars-04b.html control-chars-04-notref.html
 pref(layout.css.control-characters.visible,true) != control-chars-04c.html control-chars-04-notref.html
 pref(layout.css.control-characters.visible,true) != control-chars-04d.html control-chars-04-notref.html
 
 # font fallback for <space> when not supported in the primary font family - bug 970891
 HTTP(..) == space-font-1.html space-font-1-ref.html
 
 # handling of highly negative letter-spacing and intrinsic width
-fails == negative-letter-spacing-1.html negative-letter-spacing-1-ref.html
+== negative-letter-spacing-1.html negative-letter-spacing-1-ref.html