mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-22 09:12:13 -05:00
LibWeb: Make CSS::ComputedProperties GC-allocated
This commit is contained in:
parent
c1cad8fa0e
commit
74469a0c1f
Notes:
github-actions[bot]
2024-12-22 09:13:42 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/74469a0c1ff Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2995
138 changed files with 337 additions and 339 deletions
|
@ -921,13 +921,13 @@ void KeyframeEffect::update_computed_properties()
|
|||
if (!target)
|
||||
return;
|
||||
|
||||
Optional<CSS::ComputedProperties&> style = {};
|
||||
GC::Ptr<CSS::ComputedProperties> style = {};
|
||||
if (!pseudo_element_type().has_value())
|
||||
style = target->computed_css_values();
|
||||
style = target->computed_properties();
|
||||
else
|
||||
style = target->pseudo_element_computed_css_values(pseudo_element_type().value());
|
||||
style = target->pseudo_element_computed_properties(pseudo_element_type().value());
|
||||
|
||||
if (!style.has_value())
|
||||
if (!style)
|
||||
return;
|
||||
|
||||
auto animated_properties_before_update = style->animated_property_values();
|
||||
|
@ -937,8 +937,8 @@ void KeyframeEffect::update_computed_properties()
|
|||
|
||||
// Traversal of the subtree is necessary to update the animated properties inherited from the target element.
|
||||
target->for_each_in_subtree_of_type<DOM::Element>([&](auto& element) {
|
||||
auto element_style = element.computed_css_values();
|
||||
if (!element_style.has_value() || !element.layout_node())
|
||||
auto element_style = element.computed_properties();
|
||||
if (!element_style || !element.layout_node())
|
||||
return TraversalDecision::Continue;
|
||||
|
||||
for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <AK/NonnullRawPtr.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibCore/DirIterator.h>
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibWeb/CSS/Clip.h>
|
||||
#include <LibWeb/CSS/ComputedProperties.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
|
@ -42,91 +43,89 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
NonnullRefPtr<ComputedProperties::Data> ComputedProperties::Data::clone() const
|
||||
GC_DEFINE_ALLOCATOR(ComputedProperties);
|
||||
|
||||
ComputedProperties::ComputedProperties() = default;
|
||||
|
||||
ComputedProperties::~ComputedProperties() = default;
|
||||
|
||||
void ComputedProperties::visit_edges(Visitor& visitor)
|
||||
{
|
||||
auto clone = adopt_ref(*new ComputedProperties::Data);
|
||||
clone->m_animation_name_source = m_animation_name_source;
|
||||
clone->m_transition_property_source = m_transition_property_source;
|
||||
clone->m_property_values = m_property_values;
|
||||
clone->m_property_important = m_property_important;
|
||||
clone->m_property_inherited = m_property_inherited;
|
||||
clone->m_animated_property_values = m_animated_property_values;
|
||||
clone->m_math_depth = m_math_depth;
|
||||
clone->m_font_list = m_font_list;
|
||||
clone->m_line_height = m_line_height;
|
||||
return clone;
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_animation_name_source);
|
||||
visitor.visit(m_transition_property_source);
|
||||
}
|
||||
|
||||
bool ComputedProperties::is_property_important(CSS::PropertyID property_id) const
|
||||
{
|
||||
size_t n = to_underlying(property_id);
|
||||
return m_data->m_property_important[n / 8] & (1 << (n % 8));
|
||||
return m_property_important[n / 8] & (1 << (n % 8));
|
||||
}
|
||||
|
||||
void ComputedProperties::set_property_important(CSS::PropertyID property_id, Important important)
|
||||
{
|
||||
size_t n = to_underlying(property_id);
|
||||
if (important == Important::Yes)
|
||||
m_data->m_property_important[n / 8] |= (1 << (n % 8));
|
||||
m_property_important[n / 8] |= (1 << (n % 8));
|
||||
else
|
||||
m_data->m_property_important[n / 8] &= ~(1 << (n % 8));
|
||||
m_property_important[n / 8] &= ~(1 << (n % 8));
|
||||
}
|
||||
|
||||
bool ComputedProperties::is_property_inherited(CSS::PropertyID property_id) const
|
||||
{
|
||||
size_t n = to_underlying(property_id);
|
||||
return m_data->m_property_inherited[n / 8] & (1 << (n % 8));
|
||||
return m_property_inherited[n / 8] & (1 << (n % 8));
|
||||
}
|
||||
|
||||
void ComputedProperties::set_property_inherited(CSS::PropertyID property_id, Inherited inherited)
|
||||
{
|
||||
size_t n = to_underlying(property_id);
|
||||
if (inherited == Inherited::Yes)
|
||||
m_data->m_property_inherited[n / 8] |= (1 << (n % 8));
|
||||
m_property_inherited[n / 8] |= (1 << (n % 8));
|
||||
else
|
||||
m_data->m_property_inherited[n / 8] &= ~(1 << (n % 8));
|
||||
m_property_inherited[n / 8] &= ~(1 << (n % 8));
|
||||
}
|
||||
|
||||
void ComputedProperties::set_property(CSS::PropertyID id, NonnullRefPtr<CSSStyleValue const> value, Inherited inherited, Important important)
|
||||
{
|
||||
m_data->m_property_values[to_underlying(id)] = move(value);
|
||||
m_property_values[to_underlying(id)] = move(value);
|
||||
set_property_important(id, important);
|
||||
set_property_inherited(id, inherited);
|
||||
}
|
||||
|
||||
void ComputedProperties::revert_property(CSS::PropertyID id, ComputedProperties const& style_for_revert)
|
||||
{
|
||||
m_data->m_property_values[to_underlying(id)] = style_for_revert.m_data->m_property_values[to_underlying(id)];
|
||||
m_property_values[to_underlying(id)] = style_for_revert.m_property_values[to_underlying(id)];
|
||||
set_property_important(id, style_for_revert.is_property_important(id) ? Important::Yes : Important::No);
|
||||
set_property_inherited(id, style_for_revert.is_property_inherited(id) ? Inherited::Yes : Inherited::No);
|
||||
}
|
||||
|
||||
void ComputedProperties::set_animated_property(CSS::PropertyID id, NonnullRefPtr<CSSStyleValue const> value)
|
||||
{
|
||||
m_data->m_animated_property_values.set(id, move(value));
|
||||
m_animated_property_values.set(id, move(value));
|
||||
}
|
||||
|
||||
void ComputedProperties::reset_animated_properties()
|
||||
{
|
||||
m_data->m_animated_property_values.clear();
|
||||
m_animated_property_values.clear();
|
||||
}
|
||||
|
||||
CSSStyleValue const& ComputedProperties::property(CSS::PropertyID property_id, WithAnimationsApplied return_animated_value) const
|
||||
{
|
||||
if (return_animated_value == WithAnimationsApplied::Yes) {
|
||||
if (auto animated_value = m_data->m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
return *animated_value.value();
|
||||
}
|
||||
|
||||
// By the time we call this method, all properties have values assigned.
|
||||
return *m_data->m_property_values[to_underlying(property_id)];
|
||||
return *m_property_values[to_underlying(property_id)];
|
||||
}
|
||||
|
||||
CSSStyleValue const* ComputedProperties::maybe_null_property(CSS::PropertyID property_id) const
|
||||
{
|
||||
if (auto animated_value = m_data->m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
if (auto animated_value = m_animated_property_values.get(property_id); animated_value.has_value())
|
||||
return animated_value.value();
|
||||
return m_data->m_property_values[to_underlying(property_id)];
|
||||
return m_property_values[to_underlying(property_id)];
|
||||
}
|
||||
|
||||
Variant<LengthPercentage, NormalGap> ComputedProperties::gap_value(CSS::PropertyID id) const
|
||||
|
@ -270,7 +269,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r
|
|||
auto resolved = line_height.as_calculated().resolve_number();
|
||||
if (!resolved.has_value()) {
|
||||
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing());
|
||||
return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing());
|
||||
}
|
||||
return Length(resolved.value(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics);
|
||||
}
|
||||
|
@ -278,7 +277,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r
|
|||
auto resolved = line_height.as_calculated().resolve_length(Length::ResolutionContext { viewport_rect, font_metrics, root_font_metrics });
|
||||
if (!resolved.has_value()) {
|
||||
dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal));
|
||||
return CSSPixels::nearest_value_for(m_data->m_font_list->first().pixel_metrics().line_spacing());
|
||||
return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing());
|
||||
}
|
||||
return resolved->to_px(viewport_rect, font_metrics, root_font_metrics);
|
||||
}
|
||||
|
@ -740,12 +739,12 @@ Optional<CSS::Positioning> ComputedProperties::position() const
|
|||
|
||||
bool ComputedProperties::operator==(ComputedProperties const& other) const
|
||||
{
|
||||
if (m_data->m_property_values.size() != other.m_data->m_property_values.size())
|
||||
if (m_property_values.size() != other.m_property_values.size())
|
||||
return false;
|
||||
|
||||
for (size_t i = 0; i < m_data->m_property_values.size(); ++i) {
|
||||
auto const& my_style = m_data->m_property_values[i];
|
||||
auto const& other_style = other.m_data->m_property_values[i];
|
||||
for (size_t i = 0; i < m_property_values.size(); ++i) {
|
||||
auto const& my_style = m_property_values[i];
|
||||
auto const& other_style = other.m_property_values[i];
|
||||
if (!my_style) {
|
||||
if (other_style)
|
||||
return false;
|
||||
|
@ -1421,7 +1420,7 @@ Color ComputedProperties::stop_color() const
|
|||
|
||||
void ComputedProperties::set_math_depth(int math_depth)
|
||||
{
|
||||
m_data->m_math_depth = math_depth;
|
||||
m_math_depth = math_depth;
|
||||
// Make our children inherit our computed value, not our specified value.
|
||||
set_property(PropertyID::MathDepth, MathDepthStyleValue::create_integer(IntegerStyleValue::create(math_depth)));
|
||||
}
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibGC/Ptr.h>
|
||||
#include <LibGfx/Font/Font.h>
|
||||
#include <LibGfx/FontCascadeList.h>
|
||||
#include <LibGfx/Forward.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/CSS/ComputedValues.h>
|
||||
#include <LibWeb/CSS/LengthBox.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
|
@ -19,41 +21,21 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
class ComputedProperties {
|
||||
class ComputedProperties final : public JS::Cell {
|
||||
GC_CELL(ComputedProperties, JS::Cell);
|
||||
GC_DECLARE_ALLOCATOR(ComputedProperties);
|
||||
|
||||
public:
|
||||
static constexpr size_t number_of_properties = to_underlying(CSS::last_property_id) + 1;
|
||||
|
||||
private:
|
||||
struct Data : public RefCounted<Data> {
|
||||
friend class StyleComputer;
|
||||
|
||||
NonnullRefPtr<Data> clone() const;
|
||||
|
||||
// FIXME: These need protection from GC!
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_transition_property_source;
|
||||
|
||||
Array<RefPtr<CSSStyleValue const>, number_of_properties> m_property_values;
|
||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_important {};
|
||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_inherited {};
|
||||
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> m_animated_property_values;
|
||||
|
||||
int m_math_depth { InitialValues::math_depth() };
|
||||
mutable RefPtr<Gfx::FontCascadeList> m_font_list;
|
||||
|
||||
Optional<CSSPixels> m_line_height;
|
||||
};
|
||||
|
||||
public:
|
||||
ComputedProperties() = default;
|
||||
virtual ~ComputedProperties() override;
|
||||
|
||||
template<typename Callback>
|
||||
inline void for_each_property(Callback callback) const
|
||||
{
|
||||
for (size_t i = 0; i < m_data->m_property_values.size(); ++i) {
|
||||
if (m_data->m_property_values[i])
|
||||
callback((CSS::PropertyID)i, *m_data->m_property_values[i]);
|
||||
for (size_t i = 0; i < m_property_values.size(); ++i) {
|
||||
if (m_property_values[i])
|
||||
callback((CSS::PropertyID)i, *m_property_values[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,7 +44,7 @@ public:
|
|||
Yes
|
||||
};
|
||||
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> const& animated_property_values() const { return m_data->m_animated_property_values; }
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> const& animated_property_values() const { return m_animated_property_values; }
|
||||
void reset_animated_properties();
|
||||
|
||||
bool is_property_important(CSS::PropertyID property_id) const;
|
||||
|
@ -80,11 +62,11 @@ public:
|
|||
CSSStyleValue const* maybe_null_property(CSS::PropertyID) const;
|
||||
void revert_property(CSS::PropertyID, ComputedProperties const& style_for_revert);
|
||||
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_data->m_animation_name_source; }
|
||||
void set_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_animation_name_source = declaration; }
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> animation_name_source() const { return m_animation_name_source; }
|
||||
void set_animation_name_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_animation_name_source = declaration; }
|
||||
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> transition_property_source() const { return m_data->m_transition_property_source; }
|
||||
void set_transition_property_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_data->m_transition_property_source = declaration; }
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> transition_property_source() const { return m_transition_property_source; }
|
||||
void set_transition_property_source(GC::Ptr<CSS::CSSStyleDeclaration const> declaration) { m_transition_property_source = declaration; }
|
||||
|
||||
CSS::Size size_value(CSS::PropertyID) const;
|
||||
[[nodiscard]] Variant<LengthPercentage, NormalGap> gap_value(CSS::PropertyID) const;
|
||||
|
@ -196,23 +178,23 @@ public:
|
|||
Optional<CSS::FillRule> fill_rule() const;
|
||||
Optional<CSS::ClipRule> clip_rule() const;
|
||||
|
||||
Gfx::Font const& first_available_computed_font() const { return m_data->m_font_list->first(); }
|
||||
Gfx::Font const& first_available_computed_font() const { return m_font_list->first(); }
|
||||
|
||||
Gfx::FontCascadeList const& computed_font_list() const
|
||||
{
|
||||
VERIFY(m_data->m_font_list);
|
||||
return *m_data->m_font_list;
|
||||
VERIFY(m_font_list);
|
||||
return *m_font_list;
|
||||
}
|
||||
|
||||
void set_computed_font_list(NonnullRefPtr<Gfx::FontCascadeList> font_list) const
|
||||
{
|
||||
m_data->m_font_list = move(font_list);
|
||||
m_font_list = move(font_list);
|
||||
}
|
||||
|
||||
[[nodiscard]] CSSPixels compute_line_height(CSSPixelRect const& viewport_rect, Length::FontMetrics const& font_metrics, Length::FontMetrics const& root_font_metrics) const;
|
||||
|
||||
[[nodiscard]] CSSPixels line_height() const { return *m_data->m_line_height; }
|
||||
void set_line_height(Badge<StyleComputer> const&, CSSPixels line_height) { m_data->m_line_height = line_height; }
|
||||
[[nodiscard]] CSSPixels line_height() const { return *m_line_height; }
|
||||
void set_line_height(Badge<StyleComputer> const&, CSSPixels line_height) { m_line_height = line_height; }
|
||||
|
||||
bool operator==(ComputedProperties const&) const;
|
||||
|
||||
|
@ -220,7 +202,7 @@ public:
|
|||
Optional<int> z_index() const;
|
||||
|
||||
void set_math_depth(int math_depth);
|
||||
int math_depth() const { return m_data->m_math_depth; }
|
||||
int math_depth() const { return m_math_depth; }
|
||||
|
||||
QuotesData quotes() const;
|
||||
Vector<CounterData> counter_data(PropertyID) const;
|
||||
|
@ -234,10 +216,26 @@ public:
|
|||
private:
|
||||
friend class StyleComputer;
|
||||
|
||||
ComputedProperties();
|
||||
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
Optional<CSS::Overflow> overflow(CSS::PropertyID) const;
|
||||
Vector<CSS::ShadowData> shadow(CSS::PropertyID, Layout::Node const&) const;
|
||||
|
||||
AK::CopyOnWrite<ComputedProperties::Data> m_data;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_animation_name_source;
|
||||
GC::Ptr<CSS::CSSStyleDeclaration const> m_transition_property_source;
|
||||
|
||||
Array<RefPtr<CSSStyleValue const>, number_of_properties> m_property_values;
|
||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_important {};
|
||||
Array<u8, ceil_div(number_of_properties, 8uz)> m_property_inherited {};
|
||||
|
||||
HashMap<CSS::PropertyID, NonnullRefPtr<CSSStyleValue const>> m_animated_property_values;
|
||||
|
||||
int m_math_depth { InitialValues::math_depth() };
|
||||
mutable RefPtr<Gfx::FontCascadeList> m_font_list;
|
||||
|
||||
Optional<CSSPixels> m_line_height;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -196,8 +196,8 @@ RefPtr<CSSStyleValue const> ResolvedCSSStyleDeclaration::style_value_for_propert
|
|||
|
||||
auto get_computed_value = [this](PropertyID property_id) -> auto const& {
|
||||
if (m_pseudo_element.has_value())
|
||||
return m_element->pseudo_element_computed_css_values(m_pseudo_element.value())->property(property_id);
|
||||
return m_element->computed_css_values()->property(property_id);
|
||||
return m_element->pseudo_element_computed_properties(m_pseudo_element.value())->property(property_id);
|
||||
return m_element->computed_properties()->property(property_id);
|
||||
};
|
||||
|
||||
// A limited number of properties have special rules for producing their "resolved value".
|
||||
|
@ -554,7 +554,7 @@ Optional<StyleProperty> ResolvedCSSStyleDeclaration::property(PropertyID propert
|
|||
auto style = m_element->document().style_computer().compute_style(const_cast<DOM::Element&>(*m_element), m_pseudo_element);
|
||||
|
||||
// FIXME: This is a stopgap until we implement shorthand -> longhand conversion.
|
||||
auto const* value = style.maybe_null_property(property_id);
|
||||
auto const* value = style->maybe_null_property(property_id);
|
||||
if (!value) {
|
||||
dbgln("FIXME: ResolvedCSSStyleDeclaration::property(property_id={:#x}) No value for property ID in newly computed style case.", to_underlying(property_id));
|
||||
return {};
|
||||
|
|
|
@ -1215,7 +1215,7 @@ static void compute_transitioned_properties(ComputedProperties const& style, DOM
|
|||
auto const source_declaration = style.transition_property_source();
|
||||
if (!source_declaration)
|
||||
return;
|
||||
if (!element.computed_css_values().has_value())
|
||||
if (!element.computed_properties())
|
||||
return;
|
||||
if (source_declaration == element.cached_transition_property_source())
|
||||
return;
|
||||
|
@ -1590,16 +1590,16 @@ NonnullRefPtr<CSSStyleValue const> StyleComputer::get_inherit_value(CSS::Propert
|
|||
{
|
||||
auto* parent_element = element_to_inherit_style_from(element, pseudo_element);
|
||||
|
||||
if (!parent_element || !parent_element->computed_css_values().has_value())
|
||||
if (!parent_element || !parent_element->computed_properties())
|
||||
return property_initial_value(property_id);
|
||||
return parent_element->computed_css_values()->property(property_id);
|
||||
return parent_element->computed_properties()->property(property_id);
|
||||
}
|
||||
|
||||
void StyleComputer::compute_defaulted_property_value(ComputedProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
{
|
||||
// FIXME: If we don't know the correct initial value for a property, we fall back to `initial`.
|
||||
|
||||
auto& value_slot = style.m_data->m_property_values[to_underlying(property_id)];
|
||||
auto& value_slot = style.m_property_values[to_underlying(property_id)];
|
||||
if (!value_slot) {
|
||||
if (is_inherited_property(property_id)) {
|
||||
style.set_property(
|
||||
|
@ -1780,14 +1780,14 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
CSSPixels font_size_in_px = 16;
|
||||
|
||||
Gfx::FontPixelMetrics font_pixel_metrics;
|
||||
if (parent_element && parent_element->computed_css_values().has_value())
|
||||
font_pixel_metrics = parent_element->computed_css_values()->first_available_computed_font().pixel_metrics();
|
||||
if (parent_element && parent_element->computed_properties())
|
||||
font_pixel_metrics = parent_element->computed_properties()->first_available_computed_font().pixel_metrics();
|
||||
else
|
||||
font_pixel_metrics = Platform::FontPlugin::the().default_font().pixel_metrics();
|
||||
auto parent_font_size = [&]() -> CSSPixels {
|
||||
if (!parent_element || !parent_element->computed_css_values().has_value())
|
||||
if (!parent_element || !parent_element->computed_properties())
|
||||
return font_size_in_px;
|
||||
auto const& value = parent_element->computed_css_values()->property(CSS::PropertyID::FontSize);
|
||||
auto const& value = parent_element->computed_properties()->property(CSS::PropertyID::FontSize);
|
||||
if (value.is_length()) {
|
||||
auto length = value.as_length().length();
|
||||
if (length.is_absolute() || length.is_relative()) {
|
||||
|
@ -1836,8 +1836,8 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
// If the specified value font-size is math then the computed value of font-size is obtained by multiplying
|
||||
// the inherited value of font-size by a nonzero scale factor calculated by the following procedure:
|
||||
// 1. Let A be the inherited math-depth value, B the computed math-depth value, C be 0.71 and S be 1.0
|
||||
int inherited_math_depth = parent_element && parent_element->computed_css_values().has_value()
|
||||
? parent_element->computed_css_values()->math_depth()
|
||||
int inherited_math_depth = parent_element && parent_element->computed_properties()
|
||||
? parent_element->computed_properties()->math_depth()
|
||||
: InitialValues::math_depth();
|
||||
int computed_math_depth = math_depth;
|
||||
auto size_ratio = 0.71;
|
||||
|
@ -1876,8 +1876,8 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
|
|||
// larger may compute the font size to the next entry in the table,
|
||||
// and smaller may compute the font size to the previous entry in the table.
|
||||
if (keyword == Keyword::Smaller || keyword == Keyword::Larger) {
|
||||
if (parent_element && parent_element->computed_css_values().has_value()) {
|
||||
font_size_in_px = CSSPixels::nearest_value_for(parent_element->computed_css_values()->first_available_computed_font().pixel_metrics().size);
|
||||
if (parent_element && parent_element->computed_properties()) {
|
||||
font_size_in_px = CSSPixels::nearest_value_for(parent_element->computed_properties()->first_available_computed_font().pixel_metrics().size);
|
||||
}
|
||||
}
|
||||
font_size_in_px *= get_absolute_size_mapping(keyword);
|
||||
|
@ -2077,7 +2077,7 @@ void StyleComputer::absolutize_values(ComputedProperties& style) const
|
|||
// We have to resolve them right away, so that the *computed* line-height is ready for inheritance.
|
||||
// We can't simply absolutize *all* percentage values against the font size,
|
||||
// because most percentages are relative to containing block metrics.
|
||||
auto& line_height_value_slot = style.m_data->m_property_values[to_underlying(CSS::PropertyID::LineHeight)];
|
||||
auto& line_height_value_slot = style.m_property_values[to_underlying(CSS::PropertyID::LineHeight)];
|
||||
if (line_height_value_slot && line_height_value_slot->is_percentage()) {
|
||||
line_height_value_slot = LengthStyleValue::create(
|
||||
Length::make_px(CSSPixels::nearest_value_for(font_size * static_cast<double>(line_height_value_slot->as_percentage().percentage().as_fraction()))));
|
||||
|
@ -2090,8 +2090,8 @@ void StyleComputer::absolutize_values(ComputedProperties& style) const
|
|||
if (line_height_value_slot && line_height_value_slot->is_length())
|
||||
line_height_value_slot = LengthStyleValue::create(Length::make_px(line_height));
|
||||
|
||||
for (size_t i = 0; i < style.m_data->m_property_values.size(); ++i) {
|
||||
auto& value_slot = style.m_data->m_property_values[i];
|
||||
for (size_t i = 0; i < style.m_property_values.size(); ++i) {
|
||||
auto& value_slot = style.m_property_values[i];
|
||||
if (!value_slot)
|
||||
continue;
|
||||
value_slot = value_slot->absolutized(viewport_rect(), font_metrics, m_root_element_font_metrics);
|
||||
|
@ -2145,8 +2145,8 @@ static BoxTypeTransformation required_box_type_transformation(ComputedProperties
|
|||
auto const* parent = pseudo_element.has_value() ? &element : element.parent_element();
|
||||
|
||||
// A parent with a grid or flex display value blockifies the box’s display type. [CSS-GRID-1] [CSS-FLEXBOX-1]
|
||||
if (parent && parent->computed_css_values().has_value()) {
|
||||
auto const& parent_display = parent->computed_css_values()->display();
|
||||
if (parent && parent->computed_properties()) {
|
||||
auto const& parent_display = parent->computed_properties()->display();
|
||||
if (parent_display.is_grid_inside() || parent_display.is_flex_inside())
|
||||
return BoxTypeTransformation::Blockify;
|
||||
}
|
||||
|
@ -2244,30 +2244,30 @@ void StyleComputer::transform_box_type_if_needed(ComputedProperties& style, DOM:
|
|||
style.set_property(CSS::PropertyID::Display, DisplayStyleValue::create(new_display));
|
||||
}
|
||||
|
||||
ComputedProperties StyleComputer::create_document_style() const
|
||||
GC::Ref<ComputedProperties> StyleComputer::create_document_style() const
|
||||
{
|
||||
ComputedProperties style = {};
|
||||
auto style = document().heap().allocate<CSS::ComputedProperties>();
|
||||
compute_math_depth(style, nullptr, {});
|
||||
compute_font(style, nullptr, {});
|
||||
compute_defaulted_values(style, nullptr, {});
|
||||
absolutize_values(style);
|
||||
style.set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())));
|
||||
style.set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())));
|
||||
style.set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)));
|
||||
style->set_property(CSS::PropertyID::Width, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().width())));
|
||||
style->set_property(CSS::PropertyID::Height, CSS::LengthStyleValue::create(CSS::Length::make_px(viewport_rect().height())));
|
||||
style->set_property(CSS::PropertyID::Display, CSS::DisplayStyleValue::create(CSS::Display::from_short(CSS::Display::Short::Block)));
|
||||
return style;
|
||||
}
|
||||
|
||||
ComputedProperties StyleComputer::compute_style(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
GC::Ref<ComputedProperties> StyleComputer::compute_style(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
{
|
||||
return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal).release_value();
|
||||
return *compute_style_impl(element, move(pseudo_element), ComputeStyleMode::Normal);
|
||||
}
|
||||
|
||||
Optional<ComputedProperties> StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
GC::Ptr<ComputedProperties> StyleComputer::compute_pseudo_element_style_if_needed(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element) const
|
||||
{
|
||||
return compute_style_impl(element, move(pseudo_element), ComputeStyleMode::CreatePseudoElementStyleIfNeeded);
|
||||
}
|
||||
|
||||
Optional<ComputedProperties> StyleComputer::compute_style_impl(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, ComputeStyleMode mode) const
|
||||
GC::Ptr<ComputedProperties> StyleComputer::compute_style_impl(DOM::Element& element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element, ComputeStyleMode mode) const
|
||||
{
|
||||
build_rule_cache_if_needed();
|
||||
|
||||
|
@ -2279,7 +2279,7 @@ Optional<ComputedProperties> StyleComputer::compute_style_impl(DOM::Element& ele
|
|||
// Merge back inline styles
|
||||
if (auto inline_style = element.inline_style()) {
|
||||
for (auto const& property : inline_style->properties())
|
||||
style.set_property(property.property_id, property.value);
|
||||
style->set_property(property.property_id, property.value);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
@ -2324,9 +2324,9 @@ Optional<ComputedProperties> StyleComputer::compute_style_impl(DOM::Element& ele
|
|||
return compute_properties(element, pseudo_element, cascaded_properties);
|
||||
}
|
||||
|
||||
ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, CascadedProperties& cascaded_properties) const
|
||||
GC::Ref<ComputedProperties> StyleComputer::compute_properties(DOM::Element& element, Optional<Selector::PseudoElement::Type> pseudo_element, CascadedProperties& cascaded_properties) const
|
||||
{
|
||||
ComputedProperties computed_style;
|
||||
auto computed_style = document().heap().allocate<CSS::ComputedProperties>();
|
||||
|
||||
for (auto i = to_underlying(first_longhand_property_id); i <= to_underlying(last_longhand_property_id); ++i) {
|
||||
auto property_id = static_cast<CSS::PropertyID>(i);
|
||||
|
@ -2334,7 +2334,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti
|
|||
if ((!value && is_inherited_property(property_id))
|
||||
|| (value && value->is_inherit())) {
|
||||
if (auto inheritance_parent = element_to_inherit_style_from(&element, pseudo_element)) {
|
||||
value = inheritance_parent->computed_css_values()->property(property_id);
|
||||
value = inheritance_parent->computed_properties()->property(property_id);
|
||||
} else {
|
||||
value = property_initial_value(property_id);
|
||||
}
|
||||
|
@ -2350,19 +2350,19 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti
|
|||
value = CSSKeywordValue::create(Keyword::Initial);
|
||||
}
|
||||
|
||||
computed_style.set_property(property_id, value.release_nonnull());
|
||||
computed_style->set_property(property_id, value.release_nonnull());
|
||||
|
||||
if (property_id == PropertyID::AnimationName) {
|
||||
computed_style.set_animation_name_source(cascaded_properties.property_source(property_id));
|
||||
computed_style->set_animation_name_source(cascaded_properties.property_source(property_id));
|
||||
}
|
||||
if (property_id == PropertyID::TransitionProperty) {
|
||||
computed_style.set_transition_property_source(cascaded_properties.property_source(property_id));
|
||||
computed_style->set_transition_property_source(cascaded_properties.property_source(property_id));
|
||||
}
|
||||
}
|
||||
|
||||
// Animation declarations [css-animations-2]
|
||||
auto animation_name = [&]() -> Optional<String> {
|
||||
auto const animation_name = computed_style.maybe_null_property(PropertyID::AnimationName);
|
||||
auto const animation_name = computed_style->maybe_null_property(PropertyID::AnimationName);
|
||||
if (!animation_name)
|
||||
return OptionalNone {};
|
||||
if (animation_name->is_string())
|
||||
|
@ -2371,7 +2371,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti
|
|||
}();
|
||||
|
||||
if (animation_name.has_value()) {
|
||||
if (auto source_declaration = computed_style.animation_name_source()) {
|
||||
if (auto source_declaration = computed_style->animation_name_source()) {
|
||||
auto& realm = element.realm();
|
||||
|
||||
if (source_declaration != element.cached_animation_name_source(pseudo_element)) {
|
||||
|
@ -2450,7 +2450,7 @@ ComputedProperties StyleComputer::compute_properties(DOM::Element& element, Opti
|
|||
// 9. Transition declarations [css-transitions-1]
|
||||
// Theoretically this should be part of the cascade, but it works with computed values, which we don't have until now.
|
||||
compute_transitioned_properties(computed_style, element, pseudo_element);
|
||||
if (auto previous_style = element.computed_css_values(); previous_style.has_value()) {
|
||||
if (auto previous_style = element.computed_properties(); previous_style) {
|
||||
start_needed_transitions(*previous_style, computed_style, element, pseudo_element);
|
||||
}
|
||||
|
||||
|
@ -2912,7 +2912,7 @@ void StyleComputer::compute_math_depth(ComputedProperties& style, DOM::Element c
|
|||
auto inherited_math_depth = [&]() {
|
||||
if (!element || !element->parent_element())
|
||||
return InitialValues::math_depth();
|
||||
return element->parent_element()->computed_css_values()->math_depth();
|
||||
return element->parent_element()->computed_properties()->math_depth();
|
||||
};
|
||||
|
||||
auto const& value = style.property(CSS::PropertyID::MathDepth);
|
||||
|
|
|
@ -141,10 +141,10 @@ public:
|
|||
void push_ancestor(DOM::Element const&);
|
||||
void pop_ancestor(DOM::Element const&);
|
||||
|
||||
ComputedProperties create_document_style() const;
|
||||
[[nodiscard]] GC::Ref<ComputedProperties> create_document_style() const;
|
||||
|
||||
ComputedProperties compute_style(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type> = {}) const;
|
||||
Optional<ComputedProperties> compute_pseudo_element_style_if_needed(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>) const;
|
||||
[[nodiscard]] GC::Ref<ComputedProperties> compute_style(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type> = {}) const;
|
||||
[[nodiscard]] GC::Ptr<ComputedProperties> compute_pseudo_element_style_if_needed(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>) const;
|
||||
|
||||
Vector<MatchingRule> collect_matching_rules(DOM::Element const&, CascadeOrigin, Optional<CSS::Selector::PseudoElement::Type>, FlyString const& qualified_layer_name = {}) const;
|
||||
|
||||
|
@ -173,7 +173,7 @@ public:
|
|||
|
||||
size_t number_of_css_font_faces_with_loading_in_progress() const;
|
||||
|
||||
[[nodiscard]] ComputedProperties compute_properties(DOM::Element&, Optional<Selector::PseudoElement::Type>, CascadedProperties&) const;
|
||||
[[nodiscard]] GC::Ref<ComputedProperties> compute_properties(DOM::Element&, Optional<Selector::PseudoElement::Type>, CascadedProperties&) const;
|
||||
|
||||
private:
|
||||
enum class ComputeStyleMode {
|
||||
|
@ -185,7 +185,7 @@ private:
|
|||
|
||||
[[nodiscard]] bool should_reject_with_ancestor_filter(Selector const&) const;
|
||||
|
||||
Optional<ComputedProperties> compute_style_impl(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, ComputeStyleMode) const;
|
||||
[[nodiscard]] GC::Ptr<ComputedProperties> compute_style_impl(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, ComputeStyleMode) const;
|
||||
[[nodiscard]] GC::Ref<CascadedProperties> compute_cascaded_values(DOM::Element&, Optional<CSS::Selector::PseudoElement::Type>, bool& did_match_any_pseudo_element_rules, ComputeStyleMode) const;
|
||||
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_ascending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
||||
static RefPtr<Gfx::FontCascadeList const> find_matching_font_weight_descending(Vector<MatchingFontCandidate> const& candidates, int target_weight, float font_size_in_pt, bool inclusive);
|
||||
|
|
|
@ -1298,7 +1298,7 @@ void Document::update_layout()
|
|||
if (needs_full_style_update || node.needs_style_update()) {
|
||||
invalidation |= static_cast<Element&>(node).recompute_style();
|
||||
}
|
||||
is_display_none = static_cast<Element&>(node).computed_css_values()->display().is_none();
|
||||
is_display_none = static_cast<Element&>(node).computed_properties()->display().is_none();
|
||||
}
|
||||
node.set_needs_style_update(false);
|
||||
|
||||
|
|
|
@ -102,9 +102,11 @@ void Element::visit_edges(Cell::Visitor& visitor)
|
|||
visitor.visit(m_shadow_root);
|
||||
visitor.visit(m_custom_element_definition);
|
||||
visitor.visit(m_cascaded_properties);
|
||||
visitor.visit(m_computed_properties);
|
||||
if (m_pseudo_element_data) {
|
||||
for (auto& pseudo_element : *m_pseudo_element_data) {
|
||||
visitor.visit(pseudo_element.cascaded_properties);
|
||||
visitor.visit(pseudo_element.computed_properties);
|
||||
visitor.visit(pseudo_element.layout_node);
|
||||
}
|
||||
}
|
||||
|
@ -388,16 +390,16 @@ Vector<String> Element::get_attribute_names() const
|
|||
return names;
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> Element::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> Element::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
if (local_name() == "noscript" && document().is_scripting_enabled())
|
||||
return nullptr;
|
||||
|
||||
auto display = style.display();
|
||||
return create_layout_node_for_display_type(document(), display, move(style), this);
|
||||
auto display = style->display();
|
||||
return create_layout_node_for_display_type(document(), display, style, this);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::NodeWithStyle> Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, CSS::ComputedProperties style, Element* element)
|
||||
GC::Ptr<Layout::NodeWithStyle> Element::create_layout_node_for_display_type(DOM::Document& document, CSS::Display const& display, GC::Ref<CSS::ComputedProperties> style, Element* element)
|
||||
{
|
||||
if (display.is_table_inside() || display.is_table_row_group() || display.is_table_header_group() || display.is_table_footer_group() || display.is_table_row())
|
||||
return document.heap().allocate<Layout::Box>(document, element, move(style));
|
||||
|
@ -478,40 +480,40 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
VERIFY(parent());
|
||||
|
||||
auto& style_computer = document().style_computer();
|
||||
auto new_computed_css_values = style_computer.compute_style(*this);
|
||||
auto new_computed_properties = style_computer.compute_style(*this);
|
||||
|
||||
// Tables must not inherit -libweb-* values for text-align.
|
||||
// FIXME: Find the spec for this.
|
||||
if (is<HTML::HTMLTableElement>(*this)) {
|
||||
auto text_align = new_computed_css_values.text_align();
|
||||
auto text_align = new_computed_properties->text_align();
|
||||
if (text_align.has_value() && (text_align.value() == CSS::TextAlign::LibwebLeft || text_align.value() == CSS::TextAlign::LibwebCenter || text_align.value() == CSS::TextAlign::LibwebRight))
|
||||
new_computed_css_values.set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Start));
|
||||
new_computed_properties->set_property(CSS::PropertyID::TextAlign, CSS::CSSKeywordValue::create(CSS::Keyword::Start));
|
||||
}
|
||||
|
||||
CSS::RequiredInvalidationAfterStyleChange invalidation;
|
||||
if (m_computed_css_values.has_value())
|
||||
invalidation = compute_required_invalidation(*m_computed_css_values, new_computed_css_values);
|
||||
if (m_computed_properties)
|
||||
invalidation = compute_required_invalidation(*m_computed_properties, new_computed_properties);
|
||||
else
|
||||
invalidation = CSS::RequiredInvalidationAfterStyleChange::full();
|
||||
|
||||
if (!invalidation.is_none())
|
||||
set_computed_css_values(move(new_computed_css_values));
|
||||
set_computed_properties(move(new_computed_properties));
|
||||
|
||||
// Any document change that can cause this element's style to change, could also affect its pseudo-elements.
|
||||
auto recompute_pseudo_element_style = [&](CSS::Selector::PseudoElement::Type pseudo_element) {
|
||||
style_computer.push_ancestor(*this);
|
||||
|
||||
auto pseudo_element_style = pseudo_element_computed_css_values(pseudo_element);
|
||||
auto pseudo_element_style = pseudo_element_computed_properties(pseudo_element);
|
||||
auto new_pseudo_element_style = style_computer.compute_pseudo_element_style_if_needed(*this, pseudo_element);
|
||||
|
||||
// TODO: Can we be smarter about invalidation?
|
||||
if (pseudo_element_style.has_value() && new_pseudo_element_style.has_value()) {
|
||||
if (pseudo_element_style && new_pseudo_element_style) {
|
||||
invalidation |= compute_required_invalidation(*pseudo_element_style, *new_pseudo_element_style);
|
||||
} else if (pseudo_element_style.has_value() || new_pseudo_element_style.has_value()) {
|
||||
} else if (pseudo_element_style || new_pseudo_element_style) {
|
||||
invalidation = CSS::RequiredInvalidationAfterStyleChange::full();
|
||||
}
|
||||
|
||||
set_pseudo_element_computed_css_values(pseudo_element, move(new_pseudo_element_style));
|
||||
set_pseudo_element_computed_properties(pseudo_element, move(new_pseudo_element_style));
|
||||
style_computer.pop_ancestor(*this);
|
||||
};
|
||||
|
||||
|
@ -526,7 +528,7 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
|
||||
if (!invalidation.rebuild_layout_tree && layout_node()) {
|
||||
// If we're keeping the layout tree, we can just apply the new style to the existing layout tree.
|
||||
layout_node()->apply_style(*m_computed_css_values);
|
||||
layout_node()->apply_style(*m_computed_properties);
|
||||
if (invalidation.repaint && paintable())
|
||||
paintable()->set_needs_display();
|
||||
|
||||
|
@ -537,8 +539,8 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
if (!pseudo_element.has_value() || !pseudo_element->layout_node)
|
||||
continue;
|
||||
|
||||
auto pseudo_element_style = pseudo_element_computed_css_values(pseudo_element_type);
|
||||
if (!pseudo_element_style.has_value())
|
||||
auto pseudo_element_style = pseudo_element_computed_properties(pseudo_element_type);
|
||||
if (!pseudo_element_style)
|
||||
continue;
|
||||
|
||||
if (auto* node_with_style = dynamic_cast<Layout::NodeWithStyle*>(pseudo_element->layout_node.ptr())) {
|
||||
|
@ -552,17 +554,17 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_style()
|
|||
return invalidation;
|
||||
}
|
||||
|
||||
CSS::ComputedProperties Element::resolved_css_values(Optional<CSS::Selector::PseudoElement::Type> type)
|
||||
GC::Ref<CSS::ComputedProperties> Element::resolved_css_values(Optional<CSS::Selector::PseudoElement::Type> type)
|
||||
{
|
||||
auto element_computed_style = CSS::ResolvedCSSStyleDeclaration::create(*this, type);
|
||||
CSS::ComputedProperties properties = {};
|
||||
auto properties = heap().allocate<CSS::ComputedProperties>();
|
||||
|
||||
for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {
|
||||
auto property_id = (CSS::PropertyID)i;
|
||||
auto maybe_value = element_computed_style->property(property_id);
|
||||
if (!maybe_value.has_value())
|
||||
continue;
|
||||
properties.set_property(property_id, maybe_value.release_value().value);
|
||||
properties->set_property(property_id, maybe_value.release_value().value);
|
||||
}
|
||||
|
||||
return properties;
|
||||
|
@ -570,9 +572,9 @@ CSS::ComputedProperties Element::resolved_css_values(Optional<CSS::Selector::Pse
|
|||
|
||||
void Element::reset_animated_css_properties()
|
||||
{
|
||||
if (!m_computed_css_values.has_value())
|
||||
if (!m_computed_properties)
|
||||
return;
|
||||
m_computed_css_values->reset_animated_properties();
|
||||
m_computed_properties->reset_animated_properties();
|
||||
}
|
||||
|
||||
DOMTokenList* Element::class_list()
|
||||
|
@ -2297,29 +2299,29 @@ void Element::set_cascaded_properties(Optional<CSS::Selector::PseudoElement::Typ
|
|||
}
|
||||
}
|
||||
|
||||
void Element::set_computed_css_values(Optional<CSS::ComputedProperties> style)
|
||||
void Element::set_computed_properties(GC::Ptr<CSS::ComputedProperties> style)
|
||||
{
|
||||
m_computed_css_values = move(style);
|
||||
computed_css_values_changed();
|
||||
m_computed_properties = style;
|
||||
computed_properties_changed();
|
||||
}
|
||||
|
||||
void Element::set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type pseudo_element, Optional<CSS::ComputedProperties> style)
|
||||
void Element::set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type pseudo_element, GC::Ptr<CSS::ComputedProperties> style)
|
||||
{
|
||||
if (!m_pseudo_element_data && !style.has_value())
|
||||
if (!m_pseudo_element_data && !style)
|
||||
return;
|
||||
|
||||
if (!CSS::Selector::PseudoElement::is_known_pseudo_element_type(pseudo_element)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ensure_pseudo_element(pseudo_element).computed_css_values = move(style);
|
||||
ensure_pseudo_element(pseudo_element).computed_properties = style;
|
||||
}
|
||||
|
||||
Optional<CSS::ComputedProperties&> Element::pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type type)
|
||||
GC::Ptr<CSS::ComputedProperties> Element::pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type type)
|
||||
{
|
||||
auto pseudo_element = get_pseudo_element(type);
|
||||
if (pseudo_element.has_value())
|
||||
return pseudo_element->computed_css_values;
|
||||
return pseudo_element->computed_properties;
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -2491,7 +2493,7 @@ bool Element::check_visibility(Optional<CheckVisibilityOptions> options)
|
|||
|
||||
// 2. If an ancestor of this in the flat tree has content-visibility: hidden, return false.
|
||||
for (auto* element = parent_element(); element; element = element->parent_element()) {
|
||||
if (element->computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden)
|
||||
if (element->computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2502,14 +2504,14 @@ bool Element::check_visibility(Optional<CheckVisibilityOptions> options)
|
|||
// 3. If either the opacityProperty or the checkOpacity dictionary members of options are true, and this, or an ancestor of this in the flat tree, has a computed opacity value of 0, return false.
|
||||
if (options->opacity_property || options->check_opacity) {
|
||||
for (auto* element = this; element; element = element->parent_element()) {
|
||||
if (element->computed_css_values()->opacity() == 0.0f)
|
||||
if (element->computed_properties()->opacity() == 0.0f)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 4. If either the visibilityProperty or the checkVisibilityCSS dictionary members of options are true, and this is invisible, return false.
|
||||
if (options->visibility_property || options->check_visibility_css) {
|
||||
if (computed_css_values()->visibility() == CSS::Visibility::Hidden)
|
||||
if (computed_properties()->visibility() == CSS::Visibility::Hidden)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -2518,7 +2520,7 @@ bool Element::check_visibility(Optional<CheckVisibilityOptions> options)
|
|||
auto const skipped_contents_due_to_content_visibility_auto = false;
|
||||
if (options->content_visibility_auto && skipped_contents_due_to_content_visibility_auto) {
|
||||
for (auto* element = this; element; element = element->parent_element()) {
|
||||
if (element->computed_css_values()->content_visibility() == CSS::ContentVisibility::Auto)
|
||||
if (element->computed_properties()->content_visibility() == CSS::ContentVisibility::Auto)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -185,16 +185,16 @@ public:
|
|||
GC::Ptr<Layout::NodeWithStyle> layout_node();
|
||||
GC::Ptr<Layout::NodeWithStyle const> layout_node() const;
|
||||
|
||||
Optional<CSS::ComputedProperties>& computed_css_values() { return m_computed_css_values; }
|
||||
Optional<CSS::ComputedProperties> const& computed_css_values() const { return m_computed_css_values; }
|
||||
void set_computed_css_values(Optional<CSS::ComputedProperties>);
|
||||
CSS::ComputedProperties resolved_css_values(Optional<CSS::Selector::PseudoElement::Type> = {});
|
||||
GC::Ptr<CSS::ComputedProperties> computed_properties() { return m_computed_properties; }
|
||||
GC::Ptr<CSS::ComputedProperties const> computed_properties() const { return m_computed_properties; }
|
||||
void set_computed_properties(GC::Ptr<CSS::ComputedProperties>);
|
||||
GC::Ref<CSS::ComputedProperties> resolved_css_values(Optional<CSS::Selector::PseudoElement::Type> = {});
|
||||
|
||||
[[nodiscard]] GC::Ptr<CSS::CascadedProperties> cascaded_properties(Optional<CSS::Selector::PseudoElement::Type>) const;
|
||||
void set_cascaded_properties(Optional<CSS::Selector::PseudoElement::Type>, GC::Ptr<CSS::CascadedProperties>);
|
||||
|
||||
void set_pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type, Optional<CSS::ComputedProperties>);
|
||||
Optional<CSS::ComputedProperties&> pseudo_element_computed_css_values(CSS::Selector::PseudoElement::Type);
|
||||
void set_pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type, GC::Ptr<CSS::ComputedProperties>);
|
||||
GC::Ptr<CSS::ComputedProperties> pseudo_element_computed_properties(CSS::Selector::PseudoElement::Type);
|
||||
|
||||
void reset_animated_css_properties();
|
||||
|
||||
|
@ -240,13 +240,13 @@ public:
|
|||
GC::Ref<Geometry::DOMRect> get_bounding_client_rect() const;
|
||||
GC::Ref<Geometry::DOMRectList> get_client_rects() const;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties);
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>);
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) { }
|
||||
|
||||
virtual void did_receive_focus() { }
|
||||
virtual void did_lose_focus() { }
|
||||
|
||||
static GC::Ptr<Layout::NodeWithStyle> create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, CSS::ComputedProperties, Element*);
|
||||
static GC::Ptr<Layout::NodeWithStyle> create_layout_node_for_display_type(DOM::Document&, CSS::Display const&, GC::Ref<CSS::ComputedProperties>, Element*);
|
||||
|
||||
void set_pseudo_element_node(Badge<Layout::TreeBuilder>, CSS::Selector::PseudoElement::Type, GC::Ptr<Layout::NodeWithStyle>);
|
||||
GC::Ptr<Layout::NodeWithStyle> get_pseudo_element_node(CSS::Selector::PseudoElement::Type) const;
|
||||
|
@ -384,7 +384,7 @@ protected:
|
|||
// https://dom.spec.whatwg.org/#concept-element-attributes-change-ext
|
||||
virtual void attribute_changed(FlyString const& local_name, Optional<String> const& old_value, Optional<String> const& value, Optional<FlyString> const& namespace_);
|
||||
|
||||
virtual void computed_css_values_changed() { }
|
||||
virtual void computed_properties_changed() { }
|
||||
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
|
@ -415,14 +415,13 @@ private:
|
|||
GC::Ptr<ShadowRoot> m_shadow_root;
|
||||
|
||||
GC::Ptr<CSS::CascadedProperties> m_cascaded_properties;
|
||||
|
||||
Optional<CSS::ComputedProperties> m_computed_css_values;
|
||||
GC::Ptr<CSS::ComputedProperties> m_computed_properties;
|
||||
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
||||
|
||||
struct PseudoElement {
|
||||
GC::Ptr<Layout::NodeWithStyle> layout_node;
|
||||
GC::Ptr<CSS::CascadedProperties> cascaded_properties;
|
||||
Optional<CSS::ComputedProperties> computed_css_values;
|
||||
GC::Ptr<CSS::ComputedProperties> computed_properties;
|
||||
HashMap<FlyString, CSS::StyleProperty> custom_properties;
|
||||
};
|
||||
// TODO: CSS::Selector::PseudoElement::Type includes a lot of pseudo-elements that exist in shadow trees,
|
||||
|
|
|
@ -397,13 +397,13 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
|||
}
|
||||
}
|
||||
|
||||
if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast<DOM::Element>(layout_node.dom_node())->computed_css_values().has_value()) {
|
||||
if (show_cascaded_properties && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast<DOM::Element>(layout_node.dom_node())->computed_properties()) {
|
||||
struct NameAndValue {
|
||||
FlyString name;
|
||||
String value;
|
||||
};
|
||||
Vector<NameAndValue> properties;
|
||||
verify_cast<DOM::Element>(*layout_node.dom_node()).computed_css_values()->for_each_property([&](auto property_id, auto& value) {
|
||||
verify_cast<DOM::Element>(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) {
|
||||
properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::CSSStyleValue::SerializationMode::Normal) });
|
||||
});
|
||||
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
||||
|
|
|
@ -29,7 +29,7 @@ void HTMLAudioElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLAudioElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLAudioElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLAudioElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::AudioBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ private:
|
|||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void on_playing() override;
|
||||
|
|
|
@ -27,7 +27,7 @@ void HTMLBRElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLBRElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLBRElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLBRElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::BreakNode>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class HTMLBRElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLBRElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -175,7 +175,7 @@ WebIDL::ExceptionOr<void> HTMLCanvasElement::set_height(WebIDL::UnsignedLong val
|
|||
return {};
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLCanvasElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLCanvasElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::CanvasBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
|
||||
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
template<typename ContextType>
|
||||
|
|
|
@ -83,7 +83,7 @@ Layout::FieldSetBox* HTMLFieldSetElement::layout_node()
|
|||
return static_cast<Layout::FieldSetBox*>(Node::layout_node());
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLFieldSetElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLFieldSetElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::FieldSetBox>(document(), *this, style);
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
|
||||
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::group; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
Layout::FieldSetBox* layout_node();
|
||||
Layout::FieldSetBox const* layout_node() const;
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ void HTMLIFrameElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLIFrameElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLIFrameElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLIFrameElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::NavigableContainerViewport>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class HTMLIFrameElement final
|
|||
public:
|
||||
virtual ~HTMLIFrameElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
void set_current_navigation_was_lazy_loaded(bool value);
|
||||
|
|
|
@ -134,7 +134,7 @@ void HTMLImageElement::form_associated_element_attribute_changed(FlyString const
|
|||
}
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLImageElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLImageElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::ImageBox>(document(), *this, move(style), *this);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/embedded-content.html#the-img-element:dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return true; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void did_set_viewport_rect(CSSPixelRect const&) override;
|
||||
|
|
|
@ -99,7 +99,7 @@ GC::Ref<ValidityState const> HTMLInputElement::validity() const
|
|||
return realm.create<ValidityState>(realm);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
if (type_state() == TypeAttributeState::Hidden)
|
||||
return nullptr;
|
||||
|
@ -114,8 +114,8 @@ GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperti
|
|||
// This specification introduces the appearance property to provide some control over this behavior.
|
||||
// In particular, using appearance: none allows authors to suppress the native appearance of widgets,
|
||||
// giving them a primitive appearance where CSS can be used to restyle them.
|
||||
if (style.appearance() == CSS::Appearance::None) {
|
||||
return Element::create_layout_node_for_display_type(document(), style.display(), style, this);
|
||||
if (style->appearance() == CSS::Appearance::None) {
|
||||
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
|
||||
}
|
||||
|
||||
if (type_state() == TypeAttributeState::SubmitButton || type_state() == TypeAttributeState::Button || type_state() == TypeAttributeState::ResetButton)
|
||||
|
@ -127,7 +127,7 @@ GC::Ptr<Layout::Node> HTMLInputElement::create_layout_node(CSS::ComputedProperti
|
|||
if (type_state() == TypeAttributeState::RadioButton)
|
||||
return heap().allocate<Layout::RadioButton>(document(), *this, move(style));
|
||||
|
||||
return Element::create_layout_node_for_display_type(document(), style.display(), style, this);
|
||||
return Element::create_layout_node_for_display_type(document(), style->display(), style, this);
|
||||
}
|
||||
|
||||
void HTMLInputElement::adjust_computed_style(CSS::ComputedProperties& style)
|
||||
|
@ -1123,16 +1123,16 @@ void HTMLInputElement::create_range_input_shadow_tree()
|
|||
add_event_listener_without_options(UIEvents::EventNames::mousedown, DOM::IDLEventListener::create(realm(), mousedown_callback));
|
||||
}
|
||||
|
||||
void HTMLInputElement::computed_css_values_changed()
|
||||
void HTMLInputElement::computed_properties_changed()
|
||||
{
|
||||
auto appearance = computed_css_values()->appearance();
|
||||
auto appearance = computed_properties()->appearance();
|
||||
if (!appearance.has_value() || *appearance == CSS::Appearance::None)
|
||||
return;
|
||||
|
||||
auto palette = document().page().palette();
|
||||
auto accent_color = palette.color(ColorRole::Accent).to_string();
|
||||
|
||||
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
|
||||
auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor);
|
||||
if (accent_color_property.has_color())
|
||||
accent_color = accent_color_property.to_string(CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ class HTMLInputElement final
|
|||
public:
|
||||
virtual ~HTMLInputElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
enum class TypeAttributeState {
|
||||
|
@ -241,7 +241,7 @@ private:
|
|||
|
||||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/input.html#image-button-state-(type=image):dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return type_state() == TypeAttributeState::ImageButton; }
|
||||
|
|
|
@ -27,7 +27,7 @@ void HTMLLabelElement::initialize(JS::Realm& realm)
|
|||
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLLabelElement);
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLLabelElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLLabelElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::Label>(document(), this, move(style));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ class HTMLLabelElement final : public HTMLElement {
|
|||
public:
|
||||
virtual ~HTMLLabelElement() override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
|
||||
Optional<String> for_() const { return attribute(HTML::AttributeNames::for_); }
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ HTMLFormElement* HTMLLegendElement::form()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLLegendElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLLegendElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::LegendBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ public:
|
|||
|
||||
HTMLFormElement* form();
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
Layout::LegendBox* layout_node();
|
||||
Layout::LegendBox const* layout_node() const;
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ String HTMLObjectElement::data() const
|
|||
return document().encoding_parse_url(*data).to_string();
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLObjectElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLObjectElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
switch (m_representation) {
|
||||
case Representation::Children:
|
||||
|
|
|
@ -56,7 +56,7 @@ private:
|
|||
|
||||
virtual void apply_presentational_hints(GC::Ref<CSS::CascadedProperties>) const override;
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const;
|
||||
|
|
|
@ -130,12 +130,12 @@ void HTMLProgressElement::update_progress_value_element()
|
|||
MUST(m_progress_value_element->style_for_bindings()->set_property(CSS::PropertyID::Width, MUST(String::formatted("{}%", position() * 100))));
|
||||
}
|
||||
|
||||
void HTMLProgressElement::computed_css_values_changed()
|
||||
void HTMLProgressElement::computed_properties_changed()
|
||||
{
|
||||
auto palette = document().page().palette();
|
||||
auto accent_color = palette.color(ColorRole::Accent).to_string();
|
||||
|
||||
auto const& accent_color_property = computed_css_values()->property(CSS::PropertyID::AccentColor);
|
||||
auto const& accent_color_property = computed_properties()->property(CSS::PropertyID::AccentColor);
|
||||
if (accent_color_property.has_color())
|
||||
accent_color = accent_color_property.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ private:
|
|||
|
||||
// ^DOM::Node
|
||||
virtual bool is_html_progress_element() const final { return true; }
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
|
|
@ -516,11 +516,11 @@ void HTMLSelectElement::form_associated_element_was_removed(DOM::Node*)
|
|||
set_shadow_root(nullptr);
|
||||
}
|
||||
|
||||
void HTMLSelectElement::computed_css_values_changed()
|
||||
void HTMLSelectElement::computed_properties_changed()
|
||||
{
|
||||
// Hide chevron icon when appearance is none
|
||||
if (m_chevron_icon_element) {
|
||||
auto appearance = computed_css_values()->appearance();
|
||||
auto appearance = computed_properties()->appearance();
|
||||
if (appearance.has_value() && *appearance == CSS::Appearance::None) {
|
||||
MUST(m_chevron_icon_element->style_for_bindings()->set_property(CSS::PropertyID::Display, "none"_string));
|
||||
} else {
|
||||
|
|
|
@ -105,7 +105,7 @@ private:
|
|||
// ^DOM::Element
|
||||
virtual i32 default_tab_index_value() const override;
|
||||
|
||||
virtual void computed_css_values_changed() override;
|
||||
virtual void computed_properties_changed() override;
|
||||
|
||||
virtual void children_changed() override;
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Ref<CSS::CascadedPrope
|
|||
auto apply_border_style = [&](CSS::PropertyID style_property, CSS::PropertyID width_property, CSS::PropertyID color_property) {
|
||||
cascaded_properties->set_property_from_presentational_hint(style_property, CSS::CSSKeywordValue::create(CSS::Keyword::Inset));
|
||||
cascaded_properties->set_property_from_presentational_hint(width_property, CSS::LengthStyleValue::create(CSS::Length::make_px(1)));
|
||||
cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_css_values()->property(color_property));
|
||||
cascaded_properties->set_property_from_presentational_hint(color_property, table_element->computed_properties()->property(color_property));
|
||||
};
|
||||
apply_border_style(CSS::PropertyID::BorderLeftStyle, CSS::PropertyID::BorderLeftWidth, CSS::PropertyID::BorderLeftColor);
|
||||
apply_border_style(CSS::PropertyID::BorderTopStyle, CSS::PropertyID::BorderTopWidth, CSS::PropertyID::BorderTopColor);
|
||||
|
|
|
@ -63,7 +63,7 @@ void HTMLVideoElement::attribute_changed(FlyString const& name, Optional<String>
|
|||
}
|
||||
}
|
||||
|
||||
GC::Ptr<Layout::Node> HTMLVideoElement::create_layout_node(CSS::ComputedProperties style)
|
||||
GC::Ptr<Layout::Node> HTMLVideoElement::create_layout_node(GC::Ref<CSS::ComputedProperties> style)
|
||||
{
|
||||
return heap().allocate<Layout::VideoBox>(document(), *this, move(style));
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ private:
|
|||
// https://html.spec.whatwg.org/multipage/media.html#the-video-element:dimension-attributes
|
||||
virtual bool supports_dimension_attributes() const override { return true; }
|
||||
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(CSS::ComputedProperties) override;
|
||||
virtual GC::Ptr<Layout::Node> create_layout_node(GC::Ref<CSS::ComputedProperties>) override;
|
||||
virtual void adjust_computed_style(CSS::ComputedProperties&) override;
|
||||
|
||||
virtual void on_playing() override;
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(AudioBox);
|
||||
|
||||
AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
AudioBox::AudioBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
set_natural_width(300);
|
||||
|
|
|
@ -23,7 +23,7 @@ public:
|
|||
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
AudioBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties);
|
||||
AudioBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style)
|
||||
BlockContainer::BlockContainer(DOM::Document& document, DOM::Node* node, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Box(document, node, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class BlockContainer : public Box {
|
|||
GC_CELL(BlockContainer, Box);
|
||||
|
||||
public:
|
||||
BlockContainer(DOM::Document&, DOM::Node*, CSS::ComputedProperties);
|
||||
BlockContainer(DOM::Document&, DOM::Node*, GC::Ref<CSS::ComputedProperties>);
|
||||
BlockContainer(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
|
||||
virtual ~BlockContainer() override;
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
Box::Box(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style)
|
||||
Box::Box(DOM::Document& document, DOM::Node* node, GC::Ref<CSS::ComputedProperties> style)
|
||||
: NodeWithStyleAndBoxModelMetrics(document, node, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
protected:
|
||||
Box(DOM::Document&, DOM::Node*, CSS::ComputedProperties);
|
||||
Box(DOM::Document&, DOM::Node*, GC::Ref<CSS::ComputedProperties>);
|
||||
Box(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(BreakNode);
|
||||
|
||||
BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, CSS::ComputedProperties style)
|
||||
BreakNode::BreakNode(DOM::Document& document, HTML::HTMLBRElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Layout::NodeWithStyleAndBoxModelMetrics(document, &element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class BreakNode final : public NodeWithStyleAndBoxModelMetrics {
|
|||
GC_DECLARE_ALLOCATOR(BreakNode);
|
||||
|
||||
public:
|
||||
BreakNode(DOM::Document&, HTML::HTMLBRElement&, CSS::ComputedProperties);
|
||||
BreakNode(DOM::Document&, HTML::HTMLBRElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~BreakNode() override;
|
||||
|
||||
const HTML::HTMLBRElement& dom_node() const { return verify_cast<HTML::HTMLBRElement>(*Node::dom_node()); }
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CanvasBox);
|
||||
|
||||
CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, CSS::ComputedProperties style)
|
||||
CanvasBox::CanvasBox(DOM::Document& document, HTML::HTMLCanvasElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class CanvasBox final : public ReplacedBox {
|
|||
GC_DECLARE_ALLOCATOR(CanvasBox);
|
||||
|
||||
public:
|
||||
CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, CSS::ComputedProperties);
|
||||
CanvasBox(DOM::Document&, HTML::HTMLCanvasElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~CanvasBox() override;
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(CheckBox);
|
||||
|
||||
CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, CSS::ComputedProperties style)
|
||||
CheckBox::CheckBox(DOM::Document& document, HTML::HTMLInputElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: FormAssociatedLabelableNode(document, element, move(style))
|
||||
{
|
||||
set_natural_width(13);
|
||||
|
|
|
@ -16,7 +16,7 @@ class CheckBox final : public FormAssociatedLabelableNode {
|
|||
GC_DECLARE_ALLOCATOR(CheckBox);
|
||||
|
||||
public:
|
||||
CheckBox(DOM::Document&, HTML::HTMLInputElement&, CSS::ComputedProperties);
|
||||
CheckBox(DOM::Document&, HTML::HTMLInputElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~CheckBox() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(FieldSetBox);
|
||||
|
||||
FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
FieldSetBox::FieldSetBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, &element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class FieldSetBox final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(FieldSetBox);
|
||||
|
||||
public:
|
||||
FieldSetBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties);
|
||||
FieldSetBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~FieldSetBox() override;
|
||||
|
||||
DOM::Element& dom_node() { return static_cast<DOM::Element&>(*BlockContainer::dom_node()); }
|
||||
|
|
|
@ -21,7 +21,7 @@ public:
|
|||
HTML::FormAssociatedElement& dom_node() { return dynamic_cast<HTML::FormAssociatedElement&>(LabelableNode::dom_node()); }
|
||||
|
||||
protected:
|
||||
FormAssociatedLabelableNode(DOM::Document& document, HTML::FormAssociatedElement& element, CSS::ComputedProperties style)
|
||||
FormAssociatedLabelableNode(DOM::Document& document, HTML::FormAssociatedElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: LabelableNode(document, element.form_associated_element_to_html_element(), move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ImageBox);
|
||||
|
||||
ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style, ImageProvider const& image_provider)
|
||||
ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style, ImageProvider const& image_provider)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
, m_image_provider(image_provider)
|
||||
{
|
||||
|
|
|
@ -16,7 +16,7 @@ class ImageBox final : public ReplacedBox {
|
|||
GC_DECLARE_ALLOCATOR(ImageBox);
|
||||
|
||||
public:
|
||||
ImageBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties, ImageProvider const&);
|
||||
ImageBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>, ImageProvider const&);
|
||||
virtual ~ImageBox() override;
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(InlineNode);
|
||||
|
||||
InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, CSS::ComputedProperties style)
|
||||
InlineNode::InlineNode(DOM::Document& document, DOM::Element* element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Layout::NodeWithStyleAndBoxModelMetrics(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class InlineNode final : public NodeWithStyleAndBoxModelMetrics {
|
|||
GC_DECLARE_ALLOCATOR(InlineNode);
|
||||
|
||||
public:
|
||||
InlineNode(DOM::Document&, DOM::Element*, CSS::ComputedProperties);
|
||||
InlineNode(DOM::Document&, DOM::Element*, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~InlineNode() override;
|
||||
|
||||
GC::Ptr<Painting::PaintableWithLines> create_paintable_for_line_with_index(size_t line_index) const;
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(Label);
|
||||
|
||||
Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, CSS::ComputedProperties style)
|
||||
Label::Label(DOM::Document& document, HTML::HTMLLabelElement* element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class Label final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(Label);
|
||||
|
||||
public:
|
||||
Label(DOM::Document&, HTML::HTMLLabelElement*, CSS::ComputedProperties);
|
||||
Label(DOM::Document&, HTML::HTMLLabelElement*, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~Label() override;
|
||||
|
||||
static bool is_inside_associated_label(LabelableNode const&, CSSPixelPoint);
|
||||
|
|
|
@ -19,7 +19,7 @@ public:
|
|||
Painting::LabelablePaintable const* paintable() const;
|
||||
|
||||
protected:
|
||||
LabelableNode(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
LabelableNode(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(LegendBox);
|
||||
|
||||
LegendBox::LegendBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
LegendBox::LegendBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, &element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class LegendBox final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(LegendBox);
|
||||
|
||||
public:
|
||||
LegendBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties);
|
||||
LegendBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~LegendBox() override;
|
||||
|
||||
DOM::Element& dom_node() { return static_cast<DOM::Element&>(*Box::dom_node()); }
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ListItemBox);
|
||||
|
||||
ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, CSS::ComputedProperties style)
|
||||
ListItemBox::ListItemBox(DOM::Document& document, DOM::Element* element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Layout::BlockContainer(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class ListItemBox final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(ListItemBox);
|
||||
|
||||
public:
|
||||
ListItemBox(DOM::Document&, DOM::Element*, CSS::ComputedProperties);
|
||||
ListItemBox(DOM::Document&, DOM::Element*, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~ListItemBox() override;
|
||||
|
||||
DOM::Element& dom_node() { return static_cast<DOM::Element&>(*BlockContainer::dom_node()); }
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(ListItemMarkerBox);
|
||||
|
||||
ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, CSS::ComputedProperties style)
|
||||
ListItemMarkerBox::ListItemMarkerBox(DOM::Document& document, CSS::ListStyleType style_type, CSS::ListStylePosition style_position, size_t index, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Box(document, nullptr, move(style))
|
||||
, m_list_style_type(style_type)
|
||||
, m_list_style_position(style_position)
|
||||
|
|
|
@ -16,7 +16,7 @@ class ListItemMarkerBox final : public Box {
|
|||
GC_DECLARE_ALLOCATOR(ListItemMarkerBox);
|
||||
|
||||
public:
|
||||
explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, CSS::ComputedProperties);
|
||||
explicit ListItemMarkerBox(DOM::Document&, CSS::ListStyleType, CSS::ListStylePosition, size_t index, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~ListItemMarkerBox() override;
|
||||
|
||||
Optional<ByteString> const& text() const { return m_text; }
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(NavigableContainerViewport);
|
||||
|
||||
NavigableContainerViewport::NavigableContainerViewport(DOM::Document& document, HTML::NavigableContainer& element, CSS::ComputedProperties style)
|
||||
NavigableContainerViewport::NavigableContainerViewport(DOM::Document& document, HTML::NavigableContainer& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class NavigableContainerViewport final : public ReplacedBox {
|
|||
GC_DECLARE_ALLOCATOR(NavigableContainerViewport);
|
||||
|
||||
public:
|
||||
NavigableContainerViewport(DOM::Document&, HTML::NavigableContainer&, CSS::ComputedProperties);
|
||||
NavigableContainerViewport(DOM::Document&, HTML::NavigableContainer&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~NavigableContainerViewport() override;
|
||||
|
||||
virtual void prepare_for_replaced_layout() override;
|
||||
|
|
|
@ -276,7 +276,7 @@ bool Node::is_sticky_position() const
|
|||
return position == CSS::Positioning::Sticky;
|
||||
}
|
||||
|
||||
NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties computed_style)
|
||||
NodeWithStyle::NodeWithStyle(DOM::Document& document, DOM::Node* node, GC::Ref<CSS::ComputedProperties> computed_style)
|
||||
: Node(document, node)
|
||||
, m_computed_values(make<CSS::ComputedValues>())
|
||||
{
|
||||
|
|
|
@ -238,7 +238,7 @@ public:
|
|||
virtual void visit_edges(Cell::Visitor& visitor) override;
|
||||
|
||||
protected:
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, CSS::ComputedProperties);
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, GC::Ref<CSS::ComputedProperties>);
|
||||
NodeWithStyle(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
|
||||
|
||||
private:
|
||||
|
@ -257,8 +257,8 @@ public:
|
|||
BoxModelMetrics const& box_model() const { return m_box_model; }
|
||||
|
||||
protected:
|
||||
NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style)
|
||||
: NodeWithStyle(document, node, move(style))
|
||||
NodeWithStyleAndBoxModelMetrics(DOM::Document& document, DOM::Node* node, GC::Ref<CSS::ComputedProperties> style)
|
||||
: NodeWithStyle(document, node, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(RadioButton);
|
||||
|
||||
RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, CSS::ComputedProperties style)
|
||||
RadioButton::RadioButton(DOM::Document& document, HTML::HTMLInputElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: FormAssociatedLabelableNode(document, element, move(style))
|
||||
{
|
||||
set_natural_width(12);
|
||||
|
|
|
@ -16,7 +16,7 @@ class RadioButton final : public FormAssociatedLabelableNode {
|
|||
GC_DECLARE_ALLOCATOR(RadioButton);
|
||||
|
||||
public:
|
||||
RadioButton(DOM::Document&, HTML::HTMLInputElement&, CSS::ComputedProperties);
|
||||
RadioButton(DOM::Document&, HTML::HTMLInputElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~RadioButton() override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
ReplacedBox::ReplacedBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Box(document, &element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class ReplacedBox : public Box {
|
|||
GC_CELL(ReplacedBox, Box);
|
||||
|
||||
public:
|
||||
ReplacedBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties);
|
||||
ReplacedBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~ReplacedBox() override;
|
||||
|
||||
DOM::Element const& dom_node() const { return verify_cast<DOM::Element>(*Node::dom_node()); }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, CSS::ComputedProperties style)
|
||||
SVGBox::SVGBox(DOM::Document& document, SVG::SVGElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: Box(document, &element, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class SVGBox : public Box {
|
|||
GC_CELL(SVGBox, Box);
|
||||
|
||||
public:
|
||||
SVGBox(DOM::Document&, SVG::SVGElement&, CSS::ComputedProperties);
|
||||
SVGBox(DOM::Document&, SVG::SVGElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGBox() override = default;
|
||||
|
||||
SVG::SVGElement& dom_node() { return verify_cast<SVG::SVGElement>(*Box::dom_node()); }
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGClipBox);
|
||||
|
||||
SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, CSS::ComputedProperties properties)
|
||||
: SVGBox(document, element, properties)
|
||||
SVGClipBox::SVGClipBox(DOM::Document& document, SVG::SVGClipPathElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class SVGClipBox : public SVGBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGClipBox);
|
||||
|
||||
public:
|
||||
SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, CSS::ComputedProperties);
|
||||
SVGClipBox(DOM::Document&, SVG::SVGClipPathElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGClipBox() override = default;
|
||||
|
||||
SVG::SVGClipPathElement& dom_node() { return verify_cast<SVG::SVGClipPathElement>(SVGBox::dom_node()); }
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGForeignObjectBox);
|
||||
|
||||
SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, CSS::ComputedProperties properties)
|
||||
: BlockContainer(document, &element, properties)
|
||||
SVGForeignObjectBox::SVGForeignObjectBox(DOM::Document& document, SVG::SVGForeignObjectElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, &element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ class SVGForeignObjectBox final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(SVGForeignObjectBox);
|
||||
|
||||
public:
|
||||
SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, CSS::ComputedProperties);
|
||||
SVGForeignObjectBox(DOM::Document&, SVG::SVGForeignObjectElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGForeignObjectBox() override = default;
|
||||
|
||||
SVG::SVGForeignObjectElement& dom_node() { return static_cast<SVG::SVGForeignObjectElement&>(*BlockContainer::dom_node()); }
|
||||
|
|
|
@ -14,8 +14,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGGeometryBox);
|
||||
|
||||
SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, CSS::ComputedProperties properties)
|
||||
: SVGGraphicsBox(document, element, properties)
|
||||
SVGGeometryBox::SVGGeometryBox(DOM::Document& document, SVG::SVGGeometryElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGGraphicsBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class SVGGeometryBox final : public SVGGraphicsBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGGeometryBox);
|
||||
|
||||
public:
|
||||
SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, CSS::ComputedProperties);
|
||||
SVGGeometryBox(DOM::Document&, SVG::SVGGeometryElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGGeometryBox() override = default;
|
||||
|
||||
SVG::SVGGeometryElement& dom_node() { return static_cast<SVG::SVGGeometryElement&>(SVGGraphicsBox::dom_node()); }
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::ComputedProperties properties)
|
||||
: SVGBox(document, element, properties)
|
||||
SVGGraphicsBox::SVGGraphicsBox(DOM::Document& document, SVG::SVGGraphicsElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class SVGGraphicsBox : public SVGBox {
|
|||
GC_CELL(SVGGraphicsBox, SVGBox);
|
||||
|
||||
public:
|
||||
SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::ComputedProperties);
|
||||
SVGGraphicsBox(DOM::Document&, SVG::SVGGraphicsElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGGraphicsBox() override = default;
|
||||
|
||||
SVG::SVGGraphicsElement& dom_node() { return verify_cast<SVG::SVGGraphicsElement>(SVGBox::dom_node()); }
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
|
||||
namespace Web::Layout {
|
||||
|
||||
SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, CSS::ComputedProperties properties)
|
||||
: SVGGraphicsBox(document, element, properties)
|
||||
SVGImageBox::SVGImageBox(DOM::Document& document, SVG::SVGGraphicsElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGGraphicsBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class SVGImageBox : public SVGGraphicsBox {
|
|||
GC_CELL(SVGImageBox, SVGGraphicsBox);
|
||||
|
||||
public:
|
||||
SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, CSS::ComputedProperties);
|
||||
SVGImageBox(DOM::Document&, SVG::SVGGraphicsElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGImageBox() override = default;
|
||||
|
||||
SVG::SVGImageElement& dom_node() { return static_cast<SVG::SVGImageElement&>(SVGGraphicsBox::dom_node()); }
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGMaskBox);
|
||||
|
||||
SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, CSS::ComputedProperties properties)
|
||||
: SVGGraphicsBox(document, element, properties)
|
||||
SVGMaskBox::SVGMaskBox(DOM::Document& document, SVG::SVGMaskElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGGraphicsBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class SVGMaskBox : public SVGGraphicsBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGMaskBox);
|
||||
|
||||
public:
|
||||
SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, CSS::ComputedProperties);
|
||||
SVGMaskBox(DOM::Document&, SVG::SVGMaskElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGMaskBox() override = default;
|
||||
|
||||
virtual bool is_svg_mask_box() const override { return true; }
|
||||
|
|
|
@ -15,8 +15,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGSVGBox);
|
||||
|
||||
SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, CSS::ComputedProperties properties)
|
||||
: ReplacedBox(document, element, move(properties))
|
||||
SVGSVGBox::SVGSVGBox(DOM::Document& document, SVG::SVGSVGElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class SVGSVGBox final : public ReplacedBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGSVGBox);
|
||||
|
||||
public:
|
||||
SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, CSS::ComputedProperties);
|
||||
SVGSVGBox(DOM::Document&, SVG::SVGSVGElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGSVGBox() override = default;
|
||||
|
||||
SVG::SVGSVGElement& dom_node() { return verify_cast<SVG::SVGSVGElement>(ReplacedBox::dom_node()); }
|
||||
|
|
|
@ -12,8 +12,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGTextBox);
|
||||
|
||||
SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, CSS::ComputedProperties properties)
|
||||
: SVGGraphicsBox(document, element, properties)
|
||||
SVGTextBox::SVGTextBox(DOM::Document& document, SVG::SVGTextPositioningElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGGraphicsBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class SVGTextBox final : public SVGGraphicsBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGTextBox);
|
||||
|
||||
public:
|
||||
SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, CSS::ComputedProperties);
|
||||
SVGTextBox(DOM::Document&, SVG::SVGTextPositioningElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGTextBox() override = default;
|
||||
|
||||
SVG::SVGTextPositioningElement& dom_node() { return static_cast<SVG::SVGTextPositioningElement&>(SVGGraphicsBox::dom_node()); }
|
||||
|
|
|
@ -11,8 +11,8 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(SVGTextPathBox);
|
||||
|
||||
SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, CSS::ComputedProperties properties)
|
||||
: SVGGraphicsBox(document, element, properties)
|
||||
SVGTextPathBox::SVGTextPathBox(DOM::Document& document, SVG::SVGTextPathElement& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: SVGGraphicsBox(document, element, style)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ class SVGTextPathBox final : public SVGGraphicsBox {
|
|||
GC_DECLARE_ALLOCATOR(SVGTextPathBox);
|
||||
|
||||
public:
|
||||
SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, CSS::ComputedProperties);
|
||||
SVGTextPathBox(DOM::Document&, SVG::SVGTextPathElement&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~SVGTextPathBox() override = default;
|
||||
|
||||
SVG::SVGTextPathElement& dom_node() { return static_cast<SVG::SVGTextPathElement&>(SVGGraphicsBox::dom_node()); }
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(TableWrapper);
|
||||
|
||||
TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, CSS::ComputedProperties style)
|
||||
TableWrapper::TableWrapper(DOM::Document& document, DOM::Node* node, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, node, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ class TableWrapper : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(TableWrapper);
|
||||
|
||||
public:
|
||||
TableWrapper(DOM::Document&, DOM::Node*, CSS::ComputedProperties);
|
||||
TableWrapper(DOM::Document&, DOM::Node*, GC::Ref<CSS::ComputedProperties>);
|
||||
TableWrapper(DOM::Document&, DOM::Node*, NonnullOwnPtr<CSS::ComputedValues>);
|
||||
virtual ~TableWrapper() override;
|
||||
|
||||
|
|
|
@ -196,8 +196,8 @@ void TreeBuilder::create_pseudo_element_if_needed(DOM::Element& element, CSS::Se
|
|||
{
|
||||
auto& document = element.document();
|
||||
|
||||
auto pseudo_element_style = element.pseudo_element_computed_css_values(pseudo_element);
|
||||
if (!pseudo_element_style.has_value())
|
||||
auto pseudo_element_style = element.pseudo_element_computed_properties(pseudo_element);
|
||||
if (!pseudo_element_style)
|
||||
return;
|
||||
|
||||
auto initial_quote_nesting_level = m_quote_nesting_level;
|
||||
|
@ -346,14 +346,14 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
|
|||
|
||||
auto& document = dom_node.document();
|
||||
auto& style_computer = document.style_computer();
|
||||
Optional<CSS::ComputedProperties> style;
|
||||
GC::Ptr<CSS::ComputedProperties> style;
|
||||
CSS::Display display;
|
||||
|
||||
if (is<DOM::Element>(dom_node)) {
|
||||
auto& element = static_cast<DOM::Element&>(dom_node);
|
||||
element.clear_pseudo_element_nodes({});
|
||||
VERIFY(!element.needs_style_update());
|
||||
style = element.computed_css_values();
|
||||
style = element.computed_properties();
|
||||
element.resolve_counters(*style);
|
||||
display = style->display();
|
||||
if (display.is_none())
|
||||
|
@ -396,7 +396,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
|
|||
auto element_has_content_visibility_hidden = [&dom_node]() {
|
||||
if (is<DOM::Element>(dom_node)) {
|
||||
auto& element = static_cast<DOM::Element&>(dom_node);
|
||||
return element.computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden;
|
||||
return element.computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden;
|
||||
}
|
||||
return false;
|
||||
}();
|
||||
|
@ -443,7 +443,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
|
|||
if (is<HTML::HTMLSlotElement>(dom_node)) {
|
||||
auto& slot_element = static_cast<HTML::HTMLSlotElement&>(dom_node);
|
||||
|
||||
if (slot_element.computed_css_values()->content_visibility() == CSS::ContentVisibility::Hidden)
|
||||
if (slot_element.computed_properties()->content_visibility() == CSS::ContentVisibility::Hidden)
|
||||
return;
|
||||
|
||||
auto slottables = slot_element.assigned_nodes_internal();
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(VideoBox);
|
||||
|
||||
VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, CSS::ComputedProperties style)
|
||||
VideoBox::VideoBox(DOM::Document& document, DOM::Element& element, GC::Ref<CSS::ComputedProperties> style)
|
||||
: ReplacedBox(document, element, move(style))
|
||||
{
|
||||
document.register_viewport_client(*this);
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
||||
|
||||
private:
|
||||
VideoBox(DOM::Document&, DOM::Element&, CSS::ComputedProperties);
|
||||
VideoBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>);
|
||||
|
||||
// ^Document::ViewportClient
|
||||
virtual void did_set_viewport_rect(CSSPixelRect const&) final;
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Web::Layout {
|
|||
|
||||
GC_DEFINE_ALLOCATOR(Viewport);
|
||||
|
||||
Viewport::Viewport(DOM::Document& document, CSS::ComputedProperties style)
|
||||
Viewport::Viewport(DOM::Document& document, GC::Ref<CSS::ComputedProperties> style)
|
||||
: BlockContainer(document, &document, move(style))
|
||||
{
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class Viewport final : public BlockContainer {
|
|||
GC_DECLARE_ALLOCATOR(Viewport);
|
||||
|
||||
public:
|
||||
explicit Viewport(DOM::Document&, CSS::ComputedProperties);
|
||||
explicit Viewport(DOM::Document&, GC::Ref<CSS::ComputedProperties>);
|
||||
virtual ~Viewport() override;
|
||||
|
||||
struct TextPosition {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue