ladybird/Libraries/LibWeb/HTML/Parser/SpeculativeHTMLParser.h
Andreas Kling 936bb9ca53 LibWeb: Use Rust preload scanner
Replace the C++ speculative HTML parser token walk with the Rust
preload scanner. Keep URL resolution, duplicate suppression, and fetch
issuance in C++ so the scanner only emits base href updates and fetch
candidates.

Use the scanner callback result to stop iteration when the speculative
parser has been stopped.

Update parser comments that still described speculative mock element
production.
2026-05-18 00:23:52 +02:00

44 lines
1.1 KiB
C++

/*
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/String.h>
#include <LibGC/Ptr.h>
#include <LibJS/Heap/Cell.h>
#include <LibURL/URL.h>
#include <LibWeb/Forward.h>
struct RustFfiPreloadScannerEntry;
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/parsing.html#speculative-html-parser
class SpeculativeHTMLParser final : public JS::Cell {
GC_CELL(SpeculativeHTMLParser, JS::Cell);
GC_DECLARE_ALLOCATOR(SpeculativeHTMLParser);
public:
static GC::Ref<SpeculativeHTMLParser> create(JS::Realm&, GC::Ref<DOM::Document>, String pending_input, URL::URL base_url);
virtual ~SpeculativeHTMLParser() override;
void run();
void stop();
private:
SpeculativeHTMLParser(GC::Ref<DOM::Document>, String pending_input, URL::URL base_url);
virtual void visit_edges(JS::Cell::Visitor&) override;
void process_preload_scanner_entry(RustFfiPreloadScannerEntry const&);
GC::Ref<DOM::Document> m_document;
String m_input;
URL::URL m_base_url;
bool m_stopped { false };
};
}