Bug 1489308 part 7. Remove now-unused mDidDocumentOpen member. r=mccr8
authorBoris Zbarsky <bzbarsky@mit.edu>
Wed, 27 Feb 2019 05:11:19 +0000
changeset 519458 2166dac4d26c4b562dc673d73a42e8f693bbacc8
parent 519457 c1113b00d864eaf617be6fbc3966b73c2af3e1c4
child 519459 8e1196296ad4ff8e525194bce2eb9f043ee60834
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmccr8
bugs1489308
milestone67.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 1489308 part 7. Remove now-unused mDidDocumentOpen member. r=mccr8 This was only used to check for cases when document.open changed the global and hence elements being inserted into the document need a new reflector. Since document.open no longer changes the global (as of part 5 of the patches for this bug), this code is no longer needed. Differential Revision: https://phabricator.services.mozilla.com/D17325
dom/base/Document.cpp
dom/base/Document.h
dom/base/nsINode.cpp
dom/html/nsHTMLDocument.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -1238,17 +1238,16 @@ Document::Document(const char* aContentT
       mHasMixedContentObjectSubrequest(false),
       mHasCSP(false),
       mHasUnsafeEvalCSP(false),
       mHasUnsafeInlineCSP(false),
       mBFCacheDisallowed(false),
       mHasHadDefaultView(false),
       mStyleSheetChangeEventsEnabled(false),
       mIsSrcdocDocument(false),
-      mDidDocumentOpen(false),
       mHasDisplayDocument(false),
       mFontFaceSetDirty(true),
       mDidFireDOMContentLoaded(true),
       mHasScrollLinkedEffect(false),
       mFrameRequestCallbacksScheduled(false),
       mIsTopLevelContentDocument(false),
       mIsContentDocument(false),
       mDidCallBeginLoad(false),
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -1391,18 +1391,16 @@ class Document : public nsINode,
 
   /*
    * Gets the srcdoc string from within the channel (assuming both exist).
    * Returns a void string if this isn't a srcdoc document or if
    * the channel has not been set.
    */
   nsresult GetSrcdocData(nsAString& aSrcdocData);
 
-  bool DidDocumentOpen() { return mDidDocumentOpen; }
-
   already_AddRefed<mozilla::dom::AnonymousContent> InsertAnonymousContent(
       mozilla::dom::Element& aElement, mozilla::ErrorResult& aError);
   void RemoveAnonymousContent(mozilla::dom::AnonymousContent& aContent,
                               mozilla::ErrorResult& aError);
   /**
    * If aNode is a descendant of anonymous content inserted by
    * InsertAnonymousContent, this method returns the root element of the
    * inserted anonymous content (in other words, the clone of the aElement
@@ -4125,21 +4123,16 @@ class Document : public nsINode,
   bool mHasHadDefaultView : 1;
 
   // Whether style sheet change events will be dispatched for this document
   bool mStyleSheetChangeEventsEnabled : 1;
 
   // Whether the document was created by a srcdoc iframe.
   bool mIsSrcdocDocument : 1;
 
-  // Records whether we've done a document.open. If this is true, it's possible
-  // for nodes from this document to have outdated wrappers in their wrapper
-  // caches.
-  bool mDidDocumentOpen : 1;
-
   // Whether this document has a display document and thus is considered to
   // be a resource document.  Normally this is the same as !!mDisplayDocument,
   // but mDisplayDocument is cleared during Unlink.  mHasDisplayDocument is
   // valid in the document's destructor.
   bool mHasDisplayDocument : 1;
 
   // Is the current mFontFaceSet valid?
   bool mFontFaceSetDirty : 1;
--- a/dom/base/nsINode.cpp
+++ b/dom/base/nsINode.cpp
@@ -1164,32 +1164,16 @@ static void AdoptNodeIntoOwnerDoc(nsINod
     MOZ_ASSERT(aParent->OwnerDoc() == doc, "ownerDoc chainged while adopting");
     MOZ_ASSERT(adoptedNode == aNode, "Uh, adopt node changed nodes?");
     MOZ_ASSERT(aParent->OwnerDoc() == aNode->OwnerDoc(),
                "ownerDocument changed again after adopting!");
   }
 #endif  // DEBUG
 }
 
-static void CheckForOutdatedParent(nsINode* aParent, nsINode* aNode,
-                                   ErrorResult& aError) {
-  if (JSObject* existingObjUnrooted = aNode->GetWrapper()) {
-    JS::Rooted<JSObject*> existingObj(RootingCx(), existingObjUnrooted);
-
-    AutoJSContext cx;
-    nsIGlobalObject* global = aParent->OwnerDoc()->GetScopeObject();
-    MOZ_ASSERT(global);
-
-    if (JS::GetNonCCWObjectGlobal(existingObj) != global->GetGlobalJSObject()) {
-      JSAutoRealm ar(cx, existingObj);
-      UpdateReflectorGlobal(cx, existingObj, aError);
-    }
-  }
-}
-
 static nsresult UpdateGlobalsInSubtree(nsIContent* aRoot) {
   MOZ_ASSERT(ShouldUseNACScope(aRoot));
   // Start off with no global so we don't fire any error events on failure.
   AutoJSAPI jsapi;
   jsapi.Init();
 
   JSContext* cx = jsapi.cx();
 
@@ -1238,27 +1222,16 @@ nsresult nsINode::InsertChildBefore(nsIC
 
     // Need to WouldReportJSException() if our callee can throw a JS
     // exception (which it can) and we're neither propagating the
     // error out nor unconditionally suppressing it.
     error.WouldReportJSException();
     if (NS_WARN_IF(error.Failed())) {
       return error.StealNSResult();
     }
-  } else if (OwnerDoc()->DidDocumentOpen()) {
-    ErrorResult error;
-    CheckForOutdatedParent(this, aKid, error);
-
-    // Need to WouldReportJSException() if our callee can throw a JS
-    // exception (which it can) and we're neither propagating the
-    // error out nor unconditionally suppressing it.
-    error.WouldReportJSException();
-    if (NS_WARN_IF(error.Failed())) {
-      return error.StealNSResult();
-    }
   }
 
   if (!aChildToInsertBefore) {
     AppendChildToChildList(aKid);
   } else {
     InsertChildToChildList(aKid, aChildToInsertBefore);
   }
 
@@ -2299,21 +2272,16 @@ nsINode* nsINode::ReplaceOrInsertBefore(
   // ownerDocument according to the DOM spec, and we need to allow
   // inserting them w/o calling AdoptNode().
   Document* doc = OwnerDoc();
   if (doc != newContent->OwnerDoc()) {
     AdoptNodeIntoOwnerDoc(this, aNewChild, aError);
     if (aError.Failed()) {
       return nullptr;
     }
-  } else if (doc->DidDocumentOpen()) {
-    CheckForOutdatedParent(this, aNewChild, aError);
-    if (aError.Failed()) {
-      return nullptr;
-    }
   }
 
   /*
    * Check if we're inserting a document fragment. If we are, we need
    * to actually add its children individually (i.e. we don't add the
    * actual document fragment).
    */
   nsINode* result = aReplace ? aRefChild : aNewChild;
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1376,18 +1376,16 @@ Document* nsHTMLDocument::Open(JSContext
   // Step 12, but note <https://github.com/whatwg/html/issues/4292>.
   mSkipLoadEventAfterClose = mLoadEventFiring;
 
   // Preliminary to steps 13-16.  Set our ready state to uninitialized before
   // we do anything else, so we can then proceed to later ready state levels.
   SetReadyStateInternal(READYSTATE_UNINITIALIZED,
                         /* updateTimingInformation = */ false);
 
-  mDidDocumentOpen = true;
-
   // Step 13 -- set our compat mode to standards.
   SetCompatibilityMode(eCompatibility_FullStandards);
 
   // Step 14 -- create a new parser associated with document.  This also does
   // step 16 implicitly.
   mParserAborted = false;
   mParser = nsHtml5Module::NewHtml5Parser();
   nsHtml5Module::Initialize(mParser, this, GetDocumentURI(), shell, nullptr);