#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "third_party/blink/renderer/core/html/parser/html_construction_site.h"
#include <limits>
#include "base/notreached.h"
#include "third_party/blink/renderer/core/dom/attribute_part.h"
#include "third_party/blink/renderer/core/dom/child_node_part.h"
#include "third_party/blink/renderer/core/dom/comment.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
#include "third_party/blink/renderer/core/dom/document_part_root.h"
#include "third_party/blink/renderer/core/dom/document_type.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/element_traversal.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_part.h"
#include "third_party/blink/renderer/core/dom/template_content_document_fragment.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/dom/throw_on_dynamic_markup_insertion_count_incrementer.h"
#include "third_party/blink/renderer/core/execution_context/agent.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_client.h"
#include "third_party/blink/renderer/core/html/custom/ce_reactions_scope.h"
#include "third_party/blink/renderer/core/html/custom/custom_element.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_definition.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_descriptor.h"
#include "third_party/blink/renderer/core/html/custom/custom_element_registry.h"
#include "third_party/blink/renderer/core/html/forms/form_associated.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/html_html_element.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/html_script_element.h"
#include "third_party/blink/renderer/core/html/html_style_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_parser_idioms.h"
#include "third_party/blink/renderer/core/html/parser/html_parser_reentry_permit.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_element_factory.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/script/ignore_destructive_write_count_incrementer.h"
#include "third_party/blink/renderer/core/svg/svg_script_element.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/scheduler/public/event_loop.h"
#include "third_party/blink/renderer/platform/text/text_break_iterator.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
void HTMLConstructionSite::SetAttributes(Element* element,
AtomicHTMLToken* token) { … }
static bool HasImpliedEndTag(const HTMLStackItem* item) { … }
static bool ShouldUseLengthLimit(const ContainerNode& node) { … }
static unsigned NextTextBreakPositionForContainer(
const ContainerNode& node,
unsigned current_position,
unsigned string_length,
std::optional<unsigned>& length_limit) { … }
static inline WhitespaceMode RecomputeWhiteSpaceMode(
const StringView& string_view) { … }
enum class RecomputeMode { … };
static String CheckWhitespaceAndConvertToString(const StringView& string,
WhitespaceMode whitespace_mode,
RecomputeMode recompute_mode) { … }
static String TryCanonicalizeString(const StringView& string,
WhitespaceMode mode) { … }
static inline void Insert(HTMLConstructionSiteTask& task) { … }
static inline void ExecuteInsertTask(HTMLConstructionSiteTask& task) { … }
static inline unsigned TextFitsInContainer(const ContainerNode& node,
unsigned length) { … }
static inline void ExecuteInsertTextTask(HTMLConstructionSiteTask& task) { … }
static inline void ExecuteReparentTask(HTMLConstructionSiteTask& task) { … }
static inline void ExecuteInsertAlreadyParsedChildTask(
HTMLConstructionSiteTask& task) { … }
static inline void ExecuteTakeAllChildrenTask(HTMLConstructionSiteTask& task) { … }
void HTMLConstructionSite::ExecuteTask(HTMLConstructionSiteTask& task) { … }
static unsigned FindBreakIndexBetween(const StringBuilder& string,
unsigned current_position,
unsigned proposed_break_index) { … }
void HTMLConstructionSite::FlushPendingText() { … }
void HTMLConstructionSite::QueueTask(const HTMLConstructionSiteTask& task,
bool flush_pending_text) { … }
void HTMLConstructionSite::AttachLater(ContainerNode* parent,
Node* child,
const DOMPartsNeeded& dom_parts_needed,
bool self_closing) { … }
void HTMLConstructionSite::ExecuteQueuedTasks() { … }
HTMLConstructionSite::HTMLConstructionSite(
HTMLParserReentryPermit* reentry_permit,
Document& document,
ParserContentPolicy parser_content_policy,
DocumentFragment* fragment,
Element* context_element)
: … { … }
HTMLConstructionSite::~HTMLConstructionSite() { … }
void HTMLConstructionSite::Trace(Visitor* visitor) const { … }
void HTMLConstructionSite::Detach() { … }
HTMLFormElement* HTMLConstructionSite::TakeForm() { … }
void HTMLConstructionSite::InsertHTMLHtmlStartTagBeforeHTML(
AtomicHTMLToken* token) { … }
void HTMLConstructionSite::MergeAttributesFromTokenIntoElement(
AtomicHTMLToken* token,
Element* element) { … }
void HTMLConstructionSite::InsertHTMLHtmlStartTagInBody(
AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertHTMLBodyStartTagInBody(
AtomicHTMLToken* token) { … }
void HTMLConstructionSite::SetDefaultCompatibilityMode() { … }
void HTMLConstructionSite::SetCompatibilityMode(
Document::CompatibilityMode mode) { … }
void HTMLConstructionSite::SetCompatibilityModeFromDoctype(
html_names::HTMLTag tag,
const String& public_id,
const String& system_id) { … }
void HTMLConstructionSite::ProcessEndOfFile() { … }
void HTMLConstructionSite::FinishedParsing() { … }
void HTMLConstructionSite::InsertDoctype(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertComment(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertDOMPart(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertCommentOnDocument(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertCommentOnHTMLHtmlElement(
AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertHTMLHeadElement(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertHTMLBodyElement(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertHTMLFormElement(AtomicHTMLToken* token,
bool is_demoted) { … }
void HTMLConstructionSite::InsertHTMLTemplateElement(
AtomicHTMLToken* token,
String declarative_shadow_root_mode) { … }
void HTMLConstructionSite::InsertHTMLElement(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertSelfClosingHTMLElementDestroyingToken(
AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertFormattingElement(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertScriptElement(AtomicHTMLToken* token) { … }
void HTMLConstructionSite::InsertForeignElement(
AtomicHTMLToken* token,
const AtomicString& namespace_uri) { … }
void HTMLConstructionSite::InsertTextNode(const StringView& string,
WhitespaceMode whitespace_mode) { … }
void HTMLConstructionSite::Reparent(HTMLStackItem* new_parent,
HTMLStackItem* child) { … }
void HTMLConstructionSite::InsertAlreadyParsedChild(HTMLStackItem* new_parent,
HTMLStackItem* child) { … }
void HTMLConstructionSite::TakeAllChildren(HTMLStackItem* new_parent,
HTMLStackItem* old_parent) { … }
CreateElementFlags HTMLConstructionSite::GetCreateElementFlags() const { … }
Document& HTMLConstructionSite::OwnerDocumentForCurrentNode() { … }
CustomElementDefinition* HTMLConstructionSite::LookUpCustomElementDefinition(
Document& document,
const QualifiedName& tag_name,
const AtomicString& is) { … }
Element* HTMLConstructionSite::CreateElement(
AtomicHTMLToken* token,
const AtomicString& namespace_uri) { … }
HTMLStackItem* HTMLConstructionSite::CreateElementFromSavedToken(
HTMLStackItem* item) { … }
bool HTMLConstructionSite::IndexOfFirstUnopenFormattingElement(
unsigned& first_unopen_element_index) const { … }
void HTMLConstructionSite::ReconstructTheActiveFormattingElements() { … }
void HTMLConstructionSite::GenerateImpliedEndTagsWithExclusion(
const HTMLTokenName& name) { … }
void HTMLConstructionSite::GenerateImpliedEndTags() { … }
bool HTMLConstructionSite::InQuirksMode() { … }
void HTMLConstructionSite::FindFosterSite(HTMLConstructionSiteTask& task) { … }
bool HTMLConstructionSite::ShouldFosterParent() const { … }
void HTMLConstructionSite::FosterParent(Node* node) { … }
void HTMLConstructionSite::FinishedTemplateElement(
DocumentFragment* content_fragment) { … }
HTMLConstructionSite::PendingDOMParts::PendingDOMParts(
ContainerNode* attachment_root) { … }
void HTMLConstructionSite::PendingDOMParts::AddChildNodePartStart(
Node& previous_sibling,
Vector<String> metadata) { … }
void HTMLConstructionSite::PendingDOMParts::AddChildNodePartEnd(
Node& next_sibling) { … }
void HTMLConstructionSite::PendingDOMParts::ConstructDOMPartsIfNeeded(
Node& last_node,
const DOMPartsNeeded& dom_parts_needed) { … }
PartRoot* HTMLConstructionSite::PendingDOMParts::CurrentPartRoot() const { … }
void HTMLConstructionSite::PendingDOMParts::PushPartRoot(PartRoot* root) { … }
PartRoot* HTMLConstructionSite::PendingDOMParts::PopPartRoot() { … }
void HTMLConstructionSite::PendingText::Trace(Visitor* visitor) const { … }
void HTMLConstructionSite::PendingDOMParts::Trace(Visitor* visitor) const { … }
}