mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +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
50
Libraries/LibWeb/DOM/PseudoElement.h
Normal file
50
Libraries/LibWeb/DOM/PseudoElement.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGC/CellAllocator.h>
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibWeb/CSS/StyleProperty.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/TreeNode.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
class PseudoElement : public JS::Cell {
|
||||
GC_CELL(PseudoElement, JS::Cell);
|
||||
GC_DECLARE_ALLOCATOR(PseudoElement);
|
||||
|
||||
GC::Ptr<Layout::NodeWithStyle> layout_node() const { return m_layout_node; }
|
||||
void set_layout_node(GC::Ptr<Layout::NodeWithStyle> value) { m_layout_node = value; }
|
||||
|
||||
GC::Ptr<CSS::CascadedProperties> cascaded_properties() const { return m_cascaded_properties; }
|
||||
void set_cascaded_properties(GC::Ptr<CSS::CascadedProperties> value) { m_cascaded_properties = value; }
|
||||
|
||||
GC::Ptr<CSS::ComputedProperties> computed_properties() const { return m_computed_properties; }
|
||||
void set_computed_properties(GC::Ptr<CSS::ComputedProperties> value) { m_computed_properties = value; }
|
||||
|
||||
HashMap<FlyString, CSS::StyleProperty> const& custom_properties() const { return m_custom_properties; }
|
||||
void set_custom_properties(HashMap<FlyString, CSS::StyleProperty> value) { m_custom_properties = move(value); }
|
||||
|
||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
GC::Ptr<Layout::NodeWithStyle> m_layout_node;
|
||||
GC::Ptr<CSS::CascadedProperties> m_cascaded_properties;
|
||||
GC::Ptr<CSS::ComputedProperties> m_computed_properties;
|
||||
HashMap<FlyString, CSS::StyleProperty> m_custom_properties;
|
||||
};
|
||||
|
||||
// https://drafts.csswg.org/css-view-transitions/#pseudo-element-tree
|
||||
class PseudoElementTreeNode final
|
||||
: public PseudoElement
|
||||
, TreeNode<PseudoElementTreeNode> {
|
||||
GC_CELL(PseudoElementTreeNode, PseudoElement);
|
||||
GC_DECLARE_ALLOCATOR(PseudoElementTreeNode);
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue