mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-08 12:19:37 +03:00
LibWeb: Add a way to give DOM::Element a ShadowRoot
You can now attach a shadow root to your favorite Element. It doesn't do anything yet, but you can.
This commit is contained in:
parent
bf82e7fba2
commit
d597626ea1
Notes:
sideshowbarker
2024-07-18 22:26:56 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/d597626ea1b
@ -31,8 +31,8 @@
|
||||
#include <LibWeb/CSS/StyleInvalidator.h>
|
||||
#include <LibWeb/CSS/StyleResolver.h>
|
||||
#include <LibWeb/DOM/Document.h>
|
||||
#include <LibWeb/DOM/DocumentFragment.h>
|
||||
#include <LibWeb/DOM/Element.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/Layout/BlockBox.h>
|
||||
@ -365,4 +365,12 @@ NonnullRefPtrVector<Element> Element::get_elements_by_class_name(const FlyString
|
||||
return elements;
|
||||
}
|
||||
|
||||
void Element::set_shadow_root(RefPtr<ShadowRoot> shadow_root)
|
||||
{
|
||||
if (m_shadow_root == shadow_root)
|
||||
return;
|
||||
m_shadow_root = move(shadow_root);
|
||||
invalidate_style();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -101,6 +101,10 @@ public:
|
||||
NonnullRefPtrVector<Element> get_elements_by_tag_name(const FlyString&) const;
|
||||
NonnullRefPtrVector<Element> get_elements_by_class_name(const FlyString&) const;
|
||||
|
||||
ShadowRoot* shadow_root() { return m_shadow_root; }
|
||||
const ShadowRoot* shadow_root() const { return m_shadow_root; }
|
||||
void set_shadow_root(RefPtr<ShadowRoot>);
|
||||
|
||||
protected:
|
||||
RefPtr<Layout::Node> create_layout_node() override;
|
||||
|
||||
@ -116,6 +120,8 @@ private:
|
||||
RefPtr<CSS::StyleProperties> m_specified_css_values;
|
||||
|
||||
Vector<FlyString> m_classes;
|
||||
|
||||
RefPtr<ShadowRoot> m_shadow_root;
|
||||
};
|
||||
|
||||
template<>
|
||||
|
Loading…
Reference in New Issue
Block a user