Bug 1472237 - Always do XML Pretty print even if the frame is hidden r=mats
authorTimothy Guan-tin Chien <timdream@gmail.com>
Fri, 16 Nov 2018 08:16:27 +0000
changeset 503226 0e6465e2cdf40c3b1f18e18c52e3285d49872c25
parent 503225 e7720f22eab1ee92b069bcee8b504e9e1e67c8cd
child 503227 96d08f7859d163479054a2835df1bf7d23a06916
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1472237, 64945, 1400618, 1437956, 1503019, 590812
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 1472237 - Always do XML Pretty print even if the frame is hidden r=mats XML pretty print, as it was implemented in bug 64945, skips itself when the loaded document is not visible. There is no explanation why it does that, other than the fact that it is backed by an XBL binding, and XBL bindings always bound to DOM with layout frames. A later change in bug 1400618 made the existence of presshell necessary before binding the XBL binding. With bug 1437956 and bug 1503019, XML pretty print is now backed by Shadow DOM. That leaves no reason for keeping this behavior. The test file test_bug590812.html also revealed that XML pretty print might incorrectly opt-out itself because of the said behavior. We don't know if this something only happens in the test or it is something that may happen in the wild. Nonetheless, it's a better idea to simplify the behavior here. Differential Revision: https://phabricator.services.mozilla.com/D12088
dom/xml/nsXMLPrettyPrinter.cpp
--- a/dom/xml/nsXMLPrettyPrinter.cpp
+++ b/dom/xml/nsXMLPrettyPrinter.cpp
@@ -40,56 +40,16 @@ nsXMLPrettyPrinter::~nsXMLPrettyPrinter(
 }
 
 nsresult
 nsXMLPrettyPrinter::PrettyPrint(nsIDocument* aDocument,
                                 bool* aDidPrettyPrint)
 {
     *aDidPrettyPrint = false;
 
-    // Check for iframe with display:none. Such iframes don't have presshells
-    nsCOMPtr<nsIPresShell> shell = aDocument->GetShell();
-    if (!shell) {
-        return NS_OK;
-    }
-
-    // check if we're in an invisible iframe
-    nsPIDOMWindowOuter *internalWin = aDocument->GetWindow();
-    nsCOMPtr<Element> frameElem;
-    if (internalWin) {
-        frameElem = internalWin->GetFrameElementInternal();
-    }
-
-    if (frameElem) {
-        nsCOMPtr<nsICSSDeclaration> computedStyle;
-        if (nsIDocument* frameOwnerDoc = frameElem->OwnerDoc()) {
-            nsPIDOMWindowOuter* window = frameOwnerDoc->GetDefaultView();
-            if (window) {
-                nsCOMPtr<nsPIDOMWindowInner> innerWindow =
-                    window->GetCurrentInnerWindow();
-
-                ErrorResult dummy;
-                computedStyle = innerWindow->GetComputedStyle(*frameElem,
-                                                              EmptyString(),
-                                                              dummy);
-                dummy.SuppressException();
-            }
-        }
-
-        if (computedStyle) {
-            nsAutoString visibility;
-            computedStyle->GetPropertyValue(NS_LITERAL_STRING("visibility"),
-                                            visibility);
-            if (!visibility.EqualsLiteral("visible")) {
-
-                return NS_OK;
-            }
-        }
-    }
-
     // check the pref
     if (!Preferences::GetBool("layout.xml.prettyprint", true)) {
         return NS_OK;
     }
 
     // Ok, we should prettyprint. Let's do it!
     *aDidPrettyPrint = true;
     nsresult rv = NS_OK;