Bug 1424548 - Part 1: Fix non-unified build of HTML parser code. r=hsivonen
authorChris Peterson <cpeterson@mozilla.com>
Mon, 04 Dec 2017 13:09:15 -0800
changeset 397345 7516d49fc7317f7bfa60e5634cd9e381027775db
parent 397322 bfac566813209b4c66ee49e3c782ae950fc6482f
child 397346 9874df8448d800bfb874741b0c183f45b9dcfca6
push id33133
push usershindli@mozilla.com
push dateFri, 22 Dec 2017 21:42:06 +0000
treeherdermozilla-central@10aa75f277af [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsivonen
bugs1424548
milestone59.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 1424548 - Part 1: Fix non-unified build of HTML parser code. r=hsivonen
parser/html/nsHtml5MetaScannerCppSupplement.h
parser/html/nsHtml5OwningUTF16Buffer.cpp
parser/html/nsHtml5SpeculativeLoad.cpp
parser/html/nsHtml5SpeculativeLoad.h
parser/html/nsHtml5StreamParser.cpp
parser/html/nsHtml5StreamParserPtr.h
parser/html/nsHtml5TokenizerCppSupplement.h
parser/html/nsHtml5TreeBuilderCppSupplement.h
parser/html/nsHtml5TreeOpExecutor.cpp
--- a/parser/html/nsHtml5MetaScannerCppSupplement.h
+++ b/parser/html/nsHtml5MetaScannerCppSupplement.h
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
+
 #include "nsISupportsImpl.h"
 
 #include "mozilla/Encoding.h"
 
-const Encoding*
+const mozilla::Encoding*
 nsHtml5MetaScanner::sniff(nsHtml5ByteReadable* bytes)
 {
   readable = bytes;
   stateLoop(stateSave);
   readable = nullptr;
   return mEncoding;
 }
 
@@ -20,17 +20,17 @@ nsHtml5MetaScanner::tryCharset(nsHtml5St
 {
   // This code needs to stay in sync with
   // nsHtml5StreamParser::internalEncodingDeclaration. Unfortunately, the
   // trickery with member fields here leads to some copy-paste reuse. :-(
   nsAutoCString label;
   nsString charset16; // Not Auto, because using it to hold nsStringBuffer*
   charset.ToString(charset16);
   CopyUTF16toUTF8(charset16, label);
-  const Encoding* encoding = Encoding::ForLabel(label);
+  const mozilla::Encoding* encoding = Encoding::ForLabel(label);
   if (!encoding) {
     return false;
   }
   if (encoding == UTF_16BE_ENCODING ||
       encoding == UTF_16LE_ENCODING) {
     mEncoding = UTF_8_ENCODING;
     return true;
   }
--- a/parser/html/nsHtml5OwningUTF16Buffer.cpp
+++ b/parser/html/nsHtml5OwningUTF16Buffer.cpp
@@ -1,14 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHtml5OwningUTF16Buffer.h"
 
+#include "mozilla/Span.h"
+
+using namespace mozilla;
+
 nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(char16_t* aBuffer)
   : nsHtml5UTF16Buffer(aBuffer, 0),
     next(nullptr),
     key(nullptr)
 {}
 
 nsHtml5OwningUTF16Buffer::nsHtml5OwningUTF16Buffer(void* aKey)
   : nsHtml5UTF16Buffer(nullptr, 0),
--- a/parser/html/nsHtml5SpeculativeLoad.cpp
+++ b/parser/html/nsHtml5SpeculativeLoad.cpp
@@ -1,16 +1,18 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsHtml5SpeculativeLoad.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "mozilla/Encoding.h"
 
+using namespace mozilla;
+
 nsHtml5SpeculativeLoad::nsHtml5SpeculativeLoad()
   :
 #ifdef DEBUG
   mOpCode(eSpeculativeLoadUninitialized),
 #endif
   mIsAsync(false),
   mIsDefer(false)
 {
--- a/parser/html/nsHtml5SpeculativeLoad.h
+++ b/parser/html/nsHtml5SpeculativeLoad.h
@@ -1,17 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
- 
+
 #ifndef nsHtml5SpeculativeLoad_h
 #define nsHtml5SpeculativeLoad_h
 
 #include "nsString.h"
 #include "nsContentUtils.h"
+#include "nsHtml5DocumentMode.h"
+#include "nsHtml5String.h"
 
 class nsHtml5TreeOpExecutor;
 
 enum eHtml5SpeculativeLoad {
 #ifdef DEBUG
   eSpeculativeLoadUninitialized,
 #endif
   eSpeculativeLoadBase,
--- a/parser/html/nsHtml5StreamParser.cpp
+++ b/parser/html/nsHtml5StreamParser.cpp
@@ -11,16 +11,17 @@
 #include "nsContentUtils.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsIHttpChannel.h"
 #include "nsHtml5Parser.h"
 #include "nsHtml5TreeBuilder.h"
 #include "nsHtml5AtomTable.h"
 #include "nsHtml5Module.h"
 #include "nsHtml5StreamParserPtr.h"
+#include "nsIDocShell.h"
 #include "nsIScriptError.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/SystemGroup.h"
 #include "mozilla/UniquePtrExtensions.h"
 #include "nsHtml5Highlighter.h"
 #include "expat_config.h"
 #include "expat.h"
 #include "nsINestedURI.h"
--- a/parser/html/nsHtml5StreamParserPtr.h
+++ b/parser/html/nsHtml5StreamParserPtr.h
@@ -1,14 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #ifndef nsHtml5StreamParserPtr_h
 #define nsHtml5StreamParserPtr_h
+
+#include "nsHtml5StreamParser.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/DocGroup.h"
 
 class nsHtml5StreamParserReleaser : public mozilla::Runnable
 {
 private:
   nsHtml5StreamParser* mPtr;
 
@@ -19,16 +22,17 @@ public:
   {
   }
   NS_IMETHOD Run() override
   {
     mPtr->Release();
     return NS_OK;
   }
 };
+
 /**
  * Like nsRefPtr except release is proxied to the main
  * thread. Mostly copied from nsRefPtr.
  */
 class nsHtml5StreamParserPtr
 {
 private:
   void assign_with_AddRef(nsHtml5StreamParser* rawPtr)
@@ -260,9 +264,10 @@ operator!=(const nsHtml5StreamParserPtr&
   return lhs.get() != nullptr;
 }
 
 inline bool
 operator!=(decltype(nullptr), const nsHtml5StreamParserPtr& rhs)
 {
   return nullptr != rhs.get();
 }
+
 #endif // !defined(nsHtml5StreamParserPtr_h)
--- a/parser/html/nsHtml5TokenizerCppSupplement.h
+++ b/parser/html/nsHtml5TokenizerCppSupplement.h
@@ -1,12 +1,13 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
+#include "mozilla/CheckedInt.h"
 #include "mozilla/Likely.h"
 
 // INT32_MAX is (2^31)-1. Therefore, the highest power-of-two that fits
 // is 2^30. Note that this is counting char16_t units. The underlying
 // bytes will be twice that, but they fit even in 32-bit size_t even
 // if a contiguous chunk of memory of that size is pretty unlikely to
 // be available on a 32-bit system.
 #define MAX_POWER_OF_TWO_IN_INT32 0x40000000
@@ -14,17 +15,17 @@
 bool
 nsHtml5Tokenizer::EnsureBufferSpace(int32_t aLength)
 {
   MOZ_RELEASE_ASSERT(aLength >= 0, "Negative length.");
   if (aLength > MAX_POWER_OF_TWO_IN_INT32) {
     // Can't happen when loading from network.
     return false;
   }
-  CheckedInt<int32_t> worstCase(strBufLen);
+  mozilla::CheckedInt<int32_t> worstCase(strBufLen);
   worstCase += aLength;
   worstCase += charRefBufLen;
   // Add 2 to account for emissions of LT_GT, LT_SOLIDUS and RSQB_RSQB.
   // Adding to the general worst case instead of only the
   // TreeBuilder-exposed worst case to avoid re-introducing a bug when
   // unifying the tokenizer and tree builder buffers in the future.
   worstCase += 2;
   if (!worstCase.isValid()) {
--- a/parser/html/nsHtml5TreeBuilderCppSupplement.h
+++ b/parser/html/nsHtml5TreeBuilderCppSupplement.h
@@ -3,16 +3,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsError.h"
 #include "nsIPresShell.h"
 #include "nsNodeUtils.h"
 #include "nsIFrame.h"
+#include "mozilla/CheckedInt.h"
 #include "mozilla/Likely.h"
 #include "mozilla/UniquePtr.h"
 
 nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder)
   : scriptingEnabled(false)
   , fragment(false)
   , contextName(nullptr)
   , contextNamespace(kNameSpaceID_None)
@@ -590,17 +591,17 @@ nsHtml5TreeBuilder::insertFosterParented
       static_cast<nsIContent*>(aTable),
       mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspensionWithBuilder(rv);
     }
     return;
   }
 
-  auto bufferCopy = MakeUniqueFallible<char16_t[]>(aLength);
+  auto bufferCopy = mozilla::MakeUniqueFallible<char16_t[]>(aLength);
   if (!bufferCopy) {
     // Just assigning mBroken instead of generating tree op. The caller
     // of tokenizeBuffer() will call MarkAsBroken() as appropriate.
     mBroken = NS_ERROR_OUT_OF_MEMORY;
     requestSuspension();
     return;
   }
 
@@ -656,17 +657,17 @@ nsHtml5TreeBuilder::appendCharacters(nsI
                                deepTreeSurrogateParent : aParent),
       mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspensionWithBuilder(rv);
     }
     return;
   }
 
-  auto bufferCopy = MakeUniqueFallible<char16_t[]>(aLength);
+  auto bufferCopy = mozilla::MakeUniqueFallible<char16_t[]>(aLength);
   if (!bufferCopy) {
     // Just assigning mBroken instead of generating tree op. The caller
     // of tokenizeBuffer() will call MarkAsBroken() as appropriate.
     mBroken = NS_ERROR_OUT_OF_MEMORY;
     requestSuspension();
     return;
   }
 
@@ -699,17 +700,17 @@ nsHtml5TreeBuilder::appendComment(nsICon
       aLength,
       mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspensionWithBuilder(rv);
     }
     return;
   }
 
-  auto bufferCopy = MakeUniqueFallible<char16_t[]>(aLength);
+  auto bufferCopy = mozilla::MakeUniqueFallible<char16_t[]>(aLength);
   if (!bufferCopy) {
     // Just assigning mBroken instead of generating tree op. The caller
     // of tokenizeBuffer() will call MarkAsBroken() as appropriate.
     mBroken = NS_ERROR_OUT_OF_MEMORY;
     requestSuspension();
     return;
   }
 
@@ -735,17 +736,17 @@ nsHtml5TreeBuilder::appendCommentToDocum
       aLength,
       mBuilder);
     if (NS_FAILED(rv)) {
       MarkAsBrokenAndRequestSuspensionWithBuilder(rv);
     }
     return;
   }
 
