mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 04:37:22 +00:00
LibWeb: Make PseudoElement a class in its own right
It's getting a bit large and complicated to be a struct hidden in DOM::Element.
This commit is contained in:
parent
e56146edec
commit
e7c2f0dd52
Notes:
github-actions[bot]
2025-06-19 11:37:51 +00:00
Author: https://github.com/AtkinsSJ
Commit: e7c2f0dd52
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5132
Reviewed-by: https://github.com/tcl3
6 changed files with 96 additions and 48 deletions
|
@ -23,6 +23,7 @@
|
|||
#include <LibWeb/DOM/ChildNode.h>
|
||||
#include <LibWeb/DOM/NonDocumentTypeChildNode.h>
|
||||
#include <LibWeb/DOM/ParentNode.h>
|
||||
#include <LibWeb/DOM/PseudoElement.h>
|
||||
#include <LibWeb/DOM/QualifiedName.h>
|
||||
#include <LibWeb/DOM/Slottable.h>
|
||||
#include <LibWeb/HTML/AttributeNames.h>
|
||||
|
@ -564,25 +565,6 @@ private:
|
|||
GC::Ptr<CSS::ComputedProperties> m_computed_properties;
|
||||
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
||||
|
||||
struct PseudoElement : public JS::Cell {
|
||||
GC_CELL(PseudoElement, JS::Cell);
|
||||
GC_DECLARE_ALLOCATOR(PseudoElement);
|
||||
|
||||
GC::Ptr<Layout::NodeWithStyle> layout_node;
|
||||
GC::Ptr<CSS::CascadedProperties> cascaded_properties;
|
||||
GC::Ptr<CSS::ComputedProperties> computed_properties;
|
||||
HashMap<FlyString, CSS::StyleProperty> custom_properties;
|
||||
|
||||
private:
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
};
|
||||
// https://drafts.csswg.org/css-view-transitions/#pseudo-element-tree
|
||||
struct PseudoElementTreeNode
|
||||
: public PseudoElement
|
||||
, TreeNode<PseudoElementTreeNode> {
|
||||
GC_CELL(PseudoElementTreeNode, PseudoElement);
|
||||
GC_DECLARE_ALLOCATOR(PseudoElementTreeNode);
|
||||
};
|
||||
using PseudoElementData = HashMap<CSS::PseudoElement, GC::Ref<PseudoElement>>;
|
||||
mutable OwnPtr<PseudoElementData> m_pseudo_element_data;
|
||||
Optional<PseudoElement&> get_pseudo_element(CSS::PseudoElement) const;
|
||||
|
@ -673,7 +655,7 @@ inline bool Element::has_pseudo_element(CSS::PseudoElement type) const
|
|||
auto pseudo_element = m_pseudo_element_data->get(type);
|
||||
if (!pseudo_element.has_value())
|
||||
return false;
|
||||
return pseudo_element.value()->layout_node;
|
||||
return pseudo_element.value()->layout_node();
|
||||
}
|
||||
|
||||
bool is_valid_namespace_prefix(FlyString const&);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue