mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-09 17:44:56 +09:00
LibWeb/DOM: Introduce an ElementReference type
We have the "Element, but also maybe a pseudo-element of it" concept in a lot of places, so let's wrap it up in a single type to make it easier to deal with.
This commit is contained in:
parent
dea5fde3f9
commit
3425aa0737
Notes:
github-actions[bot]
2025-03-19 13:54:49 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3425aa0737
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3983
1 changed files with 37 additions and 0 deletions
37
Libraries/LibWeb/DOM/ElementReference.h
Normal file
37
Libraries/LibWeb/DOM/ElementReference.h
Normal file
|
@ -0,0 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Sam Atkins <sam@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGC/Cell.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
|
||||
namespace Web::DOM {
|
||||
|
||||
class ElementReference {
|
||||
public:
|
||||
ElementReference(GC::Ref<Element> element, Optional<CSS::Selector::PseudoElement::Type> pseudo_element = {})
|
||||
: m_element(element)
|
||||
, m_pseudo_element(move(pseudo_element))
|
||||
{
|
||||
}
|
||||
|
||||
Element& element() { return m_element; }
|
||||
Element const& element() const { return m_element; }
|
||||
Optional<CSS::Selector::PseudoElement::Type> pseudo_element() const { return m_pseudo_element; }
|
||||
|
||||
void visit(GC::Cell::Visitor& visitor) const
|
||||
{
|
||||
visitor.visit(m_element);
|
||||
}
|
||||
|
||||
private:
|
||||
GC::Ref<Element> m_element;
|
||||
Optional<CSS::Selector::PseudoElement::Type> m_pseudo_element;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue