LibWeb: Indicate documents are for fragment parsing during construction

This will allow testing if they are for fragment parsing during methods
invoked from Document::initialize.
This commit is contained in:
Timothy Flynn 2024-07-31 12:02:38 -04:00 committed by Andreas Kling
commit c838ca78c8
Notes: github-actions[bot] 2024-08-01 09:36:56 +00:00
3 changed files with 18 additions and 9 deletions

View file

@ -93,9 +93,15 @@ public:
HTML
};
enum class TemporaryDocumentForFragmentParsing {
No,
Yes,
};
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> create_and_initialize(Type, String content_type, HTML::NavigationParams const&);
[[nodiscard]] static JS::NonnullGCPtr<Document> create(JS::Realm&, URL::URL const& url = "about:blank"sv);
[[nodiscard]] static JS::NonnullGCPtr<Document> create_for_fragment_parsing(JS::Realm&);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<Document>> construct_impl(JS::Realm&);
virtual ~Document() override;
@ -447,8 +453,7 @@ public:
void set_parser(Badge<HTML::HTMLParser>, HTML::HTMLParser&);
void detach_parser(Badge<HTML::HTMLParser>);
void set_is_temporary_document_for_fragment_parsing(Badge<HTML::HTMLParser>) { m_temporary_document_for_fragment_parsing = true; }
[[nodiscard]] bool is_temporary_document_for_fragment_parsing() const { return m_temporary_document_for_fragment_parsing; }
[[nodiscard]] bool is_temporary_document_for_fragment_parsing() const { return m_temporary_document_for_fragment_parsing == TemporaryDocumentForFragmentParsing::Yes; }
static bool is_valid_name(String const&);
@ -684,7 +689,7 @@ protected:
virtual void visit_edges(Cell::Visitor&) override;
virtual void finalize() override;
Document(JS::Realm&, URL::URL const&);
Document(JS::Realm&, URL::URL const&, TemporaryDocumentForFragmentParsing = TemporaryDocumentForFragmentParsing::No);
private:
// ^HTML::GlobalEventHandlers
@ -889,7 +894,7 @@ private:
RefPtr<Core::Timer> m_active_refresh_timer;
bool m_temporary_document_for_fragment_parsing { false };
TemporaryDocumentForFragmentParsing m_temporary_document_for_fragment_parsing { TemporaryDocumentForFragmentParsing::No };
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry
JS::GCPtr<HTML::SessionHistoryEntry> m_latest_entry;