aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/text.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/text.rs')
-rw-r--r--components/script/dom/text.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/components/script/dom/text.rs b/components/script/dom/text.rs
index 2f0e1c66857..3f81f0be6e2 100644
--- a/components/script/dom/text.rs
+++ b/components/script/dom/text.rs
@@ -2,6 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
+use std::cell::RefCell;
+
use dom_struct::dom_struct;
use js::rust::HandleObject;
@@ -12,10 +14,12 @@ use crate::dom::bindings::codegen::Bindings::TextBinding::TextMethods;
use crate::dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
use crate::dom::bindings::error::{Error, Fallible};
use crate::dom::bindings::inheritance::Castable;
-use crate::dom::bindings::root::DomRoot;
+use crate::dom::bindings::root::{Dom, DomRoot};
use crate::dom::bindings::str::DOMString;
use crate::dom::characterdata::CharacterData;
use crate::dom::document::Document;
+use crate::dom::globalscope::GlobalScope;
+use crate::dom::htmlslotelement::{HTMLSlotElement, Slottable, SlottableData};
use crate::dom::node::Node;
use crate::dom::window::Window;
use crate::script_runtime::CanGc;
@@ -24,12 +28,14 @@ use crate::script_runtime::CanGc;
#[dom_struct]
pub(crate) struct Text {
characterdata: CharacterData,
+ slottable_data: RefCell<SlottableData>,
}
impl Text {
pub(crate) fn new_inherited(text: DOMString, document: &Document) -> Text {
Text {
characterdata: CharacterData::new_inherited(text, document),
+ slottable_data: Default::default(),
}
}
@@ -50,6 +56,10 @@ impl Text {
can_gc,
)
}
+
+ pub(crate) fn slottable_data(&self) -> &RefCell<SlottableData> {
+ &self.slottable_data
+ }
}
impl TextMethods<crate::DomTypeHolder> for Text {
@@ -119,4 +129,14 @@ impl TextMethods<crate::DomTypeHolder> for Text {
}
DOMString::from(text)
}
+
+ /// <https://dom.spec.whatwg.org/#dom-slotable-assignedslot>
+ fn GetAssignedSlot(&self) -> Option<DomRoot<HTMLSlotElement>> {
+ let cx = GlobalScope::get_cx();
+
+ // > The assignedSlot getter steps are to return the result of
+ // > find a slot given this and with the open flag set.
+ rooted!(in(*cx) let slottable = Slottable::Text(Dom::from_ref(self)));
+ slottable.find_a_slot(true)
+ }
}