1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 07:47:37 +00:00

LibWeb: Move DOM classes into the Web::DOM namespace

LibWeb keeps growing and the Web namespace is filling up fast.
Let's put DOM stuff into Web::DOM, just like we already started doing
with SVG stuff in Web::SVG.
This commit is contained in:
Andreas Kling 2020-07-26 19:37:56 +02:00
parent 96d13f75cf
commit 11ff9d0f17
178 changed files with 516 additions and 523 deletions

View file

@ -40,14 +40,14 @@ NonnullRefPtr<IRCLogBuffer> IRCLogBuffer::create()
IRCLogBuffer::IRCLogBuffer()
{
m_document = adopt(*new Web::Document);
m_document->append_child(adopt(*new Web::DocumentType(document())));
m_document = adopt(*new Web::DOM::Document);
m_document->append_child(adopt(*new Web::DOM::DocumentType(document())));
auto html_element = create_element(document(), "html");
m_document->append_child(html_element);
auto head_element = create_element(document(), "head");
html_element->append_child(head_element);
auto style_element = create_element(document(), "style");
style_element->append_child(adopt(*new Web::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
style_element->append_child(adopt(*new Web::DOM::Text(document(), "div { font-family: Csilla; font-weight: lighter; }")));
head_element->append_child(style_element);
auto body_element = create_element(document(), "body");
html_element->append_child(body_element);
@ -76,7 +76,7 @@ void IRCLogBuffer::add_message(char prefix, const String& name, const String& te
escape_html_entities(nick_string).characters(),
escape_html_entities(text).characters());
auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div);
auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
wrapper->set_inner_html(html);
m_container_element->append_child(wrapper);
@ -90,7 +90,7 @@ void IRCLogBuffer::add_message(const String& text, Color color)
"<span>%s</span>",
timestamp_string().characters(),
escape_html_entities(text).characters());
auto wrapper = Web::create_element(*m_document, Web::HTML::TagNames::div);
auto wrapper = Web::DOM::create_element(*m_document, Web::HTML::TagNames::div);
wrapper->set_attribute(Web::HTML::AttributeNames::style, String::format("color: %s", color.to_string().characters()));
wrapper->set_inner_html(html);
m_container_element->append_child(wrapper);

View file

@ -49,11 +49,11 @@ public:
void add_message(const String& text, Color = Color::Black);
void dump() const;
const Web::Document& document() const { return *m_document; }
Web::Document& document() { return *m_document; }
const Web::DOM::Document& document() const { return *m_document; }
Web::DOM::Document& document() { return *m_document; }
private:
IRCLogBuffer();
RefPtr<Web::Document> m_document;
RefPtr<Web::Element> m_container_element;
RefPtr<Web::DOM::Document> m_document;
RefPtr<Web::DOM::Element> m_container_element;
};

View file

@ -214,7 +214,7 @@ IRCWindow::~IRCWindow()
void IRCWindow::set_log_buffer(const IRCLogBuffer& log_buffer)
{
m_log_buffer = &log_buffer;
m_page_view->set_document(const_cast<Web::Document*>(&log_buffer.document()));
m_page_view->set_document(const_cast<Web::DOM::Document*>(&log_buffer.document()));
}
bool IRCWindow::is_active() const