diff options
author | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-02-14 18:19:06 +0100 |
---|---|---|
committer | Fernando Jiménez Moreno <ferjmoreno@gmail.com> | 2019-04-26 10:17:48 +0200 |
commit | 07e2f41c34d6676afd2a510cef9ea74b0fde576e (patch) | |
tree | f52776a3bfab90b0b5f29876c36c29f797f0200e /components/script/dom/shadowroot.rs | |
parent | 8641866a505733686e24d588ae8d5c9e86e2bcfe (diff) | |
download | servo-07e2f41c34d6676afd2a510cef9ea74b0fde576e.tar.gz servo-07e2f41c34d6676afd2a510cef9ea74b0fde576e.zip |
Retarget result of shadowRoot.element(s)FromPoint
Diffstat (limited to 'components/script/dom/shadowroot.rs')
-rw-r--r-- | components/script/dom/shadowroot.rs | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/components/script/dom/shadowroot.rs b/components/script/dom/shadowroot.rs index aad85d4d087..a5d67ea30cc 100644 --- a/components/script/dom/shadowroot.rs +++ b/components/script/dom/shadowroot.rs @@ -88,26 +88,44 @@ impl ShadowRootMethods for ShadowRoot { // https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint fn ElementFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Option<DomRoot<Element>> { - // XXX return the result of running the retargeting algorithm with context object - // and the original result as input - self.document_or_shadow_root.element_from_point( + // Return the result of running the retargeting algorithm with context object + // and the original result as input. + match self.document_or_shadow_root.element_from_point( x, y, None, self.document.has_browsing_context(), - ) + ) { + Some(e) => { + let retargeted_node = self.upcast::<Node>().retarget(e.upcast::<Node>()); + retargeted_node + .downcast::<Element>() + .map(|n| DomRoot::from_ref(n)) + }, + None => None, + } } // https://drafts.csswg.org/cssom-view/#dom-document-elementsfrompoint fn ElementsFromPoint(&self, x: Finite<f64>, y: Finite<f64>) -> Vec<DomRoot<Element>> { - // XXX return the result of running the retargeting algorithm with context object + // Return the result of running the retargeting algorithm with context object // and the original result as input - self.document_or_shadow_root.elements_from_point( + let mut elements = Vec::new(); + for e in self.document_or_shadow_root.elements_from_point( x, y, None, self.document.has_browsing_context(), - ) + ).iter() { + let retargeted_node = self.upcast::<Node>().retarget(e.upcast::<Node>()); + if let Some(element) = retargeted_node + .downcast::<Element>() + .map(|n| DomRoot::from_ref(n)) { + elements.push(element); + } + } + elements + } /// https://dom.spec.whatwg.org/#dom-shadowroot-mode |