1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:38:11 +00:00

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.
This commit is contained in:
Andreas Kling 2020-06-18 21:35:44 +02:00
parent dec0cd3755
commit 8c82d26668
26 changed files with 49 additions and 49 deletions

View file

@ -60,7 +60,7 @@ class Node;
class Origin;
class Page;
class PageClient;
class RenderingContext;
class PaintContext;
class Resource;
class ResourceLoader;
class Selector;

View file

@ -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) {

View file

@ -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;

View file

@ -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);

View file

@ -67,7 +67,7 @@ public:
void set_stacking_context(NonnullOwnPtr<StackingContext> 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<StyleProperties> 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;

View file

@ -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!

View file

@ -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<const HTMLCanvasElement&>(LayoutReplaced::node()); }

View file

@ -100,17 +100,17 @@ void LayoutDocument::did_set_viewport_rect(Badge<Frame>, 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);
}
}

View file

@ -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; }

View file

@ -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();

View file

@ -36,7 +36,7 @@ public:
LayoutFrame(const Element&, NonnullRefPtr<StyleProperties>);
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<const HTMLIFrameElement&>(LayoutReplaced::node()); }

View file

@ -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()) {

View file

@ -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<const Element&>(LayoutReplaced::node()); }

View file

@ -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;

View file

@ -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"; }

View file

@ -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<LayoutBox>(child).stacking_context())
return;
child.render(context, phase);
child.paint(context, phase);
});
}

View file

@ -34,7 +34,7 @@
#include <LibWeb/Forward.h>
#include <LibWeb/Layout/BoxModelMetrics.h>
#include <LibWeb/Layout/LayoutPosition.h>
#include <LibWeb/RenderingContext.h>
#include <LibWeb/Painting/PaintContext.h>
#include <LibWeb/TreeNode.h>
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;

View file

@ -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());

View file

@ -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;

View file

@ -29,12 +29,12 @@
#include <LibWeb/Layout/LayoutDocument.h>
#include <LibWeb/Layout/LayoutText.h>
#include <LibWeb/Layout/LineBoxFragment.h>
#include <LibWeb/RenderingContext.h>
#include <LibWeb/Painting/PaintContext.h>
#include <ctype.h>
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())

View file

@ -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;

View file

@ -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<LayoutDocument>(m_box).LayoutBlock::render(context, phase);
to<LayoutDocument>(m_box).LayoutBlock::paint(context, phase);
}
for (auto* child : m_children) {
child->render(context, phase);
child->paint(context, phase);
}
}

View file

@ -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;

View file

@ -47,7 +47,7 @@
#include <LibWeb/Layout/LayoutNode.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWeb/PageView.h>
#include <LibWeb/RenderingContext.h>
#include <LibWeb/Painting/PaintContext.h>
#include <stdio.h>
//#define SELECTION_DEBUG
@ -207,7 +207,7 @@ void PageView::paint_event(GUI::PaintEvent& event)
painter.translate(frame_thickness(), frame_thickness());
painter.translate(-horizontal_scrollbar().value(), -vertical_scrollbar().value());
RenderingContext context(painter, palette(), { horizontal_scrollbar().value(), vertical_scrollbar().value() });
PaintContext context(painter, palette(), { horizontal_scrollbar().value(), vertical_scrollbar().value() });
context.set_should_show_line_box_borders(m_should_show_line_box_borders);
context.set_viewport_rect(viewport_rect_in_content_coordinates());
layout_root()->paint_all_phases(context);

View file

@ -32,9 +32,9 @@
namespace Web {
class RenderingContext {
class PaintContext {
public:
explicit RenderingContext(Gfx::Painter& painter, const Palette& palette, const Gfx::IntPoint& scroll_offset)
explicit PaintContext(Gfx::Painter& painter, const Palette& palette, const Gfx::IntPoint& scroll_offset)
: m_painter(painter)
, m_palette(palette)
, m_scroll_offset(scroll_offset)

View file

@ -86,7 +86,7 @@ void PageHost::paint(const Gfx::IntRect& content_rect, Gfx::Bitmap& target)
painter.draw_tiled_bitmap(content_rect, *background_bitmap);
}
Web::RenderingContext context(painter, palette(), Gfx::IntPoint());
Web::PaintContext context(painter, palette(), Gfx::IntPoint());
context.set_viewport_rect(content_rect);
layout_root->paint_all_phases(context);
}