mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 01:05:08 +00:00
LibHTML: Have element keep a pointer to their resolved style
This will make it easy to implement a simple element style inspector.
This commit is contained in:
parent
285130cc55
commit
ffcd395afc
2 changed files with 6 additions and 0 deletions
|
@ -78,6 +78,7 @@ bool Element::has_class(const StringView& class_name) const
|
|||
RefPtr<LayoutNode> Element::create_layout_node(const StyleProperties* parent_style) const
|
||||
{
|
||||
auto style = document().style_resolver().resolve_style(*this, parent_style);
|
||||
const_cast<Element&>(*this).m_resolved_style = style;
|
||||
auto display = style->string_or_fallback(CSS::PropertyID::Display, "inline");
|
||||
|
||||
if (display == "none")
|
||||
|
@ -139,6 +140,7 @@ void Element::recompute_style()
|
|||
return;
|
||||
ASSERT(parent_layout_node);
|
||||
auto style = document().style_resolver().resolve_style(*this, &parent_layout_node->style());
|
||||
m_resolved_style = style;
|
||||
if (!layout_node()) {
|
||||
if (style->string_or_fallback(CSS::PropertyID::Display, "inline") == "none")
|
||||
return;
|
||||
|
|
|
@ -56,6 +56,8 @@ public:
|
|||
|
||||
String name() const { return attribute("name"); }
|
||||
|
||||
const StyleProperties* resolved_style() const { return m_resolved_style.ptr(); }
|
||||
|
||||
private:
|
||||
RefPtr<LayoutNode> create_layout_node(const StyleProperties* parent_style) const override;
|
||||
|
||||
|
@ -64,6 +66,8 @@ private:
|
|||
|
||||
String m_tag_name;
|
||||
Vector<Attribute> m_attributes;
|
||||
|
||||
RefPtr<StyleProperties> m_resolved_style;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue