mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 09:57:34 +00:00
LibWeb: Use ComputedCSSStyleDeclaration to generate data for inspector
This commit is contained in:
parent
2e4b34b8c3
commit
bf86419979
1 changed files with 11 additions and 22 deletions
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include <AK/AnyOf.h>
|
#include <AK/AnyOf.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <LibWeb/CSS/ComputedCSSStyleDeclaration.h>
|
||||||
#include <LibWeb/CSS/Parser/Parser.h>
|
#include <LibWeb/CSS/Parser/Parser.h>
|
||||||
#include <LibWeb/CSS/PropertyID.h>
|
#include <LibWeb/CSS/PropertyID.h>
|
||||||
#include <LibWeb/CSS/StyleInvalidator.h>
|
#include <LibWeb/CSS/StyleInvalidator.h>
|
||||||
|
@ -229,29 +230,17 @@ void Element::recompute_style()
|
||||||
|
|
||||||
NonnullRefPtr<CSS::StyleProperties> Element::computed_style()
|
NonnullRefPtr<CSS::StyleProperties> Element::computed_style()
|
||||||
{
|
{
|
||||||
// FIXME: This implementation is not doing anything it's supposed to.
|
auto element_computed_style = CSS::ComputedCSSStyleDeclaration::create(*this);
|
||||||
auto properties = m_specified_css_values->clone();
|
auto properties = CSS::StyleProperties::create();
|
||||||
if (layout_node() && layout_node()->has_style()) {
|
|
||||||
CSS::PropertyID box_model_metrics[] = {
|
for (auto i = to_underlying(CSS::first_property_id); i <= to_underlying(CSS::last_property_id); ++i) {
|
||||||
CSS::PropertyID::MarginTop,
|
auto property_id = (CSS::PropertyID)i;
|
||||||
CSS::PropertyID::MarginBottom,
|
auto maybe_value = element_computed_style->property(property_id);
|
||||||
CSS::PropertyID::MarginLeft,
|
if (!maybe_value.has_value())
|
||||||
CSS::PropertyID::MarginRight,
|
continue;
|
||||||
CSS::PropertyID::PaddingTop,
|
properties->set_property(property_id, maybe_value.release_value().value);
|
||||||
CSS::PropertyID::PaddingBottom,
|
|
||||||
CSS::PropertyID::PaddingLeft,
|
|
||||||
CSS::PropertyID::PaddingRight,
|
|
||||||
CSS::PropertyID::BorderTopWidth,
|
|
||||||
CSS::PropertyID::BorderBottomWidth,
|
|
||||||
CSS::PropertyID::BorderLeftWidth,
|
|
||||||
CSS::PropertyID::BorderRightWidth,
|
|
||||||
};
|
|
||||||
for (CSS::PropertyID id : box_model_metrics) {
|
|
||||||
auto prop = m_specified_css_values->property(id);
|
|
||||||
if (prop.has_value())
|
|
||||||
properties->set_property(id, prop.value());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue