mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:37:35 +00:00
LibWeb: Rename Element::specified_css_values() => computed_css_values()
Let's make it very clear that these are *computed* values, and not at all the specified values. The specified values are currently discarded by the CSS cascade algorithm.
This commit is contained in:
parent
43ef813f3d
commit
e31fe3eeb8
6 changed files with 23 additions and 23 deletions
|
@ -654,9 +654,9 @@ static NonnullRefPtr<StyleValue> get_inherit_value(CSS::PropertyID property_id,
|
||||||
{
|
{
|
||||||
auto* parent_element = get_parent_element(element, pseudo_element);
|
auto* parent_element = get_parent_element(element, pseudo_element);
|
||||||
|
|
||||||
if (!parent_element || !parent_element->specified_css_values())
|
if (!parent_element || !parent_element->computed_css_values())
|
||||||
return property_initial_value(property_id);
|
return property_initial_value(property_id);
|
||||||
return parent_element->specified_css_values()->property(property_id).release_value();
|
return parent_element->computed_css_values()->property(property_id).release_value();
|
||||||
};
|
};
|
||||||
|
|
||||||
void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional<CSS::Selector::PseudoElement> pseudo_element) const
|
void StyleComputer::compute_defaulted_property_value(StyleProperties& style, DOM::Element const* element, CSS::PropertyID property_id, Optional<CSS::Selector::PseudoElement> pseudo_element) const
|
||||||
|
@ -790,8 +790,8 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
|
||||||
float root_font_size = 10;
|
float root_font_size = 10;
|
||||||
|
|
||||||
Gfx::FontMetrics font_metrics;
|
Gfx::FontMetrics font_metrics;
|
||||||
if (parent_element && parent_element->specified_css_values())
|
if (parent_element && parent_element->computed_css_values())
|
||||||
font_metrics = parent_element->specified_css_values()->computed_font().metrics('M');
|
font_metrics = parent_element->computed_css_values()->computed_font().metrics('M');
|
||||||
else
|
else
|
||||||
font_metrics = Gfx::FontDatabase::default_font().metrics('M');
|
font_metrics = Gfx::FontDatabase::default_font().metrics('M');
|
||||||
|
|
||||||
|
@ -800,8 +800,8 @@ void StyleComputer::compute_font(StyleProperties& style, DOM::Element const* ele
|
||||||
// Percentages refer to parent element's font size
|
// Percentages refer to parent element's font size
|
||||||
auto percentage = font_size->as_percentage().percentage();
|
auto percentage = font_size->as_percentage().percentage();
|
||||||
auto parent_font_size = size;
|
auto parent_font_size = size;
|
||||||
if (parent_element && parent_element->specified_css_values()) {
|
if (parent_element && parent_element->computed_css_values()) {
|
||||||
auto value = parent_element->specified_css_values()->property(CSS::PropertyID::FontSize).value();
|
auto value = parent_element->computed_css_values()->property(CSS::PropertyID::FontSize).value();
|
||||||
if (value->is_length()) {
|
if (value->is_length()) {
|
||||||
auto length = static_cast<LengthStyleValue const&>(*value).to_length();
|
auto length = static_cast<LengthStyleValue const&>(*value).to_length();
|
||||||
if (length.is_absolute() || length.is_relative())
|
if (length.is_absolute() || length.is_relative())
|
||||||
|
@ -954,8 +954,8 @@ static BoxTypeTransformation required_box_type_transformation(StyleProperties co
|
||||||
// FIXME: Containment in a ruby container inlinifies the box’s display type, as described in [CSS-RUBY-1].
|
// FIXME: Containment in a ruby container inlinifies the box’s display type, as described in [CSS-RUBY-1].
|
||||||
|
|
||||||
// A parent with a grid or flex display value blockifies the box’s display type. [CSS-GRID-1] [CSS-FLEXBOX-1]
|
// A parent with a grid or flex display value blockifies the box’s display type. [CSS-GRID-1] [CSS-FLEXBOX-1]
|
||||||
if (element.parent_element() && element.parent_element()->specified_css_values()) {
|
if (element.parent_element() && element.parent_element()->computed_css_values()) {
|
||||||
auto const& parent_display = element.parent_element()->specified_css_values()->display();
|
auto const& parent_display = element.parent_element()->computed_css_values()->display();
|
||||||
if (parent_display.is_grid_inside() || parent_display.is_flex_inside())
|
if (parent_display.is_grid_inside() || parent_display.is_flex_inside())
|
||||||
return BoxTypeTransformation::Blockify;
|
return BoxTypeTransformation::Blockify;
|
||||||
}
|
}
|
||||||
|
|
|
@ -271,12 +271,12 @@ void Element::recompute_style()
|
||||||
{
|
{
|
||||||
set_needs_style_update(false);
|
set_needs_style_update(false);
|
||||||
VERIFY(parent());
|
VERIFY(parent());
|
||||||
auto new_specified_css_values = document().style_computer().compute_style(*this);
|
auto new_computed_css_values = document().style_computer().compute_style(*this);
|
||||||
|
|
||||||
if (m_specified_css_values && *m_specified_css_values == *new_specified_css_values)
|
if (m_computed_css_values && *m_computed_css_values == *new_computed_css_values)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_specified_css_values = move(new_specified_css_values);
|
m_computed_css_values = move(new_computed_css_values);
|
||||||
|
|
||||||
document().invalidate_layout();
|
document().invalidate_layout();
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,8 @@ public:
|
||||||
|
|
||||||
String name() const { return attribute(HTML::AttributeNames::name); }
|
String name() const { return attribute(HTML::AttributeNames::name); }
|
||||||
|
|
||||||
CSS::StyleProperties const* specified_css_values() const { return m_specified_css_values.ptr(); }
|
CSS::StyleProperties const* computed_css_values() const { return m_computed_css_values.ptr(); }
|
||||||
void set_specified_css_values(RefPtr<CSS::StyleProperties> style) { m_specified_css_values = move(style); }
|
void set_computed_css_values(RefPtr<CSS::StyleProperties> style) { m_computed_css_values = move(style); }
|
||||||
NonnullRefPtr<CSS::StyleProperties> resolved_css_values();
|
NonnullRefPtr<CSS::StyleProperties> resolved_css_values();
|
||||||
|
|
||||||
const CSS::CSSStyleDeclaration* inline_style() const { return m_inline_style; }
|
const CSS::CSSStyleDeclaration* inline_style() const { return m_inline_style; }
|
||||||
|
@ -149,7 +149,7 @@ private:
|
||||||
|
|
||||||
RefPtr<CSS::CSSStyleDeclaration> m_inline_style;
|
RefPtr<CSS::CSSStyleDeclaration> m_inline_style;
|
||||||
|
|
||||||
RefPtr<CSS::StyleProperties> m_specified_css_values;
|
RefPtr<CSS::StyleProperties> m_computed_css_values;
|
||||||
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
||||||
|
|
||||||
RefPtr<DOMTokenList> m_class_list;
|
RefPtr<DOMTokenList> m_class_list;
|
||||||
|
|
|
@ -263,13 +263,13 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_specified_style && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast<DOM::Element>(layout_node.dom_node())->specified_css_values()) {
|
if (show_specified_style && layout_node.dom_node() && layout_node.dom_node()->is_element() && verify_cast<DOM::Element>(layout_node.dom_node())->computed_css_values()) {
|
||||||
struct NameAndValue {
|
struct NameAndValue {
|
||||||
String name;
|
String name;
|
||||||
String value;
|
String value;
|
||||||
};
|
};
|
||||||
Vector<NameAndValue> properties;
|
Vector<NameAndValue> properties;
|
||||||
verify_cast<DOM::Element>(*layout_node.dom_node()).specified_css_values()->for_each_property([&](auto property_id, auto& value) {
|
verify_cast<DOM::Element>(*layout_node.dom_node()).computed_css_values()->for_each_property([&](auto property_id, auto& value) {
|
||||||
properties.append({ CSS::string_from_property_id(property_id), value.to_string() });
|
properties.append({ CSS::string_from_property_id(property_id), value.to_string() });
|
||||||
});
|
});
|
||||||
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; });
|
||||||
|
|
|
@ -104,7 +104,7 @@ void TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::Context&
|
||||||
style = style_computer.compute_style(element);
|
style = style_computer.compute_style(element);
|
||||||
if (style->display().is_none())
|
if (style->display().is_none())
|
||||||
return;
|
return;
|
||||||
element.set_specified_css_values(style);
|
element.set_computed_css_values(style);
|
||||||
layout_node = element.create_layout_node(*style);
|
layout_node = element.create_layout_node(*style);
|
||||||
} else if (is<DOM::Document>(dom_node)) {
|
} else if (is<DOM::Document>(dom_node)) {
|
||||||
style = style_computer.create_document_style();
|
style = style_computer.create_document_style();
|
||||||
|
|
|
@ -268,7 +268,7 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
||||||
|
|
||||||
if (node->is_element()) {
|
if (node->is_element()) {
|
||||||
auto& element = verify_cast<Web::DOM::Element>(*node);
|
auto& element = verify_cast<Web::DOM::Element>(*node);
|
||||||
if (!element.specified_css_values())
|
if (!element.computed_css_values())
|
||||||
return { false, "", "", "", "" };
|
return { false, "", "", "", "" };
|
||||||
|
|
||||||
auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> String {
|
auto serialize_json = [](Web::CSS::StyleProperties const& properties) -> String {
|
||||||
|
@ -345,18 +345,18 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
|
||||||
// in a format we can use. So, we run the StyleComputer again to get the specified
|
// in a format we can use. So, we run the StyleComputer again to get the specified
|
||||||
// values, and have to ignore the computed values and custom properties.
|
// values, and have to ignore the computed values and custom properties.
|
||||||
auto pseudo_element_style = page().focused_context().active_document()->style_computer().compute_style(element, pseudo_element);
|
auto pseudo_element_style = page().focused_context().active_document()->style_computer().compute_style(element, pseudo_element);
|
||||||
String specified_values_json = serialize_json(pseudo_element_style);
|
String computed_values = serialize_json(pseudo_element_style);
|
||||||
String computed_values_json = "{}";
|
String resolved_values = "{}";
|
||||||
String custom_properties_json = "{}";
|
String custom_properties_json = "{}";
|
||||||
String node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr());
|
String node_box_sizing_json = serialize_node_box_sizing_json(pseudo_element_node.ptr());
|
||||||
return { true, specified_values_json, computed_values_json, custom_properties_json, node_box_sizing_json };
|
return { true, computed_values, resolved_values, custom_properties_json, node_box_sizing_json };
|
||||||
}
|
}
|
||||||
|
|
||||||
String specified_values_json = serialize_json(*element.specified_css_values());
|
String computed_values = serialize_json(*element.computed_css_values());
|
||||||
String resolved_values_json = serialize_json(element.resolved_css_values());
|
String resolved_values_json = serialize_json(element.resolved_css_values());
|
||||||
String custom_properties_json = serialize_custom_properties_json(element);
|
String custom_properties_json = serialize_custom_properties_json(element);
|
||||||
String node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node());
|
String node_box_sizing_json = serialize_node_box_sizing_json(element.layout_node());
|
||||||
return { true, specified_values_json, resolved_values_json, custom_properties_json, node_box_sizing_json };
|
return { true, computed_values, resolved_values_json, custom_properties_json, node_box_sizing_json };
|
||||||
}
|
}
|
||||||
|
|
||||||
return { false, "", "", "", "" };
|
return { false, "", "", "", "" };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue