Bug 1511570 - Make content-language invalidate style data. r=jfkthame
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 04 Dec 2018 18:44:40 +0000
changeset 508722 ddd8bdd2f05e27159720709f8dd40a7d9dd006f6
parent 508708 5ca5e911d32f34d813293a6e23f64039086d5ce1
child 508723 5c0bf8772040e63d15ef4fd0abf38537e55aa17e
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)
reviewersjfkthame
bugs1511570
milestone65.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
Bug 1511570 - Make content-language invalidate style data. r=jfkthame This is needed because content-language can affect the default computed values for a given document. Differential Revision: https://phabricator.services.mozilla.com/D13636
dom/base/nsDocument.cpp
layout/base/nsPresContext.cpp
layout/base/nsPresContext.h
layout/reftests/bugs/1511570-ref.html
layout/reftests/bugs/1511570.html
layout/reftests/bugs/reftest.list
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -3574,16 +3574,19 @@ void nsIDocument::SetHeaderData(nsAtom* 
     if (!aData.IsEmpty() && !found) {
       // didn't find, append
       *lastPtr = new nsDocHeaderData(aHeaderField, aData);
     }
   }
 
   if (aHeaderField == nsGkAtoms::headerContentLanguage) {
     CopyUTF16toUTF8(aData, mContentLanguage);
+    if (auto* presContext = GetPresContext()) {
+      presContext->ContentLanguageChanged();
+    }
   }
 
   if (aHeaderField == nsGkAtoms::headerDefaultStyle) {
     SetPreferredStyleSheetSet(aData);
   }
 
   if (aHeaderField == nsGkAtoms::refresh) {
     // We get into this code before we have a script global yet, so get to
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1715,16 +1715,21 @@ void nsPresContext::CacheAllLangs() {
     GetDefaultFont(kPresContext_DefaultVariableFont_ID, nsGkAtoms::Unicode);
     for (auto iter = mLanguagesUsed.Iter(); !iter.Done(); iter.Next()) {
       GetDefaultFont(kPresContext_DefaultVariableFont_ID, iter.Get()->GetKey());
     }
   }
   mFontGroupCacheDirty = false;
 }
 
+void nsPresContext::ContentLanguageChanged() {
+  mFontGroupCacheDirty = true;
+  PostRebuildAllStyleDataEvent(nsChangeHint(0), eRestyle_ForceDescendants);
+}
+
 void nsPresContext::RebuildAllStyleData(nsChangeHint aExtraHint,
                                         nsRestyleHint aRestyleHint) {
   if (!mShell) {
     // We must have been torn down. Nothing to do here.
     return;
   }
 
   // FIXME(emilio): Why is it safe to reset mUsesRootEMUnits / mUsesEXChUnits
--- a/layout/base/nsPresContext.h
+++ b/layout/base/nsPresContext.h
@@ -268,16 +268,18 @@ class nsPresContext : public nsISupports
   void RebuildAllStyleData(nsChangeHint aExtraHint, nsRestyleHint aRestyleHint);
   /**
    * Just like RebuildAllStyleData, except (1) asynchronous and (2) it
    * doesn't rebuild the user font set.
    */
   void PostRebuildAllStyleDataEvent(nsChangeHint aExtraHint,
                                     nsRestyleHint aRestyleHint);
 
+  void ContentLanguageChanged();
+
   /**
    * Handle changes in the values of media features (used in media
    * queries).
    *
    * There are three sensible values to use for aRestyleHint:
    *  * nsRestyleHint(0) to rebuild style data, with rerunning of
    *    selector matching, only if media features have changed
    *  * eRestyle_ForceDescendants to force rebuilding of style data (but
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1511570-ref.html
@@ -0,0 +1,3 @@
+<!doctype html>
+<meta http-equiv="Content-Language" content="zh-CN">
+<p style="font-family: sans-serif">Some test in the default font for zh-CN.
new file mode 100644
--- /dev/null
+++ b/layout/reftests/bugs/1511570.html
@@ -0,0 +1,2 @@
+<!doctype html>
+<p lang="zh-CN" style="font-family: sans-serif">Some test in the default font for zh-CN.
--- a/layout/reftests/bugs/reftest.list
+++ b/layout/reftests/bugs/reftest.list
@@ -2089,8 +2089,9 @@ fuzzy(0-1,0-625) == 1466638-1.html 14666
 == bug1472465-1.html bug1472465-1-ref.html
 == 1475971-1.html 1475971-1-ref.html
 == 1483649-1.xul 1483649-1-ref.xul
 test-pref(layout.css.contain.enabled,true) == 1483946.html 1483946-ref.html
 test-pref(layout.css.visited_links_enabled,false) == 1488155.html 1488155-ref.html
 == 1492660-1.html 1492660-1-ref.html
 pref(layout.css.supports-selector.enabled,true) == 1499386.html 1499386-ref.html
 pref(layout.css.supports-selector.enabled,false) != 1499386.html 1499386-ref.html
+== 1511570.html 1511570-ref.html