mirror of
https://github.com/servo/servo.git
synced 2025-07-23 23:33:43 +01:00
Move more bindings code to script_bindings (#35578)
* Move JSContext wrapper to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move webidl constant bindings to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move CanGc to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Move Dom<T> and Root<T> types to script_bindings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Formatting. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Extra docs for new traits. Signed-off-by: Josh Matthews <josh@joshmatthews.net> * Fix clippy warnings. Signed-off-by: Josh Matthews <josh@joshmatthews.net> --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
54286229ea
commit
35f21e426b
23 changed files with 788 additions and 641 deletions
|
@ -76,7 +76,7 @@ use crate::dom::bindings::inheritance::{
|
|||
};
|
||||
use crate::dom::bindings::refcounted::Trusted;
|
||||
use crate::dom::bindings::reflector::{reflect_dom_object_with_proto, DomObject, DomObjectWrap};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom};
|
||||
use crate::dom::bindings::root::{Dom, DomRoot, DomSlice, LayoutDom, MutNullableDom, ToLayout};
|
||||
use crate::dom::bindings::str::{DOMString, USVString};
|
||||
use crate::dom::bindings::xmlname::namespace_from_domstring;
|
||||
use crate::dom::characterdata::{CharacterData, LayoutCharacterDataHelpers};
|
||||
|
@ -85,7 +85,7 @@ use crate::dom::customelementregistry::{try_upgrade_element, CallbackReaction};
|
|||
use crate::dom::document::{Document, DocumentSource, HasBrowsingContext, IsHTMLDocument};
|
||||
use crate::dom::documentfragment::DocumentFragment;
|
||||
use crate::dom::documenttype::DocumentType;
|
||||
use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator};
|
||||
use crate::dom::element::{CustomElementCreationMode, Element, ElementCreator, SelectorWrapper};
|
||||
use crate::dom::event::{Event, EventBubbles, EventCancelable};
|
||||
use crate::dom::eventtarget::EventTarget;
|
||||
use crate::dom::htmlbodyelement::HTMLBodyElement;
|
||||
|
@ -178,12 +178,6 @@ impl fmt::Debug for Node {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for DomRoot<Node> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
(**self).fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
/// Flags for node items
|
||||
#[derive(Clone, Copy, JSTraceable, MallocSizeOf)]
|
||||
pub(crate) struct NodeFlags(u16);
|
||||
|
@ -523,7 +517,11 @@ impl Iterator for QuerySelectorIterator {
|
|||
MatchingForInvalidation::No,
|
||||
);
|
||||
if let Some(element) = DomRoot::downcast(node) {
|
||||
if matches_selector_list(selectors, &element, &mut ctx) {
|
||||
if matches_selector_list(
|
||||
selectors,
|
||||
&SelectorWrapper::Borrowed(&element),
|
||||
&mut ctx,
|
||||
) {
|
||||
return Some(DomRoot::upcast(element));
|
||||
}
|
||||
}
|
||||
|
@ -1042,9 +1040,9 @@ impl Node {
|
|||
let mut descendants = self.traverse_preorder(ShadowIncluding::No);
|
||||
// Skip the root of the tree.
|
||||
assert!(&*descendants.next().unwrap() == self);
|
||||
Ok(descendants
|
||||
.filter_map(DomRoot::downcast)
|
||||
.find(|element| matches_selector_list(&selectors, element, &mut ctx)))
|
||||
Ok(descendants.filter_map(DomRoot::downcast).find(|element| {
|
||||
matches_selector_list(&selectors, &SelectorWrapper::Borrowed(element), &mut ctx)
|
||||
}))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue