Partial ShadowRoot implementation of DocumentOrShadowRoot

This commit is contained in:
Fernando Jiménez Moreno 2019-01-21 20:58:52 +01:00
parent 18ae0fcbd6
commit 4304ee28dc
9 changed files with 161 additions and 54 deletions

View file

@ -43,6 +43,7 @@ use crate::dom::cssstylesheet::CSSStyleSheet;
use crate::dom::customelementregistry::CustomElementDefinition;
use crate::dom::customevent::CustomEvent;
use crate::dom::documentfragment::DocumentFragment;
use crate::dom::documentorshadowroot::DocumentOrShadowRoot;
use crate::dom::documenttype::DocumentType;
use crate::dom::domimplementation::DOMImplementation;
use crate::dom::element::CustomElementCreationMode;
@ -486,16 +487,6 @@ impl Document {
self.has_browsing_context
}
/// <https://html.spec.whatwg.org/multipage/#concept-document-bc>
#[inline]
pub fn browsing_context(&self) -> Option<DomRoot<WindowProxy>> {
if self.has_browsing_context {
self.window.undiscarded_window_proxy()
} else {
None
}
}
#[inline]
pub fn window(&self) -> &Window {
&*self.window
@ -2395,21 +2386,6 @@ impl Document {
!self.has_browsing_context || !url_has_network_scheme(&self.url())
}
pub fn nodes_from_point(
&self,
client_point: &Point2D<f32>,
reflow_goal: NodesFromPointQueryType,
) -> Vec<UntrustedNodeAddress> {
if !self
.window
.layout_reflow(QueryMsg::NodesFromPointQuery(*client_point, reflow_goal))
{
return vec![];
};
self.window.layout().nodes_from_point_response()
}
/// <https://html.spec.whatwg.org/multipage/#look-up-a-custom-element-definition>
pub fn lookup_custom_element_definition(
&self,
@ -3270,6 +3246,8 @@ impl Document {
}
}
}
impl_document_or_shadow_root_helpers!();
}
impl Element {
@ -3300,7 +3278,7 @@ impl ProfilerMetadataFactory for Document {
impl DocumentMethods for Document {
// https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-the-documentorshadowroot-mixin
impl_document_or_shadow_root!();
impl_document_or_shadow_root_methods!(Document);
// https://dom.spec.whatwg.org/#dom-document-implementation
fn Implementation(&self) -> DomRoot<DOMImplementation> {