From 8c82d2666889c154983bb138959a36590fa324c8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 18 Jun 2020 21:35:44 +0200 Subject: LibWeb: Rename LayoutNode::render() to paint() "Paint" matches what we call this in the rest of the system. Let's not confuse things by mixing paint/render/draw all the time. I'm guilty of this in more places.. Also rename RenderingContext => PaintContext. --- Libraries/LibWeb/Layout/LayoutBlock.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutBlock.h | 2 +- Libraries/LibWeb/Layout/LayoutBox.cpp | 6 +++--- Libraries/LibWeb/Layout/LayoutBox.h | 4 ++-- Libraries/LibWeb/Layout/LayoutCanvas.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutCanvas.h | 2 +- Libraries/LibWeb/Layout/LayoutDocument.cpp | 14 +++++++------- Libraries/LibWeb/Layout/LayoutDocument.h | 4 ++-- Libraries/LibWeb/Layout/LayoutFrame.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutFrame.h | 2 +- Libraries/LibWeb/Layout/LayoutImage.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutImage.h | 2 +- Libraries/LibWeb/Layout/LayoutListItemMarker.cpp | 2 +- Libraries/LibWeb/Layout/LayoutListItemMarker.h | 2 +- Libraries/LibWeb/Layout/LayoutNode.cpp | 4 ++-- Libraries/LibWeb/Layout/LayoutNode.h | 4 ++-- Libraries/LibWeb/Layout/LayoutText.cpp | 2 +- Libraries/LibWeb/Layout/LayoutText.h | 2 +- Libraries/LibWeb/Layout/LineBoxFragment.cpp | 4 ++-- Libraries/LibWeb/Layout/LineBoxFragment.h | 2 +- Libraries/LibWeb/Layout/StackingContext.cpp | 10 +++++----- Libraries/LibWeb/Layout/StackingContext.h | 2 +- 22 files changed, 43 insertions(+), 43 deletions(-) (limited to 'Libraries/LibWeb/Layout') diff --git a/Libraries/LibWeb/Layout/LayoutBlock.cpp b/Libraries/LibWeb/Layout/LayoutBlock.cpp index daa47775e2..38b9d0f641 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.cpp +++ b/Libraries/LibWeb/Layout/LayoutBlock.cpp @@ -660,12 +660,12 @@ void LayoutBlock::compute_height() } } -void LayoutBlock::render(RenderingContext& context, PaintPhase phase) +void LayoutBlock::paint(PaintContext& context, PaintPhase phase) { if (!is_visible()) return; - LayoutBox::render(context, phase); + LayoutBox::paint(context, phase); // FIXME: Inline backgrounds etc. if (phase == PaintPhase::Foreground) { diff --git a/Libraries/LibWeb/Layout/LayoutBlock.h b/Libraries/LibWeb/Layout/LayoutBlock.h index 436c427255..226fce2869 100644 --- a/Libraries/LibWeb/Layout/LayoutBlock.h +++ b/Libraries/LibWeb/Layout/LayoutBlock.h @@ -41,7 +41,7 @@ public: virtual const char* class_name() const override { return "LayoutBlock"; } virtual void layout(LayoutMode = LayoutMode::Default) override; - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; virtual LayoutNode& inline_wrapper() override; diff --git a/Libraries/LibWeb/Layout/LayoutBox.cpp b/Libraries/LibWeb/Layout/LayoutBox.cpp index aa98a3c8f3..4a1301c150 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.cpp +++ b/Libraries/LibWeb/Layout/LayoutBox.cpp @@ -33,7 +33,7 @@ namespace Web { -void LayoutBox::paint_border(RenderingContext& context, Edge edge, const Gfx::FloatRect& rect, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id) +void LayoutBox::paint_border(PaintContext& context, Edge edge, const Gfx::FloatRect& rect, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id) { auto border_width = style().property(width_property_id); if (!border_width.has_value()) @@ -186,7 +186,7 @@ void LayoutBox::paint_border(RenderingContext& context, Edge edge, const Gfx::Fl } } -void LayoutBox::render(RenderingContext& context, PaintPhase phase) +void LayoutBox::paint(PaintContext& context, PaintPhase phase) { if (!is_visible()) return; @@ -230,7 +230,7 @@ void LayoutBox::render(RenderingContext& context, PaintPhase phase) paint_border(context, Edge::Bottom, bordered_rect, CSS::PropertyID::BorderBottomStyle, CSS::PropertyID::BorderBottomColor, CSS::PropertyID::BorderBottomWidth); } - LayoutNodeWithStyleAndBoxModelMetrics::render(context, phase); + LayoutNodeWithStyleAndBoxModelMetrics::paint(context, phase); if (phase == PaintPhase::Overlay && node() && document().inspected_node() == node()) context.painter().draw_rect(enclosing_int_rect(absolute_rect()), Color::Magenta); diff --git a/Libraries/LibWeb/Layout/LayoutBox.h b/Libraries/LibWeb/Layout/LayoutBox.h index 633601318d..bad3078489 100644 --- a/Libraries/LibWeb/Layout/LayoutBox.h +++ b/Libraries/LibWeb/Layout/LayoutBox.h @@ -67,7 +67,7 @@ public: void set_stacking_context(NonnullOwnPtr context) { m_stacking_context = move(context); } StackingContext* enclosing_stacking_context(); - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; protected: LayoutBox(const Node* node, NonnullRefPtr style) @@ -86,7 +86,7 @@ private: Bottom, Left, }; - void paint_border(RenderingContext&, Edge, const Gfx::FloatRect&, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id); + void paint_border(PaintContext&, Edge, const Gfx::FloatRect&, CSS::PropertyID style_property_id, CSS::PropertyID color_property_id, CSS::PropertyID width_property_id); Gfx::FloatPoint m_offset; Gfx::FloatSize m_size; diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.cpp b/Libraries/LibWeb/Layout/LayoutCanvas.cpp index 89b2390799..2b905219c4 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.cpp +++ b/Libraries/LibWeb/Layout/LayoutCanvas.cpp @@ -49,12 +49,12 @@ void LayoutCanvas::layout(LayoutMode layout_mode) LayoutReplaced::layout(layout_mode); } -void LayoutCanvas::render(RenderingContext& context, PaintPhase phase) +void LayoutCanvas::paint(PaintContext& context, PaintPhase phase) { if (!is_visible()) return; - LayoutReplaced::render(context, phase); + LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { // FIXME: This should be done at a different level. Also rect() does not include padding etc! diff --git a/Libraries/LibWeb/Layout/LayoutCanvas.h b/Libraries/LibWeb/Layout/LayoutCanvas.h index c97bf745a9..13733079e1 100644 --- a/Libraries/LibWeb/Layout/LayoutCanvas.h +++ b/Libraries/LibWeb/Layout/LayoutCanvas.h @@ -39,7 +39,7 @@ public: virtual ~LayoutCanvas() override; virtual void layout(LayoutMode = LayoutMode::Default) override; - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; const HTMLCanvasElement& node() const { return static_cast(LayoutReplaced::node()); } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index 41667e6a28..f4821f4bac 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -100,17 +100,17 @@ void LayoutDocument::did_set_viewport_rect(Badge, const Gfx::IntRect& a_v }); } -void LayoutDocument::paint_all_phases(RenderingContext& context) +void LayoutDocument::paint_all_phases(PaintContext& context) { - render(context, PaintPhase::Background); - render(context, PaintPhase::Border); - render(context, PaintPhase::Foreground); - render(context, PaintPhase::Overlay); + paint(context, PaintPhase::Background); + paint(context, PaintPhase::Border); + paint(context, PaintPhase::Foreground); + paint(context, PaintPhase::Overlay); } -void LayoutDocument::render(RenderingContext& context, PaintPhase phase) +void LayoutDocument::paint(PaintContext& context, PaintPhase phase) { - stacking_context()->render(context, phase); + stacking_context()->paint(context, phase); } } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.h b/Libraries/LibWeb/Layout/LayoutDocument.h index ed8bbdf796..56d3d0a7e3 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.h +++ b/Libraries/LibWeb/Layout/LayoutDocument.h @@ -40,9 +40,9 @@ public: virtual const char* class_name() const override { return "LayoutDocument"; } virtual void layout(LayoutMode = LayoutMode::Default) override; - void paint_all_phases(RenderingContext&); + void paint_all_phases(PaintContext&); - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; const LayoutRange& selection() const { return m_selection; } LayoutRange& selection() { return m_selection; } diff --git a/Libraries/LibWeb/Layout/LayoutFrame.cpp b/Libraries/LibWeb/Layout/LayoutFrame.cpp index 54dacce8af..63301c7d27 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.cpp +++ b/Libraries/LibWeb/Layout/LayoutFrame.cpp @@ -59,9 +59,9 @@ void LayoutFrame::layout(LayoutMode layout_mode) LayoutReplaced::layout(layout_mode); } -void LayoutFrame::render(RenderingContext& context, PaintPhase phase) +void LayoutFrame::paint(PaintContext& context, PaintPhase phase) { - LayoutReplaced::render(context, phase); + LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { auto* hosted_document = node().hosted_document(); diff --git a/Libraries/LibWeb/Layout/LayoutFrame.h b/Libraries/LibWeb/Layout/LayoutFrame.h index e5e6d63a0d..9d2f2c3f4b 100644 --- a/Libraries/LibWeb/Layout/LayoutFrame.h +++ b/Libraries/LibWeb/Layout/LayoutFrame.h @@ -36,7 +36,7 @@ public: LayoutFrame(const Element&, NonnullRefPtr); virtual ~LayoutFrame() override; - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; virtual void layout(LayoutMode) override; const HTMLIFrameElement& node() const { return static_cast(LayoutReplaced::node()); } diff --git a/Libraries/LibWeb/Layout/LayoutImage.cpp b/Libraries/LibWeb/Layout/LayoutImage.cpp index 67de3fdfe4..94de65f0ef 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.cpp +++ b/Libraries/LibWeb/Layout/LayoutImage.cpp @@ -77,7 +77,7 @@ void LayoutImage::layout(LayoutMode layout_mode) LayoutReplaced::layout(layout_mode); } -void LayoutImage::render(RenderingContext& context, PaintPhase phase) +void LayoutImage::paint(PaintContext& context, PaintPhase phase) { if (!is_visible()) return; @@ -86,7 +86,7 @@ void LayoutImage::render(RenderingContext& context, PaintPhase phase) if (!context.viewport_rect().intersects(enclosing_int_rect(absolute_rect()))) return; - LayoutReplaced::render(context, phase); + LayoutReplaced::paint(context, phase); if (phase == PaintPhase::Foreground) { if (renders_as_alt_text()) { diff --git a/Libraries/LibWeb/Layout/LayoutImage.h b/Libraries/LibWeb/Layout/LayoutImage.h index 269455710b..0e1a3cb923 100644 --- a/Libraries/LibWeb/Layout/LayoutImage.h +++ b/Libraries/LibWeb/Layout/LayoutImage.h @@ -39,7 +39,7 @@ public: virtual ~LayoutImage() override; virtual void layout(LayoutMode = LayoutMode::Default) override; - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; const Element& node() const { return static_cast(LayoutReplaced::node()); } diff --git a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp index a103cc8e24..551f7e36ea 100644 --- a/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp +++ b/Libraries/LibWeb/Layout/LayoutListItemMarker.cpp @@ -38,7 +38,7 @@ LayoutListItemMarker::~LayoutListItemMarker() { } -void LayoutListItemMarker::render(RenderingContext& context, PaintPhase phase) +void LayoutListItemMarker::paint(PaintContext& context, PaintPhase phase) { if (phase != PaintPhase::Foreground) return; diff --git a/Libraries/LibWeb/Layout/LayoutListItemMarker.h b/Libraries/LibWeb/Layout/LayoutListItemMarker.h index 712702ea90..0c934a158a 100644 --- a/Libraries/LibWeb/Layout/LayoutListItemMarker.h +++ b/Libraries/LibWeb/Layout/LayoutListItemMarker.h @@ -35,7 +35,7 @@ public: LayoutListItemMarker(); virtual ~LayoutListItemMarker() override; - virtual void render(RenderingContext&, PaintPhase) override; + virtual void paint(PaintContext&, PaintPhase) override; private: virtual const char* class_name() const override { return "LayoutListItemMarker"; } diff --git a/Libraries/LibWeb/Layout/LayoutNode.cpp b/Libraries/LibWeb/Layout/LayoutNode.cpp index 6ce138b842..a852ce2cb2 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.cpp +++ b/Libraries/LibWeb/Layout/LayoutNode.cpp @@ -89,7 +89,7 @@ const LayoutBlock* LayoutNode::containing_block() const return nearest_block_ancestor(); } -void LayoutNode::render(RenderingContext& context, PaintPhase phase) +void LayoutNode::paint(PaintContext& context, PaintPhase phase) { if (!is_visible()) return; @@ -97,7 +97,7 @@ void LayoutNode::render(RenderingContext& context, PaintPhase phase) for_each_child([&](auto& child) { if (child.is_box() && to(child).stacking_context()) return; - child.render(context, phase); + child.paint(context, phase); }); } diff --git a/Libraries/LibWeb/Layout/LayoutNode.h b/Libraries/LibWeb/Layout/LayoutNode.h index b78cf1d953..df2c032a36 100644 --- a/Libraries/LibWeb/Layout/LayoutNode.h +++ b/Libraries/LibWeb/Layout/LayoutNode.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include namespace Web { @@ -178,7 +178,7 @@ public: Foreground, Overlay, }; - virtual void render(RenderingContext&, PaintPhase); + virtual void paint(PaintContext&, PaintPhase); bool is_absolutely_positioned() const; bool is_fixed_position() const; diff --git a/Libraries/LibWeb/Layout/LayoutText.cpp b/Libraries/LibWeb/Layout/LayoutText.cpp index c8f3558e8b..119f8aee0c 100644 --- a/Libraries/LibWeb/Layout/LayoutText.cpp +++ b/Libraries/LibWeb/Layout/LayoutText.cpp @@ -65,7 +65,7 @@ const String& LayoutText::text_for_style(const StyleProperties& style) const return node().data(); } -void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragment& fragment) const +void LayoutText::render_fragment(PaintContext& context, const LineBoxFragment& fragment) const { auto& painter = context.painter(); painter.set_font(style().font()); diff --git a/Libraries/LibWeb/Layout/LayoutText.h b/Libraries/LibWeb/Layout/LayoutText.h index bc8aac3a3e..b5860dca02 100644 --- a/Libraries/LibWeb/Layout/LayoutText.h +++ b/Libraries/LibWeb/Layout/LayoutText.h @@ -46,7 +46,7 @@ public: virtual const char* class_name() const override { return "LayoutText"; } virtual bool is_text() const final { return true; } - void render_fragment(RenderingContext&, const LineBoxFragment&) const; + void render_fragment(PaintContext&, const LineBoxFragment&) const; virtual void split_into_lines(LayoutBlock& container, LayoutMode) override; diff --git a/Libraries/LibWeb/Layout/LineBoxFragment.cpp b/Libraries/LibWeb/Layout/LineBoxFragment.cpp index 40b19a59e0..55a9442e32 100644 --- a/Libraries/LibWeb/Layout/LineBoxFragment.cpp +++ b/Libraries/LibWeb/Layout/LineBoxFragment.cpp @@ -29,12 +29,12 @@ #include #include #include -#include +#include #include namespace Web { -void LineBoxFragment::render(RenderingContext& context) +void LineBoxFragment::render(PaintContext& context) { for (auto* ancestor = layout_node().parent(); ancestor; ancestor = ancestor->parent()) { if (!ancestor->is_visible()) diff --git a/Libraries/LibWeb/Layout/LineBoxFragment.h b/Libraries/LibWeb/Layout/LineBoxFragment.h index 3dd0967a47..47f09bc890 100644 --- a/Libraries/LibWeb/Layout/LineBoxFragment.h +++ b/Libraries/LibWeb/Layout/LineBoxFragment.h @@ -60,7 +60,7 @@ public: float absolute_x() const { return absolute_rect().x(); } - void render(RenderingContext&); + void render(PaintContext&); bool ends_in_whitespace() const; bool is_justifiable_whitespace() const; diff --git a/Libraries/LibWeb/Layout/StackingContext.cpp b/Libraries/LibWeb/Layout/StackingContext.cpp index 13a16ed9e9..6ea1cd1381 100644 --- a/Libraries/LibWeb/Layout/StackingContext.cpp +++ b/Libraries/LibWeb/Layout/StackingContext.cpp @@ -47,17 +47,17 @@ StackingContext::StackingContext(LayoutBox& box, StackingContext* parent) } } -void StackingContext::render(RenderingContext& context, LayoutNode::PaintPhase phase) +void StackingContext::paint(PaintContext& context, LayoutNode::PaintPhase phase) { if (!m_box.is_root()) { - m_box.render(context, phase); + m_box.paint(context, phase); } else { - // NOTE: LayoutDocument::render() merely calls StackingContext::render() + // NOTE: LayoutDocument::paint() merely calls StackingContext::paint() // so we call its base class instead. - to(m_box).LayoutBlock::render(context, phase); + to(m_box).LayoutBlock::paint(context, phase); } for (auto* child : m_children) { - child->render(context, phase); + child->paint(context, phase); } } diff --git a/Libraries/LibWeb/Layout/StackingContext.h b/Libraries/LibWeb/Layout/StackingContext.h index 81ae17419a..72751a198a 100644 --- a/Libraries/LibWeb/Layout/StackingContext.h +++ b/Libraries/LibWeb/Layout/StackingContext.h @@ -40,7 +40,7 @@ public: StackingContext* parent() { return m_parent; } const StackingContext* parent() const { return m_parent; } - void render(RenderingContext&, LayoutNode::PaintPhase); + void paint(PaintContext&, LayoutNode::PaintPhase); void dump(int indent = 0) const; -- cgit v1.2.3