Bug 1382568: Avoid trying to resolve styles in an uninitialized presshell in GetInnerText. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sat, 05 Aug 2017 08:55:50 +0200
changeset 641061 70b74e3883a3c07fbd815138e9c1d2dfa5fe2fb8
parent 618816 92b4376175cec6e90f41dfa1efdc95af9cd4846a
child 641062 f2e4867878b0390084f69024c05ada29cf432578
child 641063 e133594a32146f4337cb9f28b8d81cd5fb7574bc
child 641064 0e18b0b07a1cf945ddf5ad766337b066886501c9
push id72420
push userbmo:emilio+bugs@crisal.io
push dateSat, 05 Aug 2017 06:56:33 +0000
reviewersheycam
bugs1382568
milestone56.0a1
Bug 1382568: Avoid trying to resolve styles in an uninitialized presshell in GetInnerText. r?heycam 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 styled 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());
 }