mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:37:45 +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:
parent
96d13f75cf
commit
11ff9d0f17
178 changed files with 516 additions and 523 deletions
|
@ -47,13 +47,13 @@ ConsoleWidget::ConsoleWidget()
|
|||
set_layout<GUI::VerticalBoxLayout>();
|
||||
set_fill_with_background_color(true);
|
||||
|
||||
auto base_document = adopt(*new Web::Document);
|
||||
base_document->append_child(adopt(*new Web::DocumentType(base_document)));
|
||||
auto html_element = create_element(base_document, "html");
|
||||
auto base_document = adopt(*new Web::DOM::Document);
|
||||
base_document->append_child(adopt(*new Web::DOM::DocumentType(base_document)));
|
||||
auto html_element = Web::DOM::create_element(base_document, "html");
|
||||
base_document->append_child(html_element);
|
||||
auto head_element = create_element(base_document, "head");
|
||||
auto head_element = Web::DOM::create_element(base_document, "head");
|
||||
html_element->append_child(head_element);
|
||||
auto body_element = create_element(base_document, "body");
|
||||
auto body_element = Web::DOM::create_element(base_document, "body");
|
||||
html_element->append_child(body_element);
|
||||
m_output_container = body_element;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
RefPtr<GUI::TextBox> m_input;
|
||||
RefPtr<Web::PageView> m_output_view;
|
||||
RefPtr<Web::Element> m_output_container;
|
||||
RefPtr<Web::DOM::Element> m_output_container;
|
||||
WeakPtr<JS::Interpreter> m_interpreter;
|
||||
OwnPtr<BrowserConsoleClient> m_console_client;
|
||||
};
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
|
||||
namespace Browser {
|
||||
|
||||
void InspectorWidget::set_inspected_node(Web::Node* node)
|
||||
void InspectorWidget::set_inspected_node(Web::DOM::Node* node)
|
||||
{
|
||||
m_document->set_inspected_node(node);
|
||||
if (node && node->is_element()) {
|
||||
auto& element = downcast<Web::Element>(*node);
|
||||
auto& element = downcast<Web::DOM::Element>(*node);
|
||||
if (element.resolved_style()) {
|
||||
m_style_table_view->set_model(Web::StylePropertiesModel::create(*element.resolved_style()));
|
||||
m_computed_style_table_view->set_model(Web::StylePropertiesModel::create(*element.computed_style()));
|
||||
|
@ -62,7 +62,7 @@ InspectorWidget::InspectorWidget()
|
|||
|
||||
m_dom_tree_view = top_tab_widget.add_tab<GUI::TreeView>("DOM");
|
||||
m_dom_tree_view->on_selection = [this](auto& index) {
|
||||
auto* node = static_cast<Web::Node*>(index.internal_data());
|
||||
auto* node = static_cast<Web::DOM::Node*>(index.internal_data());
|
||||
set_inspected_node(node);
|
||||
};
|
||||
|
||||
|
@ -82,7 +82,7 @@ InspectorWidget::~InspectorWidget()
|
|||
{
|
||||
}
|
||||
|
||||
void InspectorWidget::set_document(Web::Document* document)
|
||||
void InspectorWidget::set_document(Web::DOM::Document* document)
|
||||
{
|
||||
if (m_document == document)
|
||||
return;
|
||||
|
|
|
@ -36,18 +36,18 @@ class InspectorWidget final : public GUI::Widget {
|
|||
public:
|
||||
virtual ~InspectorWidget();
|
||||
|
||||
void set_document(Web::Document*);
|
||||
void set_document(Web::DOM::Document*);
|
||||
|
||||
private:
|
||||
InspectorWidget();
|
||||
|
||||
void set_inspected_node(Web::Node*);
|
||||
void set_inspected_node(Web::DOM::Node*);
|
||||
|
||||
RefPtr<GUI::TreeView> m_dom_tree_view;
|
||||
RefPtr<GUI::TreeView> m_layout_tree_view;
|
||||
RefPtr<GUI::TableView> m_style_table_view;
|
||||
RefPtr<GUI::TableView> m_computed_style_table_view;
|
||||
RefPtr<Web::Document> m_document;
|
||||
RefPtr<Web::DOM::Document> m_document;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue