mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
LibWeb: Remove Layout::Node::m_visible and compute it on the fly
This fixes an issue where the value would be out of sync with reality in anonymous wrapper block boxes, since we forgot to compute m_visible after assigning the computed values to them. Fixes #21106
This commit is contained in:
parent
0a133ccba4
commit
1f69e9cddf
Notes:
sideshowbarker
2024-07-16 18:03:21 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/1f69e9cddf Pull-request: https://github.com/SerenityOS/serenity/pull/21138 Issue: https://github.com/SerenityOS/serenity/issues/21106
8 changed files with 32 additions and 9 deletions
12
Tests/LibWeb/Ref/anonymous-wrapper-css-visibility.html
Normal file
12
Tests/LibWeb/Ref/anonymous-wrapper-css-visibility.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<link rel="match" href="reference/anonymous-wrapper-css-visibility-ref.html" />
|
||||
<style>
|
||||
body {
|
||||
visibility: hidden;
|
||||
}
|
||||
body:after {
|
||||
visibility: visible;
|
||||
display: block;
|
||||
content: "Visible";
|
||||
}
|
||||
</style><body>Hidden
|
|
@ -0,0 +1,12 @@
|
|||
<!doctype html>
|
||||
<link rel="match" href="reference/anonymous-wrapper-css-visibility-ref.html" />
|
||||
<style>
|
||||
body {
|
||||
color: transparent;
|
||||
}
|
||||
body:after {
|
||||
color: black;
|
||||
display: block;
|
||||
content: "Visible";
|
||||
}
|
||||
</style><body>Hidden
|
|
@ -640,8 +640,6 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
|
|||
if (auto maybe_visibility = computed_style.visibility(); maybe_visibility.has_value())
|
||||
computed_values.set_visibility(maybe_visibility.release_value());
|
||||
|
||||
m_visible = computed_values.opacity() != 0 && computed_values.visibility() == CSS::Visibility::Visible;
|
||||
|
||||
computed_values.set_width(computed_style.size_value(CSS::PropertyID::Width));
|
||||
computed_values.set_min_width(computed_style.size_value(CSS::PropertyID::MinWidth));
|
||||
computed_values.set_max_width(computed_style.size_value(CSS::PropertyID::MaxWidth));
|
||||
|
|
|
@ -156,9 +156,6 @@ public:
|
|||
void removed_from(Node&) { }
|
||||
void children_changed() { }
|
||||
|
||||
bool is_visible() const { return m_visible; }
|
||||
void set_visible(bool visible) { m_visible = visible; }
|
||||
|
||||
virtual void set_needs_display();
|
||||
|
||||
bool children_are_inline() const { return m_children_are_inline; }
|
||||
|
@ -194,7 +191,6 @@ private:
|
|||
|
||||
bool m_anonymous { false };
|
||||
bool m_has_style { false };
|
||||
bool m_visible { true };
|
||||
bool m_children_are_inline { false };
|
||||
SelectionState m_selection_state { SelectionState::None };
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ Layout::CanvasBox const& CanvasPaintable::layout_box() const
|
|||
|
||||
void CanvasPaintable::paint(PaintContext& context, PaintPhase phase) const
|
||||
{
|
||||
if (!layout_box().is_visible())
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
PaintableBox::paint(context, phase);
|
||||
|
|
|
@ -31,7 +31,7 @@ Layout::FrameBox const& NestedBrowsingContextPaintable::layout_box() const
|
|||
|
||||
void NestedBrowsingContextPaintable::paint(PaintContext& context, PaintPhase phase) const
|
||||
{
|
||||
if (!layout_box().is_visible())
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
PaintableBox::paint(context, phase);
|
||||
|
|
|
@ -40,6 +40,11 @@ PaintableBox::~PaintableBox()
|
|||
{
|
||||
}
|
||||
|
||||
bool PaintableBox::is_visible() const
|
||||
{
|
||||
return computed_values().visibility() == CSS::Visibility::Visible && computed_values().opacity() != 0;
|
||||
}
|
||||
|
||||
void PaintableBox::invalidate_stacking_context()
|
||||
{
|
||||
m_stacking_context = nullptr;
|
||||
|
|
|
@ -25,7 +25,7 @@ public:
|
|||
|
||||
virtual void paint(PaintContext&, PaintPhase) const override;
|
||||
|
||||
bool is_visible() const { return layout_box().is_visible(); }
|
||||
[[nodiscard]] bool is_visible() const;
|
||||
|
||||
Layout::Box& layout_box() { return static_cast<Layout::Box&>(Paintable::layout_node()); }
|
||||
Layout::Box const& layout_box() const { return static_cast<Layout::Box const&>(Paintable::layout_node()); }
|
||||
|
|
Loading…
Reference in a new issue