Bug 1820575 - Make parser/html buildable outside of a unified build environment r=andi

Differential Revision: https://phabricator.services.mozilla.com/D171733
This commit is contained in:
serge-sans-paille 2023-03-15 07:30:37 +00:00
parent 860ac9660a
commit 37a9268fca
10 changed files with 22 additions and 14 deletions

View File

@ -90,5 +90,3 @@ FINAL_LIBRARY = "xul"
LOCAL_INCLUDES += [
"/dom/base",
]
REQUIRES_UNIFIED_BUILD = True

View File

@ -7,6 +7,8 @@
#ifndef nsHtml5AutoPauseUpdate_h
#define nsHtml5AutoPauseUpdate_h
#include "nsHtml5DocumentBuilder.h"
class MOZ_RAII nsHtml5AutoPauseUpdate final {
private:
RefPtr<nsHtml5DocumentBuilder> mBuilder;

View File

@ -7,6 +7,7 @@
#include "nsHtml5Parser.h"
#include "mozilla/AutoRestore.h"
#include "mozilla/UniquePtr.h"
#include "nsCRT.h"
#include "nsContentUtils.h" // for kLoadAsData
#include "nsHtml5AtomTable.h"
@ -410,10 +411,11 @@ nsresult nsHtml5Parser::Parse(const nsAString& aSourceBuffer, void* aKey,
if (!mDocWriteSpeculativeTreeBuilder) {
// Lazily initialize if uninitialized
mDocWriteSpeculativeTreeBuilder =
MakeUnique<nsHtml5TreeBuilder>(nullptr, executor->GetStage(), true);
mozilla::MakeUnique<nsHtml5TreeBuilder>(nullptr,
executor->GetStage(), true);
mDocWriteSpeculativeTreeBuilder->setScriptingEnabled(
mTreeBuilder->isScriptingEnabled());
mDocWriteSpeculativeTokenizer = MakeUnique<nsHtml5Tokenizer>(
mDocWriteSpeculativeTokenizer = mozilla::MakeUnique<nsHtml5Tokenizer>(
mDocWriteSpeculativeTreeBuilder.get(), false);
mDocWriteSpeculativeTokenizer->setInterner(&mAtomTable);
mDocWriteSpeculativeTokenizer->start();

View File

@ -31,6 +31,7 @@
#include "nsAtom.h"
#include "nsHtml5AtomTable.h"
#include "nsHtml5HtmlAttributes.h"
#include "nsHtml5String.h"
#include "nsNameSpaceManager.h"
#include "nsIContent.h"

View File

@ -150,7 +150,8 @@ nsHtml5String nsHtml5String::FromLiteral(const char* aLiteral) {
MOZ_CRASH("Out of memory.");
}
char16_t* data = reinterpret_cast<char16_t*>(buffer->Data());
ConvertAsciitoUtf16(Span(aLiteral, length), Span(data, length));
ConvertAsciitoUtf16(mozilla::Span(aLiteral, length),
mozilla::Span(data, length));
data[length] = 0;
return nsHtml5String(reinterpret_cast<uintptr_t>(buffer.forget().take()) |
eStringBuffer);

View File

@ -79,7 +79,7 @@ void nsHtml5Tokenizer::StartPlainText() {
}
void nsHtml5Tokenizer::EnableViewSource(nsHtml5Highlighter* aHighlighter) {
mViewSource = WrapUnique(aHighlighter);
mViewSource = mozilla::WrapUnique(aHighlighter);
}
bool nsHtml5Tokenizer::ShouldFlushViewSource() {

View File

@ -11,6 +11,7 @@
#include "mozilla/StaticPrefs_dom.h"
#include "mozilla/StaticPrefs_network.h"
#include "mozilla/UniquePtr.h"
#include "mozilla/UniquePtrExtensions.h"
nsHtml5TreeBuilder::nsHtml5TreeBuilder(nsHtml5OplessBuilder* aBuilder)
: mode(0),
@ -179,7 +180,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
if (nsGkAtoms::img == aName) {
nsHtml5String loading =
aAttributes->getValue(nsHtml5AttributeName::ATTR_LOADING);
if (!StaticPrefs::dom_image_lazy_loading_enabled() ||
if (!mozilla::StaticPrefs::dom_image_lazy_loading_enabled() ||
!loading.LowerCaseEqualsASCII("lazy")) {
nsHtml5String url =
aAttributes->getValue(nsHtml5AttributeName::ATTR_SRC);
@ -281,7 +282,7 @@ nsIContentHandle* nsHtml5TreeBuilder::createElement(
mSpeculativeLoadQueue.AppendElement()->InitPreconnect(
url, crossOrigin);
}
} else if (StaticPrefs::network_preload() &&
} else if (mozilla::StaticPrefs::network_preload() &&
rel.LowerCaseEqualsASCII("preload")) {
nsHtml5String url =
aAttributes->getValue(nsHtml5AttributeName::ATTR_HREF);
@ -760,7 +761,8 @@ void nsHtml5TreeBuilder::appendCharacters(nsIContentHandle* aParent,
memcpy(bufferCopy.get(), aBuffer, aLength * sizeof(char16_t));
if (mImportScanner.ShouldScan()) {
nsTArray<nsString> imports = mImportScanner.Scan(Span(aBuffer, aLength));
nsTArray<nsString> imports =
mImportScanner.Scan(mozilla::Span(aBuffer, aLength));
for (nsString& url : imports) {
mSpeculativeLoadQueue.AppendElement()->InitImportStyle(std::move(url));
}
@ -1232,7 +1234,7 @@ mozilla::Result<bool, nsresult> nsHtml5TreeBuilder::Flush(bool aDiscretionary) {
"as broken.");
}
if (!mOpSink->MoveOpsFrom(mOpQueue)) {
return Err(NS_ERROR_OUT_OF_MEMORY);
return mozilla::Err(NS_ERROR_OUT_OF_MEMORY);
}
}
return hasOps;

View File

@ -37,6 +37,7 @@
#include "nsIDocShell.h"
#include "nsIDocShellTreeItem.h"
#include "nsINestedURI.h"
#include "nsIHttpChannel.h"
#include "nsIScriptContext.h"
#include "nsIScriptError.h"
#include "nsIScriptGlobalObject.h"
@ -221,7 +222,7 @@ nsHtml5TreeOpExecutor::DidBuildModel(bool aTerminated) {
// Gather telemetry only for top-level content navigations in order to
// avoid noise from ad iframes.
bool topLevel = false;
if (BrowsingContext* bc = mDocument->GetBrowsingContext()) {
if (mozilla::dom::BrowsingContext* bc = mDocument->GetBrowsingContext()) {
topLevel = bc->IsTopContent();
}

View File

@ -10,6 +10,7 @@
#include "mozilla/Likely.h"
#include "mozilla/dom/Comment.h"
#include "mozilla/dom/CustomElementRegistry.h"
#include "mozilla/dom/DocGroup.h"
#include "mozilla/dom/DocumentType.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/LinkStyle.h"

View File

@ -15,10 +15,10 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() {
bodyAttrs->addAttribute(nsHtml5AttributeName::ATTR_ID, id, -1);
nsString klass;
if (StaticPrefs::view_source_wrap_long_lines()) {
if (mozilla::StaticPrefs::view_source_wrap_long_lines()) {
klass.AppendLiteral(u"wrap ");
}
if (StaticPrefs::view_source_syntax_highlight()) {
if (mozilla::StaticPrefs::view_source_syntax_highlight()) {
klass.AppendLiteral(u"highlight");
}
if (!klass.IsEmpty()) {
@ -26,7 +26,7 @@ nsHtml5HtmlAttributes* nsHtml5ViewSourceUtils::NewBodyAttributes() {
nsHtml5String::FromString(klass), -1);
}
int32_t tabSize = StaticPrefs::view_source_tab_size();
int32_t tabSize = mozilla::StaticPrefs::view_source_tab_size();
if (tabSize > 0) {
nsString style;
style.AssignLiteral("tab-size: ");