chromium/third_party/blink/renderer/core/html/parser/html_construction_site.cc

/*
 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
 * Copyright (C) 2011 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY GOOGLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL GOOGLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#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 {};

// Strings composed entirely of whitespace are likely to be repeated. Turn them
// into AtomicString so we share a single string for each.
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) {}

// This is only needed for TextDocuments where we might have text nodes
// approaching the default length limit (~64k) and we don't want to break a text
// node in the middle of a combining character.
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() {}

// "look up a custom element definition" for a token
// https://html.spec.whatwg.org/C/#look-up-a-custom-element-definition
// static
CustomElementDefinition* HTMLConstructionSite::LookUpCustomElementDefinition(
    Document& document,
    const QualifiedName& tag_name,
    const AtomicString& is) {}

// "create an element for a token"
// https://html.spec.whatwg.org/C/#create-an-element-for-the-token
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() {}

// Adjusts |task| to match the "adjusted insertion location" determined by the
// foster parenting algorithm, laid out as the substeps of step 2 of
// https://html.spec.whatwg.org/C/#appropriate-place-for-inserting-a-node
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 {}

}  // namespace blink