Backed out changeset f7c391670061 (bug 1440537) for mochitest failures at test_swapFrameLoaders.xul.
authorBrindusan Cristian <cbrindusan@mozilla.com>
Sat, 27 Apr 2019 15:23:16 +0300
changeset 530469 bdc963e3823832db9bc80b35be67206c25e33381
parent 530468 808fc8c6a041279ded9368af57e4c1ae2e7d34cc
child 530470 660c16b89380269752e7e67ed717a4cf5dca6e5f
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1440537
milestone68.0a1
backs outf7c39167006152340a7347a16c349bb54a8d1711
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
Backed out changeset f7c391670061 (bug 1440537) for mochitest failures at test_swapFrameLoaders.xul.
dom/base/Document.cpp
dom/base/Document.h
dom/base/nsGlobalWindowOuter.cpp
layout/style/nsComputedDOMStyle.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -3144,32 +3144,34 @@ void Document::SetPrincipals(nsIPrincipa
   // check. It's not unsafe to have a document which has a null principal in the
   // same docgroup as another document, so this should not be a problem.
   if (aNewPrincipal) {
     GetDocGroup();
   }
 #endif
 }
 
+mozilla::dom::DocGroup* Document::GetDocGroup() const {
 #ifdef DEBUG
-void Document::AssertDocGroupMatchesKey() const {
   // Sanity check that we have an up-to-date and accurate docgroup
   if (mDocGroup) {
     nsAutoCString docGroupKey;
 
     // GetKey() can fail, e.g. after the TLD service has shut down.
     nsresult rv = mozilla::dom::DocGroup::GetKey(NodePrincipal(), docGroupKey);
     if (NS_SUCCEEDED(rv)) {
       MOZ_ASSERT(mDocGroup->MatchesKey(docGroupKey));
     }
     // XXX: Check that the TabGroup is correct as well!
   }
-}
 #endif
 
+  return mDocGroup;
+}
+
 nsresult Document::Dispatch(TaskCategory aCategory,
                             already_AddRefed<nsIRunnable>&& aRunnable) {
   // Note that this method may be called off the main thread.
   if (mDocGroup) {
     return mDocGroup->Dispatch(aCategory, std::move(aRunnable));
   }
   return DispatcherTrait::Dispatch(aCategory, std::move(aRunnable));
 }
@@ -7327,18 +7329,17 @@ void Document::FlushPendingNotifications
   // container is reflowed if its size was changed.  But if it's not safe to
   // flush ourselves, then don't flush the parent, since that can cause things
   // like resizes of our frame's widget, which we can't handle while flushing
   // is unsafe.
   // Since media queries mean that a size change of our container can
   // affect style, we need to promote a style flush on ourself to a
   // layout flush on our parent, since we need our container to be the
   // correct size to determine the correct style.
