Bug 1319424 - Ensure to setup line breaker before using it. r=jfkthame
authorXidorn Quan <me@upsuper.org>
Fri, 25 Nov 2016 16:19:32 +1100
changeset 325306 d412e21e3bba0a5de670cca8a4ef4ecd49b2a4b4
parent 325286 3ec83fde43f2e1ba1dc583df0c722033c63ab7b7
child 325307 6582ffa93666bb912e6d7e8368924830d48195f6
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersjfkthame
bugs1319424
milestone53.0a1
Bug 1319424 - Ensure to setup line breaker before using it. r=jfkthame MozReview-Commit-ID: EOuPLXTIBcZ
layout/generic/nsTextFrame.cpp
layout/reftests/text/reftest.list
layout/reftests/text/wordbreak-dynamic-1-ref.html
layout/reftests/text/wordbreak-dynamic-1.html
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -2059,29 +2059,16 @@ BuildTextRunsScanner::BuildTextRunForFra
 
   uint32_t nextBreakIndex = 0;
   nsTextFrame* nextBreakBeforeFrame = GetNextBreakBeforeFrame(&nextBreakIndex);
   bool isSVG = mLineContainer->IsSVGText();
   bool enabledJustification =
     (mLineContainer->StyleText()->mTextAlign == NS_STYLE_TEXT_ALIGN_JUSTIFY ||
      mLineContainer->StyleText()->mTextAlignLast == NS_STYLE_TEXT_ALIGN_JUSTIFY);
 
-  // for word-break style
-  switch (mLineContainer->StyleText()->mWordBreak) {
-    case NS_STYLE_WORDBREAK_BREAK_ALL:
-      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_BreakAll);
-      break;
-    case NS_STYLE_WORDBREAK_KEEP_ALL:
-      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_KeepAll);
-      break;
-    default:
-      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_Normal);
-      break;
-  }
-
   const nsStyleText* textStyle = nullptr;
   const nsStyleFont* fontStyle = nullptr;
   nsStyleContext* lastStyleContext = nullptr;
   for (uint32_t i = 0; i < mMappedFlows.Length(); ++i) {
     MappedFlow* mappedFlow = &mMappedFlows[i];
     nsTextFrame* f = mappedFlow->mStartFrame;
 
     lastStyleContext = f->StyleContext();
@@ -2550,16 +2537,29 @@ HasCompressedLeadingWhitespace(nsTextFra
   }
   return false;
 }
 
 void
 BuildTextRunsScanner::SetupBreakSinksForTextRun(gfxTextRun* aTextRun,
                                                 const void* aTextPtr)
 {
+  // for word-break style
+  switch (mLineContainer->StyleText()->mWordBreak) {
+    case NS_STYLE_WORDBREAK_BREAK_ALL:
+      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_BreakAll);
+      break;
+    case NS_STYLE_WORDBREAK_KEEP_ALL:
+      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_KeepAll);
+      break;
+    default:
+      mLineBreaker.SetWordBreak(nsILineBreaker::kWordBreak_Normal);
+      break;
+  }
+
   // textruns have uniform language
   const nsStyleFont *styleFont = mMappedFlows[0].mStartFrame->StyleFont();
   // We should only use a language for hyphenation if it was specified
   // explicitly.
   nsIAtom* hyphenationLanguage =
     styleFont->mExplicitLanguage ? styleFont->mLanguage.get() : nullptr;
   // We keep this pointed at the skip-chars data for the current mappedFlow.
   // This lets us cheaply check whether the flow has compressed initial
--- a/layout/reftests/text/reftest.list
+++ b/layout/reftests/text/reftest.list
@@ -117,16 +117,17 @@ HTTP(..) == variation-selector-unsupport
 skip-if(Android) == wordbreak-4a.html wordbreak-4a-ref.html
 == wordbreak-4b.html wordbreak-4b-ref.html
 == wordbreak-5.html wordbreak-5-ref.html
 fails-if(/^Windows\x20NT\x2010\.0/.test(http.oscpu)) == wordbreak-6.html wordbreak-6-ref.html # Bug 1258239
 HTTP(..) == wordbreak-7a.html wordbreak-7a-ref.html
 fails HTTP(..) == wordbreak-7b.html wordbreak-7b-ref.html # bug 479829
 == wordbreak-8.html wordbreak-8-ref.html
 pref(gfx.font_rendering.graphite.enabled,true) HTTP(..) == wordbreak-9.html wordbreak-9-ref.html
+== wordbreak-dynamic-1.html wordbreak-dynamic-1-ref.html
 == wordwrap-01.html wordwrap-01-ref.html
 HTTP(..) == wordwrap-02.html wordwrap-02-ref.html
 fuzzy-if(gtkWidget,1,177) fuzzy-if(skiaContent,1,50) HTTP(..) == wordwrap-03.html wordwrap-03-ref.html # Fuzzy on Linux because the native textbox gradient is painted in a slightly different position depending on the invalid area.
 == wordwrap-04.html wordwrap-04-ref.html
 == overflowwrap-04.html wordwrap-04-ref.html
 == wordwrap-05.html wordwrap-05-ref.html
 == overflowwrap-05.html wordwrap-05-ref.html
 == wordwrap-06.html wordwrap-06-ref.html
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/wordbreak-dynamic-1-ref.html
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="UTF-8">
+  <title>Reference - word-break: break-all with dynamic change</title>
+  <style>
+    div {
+      font-family: monospace;
+      width: 3ch;
+      background: pink;
+      word-break: break-all;
+    }
+  </style>
+</head>
+<body>
+  <div>a bcdef</div>
+</body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/text/wordbreak-dynamic-1.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+  <meta charset="UTF-8">
+  <title>Test - word-break: break-all with dynamic change</title>
+  <style>
+    div {
+      font-family: monospace;
+      width: 3ch;
+      background: pink;
+      word-break: break-all;
+    }
+  </style>
+</head>
+<body>
+  <div>a bcdef<div></div></div>
+  <script>
+    document.addEventListener("DOMContentLoaded", function() {
+      document.body.offsetHeight;
+      document.querySelector('div > div').style.display = 'none';
+      document.documentElement.classList.remove('reftest-wait');
+    });
+  </script>
+</body>
+</html>