-  auto bufferCopy = MakeUniqueFallible<char16_t[]>(aLength);
+  auto bufferCopy = mozilla::MakeUniqueFallible<char16_t[]>(aLength);
   if (!bufferCopy) {
     // Just assigning mBroken instead of generating tree op. The caller
     // of tokenizeBuffer() will call MarkAsBroken() as appropriate.
     mBroken = NS_ERROR_OUT_OF_MEMORY;
     requestSuspension();
     return;
   }
 
@@ -1076,17 +1077,17 @@ nsHtml5TreeBuilder::accumulateCharacters
 // be available on a 32-bit system.
 #define MAX_POWER_OF_TWO_IN_INT32 0x40000000
 
 bool
 nsHtml5TreeBuilder::EnsureBufferSpace(int32_t aLength)
 {
   // TODO: Unify nsHtml5Tokenizer::strBuf and nsHtml5TreeBuilder::charBuffer
   // so that this method becomes unnecessary.
-  CheckedInt<int32_t> worstCase(charBufferLen);
+  mozilla::CheckedInt<int32_t> worstCase(charBufferLen);
   worstCase += aLength;
   if (!worstCase.isValid()) {
     return false;
   }
   if (worstCase.value() > MAX_POWER_OF_TWO_IN_INT32) {
     return false;
   }
   if (!charBuffer) {
@@ -1114,17 +1115,17 @@ nsIContentHandle*
 nsHtml5TreeBuilder::AllocateContentHandle()
 {
   if (MOZ_UNLIKELY(mBuilder)) {
     MOZ_ASSERT_UNREACHABLE("Must never allocate a handle with builder.");
     return nullptr;
   }
   if (mHandlesUsed == NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH) {
     mOldHandles.AppendElement(Move(mHandles));
-    mHandles = MakeUnique<nsIContent*[]>(NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH);
+    mHandles = mozilla::MakeUnique<nsIContent*[]>(NS_HTML5_TREE_BUILDER_HANDLE_ARRAY_LENGTH);
     mHandlesUsed = 0;
   }
 #ifdef DEBUG
   mHandles[mHandlesUsed] = reinterpret_cast<nsIContent*>(uintptr_t(0xC0DEDBAD));
 #endif
   return &mHandles[mHandlesUsed++];
 }
 
--- a/parser/html/nsHtml5TreeOpExecutor.cpp
+++ b/parser/html/nsHtml5TreeOpExecutor.cpp
@@ -11,16 +11,17 @@
 
 #include "nsError.h"
 #include "nsHtml5TreeOpExecutor.h"
 #include "nsIContentViewer.h"
 #include "nsIContentSecurityPolicy.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShell.h"
 #include "nsIDOMDocument.h"
+#include "nsINestedURI.h"
 #include "nsIScriptGlobalObject.h"
 #include "nsIWebShellServices.h"
 #include "nsContentUtils.h"
 #include "mozAutoDocUpdate.h"
 #include "nsNetUtil.h"
 #include "nsHtml5Parser.h"
 #include "nsHtml5Tokenizer.h"
 #include "nsHtml5TreeBuilder.h"