mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-06 16:19:40 +00:00
LibGC+Everywhere: Factor out a LibGC from LibJS
Resulting in a massive rename across almost everywhere! Alongside the namespace change, we now have the following names: * JS::NonnullGCPtr -> GC::Ref * JS::GCPtr -> GC::Ptr * JS::HeapFunction -> GC::Function * JS::CellImpl -> GC::Cell * JS::Handle -> GC::Root
This commit is contained in:
parent
ce23efc5f6
commit
f87041bf3a
Notes:
github-actions[bot]
2024-11-15 13:50:17 +00:00
Author: https://github.com/shannonbooth
Commit: f87041bf3a
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2345
1722 changed files with 9939 additions and 9906 deletions
|
@ -95,7 +95,7 @@ Optional<StringView> extract_character_encoding_from_meta_element(ByteString con
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#concept-get-attributes-when-sniffing
|
||||
JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document& document, ByteBuffer const& input, size_t& position)
|
||||
GC::Ptr<DOM::Attr> prescan_get_attribute(DOM::Document& document, ByteBuffer const& input, size_t& position)
|
||||
{
|
||||
// 1. If the byte at position is one of 0x09 (HT), 0x0A (LF), 0x0C (FF), 0x0D (CR), 0x20 (SP), or 0x2F (/) then advance position to the next byte and redo this step.
|
||||
if (!prescan_skip_whitespace_and_slashes(input, position))
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
@ -17,7 +17,7 @@ bool prescan_should_abort(ByteBuffer const& input, size_t const& position);
|
|||
bool prescan_is_whitespace_or_slash(u8 const& byte);
|
||||
bool prescan_skip_whitespace_and_slashes(ByteBuffer const& input, size_t& position);
|
||||
Optional<StringView> extract_character_encoding_from_meta_element(ByteString const&);
|
||||
JS::GCPtr<DOM::Attr> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position);
|
||||
GC::Ptr<DOM::Attr> prescan_get_attribute(DOM::Document&, ByteBuffer const& input, size_t& position);
|
||||
Optional<ByteString> run_prescan_byte_stream_algorithm(DOM::Document&, ByteBuffer const& input);
|
||||
Optional<ByteString> run_bom_sniff(ByteBuffer const& input);
|
||||
ByteString run_encoding_sniffing_algorithm(DOM::Document&, ByteBuffer const& input, Optional<MimeSniff::MimeType> maybe_mime_type = {});
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
namespace Web::HTML {
|
||||
|
||||
JS_DEFINE_ALLOCATOR(HTMLParser);
|
||||
GC_DEFINE_ALLOCATOR(HTMLParser);
|
||||
|
||||
static inline void log_parse_error(SourceLocation const& location = SourceLocation::current())
|
||||
{
|
||||
|
@ -246,7 +246,7 @@ void HTMLParser::run(const URL::URL& url, HTMLTokenizer::StopAtInsertionPoint st
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#the-end
|
||||
void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTMLParser> parser)
|
||||
void HTMLParser::the_end(GC::Ref<DOM::Document> document, GC::Ptr<HTMLParser> parser)
|
||||
{
|
||||
auto& heap = document->heap();
|
||||
|
||||
|
@ -300,7 +300,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
|||
while (!document->scripts_to_execute_when_parsing_has_finished().is_empty()) {
|
||||
// 1. Spin the event loop until the first script in the list of scripts that will execute when the document has finished parsing
|
||||
// has its "ready to be parser-executed" flag set and the parser's Document has no style sheet that is blocking scripts.
|
||||
main_thread_event_loop().spin_until(JS::create_heap_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
return document->scripts_to_execute_when_parsing_has_finished().first()->is_ready_to_be_parser_executed()
|
||||
&& !document->has_a_style_sheet_that_is_blocking_scripts();
|
||||
}));
|
||||
|
@ -313,7 +313,7 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
|||
}
|
||||
|
||||
// 6. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following substeps:
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, JS::create_heap_function(heap, [document = document] {
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(heap, [document = document] {
|
||||
// 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||
document->load_timing_info().dom_content_loaded_event_start_time = HighResolutionTime::current_high_resolution_time(relevant_global_object(*document));
|
||||
|
||||
|
@ -331,17 +331,17 @@ void HTMLParser::the_end(JS::NonnullGCPtr<DOM::Document> document, JS::GCPtr<HTM
|
|||
}));
|
||||
|
||||
// 7. Spin the event loop until the set of scripts that will execute as soon as possible and the list of scripts that will execute in order as soon as possible are empty.
|
||||
main_thread_event_loop().spin_until(JS::create_heap_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
return document->scripts_to_execute_as_soon_as_possible().is_empty();
|
||||
}));
|
||||
|
||||
// 8. Spin the event loop until there is nothing that delays the load event in the Document.
|
||||
main_thread_event_loop().spin_until(JS::create_heap_function(heap, [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap, [&] {
|
||||
return !document->anything_is_delaying_the_load_event();
|
||||
}));
|
||||
|
||||
// 9. Queue a global task on the DOM manipulation task source given the Document's relevant global object to run the following steps:
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, JS::create_heap_function(document->heap(), [document = document] {
|
||||
queue_global_task(HTML::Task::Source::DOMManipulation, *document, GC::create_function(document->heap(), [document = document] {
|
||||
// 1. Update the current document readiness to "complete".
|
||||
document->update_readiness(HTML::DocumentReadyState::Complete);
|
||||
|
||||
|
@ -610,7 +610,7 @@ AnythingElse:
|
|||
return;
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Element> HTMLParser::current_node()
|
||||
GC::Ptr<DOM::Element> HTMLParser::current_node()
|
||||
{
|
||||
if (m_stack_of_open_elements.is_empty())
|
||||
return nullptr;
|
||||
|
@ -618,7 +618,7 @@ JS::GCPtr<DOM::Element> HTMLParser::current_node()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#adjusted-current-node
|
||||
JS::GCPtr<DOM::Element> HTMLParser::adjusted_current_node()
|
||||
GC::Ptr<DOM::Element> HTMLParser::adjusted_current_node()
|
||||
{
|
||||
// The adjusted current node is the context element if the parser was created as part of the
|
||||
// HTML fragment parsing algorithm and the stack of open elements has only one element in it
|
||||
|
@ -630,7 +630,7 @@ JS::GCPtr<DOM::Element> HTMLParser::adjusted_current_node()
|
|||
return current_node();
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Element> HTMLParser::node_before_current_node()
|
||||
GC::Ptr<DOM::Element> HTMLParser::node_before_current_node()
|
||||
{
|
||||
if (m_stack_of_open_elements.elements().size() < 2)
|
||||
return nullptr;
|
||||
|
@ -638,7 +638,7 @@ JS::GCPtr<DOM::Element> HTMLParser::node_before_current_node()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#appropriate-place-for-inserting-a-node
|
||||
HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_inserting_node(JS::GCPtr<DOM::Element> override_target)
|
||||
HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_inserting_node(GC::Ptr<DOM::Element> override_target)
|
||||
{
|
||||
// 1. If there was an override target specified, then let target be the override target.
|
||||
auto& target = override_target ? *override_target.ptr() : *current_node();
|
||||
|
@ -694,13 +694,13 @@ HTMLParser::AdjustedInsertionLocation HTMLParser::find_appropriate_place_for_ins
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token
|
||||
JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Optional<FlyString> const& namespace_, DOM::Node& intended_parent)
|
||||
GC::Ref<DOM::Element> HTMLParser::create_element_for(HTMLToken const& token, Optional<FlyString> const& namespace_, DOM::Node& intended_parent)
|
||||
{
|
||||
// FIXME: 1. If the active speculative HTML parser is not null, then return the result of creating a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
|
||||
// FIXME: 2. Otherwise, optionally create a speculative mock element given given namespace, the tag name of the given token, and the attributes of the given token.
|
||||
|
||||
// 3. Let document be intended parent's node document.
|
||||
JS::NonnullGCPtr<DOM::Document> document = intended_parent.document();
|
||||
GC::Ref<DOM::Document> document = intended_parent.document();
|
||||
|
||||
// 4. Let local name be the tag name of the token.
|
||||
auto const& local_name = token.tag_name();
|
||||
|
@ -784,7 +784,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::create_element_for(HTMLToken const& t
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#insert-a-foreign-element
|
||||
JS::NonnullGCPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, Optional<FlyString> const& namespace_, OnlyAddToElementStack only_add_to_element_stack)
|
||||
GC::Ref<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken const& token, Optional<FlyString> const& namespace_, OnlyAddToElementStack only_add_to_element_stack)
|
||||
{
|
||||
// 1. Let the adjusted insertion location be the appropriate place for inserting a node.
|
||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||
|
@ -805,7 +805,7 @@ JS::NonnullGCPtr<DOM::Element> HTMLParser::insert_foreign_element(HTMLToken cons
|
|||
return element;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<DOM::Element> HTMLParser::insert_html_element(HTMLToken const& token)
|
||||
GC::Ref<DOM::Element> HTMLParser::insert_html_element(HTMLToken const& token)
|
||||
{
|
||||
return insert_foreign_element(token, Namespace::HTML, OnlyAddToElementStack::No);
|
||||
}
|
||||
|
@ -1487,7 +1487,7 @@ HTMLParser::AdoptionAgencyAlgorithmOutcome HTMLParser::run_the_adoption_agency_a
|
|||
|
||||
// 7. Let furthest block be the topmost node in the stack of open elements that is lower in the stack than formatting element,
|
||||
// and is an element in the special category. There might not be one.
|
||||
JS::GCPtr<DOM::Element> furthest_block = m_stack_of_open_elements.topmost_special_node_below(*formatting_element);
|
||||
GC::Ptr<DOM::Element> furthest_block = m_stack_of_open_elements.topmost_special_node_below(*formatting_element);
|
||||
|
||||
// 8. If there is no furthest block
|
||||
if (!furthest_block) {
|
||||
|
@ -2011,7 +2011,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
|||
// 2. Initialize node to be the current node (the bottommost node of the stack).
|
||||
// 3. Loop: If node is an li element, then run these substeps:
|
||||
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
||||
JS::GCPtr<DOM::Element> node = m_stack_of_open_elements.elements()[i].ptr();
|
||||
GC::Ptr<DOM::Element> node = m_stack_of_open_elements.elements()[i].ptr();
|
||||
if (node->local_name() == HTML::TagNames::li) {
|
||||
// 1. Generate implied end tags, except for li elements.
|
||||
generate_implied_end_tags(HTML::TagNames::li);
|
||||
|
@ -2054,7 +2054,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
|||
// 4. If node is a dt element, then run these substeps:
|
||||
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
||||
// 1. Generate implied end tags, except for dd elements.
|
||||
JS::GCPtr<DOM::Element> node = m_stack_of_open_elements.elements()[i].ptr();
|
||||
GC::Ptr<DOM::Element> node = m_stack_of_open_elements.elements()[i].ptr();
|
||||
if (node->local_name() == HTML::TagNames::dd) {
|
||||
generate_implied_end_tags(HTML::TagNames::dd);
|
||||
// 2. If the current node is not a dd element, then this is a parse error.
|
||||
|
@ -2707,7 +2707,7 @@ void HTMLParser::handle_in_body(HTMLToken& token)
|
|||
if (token.is_end_tag()) {
|
||||
AnyOtherEndTag:
|
||||
// 1. Initialize node to be the current node (the bottommost node of the stack).
|
||||
JS::GCPtr<DOM::Element> node;
|
||||
GC::Ptr<DOM::Element> node;
|
||||
|
||||
// 2. Loop: If node is an HTML element with the same tag name as the token, then:
|
||||
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
||||
|
@ -2943,7 +2943,7 @@ void HTMLParser::handle_text(HTMLToken& token)
|
|||
perform_a_microtask_checkpoint();
|
||||
|
||||
// Let script be the current node (which will be a script element).
|
||||
JS::NonnullGCPtr<HTMLScriptElement> script = verify_cast<HTMLScriptElement>(*current_node());
|
||||
GC::Ref<HTMLScriptElement> script = verify_cast<HTMLScriptElement>(*current_node());
|
||||
|
||||
// Pop the current node off the stack of open elements.
|
||||
(void)m_stack_of_open_elements.pop();
|
||||
|
@ -3005,7 +3005,7 @@ void HTMLParser::handle_text(HTMLToken& token)
|
|||
if (m_document->has_a_style_sheet_that_is_blocking_scripts() || the_script->is_ready_to_be_parser_executed() == false) {
|
||||
// spin the event loop until the parser's Document has no style sheet that is blocking scripts
|
||||
// and the script's ready to be parser-executed becomes true.
|
||||
main_thread_event_loop().spin_until(JS::create_heap_function(heap(), [&] {
|
||||
main_thread_event_loop().spin_until(GC::create_function(heap(), [&] {
|
||||
return !m_document->has_a_style_sheet_that_is_blocking_scripts() && the_script->is_ready_to_be_parser_executed();
|
||||
}));
|
||||
}
|
||||
|
@ -4265,7 +4265,7 @@ void HTMLParser::process_using_the_rules_for_foreign_content(HTMLToken& token)
|
|||
// -> Any other end tag
|
||||
if (token.is_end_tag()) {
|
||||
// 1. Initialize node to be the current node (the bottommost node of the stack).
|
||||
JS::GCPtr<DOM::Element> node = current_node();
|
||||
GC::Ptr<DOM::Element> node = current_node();
|
||||
|
||||
// 2. If node's tag name, converted to ASCII lowercase, is not the same as the tag name of the token, then this is a parse error.
|
||||
if (node->tag_name().equals_ignoring_ascii_case(token.tag_name()))
|
||||
|
@ -4309,7 +4309,7 @@ void HTMLParser::reset_the_insertion_mode_appropriately()
|
|||
for (ssize_t i = m_stack_of_open_elements.elements().size() - 1; i >= 0; --i) {
|
||||
bool last = i == 0;
|
||||
// NOTE: When parsing fragments, we substitute the context element for the root of the stack of open elements.
|
||||
JS::GCPtr<DOM::Element> node;
|
||||
GC::Ptr<DOM::Element> node;
|
||||
if (last && m_parsing_fragment) {
|
||||
node = m_context_element.ptr();
|
||||
} else {
|
||||
|
@ -4423,7 +4423,7 @@ DOM::Document& HTMLParser::document()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-html-fragments
|
||||
Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup, AllowDeclarativeShadowRoots allow_declarative_shadow_roots)
|
||||
Vector<GC::Root<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& context_element, StringView markup, AllowDeclarativeShadowRoots allow_declarative_shadow_roots)
|
||||
{
|
||||
// 1. Create a new Document node, and mark it as being an HTML document.
|
||||
auto temp_document = DOM::Document::create_for_fragment_parsing(context_element.realm());
|
||||
|
@ -4515,21 +4515,21 @@ Vector<JS::Handle<DOM::Node>> HTMLParser::parse_html_fragment(DOM::Element& cont
|
|||
parser->run(context_element.document().url());
|
||||
|
||||
// 15. Return the child nodes of root, in tree order.
|
||||
Vector<JS::Handle<DOM::Node>> children;
|
||||
while (JS::GCPtr<DOM::Node> child = root->first_child()) {
|
||||
Vector<GC::Root<DOM::Node>> children;
|
||||
while (GC::Ptr<DOM::Node> child = root->first_child()) {
|
||||
MUST(root->remove_child(*child));
|
||||
context_element.document().adopt_node(*child);
|
||||
children.append(JS::make_handle(*child));
|
||||
children.append(GC::make_root(*child));
|
||||
}
|
||||
return children;
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& document)
|
||||
GC::Ref<HTMLParser> HTMLParser::create_for_scripting(DOM::Document& document)
|
||||
{
|
||||
return document.heap().allocate<HTMLParser>(document);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input, Optional<MimeSniff::MimeType> maybe_mime_type)
|
||||
GC::Ref<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Document& document, ByteBuffer const& input, Optional<MimeSniff::MimeType> maybe_mime_type)
|
||||
{
|
||||
if (document.has_encoding())
|
||||
return document.heap().allocate<HTMLParser>(document, input, document.encoding().value().to_byte_string());
|
||||
|
@ -4538,7 +4538,7 @@ JS::NonnullGCPtr<HTMLParser> HTMLParser::create_with_uncertain_encoding(DOM::Doc
|
|||
return document.heap().allocate<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, StringView encoding)
|
||||
GC::Ref<HTMLParser> HTMLParser::create(DOM::Document& document, StringView input, StringView encoding)
|
||||
{
|
||||
return document.heap().allocate<HTMLParser>(document, input, encoding);
|
||||
}
|
||||
|
@ -4574,7 +4574,7 @@ static String escape_string(StringView string, AttributeMode attribute_mode)
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-serialisation-algorithm
|
||||
String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableShadowRoots serializable_shadow_roots, Vector<JS::Handle<DOM::ShadowRoot>> const& shadow_roots, DOM::FragmentSerializationMode fragment_serialization_mode)
|
||||
String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableShadowRoots serializable_shadow_roots, Vector<GC::Root<DOM::ShadowRoot>> const& shadow_roots, DOM::FragmentSerializationMode fragment_serialization_mode)
|
||||
{
|
||||
// NOTE: Steps in this function are jumbled a bit to accommodate the Element.outerHTML API.
|
||||
// When called with FragmentSerializationMode::Outer, we will serialize the element itself,
|
||||
|
@ -4668,7 +4668,7 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node, SerializableSh
|
|||
|
||||
// The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as the node.
|
||||
VERIFY(node.is_element() || node.is_document() || node.is_document_fragment());
|
||||
JS::NonnullGCPtr<DOM::Node const> actual_node = node;
|
||||
GC::Ref<DOM::Node const> actual_node = node;
|
||||
|
||||
if (is<DOM::Element>(node)) {
|
||||
auto const& element = verify_cast<DOM::Element>(node);
|
||||
|
@ -5092,7 +5092,7 @@ void HTMLParser::abort()
|
|||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location
|
||||
void HTMLParser::insert_an_element_at_the_adjusted_insertion_location(JS::NonnullGCPtr<DOM::Element> element)
|
||||
void HTMLParser::insert_an_element_at_the_adjusted_insertion_location(GC::Ref<DOM::Element> element)
|
||||
{
|
||||
// 1. Let the adjusted insertion location be the appropriate place for inserting a node.
|
||||
auto adjusted_insertion_location = find_appropriate_place_for_inserting_node();
|
||||
|
|
|
@ -42,34 +42,34 @@ namespace Web::HTML {
|
|||
__ENUMERATE_INSERTION_MODE(AfterAfterFrameset)
|
||||
|
||||
class HTMLParser final : public JS::Cell {
|
||||
JS_CELL(HTMLParser, JS::Cell);
|
||||
JS_DECLARE_ALLOCATOR(HTMLParser);
|
||||
GC_CELL(HTMLParser, JS::Cell);
|
||||
GC_DECLARE_ALLOCATOR(HTMLParser);
|
||||
|
||||
friend class HTMLTokenizer;
|
||||
|
||||
public:
|
||||
~HTMLParser();
|
||||
|
||||
static JS::NonnullGCPtr<HTMLParser> create_for_scripting(DOM::Document&);
|
||||
static JS::NonnullGCPtr<HTMLParser> create_with_uncertain_encoding(DOM::Document&, ByteBuffer const& input, Optional<MimeSniff::MimeType> maybe_mime_type = {});
|
||||
static JS::NonnullGCPtr<HTMLParser> create(DOM::Document&, StringView input, StringView encoding);
|
||||
static GC::Ref<HTMLParser> create_for_scripting(DOM::Document&);
|
||||
static GC::Ref<HTMLParser> create_with_uncertain_encoding(DOM::Document&, ByteBuffer const& input, Optional<MimeSniff::MimeType> maybe_mime_type = {});
|
||||
static GC::Ref<HTMLParser> create(DOM::Document&, StringView input, StringView encoding);
|
||||
|
||||
void run(HTMLTokenizer::StopAtInsertionPoint = HTMLTokenizer::StopAtInsertionPoint::No);
|
||||
void run(const URL::URL&, HTMLTokenizer::StopAtInsertionPoint = HTMLTokenizer::StopAtInsertionPoint::No);
|
||||
|
||||
static void the_end(JS::NonnullGCPtr<DOM::Document>, JS::GCPtr<HTMLParser> = nullptr);
|
||||
static void the_end(GC::Ref<DOM::Document>, GC::Ptr<HTMLParser> = nullptr);
|
||||
|
||||
DOM::Document& document();
|
||||
enum class AllowDeclarativeShadowRoots {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
static Vector<JS::Handle<DOM::Node>> parse_html_fragment(DOM::Element& context_element, StringView, AllowDeclarativeShadowRoots = AllowDeclarativeShadowRoots::No);
|
||||
static Vector<GC::Root<DOM::Node>> parse_html_fragment(DOM::Element& context_element, StringView, AllowDeclarativeShadowRoots = AllowDeclarativeShadowRoots::No);
|
||||
enum class SerializableShadowRoots {
|
||||
No,
|
||||
Yes,
|
||||
};
|
||||
static String serialize_html_fragment(DOM::Node const&, SerializableShadowRoots, Vector<JS::Handle<DOM::ShadowRoot>> const&, DOM::FragmentSerializationMode = DOM::FragmentSerializationMode::Inner);
|
||||
static String serialize_html_fragment(DOM::Node const&, SerializableShadowRoots, Vector<GC::Root<DOM::ShadowRoot>> const&, DOM::FragmentSerializationMode = DOM::FragmentSerializationMode::Inner);
|
||||
|
||||
enum class InsertionMode {
|
||||
#define __ENUMERATE_INSERTION_MODE(mode) mode,
|
||||
|
@ -129,16 +129,16 @@ private:
|
|||
|
||||
void generate_implied_end_tags(FlyString const& exception = {});
|
||||
void generate_all_implied_end_tags_thoroughly();
|
||||
JS::NonnullGCPtr<DOM::Element> create_element_for(HTMLToken const&, Optional<FlyString> const& namespace_, DOM::Node& intended_parent);
|
||||
GC::Ref<DOM::Element> create_element_for(HTMLToken const&, Optional<FlyString> const& namespace_, DOM::Node& intended_parent);
|
||||
|
||||
struct AdjustedInsertionLocation {
|
||||
JS::GCPtr<DOM::Node> parent;
|
||||
JS::GCPtr<DOM::Node> insert_before_sibling;
|
||||
GC::Ptr<DOM::Node> parent;
|
||||
GC::Ptr<DOM::Node> insert_before_sibling;
|
||||
};
|
||||
|
||||
AdjustedInsertionLocation find_appropriate_place_for_inserting_node(JS::GCPtr<DOM::Element> override_target = nullptr);
|
||||
AdjustedInsertionLocation find_appropriate_place_for_inserting_node(GC::Ptr<DOM::Element> override_target = nullptr);
|
||||
|
||||
void insert_an_element_at_the_adjusted_insertion_location(JS::NonnullGCPtr<DOM::Element>);
|
||||
void insert_an_element_at_the_adjusted_insertion_location(GC::Ref<DOM::Element>);
|
||||
|
||||
DOM::Text* find_character_insertion_node();
|
||||
void flush_character_insertions();
|
||||
|
@ -146,11 +146,11 @@ private:
|
|||
No,
|
||||
Yes,
|
||||
};
|
||||
JS::NonnullGCPtr<DOM::Element> insert_foreign_element(HTMLToken const&, Optional<FlyString> const& namespace_, OnlyAddToElementStack);
|
||||
JS::NonnullGCPtr<DOM::Element> insert_html_element(HTMLToken const&);
|
||||
[[nodiscard]] JS::GCPtr<DOM::Element> current_node();
|
||||
[[nodiscard]] JS::GCPtr<DOM::Element> adjusted_current_node();
|
||||
[[nodiscard]] JS::GCPtr<DOM::Element> node_before_current_node();
|
||||
GC::Ref<DOM::Element> insert_foreign_element(HTMLToken const&, Optional<FlyString> const& namespace_, OnlyAddToElementStack);
|
||||
GC::Ref<DOM::Element> insert_html_element(HTMLToken const&);
|
||||
[[nodiscard]] GC::Ptr<DOM::Element> current_node();
|
||||
[[nodiscard]] GC::Ptr<DOM::Element> adjusted_current_node();
|
||||
[[nodiscard]] GC::Ptr<DOM::Element> node_before_current_node();
|
||||
void insert_character(u32 data);
|
||||
void insert_comment(HTMLToken&);
|
||||
void reconstruct_the_active_formatting_elements();
|
||||
|
@ -203,14 +203,14 @@ private:
|
|||
|
||||
JS::Realm& realm();
|
||||
|
||||
JS::GCPtr<DOM::Document> m_document;
|
||||
JS::GCPtr<HTMLHeadElement> m_head_element;
|
||||
JS::GCPtr<HTMLFormElement> m_form_element;
|
||||
JS::GCPtr<DOM::Element> m_context_element;
|
||||
GC::Ptr<DOM::Document> m_document;
|
||||
GC::Ptr<HTMLHeadElement> m_head_element;
|
||||
GC::Ptr<HTMLFormElement> m_form_element;
|
||||
GC::Ptr<DOM::Element> m_context_element;
|
||||
|
||||
Vector<HTMLToken> m_pending_table_character_tokens;
|
||||
|
||||
JS::GCPtr<DOM::Text> m_character_insertion_node;
|
||||
GC::Ptr<DOM::Text> m_character_insertion_node;
|
||||
StringBuilder m_character_insertion_builder;
|
||||
};
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Utf8View.h>
|
||||
#include <LibJS/Heap/GCPtr.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLToken.h>
|
||||
|
||||
|
@ -181,7 +181,7 @@ private:
|
|||
void restore_to(Utf8CodePointIterator const& new_iterator);
|
||||
HTMLToken::Position nth_last_position(size_t n = 0);
|
||||
|
||||
JS::GCPtr<HTMLParser> m_parser;
|
||||
GC::Ptr<HTMLParser> m_parser;
|
||||
|
||||
State m_state { State::Data };
|
||||
State m_return_state { State::Data };
|
||||
|
|
|
@ -78,7 +78,7 @@ void ListOfActiveFormattingElements::replace(DOM::Element& to_remove, DOM::Eleme
|
|||
{
|
||||
for (size_t i = 0; i < m_entries.size(); i++) {
|
||||
if (m_entries[i].element.ptr() == &to_remove)
|
||||
m_entries[i].element = JS::make_handle(to_add);
|
||||
m_entries[i].element = GC::make_root(to_add);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
struct Entry {
|
||||
bool is_marker() const { return !element; }
|
||||
|
||||
JS::GCPtr<DOM::Element> element;
|
||||
GC::Ptr<DOM::Element> element;
|
||||
};
|
||||
|
||||
bool is_empty() const { return m_entries.is_empty(); }
|
||||
|
|
|
@ -124,9 +124,9 @@ void StackOfOpenElements::pop_until_an_element_with_tag_name_has_been_popped(Fly
|
|||
(void)pop();
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Element> StackOfOpenElements::topmost_special_node_below(DOM::Element const& formatting_element)
|
||||
GC::Ptr<DOM::Element> StackOfOpenElements::topmost_special_node_below(DOM::Element const& formatting_element)
|
||||
{
|
||||
JS::GCPtr<DOM::Element> found_element = nullptr;
|
||||
GC::Ptr<DOM::Element> found_element = nullptr;
|
||||
for (auto& element : m_elements.in_reverse()) {
|
||||
if (element.ptr() == &formatting_element)
|
||||
break;
|
||||
|
@ -146,7 +146,7 @@ StackOfOpenElements::LastElementResult StackOfOpenElements::last_element_with_ta
|
|||
return { nullptr, -1 };
|
||||
}
|
||||
|
||||
JS::GCPtr<DOM::Element> StackOfOpenElements::element_immediately_above(DOM::Element const& target)
|
||||
GC::Ptr<DOM::Element> StackOfOpenElements::element_immediately_above(DOM::Element const& target)
|
||||
{
|
||||
bool found_target = false;
|
||||
for (auto& element : m_elements.in_reverse()) {
|
||||
|
@ -165,7 +165,7 @@ void StackOfOpenElements::remove(DOM::Element const& element)
|
|||
});
|
||||
}
|
||||
|
||||
void StackOfOpenElements::replace(DOM::Element const& to_remove, JS::NonnullGCPtr<DOM::Element> to_add)
|
||||
void StackOfOpenElements::replace(DOM::Element const& to_remove, GC::Ref<DOM::Element> to_add)
|
||||
{
|
||||
for (size_t i = 0; i < m_elements.size(); i++) {
|
||||
if (m_elements[i].ptr() == &to_remove) {
|
||||
|
@ -176,7 +176,7 @@ void StackOfOpenElements::replace(DOM::Element const& to_remove, JS::NonnullGCPt
|
|||
}
|
||||
}
|
||||
|
||||
void StackOfOpenElements::insert_immediately_below(JS::NonnullGCPtr<DOM::Element> element_to_add, DOM::Element const& target)
|
||||
void StackOfOpenElements::insert_immediately_below(GC::Ref<DOM::Element> element_to_add, DOM::Element const& target)
|
||||
{
|
||||
for (size_t i = 0; i < m_elements.size(); i++) {
|
||||
if (m_elements[i].ptr() == &target) {
|
||||
|
|
|
@ -26,11 +26,11 @@ public:
|
|||
DOM::Element& last() { return *m_elements.last(); }
|
||||
|
||||
bool is_empty() const { return m_elements.is_empty(); }
|
||||
void push(JS::NonnullGCPtr<DOM::Element> element) { m_elements.append(element); }
|
||||
JS::NonnullGCPtr<DOM::Element> pop() { return *m_elements.take_last(); }
|
||||
void push(GC::Ref<DOM::Element> element) { m_elements.append(element); }
|
||||
GC::Ref<DOM::Element> pop() { return *m_elements.take_last(); }
|
||||
void remove(DOM::Element const& element);
|
||||
void replace(DOM::Element const& to_remove, JS::NonnullGCPtr<DOM::Element> to_add);
|
||||
void insert_immediately_below(JS::NonnullGCPtr<DOM::Element> element_to_add, DOM::Element const& target);
|
||||
void replace(DOM::Element const& to_remove, GC::Ref<DOM::Element> to_add);
|
||||
void insert_immediately_below(GC::Ref<DOM::Element> element_to_add, DOM::Element const& target);
|
||||
|
||||
const DOM::Element& current_node() const { return *m_elements.last(); }
|
||||
DOM::Element& current_node() { return *m_elements.last(); }
|
||||
|
@ -51,14 +51,14 @@ public:
|
|||
|
||||
void pop_until_an_element_with_tag_name_has_been_popped(FlyString const& local_name);
|
||||
|
||||
JS::GCPtr<DOM::Element> topmost_special_node_below(DOM::Element const&);
|
||||
GC::Ptr<DOM::Element> topmost_special_node_below(DOM::Element const&);
|
||||
|
||||
struct LastElementResult {
|
||||
JS::GCPtr<DOM::Element> element;
|
||||
GC::Ptr<DOM::Element> element;
|
||||
ssize_t index;
|
||||
};
|
||||
LastElementResult last_element_with_tag_name(FlyString const&);
|
||||
JS::GCPtr<DOM::Element> element_immediately_above(DOM::Element const&);
|
||||
GC::Ptr<DOM::Element> element_immediately_above(DOM::Element const&);
|
||||
|
||||
void visit_edges(JS::Cell::Visitor&);
|
||||
|
||||
|
@ -66,7 +66,7 @@ private:
|
|||
bool has_in_scope_impl(FlyString const& tag_name, Vector<FlyString> const&) const;
|
||||
bool has_in_scope_impl(const DOM::Element& target_node, Vector<FlyString> const&) const;
|
||||
|
||||
Vector<JS::NonnullGCPtr<DOM::Element>> m_elements;
|
||||
Vector<GC::Ref<DOM::Element>> m_elements;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue