Bug 1457102: Avoid all the work if the compat mode hasn't actually changed. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Thu, 26 Apr 2018 16:07:30 +0200
changeset 788397 d3f7be9324545032273a80372a7f9a813fa331eb
parent 788396 bdfbe182c6f5f0a28e359a0799fab71cd681def9
child 788398 c073567bd8dd67289d54fad1925902718b9feece
push id107983
push userbmo:emilio@crisal.io
push dateThu, 26 Apr 2018 14:14:28 +0000
reviewersheycam
bugs1457102
milestone61.0a1
Bug 1457102: Avoid all the work if the compat mode hasn't actually changed. r?heycam In this case the stylist is marked dirty because a compat mode change. The change just doesn't exist (NavQuirks -> NavQuirks). So avoid the work in the first place. MozReview-Commit-ID: lchKJECNkO
dom/html/nsHTMLDocument.cpp
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -848,16 +848,19 @@ nsHTMLDocument::EndLoad()
 }
 
 void
 nsHTMLDocument::SetCompatibilityMode(nsCompatibility aMode)
 {
   NS_ASSERTION(IsHTMLDocument() || aMode == eCompatibility_FullStandards,
                "Bad compat mode for XHTML document!");
 
+  if (mCompatMode == aMode) {
+    return;
+  }
   mCompatMode = aMode;
   CSSLoader()->SetCompatibilityMode(mCompatMode);
   RefPtr<nsPresContext> pc = GetPresContext();
   if (pc) {
     pc->CompatibilityModeChanged();
   }
 }