mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 09:49:15 +03:00
LibWeb: Add mutable_computed_values()
for NodeWithStyle
This fixes the issue that we previously had to use a gross static_cast whenever we wanted to mutate computed values outside of the Node methods.
This commit is contained in:
parent
44b2735b9e
commit
7eee3f6952
Notes:
sideshowbarker
2024-07-17 09:41:18 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/7eee3f6952 Pull-request: https://github.com/SerenityOS/serenity/pull/21000 Reviewed-by: https://github.com/awesomekling
@ -927,7 +927,7 @@ static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewpo
|
||||
// UAs must apply the overflow-* values set on the root element to the viewport
|
||||
// when the root element’s display value is not none.
|
||||
auto* overflow_origin_node = root_element.layout_node();
|
||||
auto& viewport_computed_values = const_cast<CSS::MutableComputedValues&>(static_cast<CSS::MutableComputedValues const&>(static_cast<CSS::ComputedValues const&>(viewport.computed_values())));
|
||||
auto& viewport_computed_values = viewport.mutable_computed_values();
|
||||
|
||||
// However, when the root element is an [HTML] html element (including XML syntax for HTML)
|
||||
// whose overflow value is visible (in both axes), and that element has as a child
|
||||
@ -935,7 +935,7 @@ static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewpo
|
||||
// user agents must instead apply the overflow-* values of the first such child element to the viewport.
|
||||
if (root_element.is_html_html_element()) {
|
||||
auto* root_element_layout_node = root_element.layout_node();
|
||||
auto& root_element_computed_values = const_cast<CSS::MutableComputedValues&>(static_cast<CSS::MutableComputedValues const&>(static_cast<CSS::ComputedValues const&>(root_element_layout_node->computed_values())));
|
||||
auto& root_element_computed_values = root_element_layout_node->mutable_computed_values();
|
||||
if (root_element_computed_values.overflow_x() == CSS::Overflow::Visible && root_element_computed_values.overflow_y() == CSS::Overflow::Visible) {
|
||||
auto* body_element = root_element.first_child_of_type<HTML::HTMLBodyElement>();
|
||||
if (body_element && body_element->layout_node())
|
||||
@ -944,7 +944,7 @@ static void propagate_overflow_to_viewport(Element& root_element, Layout::Viewpo
|
||||
}
|
||||
|
||||
// NOTE: This is where we assign the chosen overflow values to the viewport.
|
||||
auto& overflow_origin_computed_values = const_cast<CSS::MutableComputedValues&>(static_cast<CSS::MutableComputedValues const&>(static_cast<CSS::ComputedValues const&>(overflow_origin_node->computed_values())));
|
||||
auto& overflow_origin_computed_values = overflow_origin_node->mutable_computed_values();
|
||||
viewport_computed_values.set_overflow_x(overflow_origin_computed_values.overflow_x());
|
||||
viewport_computed_values.set_overflow_y(overflow_origin_computed_values.overflow_y());
|
||||
|
||||
|
@ -209,6 +209,7 @@ public:
|
||||
virtual ~NodeWithStyle() override = default;
|
||||
|
||||
const CSS::ImmutableComputedValues& computed_values() const { return static_cast<const CSS::ImmutableComputedValues&>(m_computed_values); }
|
||||
CSS::MutableComputedValues& mutable_computed_values() { return static_cast<CSS::MutableComputedValues&>(m_computed_values); }
|
||||
|
||||
void apply_style(const CSS::StyleProperties&);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user