-  if (StyleOrLayoutObservablyDependsOnParentDocumentLayout() &&
-      IsSafeToFlush()) {
+  if (mParentDocument && IsSafeToFlush()) {
     mozilla::ChangesToFlush parentFlush = aFlush;
     if (flushType >= FlushType::Style) {
       parentFlush.mFlushType = std::max(FlushType::Layout, flushType);
     }
     mParentDocument->FlushPendingNotifications(parentFlush);
   }
 
   if (RefPtr<PresShell> presShell = GetPresShell()) {
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -2401,16 +2401,17 @@ class Document : public nsINode,
    * document.
    */
   bool HaveFiredDOMTitleChange() const { return mHaveFiredTitleChange; }
 
   Element* GetAnonymousElementByAttribute(nsIContent* aElement,
                                           nsAtom* aAttrName,
                                           const nsAString& aAttrValue) const;
 
+
   /**
    * To batch DOMSubtreeModified, document needs to be informed when
    * a mutation event might be dispatched, even if the event isn't actually
    * created because there are no listeners for it.
    *
    * @param aTarget is the target for the mutation event.
    */
   void MayDispatchMutationEvent(nsINode* aTarget) {
@@ -3491,40 +3492,17 @@ class Document : public nsINode,
 
   bool HasScriptsBlockedBySandbox();
 
   bool InlineScriptAllowedByCSP();
 
   void ReportHasScrollLinkedEffect();
   bool HasScrollLinkedEffect() const { return mHasScrollLinkedEffect; }
 
-#ifdef DEBUG
-  void AssertDocGroupMatchesKey() const;
-#endif
-
-  DocGroup* GetDocGroup() const {
-#ifdef DEBUG
-    AssertDocGroupMatchesKey();
-#endif
-    return mDocGroup;
-  }
-
-  /**
-   * If we're a sub-document, the parent document's layout can affect our style
-   * and layout (due to the viewport size, viewport units, media queries...).
-   *
-   * This function returns true if our parent document and our child document
-   * can observe each other. If they cannot, then we don't need to synchronously
-   * update the parent document layout every time the child document may need
-   * up-to-date layout information.
-   */
-  bool StyleOrLayoutObservablyDependsOnParentDocumentLayout() const {
-    return GetParentDocument() &&
-           GetDocGroup() == GetParentDocument()->GetDocGroup();
-  }
+  DocGroup* GetDocGroup() const;
 
   void AddIntersectionObserver(DOMIntersectionObserver* aObserver) {
     MOZ_ASSERT(!mIntersectionObservers.Contains(aObserver),
                "Intersection observer already in the list");
     mIntersectionObservers.PutEntry(aObserver);
   }
 
   void RemoveIntersectionObserver(DOMIntersectionObserver* aObserver) {
--- a/dom/base/nsGlobalWindowOuter.cpp
+++ b/dom/base/nsGlobalWindowOuter.cpp
@@ -7361,22 +7361,26 @@ nsresult nsGlobalWindowOuter::SecurityCh
 
 void nsGlobalWindowOuter::FlushPendingNotifications(FlushType aType) {
   if (mDoc) {
     mDoc->FlushPendingNotifications(aType);
   }
 }
 
 void nsGlobalWindowOuter::EnsureSizeAndPositionUpToDate() {
-  // If we're a subframe, make sure our size is up to date.  Make sure to go
-  // through the document chain rather than the window chain to not flush on
-  // detached iframes, see bug 1545516.
-  if (mDoc && mDoc->StyleOrLayoutObservablyDependsOnParentDocumentLayout()) {
-    RefPtr<Document> parent = mDoc->GetParentDocument();
-    parent->FlushPendingNotifications(FlushType::Layout);
+  // If we're a subframe, make sure our size is up to date.  It's OK that this
+  // crosses the content/chrome boundary, since chrome can have pending reflows
+  // too.
+  //
+  // Make sure to go through the document chain rather than the window chain to
+  // not flush on detached iframes, see bug 1545516.
+  if (mDoc) {
+    if (RefPtr<Document> parent = mDoc->GetParentDocument()) {
+      parent->FlushPendingNotifications(FlushType::Layout);
+    }
   }
 }
 
 already_AddRefed<nsISupports> nsGlobalWindowOuter::SaveWindowState() {
   if (!mContext || !GetWrapperPreserveColor()) {
     // The window may be getting torn down; don't bother saving state.
     return nullptr;
   }
--- a/layout/style/nsComputedDOMStyle.cpp
+++ b/layout/style/nsComputedDOMStyle.cpp
@@ -780,18 +780,17 @@ bool nsComputedDOMStyle::NeedsToFlush() 
   // We always compute styles from the element's owner document.
   if (ElementNeedsRestyle(mElement, mPseudo)) {
     return true;
   }
 
   Document* doc = mElement->OwnerDoc();
   // If parent document is there, also needs to check if there is some change
   // that needs to flush this document (e.g. size change for iframe).
-  while (doc->StyleOrLayoutObservablyDependsOnParentDocumentLayout()) {
-    Document* parentDocument = doc->GetParentDocument();
+  while (Document* parentDocument = doc->GetParentDocument()) {
     Element* element = parentDocument->FindContentForSubDocument(doc);
     if (ElementNeedsRestyle(element, nullptr)) {
       return true;
     }
     doc = parentDocument;
   }
 
   return false;