mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Rename LayoutNode::node() => LayoutNode::dom_node()
This commit is contained in:
parent
85859544fa
commit
f358f2255f
Notes:
sideshowbarker
2024-07-19 01:19:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/f358f2255fe
30 changed files with 92 additions and 92 deletions
|
@ -69,7 +69,7 @@ InspectorWidget::InspectorWidget()
|
|||
m_layout_tree_view = top_tab_widget.add_tab<GUI::TreeView>("Layout");
|
||||
m_layout_tree_view->on_selection = [this](auto& index) {
|
||||
auto* node = static_cast<Web::LayoutNode*>(index.internal_data());
|
||||
set_inspected_node(node->node());
|
||||
set_inspected_node(node->dom_node());
|
||||
};
|
||||
|
||||
auto& bottom_tab_widget = splitter.add<GUI::TabWidget>();
|
||||
|
|
|
@ -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<DOM::Text>(layout_node.node()))
|
||||
else if (is<DOM::Text>(layout_node.dom_node()))
|
||||
tag_name = "#text";
|
||||
else if (is<DOM::Document>(layout_node.node()))
|
||||
else if (is<DOM::Document>(layout_node.dom_node()))
|
||||
tag_name = "#document";
|
||||
else if (is<DOM::Element>(layout_node.node()))
|
||||
tag_name = downcast<DOM::Element>(*layout_node.node()).local_name();
|
||||
else if (is<DOM::Element>(layout_node.dom_node()))
|
||||
tag_name = downcast<DOM::Element>(*layout_node.dom_node()).local_name();
|
||||
else
|
||||
tag_name = "???";
|
||||
|
||||
String identifier = "";
|
||||
if (layout_node.node() && is<DOM::Element>(*layout_node.node())) {
|
||||
auto& element = downcast<DOM::Element>(*layout_node.node());
|
||||
if (layout_node.dom_node() && is<DOM::Element>(*layout_node.dom_node())) {
|
||||
auto& element = downcast<DOM::Element>(*layout_node.dom_node());
|
||||
StringBuilder builder;
|
||||
auto id = element.attribute(HTML::AttributeNames::id);
|
||||
if (!id.is_empty()) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<DOM::Element>(*node()).is_focused()) {
|
||||
if (phase == PaintPhase::FocusOutline && dom_node() && dom_node()->is_element() && downcast<DOM::Element>(*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();
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
LayoutBreak(DOM::Document&, HTML::HTMLBRElement&);
|
||||
virtual ~LayoutBreak() override;
|
||||
|
||||
const HTML::HTMLBRElement& node() const { return downcast<HTML::HTMLBRElement>(*LayoutNode::node()); }
|
||||
const HTML::HTMLBRElement& dom_node() const { return downcast<HTML::HTMLBRElement>(*LayoutNode::dom_node()); }
|
||||
|
||||
private:
|
||||
virtual bool is_break() const override { return true; }
|
||||
|
|
|
@ -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<EventHandler>, 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<EventHandler>, const Gfx::IntPoint&, u
|
|||
|
||||
void LayoutButton::handle_mouseup(Badge<EventHandler>, 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<EventHandler>, 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<EventHandler>, const Gfx::IntPoint& posi
|
|||
|
||||
void LayoutButton::handle_mousemove(Badge<EventHandler>, 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);
|
||||
|
|
|
@ -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<const HTML::HTMLInputElement&>(LayoutReplaced::node()); }
|
||||
HTML::HTMLInputElement& node() { return static_cast<HTML::HTMLInputElement&>(LayoutReplaced::node()); }
|
||||
const HTML::HTMLInputElement& dom_node() const { return static_cast<const HTML::HTMLInputElement&>(LayoutReplaced::dom_node()); }
|
||||
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(LayoutReplaced::dom_node()); }
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LayoutButton"; }
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<const HTML::HTMLCanvasElement&>(LayoutReplaced::node()); }
|
||||
const HTML::HTMLCanvasElement& dom_node() const { return static_cast<const HTML::HTMLCanvasElement&>(LayoutReplaced::dom_node()); }
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LayoutCanvas"; }
|
||||
|
|
|
@ -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<EventHandler>, 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<EventHandler>, const Gfx::IntPoint&,
|
|||
|
||||
void LayoutCheckBox::handle_mouseup(Badge<EventHandler>, 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<EventHandler>, 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<EventHandler>, const Gfx::IntPoint& po
|
|||
|
||||
void LayoutCheckBox::handle_mousemove(Badge<EventHandler>, 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);
|
||||
|
|
|
@ -38,8 +38,8 @@ public:
|
|||
|
||||
virtual void paint(PaintContext&, PaintPhase) override;
|
||||
|
||||
const HTML::HTMLInputElement& node() const { return static_cast<const HTML::HTMLInputElement&>(LayoutReplaced::node()); }
|
||||
HTML::HTMLInputElement& node() { return static_cast<HTML::HTMLInputElement&>(LayoutReplaced::node()); }
|
||||
const HTML::HTMLInputElement& dom_node() const { return static_cast<const HTML::HTMLInputElement&>(LayoutReplaced::dom_node()); }
|
||||
HTML::HTMLInputElement& dom_node() { return static_cast<HTML::HTMLInputElement&>(LayoutReplaced::dom_node()); }
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LayoutCheckBox"; }
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
explicit LayoutDocument(DOM::Document&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~LayoutDocument() override;
|
||||
|
||||
const DOM::Document& node() const { return static_cast<const DOM::Document&>(*LayoutNode::node()); }
|
||||
const DOM::Document& dom_node() const { return static_cast<const DOM::Document&>(*LayoutNode::dom_node()); }
|
||||
virtual const char* class_name() const override { return "LayoutDocument"; }
|
||||
|
||||
void paint_all_phases(PaintContext&);
|
||||
|
|
|
@ -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<LayoutDocument*>(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<int>());
|
||||
ASSERT(dom_node().content_frame());
|
||||
dom_node().content_frame()->set_size(size().to_type<int>());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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<HTML::HTMLIFrameElement>(LayoutReplaced::node()); }
|
||||
HTML::HTMLIFrameElement& node() { return downcast<HTML::HTMLIFrameElement>(LayoutReplaced::node()); }
|
||||
const HTML::HTMLIFrameElement& dom_node() const { return downcast<HTML::HTMLIFrameElement>(LayoutReplaced::dom_node()); }
|
||||
HTML::HTMLIFrameElement& dom_node() { return downcast<HTML::HTMLIFrameElement>(LayoutReplaced::dom_node()); }
|
||||
|
||||
private:
|
||||
virtual bool is_frame() const final { return true; }
|
||||
|
|
|
@ -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<HTML::HTMLImageElement>(node());
|
||||
auto& image_element = downcast<HTML::HTMLImageElement>(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<HTML::HTMLImageElement>(node());
|
||||
auto& image_element = downcast<HTML::HTMLImageElement>(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<HTML::HTMLImageElement>(node()))
|
||||
if (is<HTML::HTMLImageElement>(dom_node()))
|
||||
return !m_image_loader.has_image();
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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<const DOM::Element&>(LayoutReplaced::node()); }
|
||||
const DOM::Element& dom_node() const { return static_cast<const DOM::Element&>(LayoutReplaced::dom_node()); }
|
||||
|
||||
bool renders_as_alt_text() const;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<DOM::Document> m_document;
|
||||
RefPtr<DOM::Node> m_node;
|
||||
RefPtr<DOM::Node> m_dom_node;
|
||||
|
||||
bool m_inline { false };
|
||||
bool m_has_style { false };
|
||||
|
|
|
@ -36,8 +36,8 @@ public:
|
|||
LayoutReplaced(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~LayoutReplaced() override;
|
||||
|
||||
const DOM::Element& node() const { return downcast<DOM::Element>(*LayoutNode::node()); }
|
||||
DOM::Element& node() { return downcast<DOM::Element>(*LayoutNode::node()); }
|
||||
const DOM::Element& dom_node() const { return downcast<DOM::Element>(*LayoutNode::dom_node()); }
|
||||
DOM::Element& dom_node() { return downcast<DOM::Element>(*LayoutNode::dom_node()); }
|
||||
|
||||
virtual bool is_replaced() const final { return true; }
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ void LayoutSVGGraphics::before_children_paint(PaintContext& context, LayoutNode:
|
|||
if (phase != LayoutNode::PaintPhase::Foreground)
|
||||
return;
|
||||
|
||||
auto& graphics_element = downcast<SVG::SVGGraphicsElement>(node());
|
||||
auto& graphics_element = downcast<SVG::SVGGraphicsElement>(dom_node());
|
||||
|
||||
if (graphics_element.fill_color().has_value())
|
||||
context.svg_context().set_fill_color(graphics_element.fill_color().value());
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,7 +35,7 @@ public:
|
|||
LayoutSVGPath(DOM::Document&, SVG::SVGPathElement&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~LayoutSVGPath() override = default;
|
||||
|
||||
SVG::SVGPathElement& node() { return downcast<SVG::SVGPathElement>(LayoutSVGGraphics::node()); }
|
||||
SVG::SVGPathElement& dom_node() { return downcast<SVG::SVGPathElement>(LayoutSVGGraphics::dom_node()); }
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
virtual void paint(PaintContext& context, PaintPhase phase) override;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
LayoutSVGSVG(DOM::Document&, SVG::SVGSVGElement&, NonnullRefPtr<CSS::StyleProperties>);
|
||||
virtual ~LayoutSVGSVG() override = default;
|
||||
|
||||
SVG::SVGSVGElement& node() { return downcast<SVG::SVGSVGElement>(LayoutSVGGraphics::node()); }
|
||||
SVG::SVGSVGElement& dom_node() { return downcast<SVG::SVGSVGElement>(LayoutSVGGraphics::dom_node()); }
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
|
||||
|
|
|
@ -41,8 +41,8 @@ LayoutTableCell::~LayoutTableCell()
|
|||
|
||||
size_t LayoutTableCell::colspan() const
|
||||
{
|
||||
ASSERT(node());
|
||||
return downcast<DOM::Element>(*node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
|
||||
ASSERT(dom_node());
|
||||
return downcast<DOM::Element>(*dom_node()).attribute(HTML::AttributeNames::colspan).to_uint().value_or(1);
|
||||
}
|
||||
|
||||
float LayoutTableCell::width_of_logical_containing_block() const
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
LayoutText(DOM::Document&, DOM::Text&);
|
||||
virtual ~LayoutText() override;
|
||||
|
||||
const DOM::Text& node() const { return static_cast<const DOM::Text&>(*LayoutNode::node()); }
|
||||
const DOM::Text& dom_node() const { return static_cast<const DOM::Text&>(*LayoutNode::dom_node()); }
|
||||
|
||||
const String& text_for_style(const CSS::StyleProperties&) const;
|
||||
const String& text_for_rendering() const { return m_text_for_rendering; }
|
||||
|
|
|
@ -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<DOM::Element>(*node.node());
|
||||
auto& element = downcast<DOM::Element>(*node.dom_node());
|
||||
builder.append('<');
|
||||
builder.append(element.local_name());
|
||||
element.for_each_attribute([&](auto& name, auto& value) {
|
||||
|
|
|
@ -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<DOM::Node> node = result.layout_node->node();
|
||||
if (result.layout_node && result.layout_node->dom_node()) {
|
||||
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
||||
if (is<HTML::HTMLIFrameElement>(*node)) {
|
||||
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*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<DOM::Node> node = result.layout_node->node();
|
||||
RefPtr<DOM::Node> 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<DOM::Node> node = result.layout_node->node();
|
||||
RefPtr<DOM::Node> node = result.layout_node->dom_node();
|
||||
|
||||
if (node && is<HTML::HTMLIFrameElement>(*node)) {
|
||||
if (auto* subframe = downcast<HTML::HTMLIFrameElement>(*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");
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue