From f358f2255fec7228b7ddf510936a2b7a150e509e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 22 Nov 2020 14:46:36 +0100 Subject: [PATCH] LibWeb: Rename LayoutNode::node() => LayoutNode::dom_node() --- Applications/Browser/InspectorWidget.cpp | 2 +- Libraries/LibWeb/Dump.cpp | 12 ++++++------ Libraries/LibWeb/Layout/LayoutBlock.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutBox.cpp | 8 ++++---- Libraries/LibWeb/Layout/LayoutBreak.h | 2 +- Libraries/LibWeb/Layout/LayoutButton.cpp | 16 ++++++++-------- Libraries/LibWeb/Layout/LayoutButton.h | 4 ++-- Libraries/LibWeb/Layout/LayoutCanvas.cpp | 8 ++++---- Libraries/LibWeb/Layout/LayoutCanvas.h | 2 +- Libraries/LibWeb/Layout/LayoutCheckBox.cpp | 10 +++++----- Libraries/LibWeb/Layout/LayoutCheckBox.h | 4 ++-- Libraries/LibWeb/Layout/LayoutDocument.h | 2 +- Libraries/LibWeb/Layout/LayoutFrame.cpp | 14 +++++++------- Libraries/LibWeb/Layout/LayoutFrame.h | 4 ++-- Libraries/LibWeb/Layout/LayoutImage.cpp | 10 +++++----- Libraries/LibWeb/Layout/LayoutImage.h | 2 +- Libraries/LibWeb/Layout/LayoutNode.cpp | 10 +++++----- Libraries/LibWeb/Layout/LayoutNode.h | 8 ++++---- Libraries/LibWeb/Layout/LayoutReplaced.h | 4 ++-- Libraries/LibWeb/Layout/LayoutSVGGraphics.cpp | 2 +- Libraries/LibWeb/Layout/LayoutSVGPath.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutSVGPath.h | 2 +- Libraries/LibWeb/Layout/LayoutSVGSVG.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutSVGSVG.h | 2 +- Libraries/LibWeb/Layout/LayoutTableCell.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutText.cpp | 16 ++++++++-------- Libraries/LibWeb/Layout/LayoutText.h | 2 +- Libraries/LibWeb/LayoutTreeModel.cpp | 6 +++--- Libraries/LibWeb/Page/EventHandler.cpp | 14 +++++++------- Libraries/LibWeb/Painting/StackingContext.cpp | 2 +- 30 files changed, 92 insertions(+), 92 deletions(-) diff --git a/Applications/Browser/InspectorWidget.cpp b/Applications/Browser/InspectorWidget.cpp index 7d62193791..f1557a4045 100644 --- a/Applications/Browser/InspectorWidget.cpp +++ b/Applications/Browser/InspectorWidget.cpp @@ -69,7 +69,7 @@ InspectorWidget::InspectorWidget() m_layout_tree_view = top_tab_widget.add_tab("Layout"); m_layout_tree_view->on_selection = [this](auto& index) { auto* node = static_cast(index.internal_data()); - set_inspected_node(node->node()); + set_inspected_node(node->dom_node()); }; auto& bottom_tab_widget = splitter.add(); diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index 002e71795b..d2eb66758a 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -89,18 +89,18 @@ void dump_tree(const LayoutNode& layout_node) FlyString tag_name; if (layout_node.is_anonymous()) tag_name = "(anonymous)"; - else if (is(layout_node.node())) + else if (is(layout_node.dom_node())) tag_name = "#text"; - else if (is(layout_node.node())) + else if (is(layout_node.dom_node())) tag_name = "#document"; - else if (is(layout_node.node())) - tag_name = downcast(*layout_node.node()).local_name(); + else if (is(layout_node.dom_node())) + tag_name = downcast(*layout_node.dom_node()).local_name(); else tag_name = "???"; String identifier = ""; - if (layout_node.node() && is(*layout_node.node())) { - auto& element = downcast(*layout_node.node()); + if (layout_node.dom_node() && is(*layout_node.dom_node())) { + auto& element = downcast(*layout_node.dom_node()); StringBuilder builder; auto id = element.attribute(HTML::AttributeNames::id); if (!id.is_empty()) { diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index e673c31a58..b3b85ed931 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -49,7 +49,7 @@ LayoutBlock::~LayoutBlock() LayoutNode& LayoutBlock::inline_wrapper() { - if (!last_child() || !last_child()->is_block() || last_child()->node() != nullptr) { + if (!last_child() || !last_child()->is_block() || last_child()->dom_node() != nullptr) { append_child(adopt(*new LayoutBlock(document(), nullptr, style_for_anonymous_block()))); last_child()->set_children_are_inline(true); } @@ -80,7 +80,7 @@ void LayoutBlock::paint(PaintContext& context, PaintPhase phase) if (children_are_inline()) { for (auto& line_box : m_line_boxes) { for (auto& fragment : line_box.fragments()) { - auto* node = fragment.layout_node().node(); + auto* node = fragment.layout_node().dom_node(); if (!node) continue; auto* parent = node->parent_element(); diff --git a/Libraries/LibWeb/Layout/LayoutBox.cpp b/Libraries/LibWeb/Layout/LayoutBox.cpp index 80ee295d02..2935363896 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutBox.cpp @@ -208,7 +208,7 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase) LayoutNodeWithStyleAndBoxModelMetrics::paint(context, phase); - if (phase == PaintPhase::Overlay && node() && document().inspected_node() == node()) { + if (phase == PaintPhase::Overlay && dom_node() && document().inspected_node() == dom_node()) { auto content_rect = absolute_rect(); auto margin_box = box_model().margin_box(*this); @@ -223,7 +223,7 @@ void LayoutBox::paint(PaintContext& context, PaintPhase phase) context.painter().draw_rect(enclosing_int_rect(content_rect), Color::Magenta); } - if (phase == PaintPhase::FocusOutline && node() && node()->is_element() && downcast(*node()).is_focused()) { + if (phase == PaintPhase::FocusOutline && dom_node() && dom_node()->is_element() && downcast(*dom_node()).is_focused()) { context.painter().draw_rect(enclosing_int_rect(absolute_rect()), context.palette().focus_outline()); } } @@ -256,7 +256,7 @@ void LayoutBox::set_needs_display() bool LayoutBox::is_body() const { - return node() && node() == document().body(); + return dom_node() && dom_node() == document().body(); } void LayoutBox::set_offset(const Gfx::FloatPoint& offset) @@ -315,7 +315,7 @@ bool LayoutBox::establishes_stacking_context() const { if (!has_style()) return false; - if (node() == document().root()) + if (dom_node() == document().root()) return true; auto position = style().position(); auto z_index = style().z_index(); diff --git a/Libraries/LibWeb/Layout/LayoutBreak.h b/Libraries/LibWeb/Layout/LayoutBreak.h index 7f4d973c91..076c675109 100644 --- a/Libraries/LibWeb/Layout/LayoutBreak.h +++ b/Libraries/LibWeb/Layout/LayoutBreak.h @@ -36,7 +36,7 @@ public: LayoutBreak(DOM::Document&, HTML::HTMLBRElement&); virtual ~LayoutBreak() override; - const HTML::HTMLBRElement& node() const { return downcast(*LayoutNode::node()); } + const HTML::HTMLBRElement& dom_node() const { return downcast(*LayoutNode::dom_node()); } private: virtual bool is_break() const override { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutButton.cpp b/Libraries/LibWeb/Layout/LayoutButton.cpp index 3322894f64..d7533e63d6 100644 --- a/Libraries/LibWeb/Layout/LayoutButton.cpp +++ b/Libraries/LibWeb/Layout/LayoutButton.cpp @@ -46,7 +46,7 @@ LayoutButton::~LayoutButton() void LayoutButton::prepare_for_replaced_layout() { auto& font = specified_style().font(); - set_intrinsic_width(font.width(node().value()) + 20); + set_intrinsic_width(font.width(dom_node().value()) + 20); set_has_intrinsic_width(true); set_intrinsic_height(20); @@ -61,19 +61,19 @@ void LayoutButton::paint(PaintContext& context, PaintPhase phase) LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { - bool hovered = document().hovered_node() == &node(); - Gfx::StylePainter::paint_button(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::ButtonStyle::Normal, m_being_pressed, hovered, node().checked(), node().enabled()); + bool hovered = document().hovered_node() == &dom_node(); + Gfx::StylePainter::paint_button(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::ButtonStyle::Normal, m_being_pressed, hovered, dom_node().checked(), dom_node().enabled()); auto text_rect = enclosing_int_rect(absolute_rect()); if (m_being_pressed) text_rect.move_by(1, 1); - context.painter().draw_text(text_rect, node().value(), specified_style().font(), Gfx::TextAlignment::Center, context.palette().button_text()); + context.painter().draw_text(text_rect, dom_node().value(), specified_style().font(), Gfx::TextAlignment::Center, context.palette().button_text()); } } void LayoutButton::handle_mousedown(Badge, const Gfx::IntPoint&, unsigned button, unsigned) { - if (button != GUI::MouseButton::Left || !node().enabled()) + if (button != GUI::MouseButton::Left || !dom_node().enabled()) return; m_being_pressed = true; @@ -85,7 +85,7 @@ void LayoutButton::handle_mousedown(Badge, const Gfx::IntPoint&, u void LayoutButton::handle_mouseup(Badge, const Gfx::IntPoint& position, unsigned button, unsigned) { - if (!m_tracking_mouse || button != GUI::MouseButton::Left || !node().enabled()) + if (!m_tracking_mouse || button != GUI::MouseButton::Left || !dom_node().enabled()) return; // NOTE: Handling the click may run arbitrary JS, which could disappear this node. @@ -94,7 +94,7 @@ void LayoutButton::handle_mouseup(Badge, const Gfx::IntPoint& posi bool is_inside = enclosing_int_rect(absolute_rect()).contains(position); if (is_inside) - node().did_click_button({}); + dom_node().did_click_button({}); m_being_pressed = false; m_tracking_mouse = false; @@ -104,7 +104,7 @@ void LayoutButton::handle_mouseup(Badge, const Gfx::IntPoint& posi void LayoutButton::handle_mousemove(Badge, const Gfx::IntPoint& position, unsigned, unsigned) { - if (!m_tracking_mouse || !node().enabled()) + if (!m_tracking_mouse || !dom_node().enabled()) return; bool is_inside = enclosing_int_rect(absolute_rect()).contains(position); diff --git a/Libraries/LibWeb/Layout/LayoutButton.h b/Libraries/LibWeb/Layout/LayoutButton.h index 685e4d6722..5d6fa36b74 100644 --- a/Libraries/LibWeb/Layout/LayoutButton.h +++ b/Libraries/LibWeb/Layout/LayoutButton.h @@ -39,8 +39,8 @@ public: virtual void prepare_for_replaced_layout() override; virtual void paint(PaintContext&, PaintPhase) override; - const HTML::HTMLInputElement& node() const { return static_cast(LayoutReplaced::node()); } - HTML::HTMLInputElement& node() { return static_cast(LayoutReplaced::node()); } + const HTML::HTMLInputElement& dom_node() const { return static_cast(LayoutReplaced::dom_node()); } + HTML::HTMLInputElement& dom_node() { return static_cast(LayoutReplaced::dom_node()); } private: virtual const char* class_name() const override { return "LayoutButton"; } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.cpp b/Libraries/LibWeb/Layout/LayoutCanvas.cpp index e78b17c456..9a5cca4c82 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.cpp +++ b/Libraries/LibWeb/Layout/LayoutCanvas.cpp @@ -44,8 +44,8 @@ void LayoutCanvas::prepare_for_replaced_layout() { set_has_intrinsic_width(true); set_has_intrinsic_height(true); - set_intrinsic_width(node().width()); - set_intrinsic_height(node().height()); + set_intrinsic_width(dom_node().width()); + set_intrinsic_height(dom_node().height()); } void LayoutCanvas::paint(PaintContext& context, PaintPhase phase) @@ -60,8 +60,8 @@ void LayoutCanvas::paint(PaintContext& context, PaintPhase phase) if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect()))) return; - if (node().bitmap()) - context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *node().bitmap(), node().bitmap()->rect()); + if (dom_node().bitmap()) + context.painter().draw_scaled_bitmap(enclosing_int_rect(absolute_rect()), *dom_node().bitmap(), dom_node().bitmap()->rect()); } } diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.h b/Libraries/LibWeb/Layout/LayoutCanvas.h index 09a4d634ba..7f2d8220c2 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.h +++ b/Libraries/LibWeb/Layout/LayoutCanvas.h @@ -39,7 +39,7 @@ public: virtual void prepare_for_replaced_layout() override; virtual void paint(PaintContext&, PaintPhase) override; - const HTML::HTMLCanvasElement& node() const { return static_cast(LayoutReplaced::node()); } + const HTML::HTMLCanvasElement& dom_node() const { return static_cast(LayoutReplaced::dom_node()); } private: virtual const char* class_name() const override { return "LayoutCanvas"; } diff --git a/Libraries/LibWeb/Layout/LayoutCheckBox.cpp b/Libraries/LibWeb/Layout/LayoutCheckBox.cpp index 3195044057..6ba9f18585 100644 --- a/Libraries/LibWeb/Layout/LayoutCheckBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutCheckBox.cpp @@ -54,13 +54,13 @@ void LayoutCheckBox::paint(PaintContext& context, PaintPhase phase) LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { - Gfx::StylePainter::paint_check_box(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), node().enabled(), node().checked(), m_being_pressed); + Gfx::StylePainter::paint_check_box(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), dom_node().enabled(), dom_node().checked(), m_being_pressed); } } void LayoutCheckBox::handle_mousedown(Badge, const Gfx::IntPoint&, unsigned button, unsigned) { - if (button != GUI::MouseButton::Left || !node().enabled()) + if (button != GUI::MouseButton::Left || !dom_node().enabled()) return; m_being_pressed = true; @@ -72,7 +72,7 @@ void LayoutCheckBox::handle_mousedown(Badge, const Gfx::IntPoint&, void LayoutCheckBox::handle_mouseup(Badge, const Gfx::IntPoint& position, unsigned button, unsigned) { - if (!m_tracking_mouse || button != GUI::MouseButton::Left || !node().enabled()) + if (!m_tracking_mouse || button != GUI::MouseButton::Left || !dom_node().enabled()) return; // NOTE: Changing the checked state of the DOM node may run arbitrary JS, which could disappear this node. @@ -80,7 +80,7 @@ void LayoutCheckBox::handle_mouseup(Badge, const Gfx::IntPoint& po bool is_inside = enclosing_int_rect(absolute_rect()).contains(position); if (is_inside) - node().set_checked(!node().checked()); + dom_node().set_checked(!dom_node().checked()); m_being_pressed = false; m_tracking_mouse = false; @@ -89,7 +89,7 @@ void LayoutCheckBox::handle_mouseup(Badge, const Gfx::IntPoint& po void LayoutCheckBox::handle_mousemove(Badge, const Gfx::IntPoint& position, unsigned, unsigned) { - if (!m_tracking_mouse || !node().enabled()) + if (!m_tracking_mouse || !dom_node().enabled()) return; bool is_inside = enclosing_int_rect(absolute_rect()).contains(position); diff --git a/Libraries/LibWeb/Layout/LayoutCheckBox.h b/Libraries/LibWeb/Layout/LayoutCheckBox.h index ed495e35f7..1e4482a579 100644 --- a/Libraries/LibWeb/Layout/LayoutCheckBox.h +++ b/Libraries/LibWeb/Layout/LayoutCheckBox.h @@ -38,8 +38,8 @@ public: virtual void paint(PaintContext&, PaintPhase) override; - const HTML::HTMLInputElement& node() const { return static_cast(LayoutReplaced::node()); } - HTML::HTMLInputElement& node() { return static_cast(LayoutReplaced::node()); } + const HTML::HTMLInputElement& dom_node() const { return static_cast(LayoutReplaced::dom_node()); } + HTML::HTMLInputElement& dom_node() { return static_cast(LayoutReplaced::dom_node()); } private: virtual const char* class_name() const override { return "LayoutCheckBox"; } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.h b/Libraries/LibWeb/Layout/LayoutDocument.h index 96d6a4c425..33e55b4f5b 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.h +++ b/Libraries/LibWeb/Layout/LayoutDocument.h @@ -36,7 +36,7 @@ public: explicit LayoutDocument(DOM::Document&, NonnullRefPtr); virtual ~LayoutDocument() override; - const DOM::Document& node() const { return static_cast(*LayoutNode::node()); } + const DOM::Document& dom_node() const { return static_cast(*LayoutNode::dom_node()); } virtual const char* class_name() const override { return "LayoutDocument"; } void paint_all_phases(PaintContext&); diff --git a/Libraries/LibWeb/Layout/LayoutFrame.cpp b/Libraries/LibWeb/Layout/LayoutFrame.cpp index 5f9b3b0236..ccd3666c8a 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.cpp +++ b/Libraries/LibWeb/Layout/LayoutFrame.cpp @@ -50,13 +50,13 @@ LayoutFrame::~LayoutFrame() void LayoutFrame::prepare_for_replaced_layout() { - ASSERT(node().content_frame()); + ASSERT(dom_node().content_frame()); set_has_intrinsic_width(true); set_has_intrinsic_height(true); // FIXME: Do proper error checking, etc. - set_intrinsic_width(node().attribute(HTML::AttributeNames::width).to_int().value_or(300)); - set_intrinsic_height(node().attribute(HTML::AttributeNames::height).to_int().value_or(150)); + set_intrinsic_width(dom_node().attribute(HTML::AttributeNames::width).to_int().value_or(300)); + set_intrinsic_height(dom_node().attribute(HTML::AttributeNames::height).to_int().value_or(150)); } void LayoutFrame::paint(PaintContext& context, PaintPhase phase) @@ -64,7 +64,7 @@ void LayoutFrame::paint(PaintContext& context, PaintPhase phase) LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { - auto* hosted_document = node().content_document(); + auto* hosted_document = dom_node().content_document(); if (!hosted_document) return; auto* hosted_layout_tree = hosted_document->layout_node(); @@ -77,7 +77,7 @@ void LayoutFrame::paint(PaintContext& context, PaintPhase phase) context.painter().add_clip_rect(enclosing_int_rect(absolute_rect())); context.painter().translate(absolute_x(), absolute_y()); - context.set_viewport_rect({ {}, node().content_frame()->size() }); + context.set_viewport_rect({ {}, dom_node().content_frame()->size() }); const_cast(hosted_layout_tree)->paint_all_phases(context); context.set_viewport_rect(old_viewport_rect); @@ -95,8 +95,8 @@ void LayoutFrame::did_set_rect() { LayoutReplaced::did_set_rect(); - ASSERT(node().content_frame()); - node().content_frame()->set_size(size().to_type()); + ASSERT(dom_node().content_frame()); + dom_node().content_frame()->set_size(size().to_type()); } } diff --git a/Libraries/LibWeb/Layout/LayoutFrame.h b/Libraries/LibWeb/Layout/LayoutFrame.h index 4dbc134fe8..fa9be9bf1d 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.h +++ b/Libraries/LibWeb/Layout/LayoutFrame.h @@ -39,8 +39,8 @@ public: virtual void paint(PaintContext&, PaintPhase) override; virtual void prepare_for_replaced_layout() override; - const HTML::HTMLIFrameElement& node() const { return downcast(LayoutReplaced::node()); } - HTML::HTMLIFrameElement& node() { return downcast(LayoutReplaced::node()); } + const HTML::HTMLIFrameElement& dom_node() const { return downcast(LayoutReplaced::dom_node()); } + HTML::HTMLIFrameElement& dom_node() { return downcast(LayoutReplaced::dom_node()); } private: virtual bool is_frame() const final { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutImage.cpp b/Libraries/LibWeb/Layout/LayoutImage.cpp index b05d528f69..e3b89a0fc5 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.cpp +++ b/Libraries/LibWeb/Layout/LayoutImage.cpp @@ -44,12 +44,12 @@ LayoutImage::~LayoutImage() int LayoutImage::preferred_width() const { - return node().attribute(HTML::AttributeNames::width).to_int().value_or(m_image_loader.width()); + return dom_node().attribute(HTML::AttributeNames::width).to_int().value_or(m_image_loader.width()); } int LayoutImage::preferred_height() const { - return node().attribute(HTML::AttributeNames::height).to_int().value_or(m_image_loader.height()); + return dom_node().attribute(HTML::AttributeNames::height).to_int().value_or(m_image_loader.height()); } void LayoutImage::prepare_for_replaced_layout() @@ -78,7 +78,7 @@ void LayoutImage::prepare_for_replaced_layout() } if (renders_as_alt_text()) { - auto& image_element = downcast(node()); + auto& image_element = downcast(dom_node()); auto& font = Gfx::Font::default_font(); auto alt = image_element.alt(); if (alt.is_empty()) @@ -106,7 +106,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase) if (phase == PaintPhase::Foreground) { if (renders_as_alt_text()) { - auto& image_element = downcast(node()); + auto& image_element = downcast(dom_node()); context.painter().set_font(Gfx::Font::default_font()); Gfx::StylePainter::paint_frame(context.painter(), enclosing_int_rect(absolute_rect()), context.palette(), Gfx::FrameShape::Container, Gfx::FrameShadow::Sunken, 2); auto alt = image_element.alt(); @@ -121,7 +121,7 @@ void LayoutImage::paint(PaintContext& context, PaintPhase phase) bool LayoutImage::renders_as_alt_text() const { - if (is(node())) + if (is(dom_node())) return !m_image_loader.has_image(); return false; } diff --git a/Libraries/LibWeb/Layout/LayoutImage.h b/Libraries/LibWeb/Layout/LayoutImage.h index 740be79e8c..3cbf29a19c 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.h +++ b/Libraries/LibWeb/Layout/LayoutImage.h @@ -39,7 +39,7 @@ public: virtual void prepare_for_replaced_layout() override; virtual void paint(PaintContext&, PaintPhase) override; - const DOM::Element& node() const { return static_cast(LayoutReplaced::node()); } + const DOM::Element& dom_node() const { return static_cast(LayoutReplaced::dom_node()); } bool renders_as_alt_text() const; diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index 2686904767..7fcf45e0b8 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -37,16 +37,16 @@ namespace Web { LayoutNode::LayoutNode(DOM::Document& document, DOM::Node* node) : m_document(document) - , m_node(node) + , m_dom_node(node) { - if (m_node) - m_node->set_layout_node({}, this); + if (m_dom_node) + m_dom_node->set_layout_node({}, this); } LayoutNode::~LayoutNode() { - if (m_node && m_node->layout_node() == this) - m_node->set_layout_node({}, nullptr); + if (m_dom_node && m_dom_node->layout_node() == this) + m_dom_node->set_layout_node({}, nullptr); } bool LayoutNode::can_contain_boxes_with_position_absolute() const diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index 12e8702c83..d3fb8c5d16 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -70,9 +70,9 @@ public: virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const; - bool is_anonymous() const { return !m_node; } - const DOM::Node* node() const { return m_node; } - DOM::Node* node() { return m_node; } + bool is_anonymous() const { return !m_dom_node; } + const DOM::Node* dom_node() const { return m_dom_node; } + DOM::Node* dom_node() { return m_dom_node; } DOM::Document& document() { return m_document; } const DOM::Document& document() const { return m_document; } @@ -178,7 +178,7 @@ private: friend class LayoutNodeWithStyle; NonnullRefPtr m_document; - RefPtr m_node; + RefPtr m_dom_node; bool m_inline { false }; bool m_has_style { false }; diff --git a/Libraries/LibWeb/Layout/LayoutReplaced.h b/Libraries/LibWeb/Layout/LayoutReplaced.h index a474534cec..14f461e773 100644 --- a/Libraries/LibWeb/Layout/LayoutReplaced.h +++ b/Libraries/LibWeb/Layout/LayoutReplaced.h @@ -36,8 +36,8 @@ public: LayoutReplaced(DOM::Document&, DOM::Element&, NonnullRefPtr); virtual ~LayoutReplaced() override; - const DOM::Element& node() const { return downcast(*LayoutNode::node()); } - DOM::Element& node() { return downcast(*LayoutNode::node()); } + const DOM::Element& dom_node() const { return downcast(*LayoutNode::dom_node()); } + DOM::Element& dom_node() { return downcast(*LayoutNode::dom_node()); } virtual bool is_replaced() const final { return true; } diff --git a/Libraries/LibWeb/Layout/LayoutSVGGraphics.cpp b/Libraries/LibWeb/Layout/LayoutSVGGraphics.cpp index 787b7e16fd..b85237aeea 100644 --- a/Libraries/LibWeb/Layout/LayoutSVGGraphics.cpp +++ b/Libraries/LibWeb/Layout/LayoutSVGGraphics.cpp @@ -39,7 +39,7 @@ void LayoutSVGGraphics::before_children_paint(PaintContext& context, LayoutNode: if (phase != LayoutNode::PaintPhase::Foreground) return; - auto& graphics_element = downcast(node()); + auto& graphics_element = downcast(dom_node()); if (graphics_element.fill_color().has_value()) context.svg_context().set_fill_color(graphics_element.fill_color().value()); diff --git a/Libraries/LibWeb/Layout/LayoutSVGPath.cpp b/Libraries/LibWeb/Layout/LayoutSVGPath.cpp index b33190c73b..f4f1225fac 100644 --- a/Libraries/LibWeb/Layout/LayoutSVGPath.cpp +++ b/Libraries/LibWeb/Layout/LayoutSVGPath.cpp @@ -37,7 +37,7 @@ LayoutSVGPath::LayoutSVGPath(DOM::Document& document, SVG::SVGPathElement& eleme void LayoutSVGPath::prepare_for_replaced_layout() { - auto& bounding_box = node().get_path().bounding_box(); + auto& bounding_box = dom_node().get_path().bounding_box(); set_has_intrinsic_width(true); set_has_intrinsic_height(true); set_intrinsic_width(bounding_box.width()); @@ -57,7 +57,7 @@ void LayoutSVGPath::paint(PaintContext& context, LayoutNode::PaintPhase phase) if (phase != LayoutNode::PaintPhase::Foreground) return; - auto& path_element = node(); + auto& path_element = dom_node(); auto& path = path_element.get_path(); // We need to fill the path before applying the stroke, however the filled diff --git a/Libraries/LibWeb/Layout/LayoutSVGPath.h b/Libraries/LibWeb/Layout/LayoutSVGPath.h index 0ed38f34d1..a378665a8c 100644 --- a/Libraries/LibWeb/Layout/LayoutSVGPath.h +++ b/Libraries/LibWeb/Layout/LayoutSVGPath.h @@ -35,7 +35,7 @@ public: LayoutSVGPath(DOM::Document&, SVG::SVGPathElement&, NonnullRefPtr); virtual ~LayoutSVGPath() override = default; - SVG::SVGPathElement& node() { return downcast(LayoutSVGGraphics::node()); } + SVG::SVGPathElement& dom_node() { return downcast(LayoutSVGGraphics::dom_node()); } virtual void prepare_for_replaced_layout() override; virtual void paint(PaintContext& context, PaintPhase phase) override; diff --git a/Libraries/LibWeb/Layout/LayoutSVGSVG.cpp b/Libraries/LibWeb/Layout/LayoutSVGSVG.cpp index 5b114c4b75..23dde716a4 100644 --- a/Libraries/LibWeb/Layout/LayoutSVGSVG.cpp +++ b/Libraries/LibWeb/Layout/LayoutSVGSVG.cpp @@ -37,8 +37,8 @@ void LayoutSVGSVG::prepare_for_replaced_layout() { set_has_intrinsic_width(true); set_has_intrinsic_height(true); - set_intrinsic_width(node().width()); - set_intrinsic_height(node().height()); + set_intrinsic_width(dom_node().width()); + set_intrinsic_height(dom_node().height()); } void LayoutSVGSVG::before_children_paint(PaintContext& context, LayoutNode::PaintPhase phase) diff --git a/Libraries/LibWeb/Layout/LayoutSVGSVG.h b/Libraries/LibWeb/Layout/LayoutSVGSVG.h index ea321d5a36..01fb4ea8be 100644 --- a/Libraries/LibWeb/Layout/LayoutSVGSVG.h +++ b/Libraries/LibWeb/Layout/LayoutSVGSVG.h @@ -36,7 +36,7 @@ public: LayoutSVGSVG(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr); virtual ~LayoutSVGSVG() override = default; - SVG::SVGSVGElement& node() { return downcast(LayoutSVGGraphics::node()); } + SVG::SVGSVGElement& dom_node() { return downcast(LayoutSVGGraphics::dom_node()); } virtual void prepare_for_replaced_layout() override; diff --git a/Libraries/LibWeb/Layout/LayoutTableCell.cpp b/Libraries/LibWeb/Layout/LayoutTableCell.cpp index d082d86d84..27c9a2780d 100644 --- a/Libraries/LibWeb/Layout/LayoutTableCell.cpp +++ b/Libraries/LibWeb/Layout/LayoutTableCell.cpp @@ -41,8 +41,8 @@ LayoutTableCell::~LayoutTableCell() size_t LayoutTableCell::colspan() const { - ASSERT(node()); - return downcast(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); + ASSERT(dom_node()); + return downcast(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1); } float LayoutTableCell::width_of_logical_containing_block() const diff --git a/Libraries/LibWeb/Layout/LayoutText.cpp b/Libraries/LibWeb/Layout/LayoutText.cpp index 941cf40a5d..b6d8e2b001 100644 --- a/Libraries/LibWeb/Layout/LayoutText.cpp +++ b/Libraries/LibWeb/Layout/LayoutText.cpp @@ -59,11 +59,11 @@ static bool is_all_whitespace(const StringView& string) const String& LayoutText::text_for_style(const CSS::StyleProperties& style) const { static String one_space = " "; - if (is_all_whitespace(node().data())) { + if (is_all_whitespace(dom_node().data())) { if (style.white_space().value_or(CSS::WhiteSpace::Normal) == CSS::WhiteSpace::Normal) return one_space; } - return node().data(); + return dom_node().data(); } void LayoutText::paint_fragment(PaintContext& context, const LineBoxFragment& fragment) const @@ -78,7 +78,7 @@ void LayoutText::paint_fragment(PaintContext& context, const LineBoxFragment& fr auto color = specified_style().color_or_fallback(CSS::PropertyID::Color, document(), context.palette().base_text()); auto text_decoration = specified_style().string_or_fallback(CSS::PropertyID::TextDecoration, "none"); - if (document().inspected_node() == &node()) + if (document().inspected_node() == &dom_node()) context.painter().draw_rect(enclosing_int_rect(fragment.absolute_rect()), Color::Magenta); bool is_underline = text_decoration == "underline"; @@ -114,13 +114,13 @@ void LayoutText::paint_cursor_if_needed(PaintContext& context, const LineBoxFrag if (!frame().cursor_blink_state()) return; - if (frame().cursor_position().node() != &node()) + if (frame().cursor_position().node() != &dom_node()) return; if (!(frame().cursor_position().offset() >= (unsigned)fragment.start() && frame().cursor_position().offset() < (unsigned)(fragment.start() + fragment.length()))) return; - if (!fragment.layout_node().node() || !fragment.layout_node().node()->is_editable()) + if (!fragment.layout_node().dom_node() || !fragment.layout_node().dom_node()->is_editable()) return; auto fragment_rect = fragment.absolute_rect(); @@ -196,8 +196,8 @@ void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode la // Collapse whitespace into single spaces if (do_collapse) { - auto utf8_view = Utf8View(node().data()); - StringBuilder builder(node().data().length()); + auto utf8_view = Utf8View(dom_node().data()); + StringBuilder builder(dom_node().data().length()); auto it = utf8_view.begin(); auto skip_over_whitespace = [&] { auto prev = it; @@ -219,7 +219,7 @@ void LayoutText::split_into_lines_by_rules(LayoutBlock& container, LayoutMode la } m_text_for_rendering = builder.to_string(); } else { - m_text_for_rendering = node().data(); + m_text_for_rendering = dom_node().data(); } // do_wrap_lines => chunks_are_words diff --git a/Libraries/LibWeb/Layout/LayoutText.h b/Libraries/LibWeb/Layout/LayoutText.h index 155694c25a..4b30426b84 100644 --- a/Libraries/LibWeb/Layout/LayoutText.h +++ b/Libraries/LibWeb/Layout/LayoutText.h @@ -38,7 +38,7 @@ public: LayoutText(DOM::Document&, DOM::Text&); virtual ~LayoutText() override; - const DOM::Text& node() const { return static_cast(*LayoutNode::node()); } + const DOM::Text& dom_node() const { return static_cast(*LayoutNode::dom_node()); } const String& text_for_style(const CSS::StyleProperties&) const; const String& text_for_rendering() const { return m_text_for_rendering; } diff --git a/Libraries/LibWeb/LayoutTreeModel.cpp b/Libraries/LibWeb/LayoutTreeModel.cpp index 3a681295f4..cbfb583109 100644 --- a/Libraries/LibWeb/LayoutTreeModel.cpp +++ b/Libraries/LibWeb/LayoutTreeModel.cpp @@ -133,10 +133,10 @@ GUI::Variant LayoutTreeModel::data(const GUI::ModelIndex& index, GUI::ModelRole builder.append(' '); if (node.is_anonymous()) { builder.append("[anonymous]"); - } else if (!node.node()->is_element()) { - builder.append(node.node()->node_name()); + } else if (!node.dom_node()->is_element()) { + builder.append(node.dom_node()->node_name()); } else { - auto& element = downcast(*node.node()); + auto& element = downcast(*node.dom_node()); builder.append('<'); builder.append(element.local_name()); element.for_each_attribute([&](auto& name, auto& value) { diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index 30bda6c150..3d0e4ed85f 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -95,8 +95,8 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button result = layout_root()->hit_test(position, HitTestType::Exact); } - if (result.layout_node && result.layout_node->node()) { - RefPtr node = result.layout_node->node(); + if (result.layout_node && result.layout_node->dom_node()) { + RefPtr node = result.layout_node->dom_node(); if (is(*node)) { if (auto* subframe = downcast(*node).content_frame()) return subframe->event_handler().handle_mouseup(position.translated(compute_mouse_event_offset({}, *result.layout_node)), button, modifiers); @@ -130,7 +130,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (!result.layout_node) return false; - RefPtr node = result.layout_node->node(); + RefPtr node = result.layout_node->dom_node(); document->set_hovered_node(node); if (result.layout_node->wants_mouse_events()) { @@ -194,7 +194,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt } else { if (button == GUI::MouseButton::Left) { auto result = layout_root()->hit_test(position, HitTestType::TextCursor); - if (result.layout_node && result.layout_node->node()) { + if (result.layout_node && result.layout_node->dom_node()) { m_frame.set_cursor_position(DOM::Position(*node, result.index_in_node)); layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} }); dump_selection("MouseDown"); @@ -228,7 +228,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt if (result.layout_node) { if (result.layout_node->wants_mouse_events()) { - document.set_hovered_node(result.layout_node->node()); + document.set_hovered_node(result.layout_node->dom_node()); result.layout_node->handle_mousemove({}, position, buttons, modifiers); // FIXME: It feels a bit aggressive to always update the cursor like this. if (auto* page = m_frame.page()) @@ -236,7 +236,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt return true; } - RefPtr node = result.layout_node->node(); + RefPtr node = result.layout_node->dom_node(); if (node && is(*node)) { if (auto* subframe = downcast(*node).content_frame()) @@ -259,7 +259,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt } if (m_in_mouse_selection) { auto hit = layout_root()->hit_test(position, HitTestType::TextCursor); - if (hit.layout_node && hit.layout_node->node()) { + if (hit.layout_node && hit.layout_node->dom_node()) { layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node }); } dump_selection("MouseMove"); diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index f55cfe355d..4d27abacd8 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -84,7 +84,7 @@ void StackingContext::dump(int indent) const { for (int i = 0; i < indent; ++i) dbgprintf(" "); - dbgprintf("SC for %s{%s} %s [children: %zu]\n", m_box.class_name(), m_box.node() ? m_box.node()->node_name().characters() : "(anonymous)", m_box.absolute_rect().to_string().characters(), m_children.size()); + dbgprintf("SC for %s{%s} %s [children: %zu]\n", m_box.class_name(), m_box.dom_node() ? m_box.dom_node()->node_name().characters() : "(anonymous)", m_box.absolute_rect().to_string().characters(), m_children.size()); for (auto& child : m_children) child->dump(indent + 1); }