Bug 1412866 - Use spec nomenclature for the ignore-destructive-writes counter. r?smaug draft
authorHenri Sivonen <hsivonen@hsivonen.fi>
Mon, 30 Oct 2017 17:45:09 +0200
changeset 688742 cf0fae199a6712483555827702fd0352a04aacc3
parent 687654 b47ad61d282f1966490f015a80c0419c8d766337
child 738149 ecaad1983eb4022f072faeb0788f565ebfd877dd
push id86834
push userbmo:hsivonen@hsivonen.fi
push dateMon, 30 Oct 2017 15:45:28 +0000
reviewerssmaug
bugs1412866
milestone58.0a1
Bug 1412866 - Use spec nomenclature for the ignore-destructive-writes counter. r?smaug MozReview-Commit-ID: FKwbEZll95J
dom/base/nsDocument.cpp
dom/base/nsIDocument.h
dom/html/nsHTMLDocument.cpp
dom/script/ScriptLoader.cpp
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1579,17 +1579,17 @@ nsIDocument::nsIDocument()
 #endif
     mBidiOptions(IBMBIDI_DEFAULT_BIDI_OPTIONS),
     mSandboxFlags(0),
     mPartID(0),
     mMarkedCCGeneration(0),
     mPresShell(nullptr),
     mSubtreeModifiedDepth(0),
     mEventsSuppressed(0),
-    mExternalScriptsBeingEvaluated(0),
+    mIgnoreDestructiveWritesCounter(0),
     mFrameRequestCallbackCounter(0),
     mStaticCloneCount(0),
     mWindow(nullptr),
     mBFCacheEntry(nullptr),
     mInSyncOperationCount(0),
     mBlockDOMContentLoaded(0),
     mUseCounters(0),
     mChildDocumentUseCounters(0),
--- a/dom/base/nsIDocument.h
+++ b/dom/base/nsIDocument.h
@@ -2435,24 +2435,24 @@ public:
 
   uint32_t EventHandlingSuppressed() const { return mEventsSuppressed; }
 
   bool IsEventHandlingEnabled() {
     return !EventHandlingSuppressed() && mScriptGlobalObject;
   }
 
   /**
-   * Increment the number of external scripts being evaluated.
+   * Increment https://html.spec.whatwg.org/#ignore-destructive-writes-counter
    */
-  void BeginEvaluatingExternalScript() { ++mExternalScriptsBeingEvaluated; }
+  void IncrementIgnoreDestructiveWritesCounter() { ++mIgnoreDestructiveWritesCounter; }
 
   /**
-   * Decrement the number of external scripts being evaluated.
+   * Decrement https://html.spec.whatwg.org/#ignore-destructive-writes-counter
    */
-  void EndEvaluatingExternalScript() { --mExternalScriptsBeingEvaluated; }
+  void DecrementIgnoreDestructiveWritesCounter() { --mIgnoreDestructiveWritesCounter; }
 
   bool IsDNSPrefetchAllowed() const { return mAllowDNSPrefetch; }
 
   /**
    * Returns true if this document is allowed to contain XUL element and
    * use non-builtin XBL bindings.
    */
   bool AllowXULXBL() {
@@ -3653,20 +3653,19 @@ protected:
   // If we're an external resource document, this will be non-null and will
   // point to our "display document": the one that all resource lookups should
   // go to.
   nsCOMPtr<nsIDocument> mDisplayDocument;
 
   uint32_t mEventsSuppressed;
 
   /**
-   * The number number of external scripts (ones with the src attribute) that
-   * have this document as their owner and that are being evaluated right now.
+   * https://html.spec.whatwg.org/#ignore-destructive-writes-counter
    */
-  uint32_t mExternalScriptsBeingEvaluated;
+  uint32_t mIgnoreDestructiveWritesCounter;
 
   /**
    * The current frame request callback handle
    */
   int32_t mFrameRequestCallbackCounter;
 
   // Count of live static clones of this document.
   uint32_t mStaticCloneCount;
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1946,32 +1946,32 @@ nsHTMLDocument::WriteCommon(JSContext *c
     // theoretically defined insertion point using mParserAborted.
     return NS_OK;
   }
 
   nsresult rv = NS_OK;
 
   void *key = GenerateParserKey();
   if (mParser && !mParser->IsInsertionPointDefined()) {
-    if (mExternalScriptsBeingEvaluated) {
+    if (mIgnoreDestructiveWritesCounter) {
       // Instead of implying a call to document.open(), ignore the call.
       nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                       NS_LITERAL_CSTRING("DOM Events"), this,
                                       nsContentUtils::eDOM_PROPERTIES,
                                       "DocumentWriteIgnored",
                                       nullptr, 0,
                                       mDocumentURI);
       return NS_OK;
     }
     mParser->Terminate();
     NS_ASSERTION(!mParser, "mParser should have been null'd out");
   }
 
   if (!mParser) {
-    if (mExternalScriptsBeingEvaluated) {
+    if (mIgnoreDestructiveWritesCounter) {
       // Instead of implying a call to document.open(), ignore the call.
       nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
                                       NS_LITERAL_CSTRING("DOM Events"), this,
                                       nsContentUtils::eDOM_PROPERTIES,
                                       "DocumentWriteIgnored",
                                       nullptr, 0,
                                       mDocumentURI);
       return NS_OK;
@@ -3811,9 +3811,9 @@ nsHTMLDocument::GetFormsAndFormControls(
     if (NS_SUCCEEDED(Dispatch(TaskCategory::GarbageCollection,
                               runnable.forget()))) {
       mContentListHolder = holder;
     }
   }
 
   NS_ADDREF(*aFormList = holder->mFormList);
   NS_ADDREF(*aFormControlList = holder->mFormControlList);
-}
\ No newline at end of file
+}
--- a/dom/script/ScriptLoader.cpp
+++ b/dom/script/ScriptLoader.cpp
@@ -1885,21 +1885,21 @@ ScriptLoader::ProcessRequest(ScriptLoadR
   pwin = mDocument->GetInnerWindow();
   if (!pwin) {
     runScript = false;
   }
 
   nsresult rv = NS_OK;
   if (runScript) {
     if (doc) {
-      doc->BeginEvaluatingExternalScript();
+      doc->IncrementIgnoreDestructiveWritesCounter();
     }
     rv = EvaluateScript(aRequest);
     if (doc) {
-      doc->EndEvaluatingExternalScript();
+      doc->DecrementIgnoreDestructiveWritesCounter();
     }
 
     nsContentUtils::DispatchTrustedEvent(scriptElem->OwnerDoc(),
                                          scriptElem,
                                          NS_LITERAL_STRING("afterscriptexecute"),
                                          true, false);
   }