mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-08 09:09:43 +00:00
LibWeb: Store visibility for Paintables
For every invocation of `::before_paint()` and `::after_paint()`, we would reach into the node's computed values to determine its visibility. Let's just do this once during construction of the paintable instead, since this was showing up in profiles.
This commit is contained in:
parent
1871843acb
commit
7dc8062283
Notes:
github-actions[bot]
2025-06-17 09:56:41 +00:00
Author: https://github.com/gmta
Commit: 7dc8062283
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5104
2 changed files with 3 additions and 7 deletions
|
@ -24,6 +24,7 @@ Paintable::Paintable(Layout::Node const& layout_node)
|
|||
m_positioned = computed_values.position() != CSS::Positioning::Static;
|
||||
}
|
||||
|
||||
m_visible = computed_values.visibility() == CSS::Visibility::Visible && computed_values.opacity() != 0;
|
||||
m_fixed_position = computed_values.position() == CSS::Positioning::Fixed;
|
||||
m_sticky_position = computed_values.position() == CSS::Positioning::Sticky;
|
||||
m_absolutely_positioned = computed_values.position() == CSS::Positioning::Absolute;
|
||||
|
@ -45,12 +46,6 @@ void Paintable::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_containing_block.value());
|
||||
}
|
||||
|
||||
bool Paintable::is_visible() const
|
||||
{
|
||||
auto const& computed_values = this->computed_values();
|
||||
return computed_values.visibility() == CSS::Visibility::Visible && computed_values.opacity() != 0;
|
||||
}
|
||||
|
||||
DOM::Document const& Paintable::document() const
|
||||
{
|
||||
return layout_node().document();
|
||||
|
|
|
@ -56,7 +56,7 @@ class Paintable
|
|||
public:
|
||||
virtual ~Paintable();
|
||||
|
||||
[[nodiscard]] bool is_visible() const;
|
||||
[[nodiscard]] bool is_visible() const { return m_visible; }
|
||||
[[nodiscard]] bool is_positioned() const { return m_positioned; }
|
||||
[[nodiscard]] bool is_fixed_position() const { return m_fixed_position; }
|
||||
[[nodiscard]] bool is_sticky_position() const { return m_sticky_position; }
|
||||
|
@ -168,6 +168,7 @@ private:
|
|||
|
||||
SelectionState m_selection_state { SelectionState::None };
|
||||
|
||||
bool m_visible : 1 { false };
|
||||
bool m_positioned : 1 { false };
|
||||
bool m_fixed_position : 1 { false };
|
||||
bool m_sticky_position : 1 { false };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue