#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/html/parser/html_tree_builder.h"
#include <memory>
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/html/forms/html_form_control_element.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_text_area_element.h"
#include "third_party/blink/renderer/core/html/html_template_element.h"
#include "third_party/blink/renderer/core/html/parser/atomic_html_token.h"
#include "third_party/blink/renderer/core/html/parser/html_document_parser.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
#include "third_party/blink/renderer/core/html/parser/html_stack_item.h"
#include "third_party/blink/renderer/core/html/parser/html_token.h"
#include "third_party/blink/renderer/core/html/parser/html_tokenizer.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/mathml_names.h"
#include "third_party/blink/renderer/core/svg_names.h"
#include "third_party/blink/renderer/core/xlink_names.h"
#include "third_party/blink/renderer/core/xml_names.h"
#include "third_party/blink/renderer/core/xmlns_names.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/bindings/runtime_call_stats.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/text/platform_locale.h"
#include "third_party/blink/renderer/platform/wtf/text/character_names.h"
#include "third_party/blink/renderer/platform/wtf/text/character_visitor.h"
#include "third_party/blink/renderer/platform/wtf/text/string_buffer.h"
namespace blink {
HTMLTag;
namespace {
inline bool IsHTMLSpaceOrReplacementCharacter(UChar character) { … }
}
static TextPosition UninitializedPositionValue1() { … }
static inline bool IsAllWhitespace(const StringView& string_view) { … }
static inline bool IsAllWhitespaceOrReplacementCharacters(
const StringView& string_view) { … }
#define CAPTION_COL_OR_COLGROUP_CASES …
#define NUMBERED_HEADER_CASES …
#define TABLE_BODY_CONTEXT_CASES …
#define TABLE_CELL_CONTEXT_CASES …
static bool IsTableBodyContextTag(HTMLTag tag) { … }
class HTMLTreeBuilder::CharacterTokenBuffer { … };
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser,
Document& document,
ParserContentPolicy parser_content_policy,
const HTMLParserOptions& options,
bool include_shadow_roots,
DocumentFragment* for_fragment,
Element* fragment_context_element)
: … { … }
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser,
Document& document,
ParserContentPolicy parser_content_policy,
const HTMLParserOptions& options,
bool include_shadow_roots)
: … { … }
HTMLTreeBuilder::HTMLTreeBuilder(HTMLDocumentParser* parser,
DocumentFragment* fragment,
Element* context_element,
ParserContentPolicy parser_content_policy,
const HTMLParserOptions& options,
bool include_shadow_roots)
: … { … }
HTMLTreeBuilder::~HTMLTreeBuilder() = default;
void HTMLTreeBuilder::FragmentParsingContext::Init(DocumentFragment* fragment,
Element* context_element) { … }
void HTMLTreeBuilder::FragmentParsingContext::Trace(Visitor* visitor) const { … }
void HTMLTreeBuilder::Trace(Visitor* visitor) const { … }
void HTMLTreeBuilder::Detach() { … }
Element* HTMLTreeBuilder::TakeScriptToProcess(
TextPosition& script_start_position) { … }
void HTMLTreeBuilder::ConstructTree(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessToken(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessDoctypeToken(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessFakeStartTag(HTMLTag tag,
const Vector<Attribute>& attributes) { … }
void HTMLTreeBuilder::ProcessFakeEndTag(HTMLTag tag) { … }
void HTMLTreeBuilder::ProcessFakeEndTag(const HTMLStackItem& stack_item) { … }
void HTMLTreeBuilder::ProcessFakePEndTagIfPInButtonScope() { … }
namespace {
bool IsLi(const HTMLStackItem* item) { … }
bool IsDdOrDt(const HTMLStackItem* item) { … }
}
template <bool shouldClose(const HTMLStackItem*)>
void HTMLTreeBuilder::ProcessCloseWhenNestedTag(AtomicHTMLToken* token) { … }
namespace {
PrefixedNameToQualifiedNameMap;
template <typename TableQualifiedName>
void MapLoweredLocalNameToName(PrefixedNameToQualifiedNameMap* map,
const TableQualifiedName* const* names,
size_t length) { … }
void AddManualLocalName(PrefixedNameToQualifiedNameMap* map, const char* name) { … }
void AdjustSVGTagNameCase(AtomicHTMLToken* token) { … }
template <std::unique_ptr<const QualifiedName* []> getAttrs(),
unsigned length,
bool forSVG>
void AdjustAttributes(AtomicHTMLToken* token) { … }
void AdjustSVGAttributes(AtomicHTMLToken* token) { … }
void AdjustMathMLAttributes(AtomicHTMLToken* token) { … }
void AddNamesWithPrefix(PrefixedNameToQualifiedNameMap* map,
const AtomicString& prefix,
const QualifiedName* const* names,
size_t length) { … }
void AdjustForeignAttributes(AtomicHTMLToken* token) { … }
}
void HTMLTreeBuilder::ProcessStartTagForInBody(AtomicHTMLToken* token) { … }
namespace {
String DeclarativeShadowRootModeFromToken(AtomicHTMLToken* token,
const Document& document,
bool include_shadow_roots) { … }
}
void HTMLTreeBuilder::ProcessTemplateStartTag(AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ProcessTemplateEndTag(AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ProcessEndOfFileForInTemplateContents(
AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ProcessColgroupEndTagForInColumnGroup() { … }
HTMLStackItem* HTMLTreeBuilder::AdjustedCurrentStackItem() const { … }
void HTMLTreeBuilder::CloseTheCell() { … }
void HTMLTreeBuilder::ProcessStartTagForInTable(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessStartTag(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessHtmlStartTagForInBody(AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ProcessBodyEndTagForInBody(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessAnyOtherEndTagForInBody(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::CallTheAdoptionAgency(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ResetInsertionModeAppropriately() { … }
void HTMLTreeBuilder::ProcessEndTagForInTableBody(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessEndTagForInRow(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessEndTagForInCell(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessEndTagForInBody(AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ProcessCaptionEndTagForInCaption() { … }
bool HTMLTreeBuilder::ProcessTrEndTagForInRow() { … }
bool HTMLTreeBuilder::ProcessTableEndTagForInTable() { … }
void HTMLTreeBuilder::ProcessEndTagForInTable(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessEndTag(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessComment(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessDOMPart(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessCharacter(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessCharacterBuffer(CharacterTokenBuffer& buffer) { … }
void HTMLTreeBuilder::ProcessCharacterBufferForInBody(
CharacterTokenBuffer& buffer) { … }
void HTMLTreeBuilder::ProcessEndOfFile(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::DefaultForInitial() { … }
void HTMLTreeBuilder::DefaultForBeforeHTML() { … }
void HTMLTreeBuilder::DefaultForBeforeHead() { … }
void HTMLTreeBuilder::DefaultForInHead() { … }
void HTMLTreeBuilder::DefaultForInHeadNoscript() { … }
void HTMLTreeBuilder::DefaultForAfterHead() { … }
void HTMLTreeBuilder::DefaultForInTableText() { … }
bool HTMLTreeBuilder::ProcessStartTagForInHead(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessGenericRCDATAStartTag(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessGenericRawTextStartTag(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessScriptStartTag(AtomicHTMLToken* token) { … }
bool HTMLTreeBuilder::ShouldProcessTokenInForeignContent(
AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::ProcessTokenInForeignContent(AtomicHTMLToken* token) { … }
void HTMLTreeBuilder::Finished() { … }
void HTMLTreeBuilder::ParseError(AtomicHTMLToken*) { … }
#ifndef NDEBUG
const char* HTMLTreeBuilder::ToString(HTMLTreeBuilder::InsertionMode mode) { … }
#endif
}