Bug 1375332 - stylo: force restyle descendants after character set is updated. draft
authorJeremy Chen <jeremychen@mozilla.com>
Mon, 21 Aug 2017 18:58:53 +0800
changeset 651279 c9e9b1fd707a2041cf1ed242c356c237d81591a4
parent 651278 03b2f213e83ce0103d04eba05fbdeeb0297e7d58
child 727643 5b2304f6b8bff19331af281bb8b65dadea0e5efa
push id75653
push userbmo:jeremychen@mozilla.com
push dateWed, 23 Aug 2017 11:55:04 +0000
bugs1375332
milestone57.0a1
Bug 1375332 - stylo: force restyle descendants after character set is updated. In Stylo, if there exists one or more <script> elements in the document, frame construction might happen earlier than the UpdateCharSet(), which leads to an incorrect style data for the frames. So, we force a restyle in this situation, to make the style data of all the descendants up-to-date. MozReview-Commit-ID: BwCwp6Ndvmc
layout/base/nsPresContext.cpp
layout/base/tests/mochitest.ini
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1076,17 +1076,22 @@ nsPresContext::DetachShell()
   }
 }
 
 void
 nsPresContext::DoChangeCharSet(NotNull<const Encoding*> aCharSet)
 {
   UpdateCharSet(aCharSet);
   mDeviceContext->FlushFontCache();
-  RebuildAllStyleData(NS_STYLE_HINT_REFLOW, nsRestyleHint(0));
+  // In Stylo, if a document contains one or more <script> elements, frame
+  // construction might happen earlier than the UpdateCharSet(), so we need to
+  // restyle descendants to make their style data up-to-date.
+  RebuildAllStyleData(NS_STYLE_HINT_REFLOW,
+                      mDocument->IsStyledByServo()
+                      ? eRestyle_ForceDescendants : nsRestyleHint(0));
 }
 
 void
 nsPresContext::UpdateCharSet(NotNull<const Encoding*> aCharSet)
 {
   mLanguage = mLangService->LookupCharSet(aCharSet);
   // this will be a language group (or script) code rather than a true language code
 
--- a/layout/base/tests/mochitest.ini
+++ b/layout/base/tests/mochitest.ini
@@ -72,17 +72,16 @@ skip-if = toolkit == 'android' # Require
 [test_bug646757.html]
 [test_bug667512.html]
 [test_bug677878.html]
 [test_bug687297.html]
 support-files =
   bug687297_a.html
   bug687297_b.html
   bug687297_c.html
-fail-if = stylo # bug 1375332
 [test_bug696020.html]
 [test_bug718809.html]
 [test_bug725426.html]
 [test_bug731777.html]
 [test_bug749186.html]
 [test_bug761572.html]
 [test_bug770106.html]
 [test_bug842853.html]