Bug 1550524 part 3. Remove the now-unused aContentType argument to nsHtml5Parser::Parse. r=hsivonen
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 14 May 2019 19:46:26 +0000
changeset 474555 68b3e0acc50371007c682e55c79158d98d6325ae
parent 474554 3eef21fc64b778f57aaa416f2b0c2ed469033a10
child 474556 d9cfca9f112f29bffc562a979c3c0e35ae74ac27
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs1550524
milestone69.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 1550524 part 3. Remove the now-unused aContentType argument to nsHtml5Parser::Parse. r=hsivonen Differential Revision: https://phabricator.services.mozilla.com/D30752
dom/base/Document.cpp
dom/base/Document.h
dom/html/nsHTMLDocument.cpp
parser/html/nsHtml5Parser.cpp
parser/html/nsHtml5Parser.h
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -11905,17 +11905,16 @@ void Document::SetCachedEncoder(already_
 void Document::SetContentTypeInternal(const nsACString& aType) {
   if (!IsHTMLOrXHTML() && mDefaultElementType == kNameSpaceID_None &&
       aType.EqualsLiteral("application/xhtml+xml")) {
     mDefaultElementType = kNameSpaceID_XHTML;
   }
 
   mCachedEncoder = nullptr;
   mContentType = aType;
-  mContentTypeForWriteCalls = aType;
 }
 
 nsILoadContext* Document::GetLoadContext() const { return mDocumentContainer; }
 
 nsIDocShell* Document::GetDocShell() const { return mDocumentContainer; }
 
 void Document::SetStateObject(nsIStructuredCloneContainer* scContainer) {
   mStateObjectContainer = scContainer;
--- a/dom/base/Document.h
+++ b/dom/base/Document.h
@@ -4414,20 +4414,16 @@ class Document : public nsINode,
 
   // The channel that got passed to Document::StartDocumentLoad(), if any.
   nsCOMPtr<nsIChannel> mChannel;
 
  private:
   nsCString mContentType;
 
  protected:
-  // For document.write() we may need a different content type than
-  // mContentType.
-  nsCString mContentTypeForWriteCalls;
-
   // The document's security info
   nsCOMPtr<nsISupports> mSecurityInfo;
 
   // The channel that failed to load and resulted in an error page.
   // This only applies to error pages. Might be null.
   nsCOMPtr<nsIChannel> mFailedChannel;
 
   // if this document is part of a multipart document,
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -1194,19 +1194,16 @@ Document* nsHTMLDocument::Open(const Opt
     }
   }
   nsresult rv = parser->StartExecutor();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     aError.Throw(rv);
     return nullptr;
   }
 
-  // Some internal non-spec bookkeeping.
-  mContentTypeForWriteCalls.AssignLiteral("text/html");
-
   if (shell) {
     // Prepare the docshell and the document viewer for the impending
     // out-of-band document.write()
     shell->PrepareForNewContentModel();
 
     nsCOMPtr<nsIContentViewer> cv;
     shell->GetContentViewer(getter_AddRefs(cv));
     if (cv) {
@@ -1238,17 +1235,17 @@ void nsHTMLDocument::Close(ErrorResult& 
   }
 
   if (!mParser || !mParser->IsScriptCreated()) {
     return;
   }
 
   ++mWriteLevel;
   rv = (static_cast<nsHtml5Parser*>(mParser.get()))
-           ->Parse(EmptyString(), nullptr, mContentTypeForWriteCalls, true);
+           ->Parse(EmptyString(), nullptr, true);
   --mWriteLevel;
 
   // Even if that Parse() call failed, do the rest of this method
 
   // XXX Make sure that all the document.written content is
   // reflowed.  We should remove this call once we change
   // nsHTMLDocument::OpenCommon() so that it completely destroys the
   // earlier document's content and frame hierarchy.  Right now, it
@@ -1370,20 +1367,20 @@ void nsHTMLDocument::WriteCommon(const n
   ++mWriteLevel;
 
   // This could be done with less code, but for performance reasons it
   // makes sense to have the code for two separate Parse() calls here
   // since the concatenation of strings costs more than we like. And
   // why pay that price when we don't need to?
   if (aNewlineTerminate) {
     aRv = (static_cast<nsHtml5Parser*>(mParser.get()))
-              ->Parse(aText + new_line, key, mContentTypeForWriteCalls, false);
+              ->Parse(aText + new_line, key, false);
   } else {
-    aRv = (static_cast<nsHtml5Parser*>(mParser.get()))
-              ->Parse(aText, key, mContentTypeForWriteCalls, false);
+    aRv =
+        (static_cast<nsHtml5Parser*>(mParser.get()))->Parse(aText, key, false);
   }
 
   --mWriteLevel;
 
   mTooDeepWriteRecursion = (mWriteLevel != 0 && mTooDeepWriteRecursion);
 }
 
 void nsHTMLDocument::Write(const Sequence<nsString>& aText, ErrorResult& rv) {
--- a/parser/html/nsHtml5Parser.cpp
+++ b/parser/html/nsHtml5Parser.cpp
@@ -169,19 +169,17 @@ nsHtml5Parser::Parse(nsIURI* aURL, nsIRe
   GetStreamParser()->SetObserver(aObserver);
   GetStreamParser()->SetViewSourceTitle(aURL);  // In case we're viewing source
   mExecutor->SetStreamParser(GetStreamParser());
   mExecutor->SetParser(this);
   return NS_OK;
 }
 
 nsresult nsHtml5Parser::Parse(const nsAString& aSourceBuffer, void* aKey,
-                              const nsACString& aContentType, bool aLastCall,
-                              nsDTDMode aMode)  // ignored
-{
+                              bool aLastCall) {
   nsresult rv;
   if (NS_FAILED(rv = mExecutor->IsBroken())) {
     return rv;
   }
   if (aSourceBuffer.Length() > INT32_MAX) {
     return mExecutor->MarkAsBroken(NS_ERROR_OUT_OF_MEMORY);
   }
 
--- a/parser/html/nsHtml5Parser.h
+++ b/parser/html/nsHtml5Parser.h
@@ -130,23 +130,19 @@ class nsHtml5Parser final : public nsIPa
                    void* aKey = 0,
                    nsDTDMode aMode = eDTDMode_autodetect) override;
 
   /**
    * document.write and document.close
    *
    * @param   aSourceBuffer the argument of document.write (empty for .close())
    * @param   aKey a key unique to the script element that caused this call
-   * @param   aContentType "text/html" for HTML mode, else text/plain mode
    * @param   aLastCall true if .close() false if .write()
-   * @param   aMode ignored (for interface compat only)
    */
-  nsresult Parse(const nsAString& aSourceBuffer, void* aKey,
-                 const nsACString& aContentType, bool aLastCall,
-                 nsDTDMode aMode = eDTDMode_autodetect);
+  nsresult Parse(const nsAString& aSourceBuffer, void* aKey, bool aLastCall);
 
   /**
    * Stops the parser prematurely
    */
   NS_IMETHOD Terminate() override;
 
   /**
    * Don't call. For interface backwards compat only.