Bug 1382568 - Avoid trying to resolve styles in an uninitialized presshell in GetInnerText. r=heycam, a=lizzard
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 05 Aug 2017 11:42:08 +0200
changeset 423422 f5864cfeab489250412e0210a7d4724a309f4a6f
parent 423421 524c06e940a4688ef58c2542d430ca03fe842bdc
child 423423 6851090c25c3660929778e3e79b9db87fd3d85c9
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam, lizzard
bugs1382568
milestone56.0
Bug 1382568 - Avoid trying to resolve styles in an uninitialized presshell in GetInnerText. r=heycam, a=lizzard MozReview-Commit-ID: DFFb5OCQpHG
dom/html/nsGenericHTMLElement.cpp
--- a/dom/html/nsGenericHTMLElement.cpp
+++ b/dom/html/nsGenericHTMLElement.cpp
@@ -3012,17 +3012,20 @@ IsOrHasAncestorWithDisplayNone(Element* 
 }
 
 void
 nsGenericHTMLElement::GetInnerText(mozilla::dom::DOMString& aValue,
                                    mozilla::ErrorResult& aError)
 {
   if (!GetPrimaryFrame(FlushType::Layout)) {
     nsIPresShell* presShell = nsComputedDOMStyle::GetPresShellForContent(this);
-    if (!presShell || IsOrHasAncestorWithDisplayNone(this, presShell)) {
+    // NOTE(emilio): We need to check the presshell is initialized in order to
+    // ensure the document is styled.
+    if (!presShell || !presShell->DidInitialize() ||
+        IsOrHasAncestorWithDisplayNone(this, presShell)) {
       GetTextContentInternal(aValue, aError);
       return;
     }
   }
 
   nsRange::GetInnerTextNoFlush(aValue, aError, this, 0, this, GetChildCount());
 }