mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:57:35 +00:00
LibWeb: Store HTML document ready state as an enum
This commit is contained in:
parent
c4ccbc5b83
commit
8496024756
4 changed files with 39 additions and 6 deletions
|
@ -897,8 +897,23 @@ void Document::set_active_element(Element* element)
|
|||
m_layout_root->set_needs_display();
|
||||
}
|
||||
|
||||
void Document::set_ready_state(const String& ready_state)
|
||||
String Document::ready_state() const
|
||||
{
|
||||
switch (m_ready_state) {
|
||||
case HTML::DocumentReadyState::Loading:
|
||||
return "loading"sv;
|
||||
case HTML::DocumentReadyState::Interactive:
|
||||
return "interactive"sv;
|
||||
case HTML::DocumentReadyState::Complete:
|
||||
return "complete"sv;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void Document::set_ready_state(HTML::DocumentReadyState ready_state)
|
||||
{
|
||||
if (m_ready_state == ready_state)
|
||||
return;
|
||||
m_ready_state = ready_state;
|
||||
dispatch_event(Event::create(HTML::EventNames::readystatechange));
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/DOM/NonElementParentNode.h>
|
||||
#include <LibWeb/DOM/ParentNode.h>
|
||||
#include <LibWeb/HTML/DocumentReadyState.h>
|
||||
#include <LibWeb/HTML/HTMLScriptElement.h>
|
||||
#include <LibWeb/HTML/History.h>
|
||||
|
||||
|
@ -226,8 +227,8 @@ public:
|
|||
const Document* associated_inert_template_document() const { return m_associated_inert_template_document; }
|
||||
void set_associated_inert_template_document(Document& document) { m_associated_inert_template_document = document; }
|
||||
|
||||
const String& ready_state() const { return m_ready_state; }
|
||||
void set_ready_state(const String&);
|
||||
String ready_state() const;
|
||||
void set_ready_state(HTML::DocumentReadyState);
|
||||
|
||||
void ref_from_node(Badge<Node>)
|
||||
{
|
||||
|
@ -358,7 +359,7 @@ private:
|
|||
bool m_created_for_appropriate_template_contents { false };
|
||||
RefPtr<Document> m_associated_inert_template_document;
|
||||
|
||||
String m_ready_state { "loading" };
|
||||
HTML::DocumentReadyState m_ready_state { HTML::DocumentReadyState::Loading };
|
||||
String m_content_type { "application/xml" };
|
||||
Optional<String> m_encoding;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue