mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Further changes required by Servo
This commit is contained in:
parent
4878422c93
commit
b05552369f
3 changed files with 35 additions and 25 deletions
|
@ -111,6 +111,7 @@ use std::cell::Cell;
|
|||
use std::default::Default;
|
||||
use std::fmt;
|
||||
use std::mem;
|
||||
use std::ops::Deref;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
use style::applicable_declarations::ApplicableDeclarationBlock;
|
||||
|
@ -3218,15 +3219,11 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
|||
Element::namespace(self) == Element::namespace(other)
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(
|
||||
fn match_non_ts_pseudo_class(
|
||||
&self,
|
||||
pseudo_class: &NonTSPseudoClass,
|
||||
_: &mut MatchingContext<Self::Impl>,
|
||||
_: &mut F,
|
||||
) -> bool
|
||||
where
|
||||
F: FnMut(&Self, ElementSelectorFlags),
|
||||
{
|
||||
) -> bool {
|
||||
match *pseudo_class {
|
||||
// https://github.com/servo/servo/issues/8718
|
||||
NonTSPseudoClass::Link | NonTSPseudoClass::AnyLink => self.is_link(),
|
||||
|
@ -3307,6 +3304,15 @@ impl<'a> SelectorsElement for DomRoot<Element> {
|
|||
fn is_html_slot_element(&self) -> bool {
|
||||
self.is_html_element() && self.local_name() == &local_name!("slot")
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
#[allow(unsafe_code)]
|
||||
unsafe {
|
||||
Dom::from_ref(self.deref())
|
||||
.to_layout()
|
||||
.insert_selector_flags(flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Element {
|
||||
|
|
|
@ -79,7 +79,9 @@ use script_layout_interface::{HTMLCanvasData, HTMLMediaData, LayoutElementType,
|
|||
use script_layout_interface::{SVGSVGData, StyleAndOpaqueLayoutData, TrustedNodeAddress};
|
||||
use script_traits::DocumentActivity;
|
||||
use script_traits::UntrustedNodeAddress;
|
||||
use selectors::matching::{matches_selector_list, MatchingContext, MatchingMode};
|
||||
use selectors::matching::{
|
||||
matches_selector_list, MatchingContext, MatchingMode, NeedsSelectorFlags,
|
||||
};
|
||||
use selectors::parser::SelectorList;
|
||||
use servo_arc::Arc;
|
||||
use servo_url::ServoUrl;
|
||||
|
@ -473,6 +475,7 @@ impl<'a> Iterator for QuerySelectorIterator {
|
|||
None,
|
||||
None,
|
||||
node.owner_doc().quirks_mode(),
|
||||
NeedsSelectorFlags::No,
|
||||
);
|
||||
if let Some(element) = DomRoot::downcast(node) {
|
||||
if matches_selector_list(selectors, &element, &mut ctx) {
|
||||
|
@ -956,8 +959,13 @@ impl Node {
|
|||
// Step 3.
|
||||
Ok(selectors) => {
|
||||
// FIXME(bholley): Consider an nth-index cache here.
|
||||
let mut ctx =
|
||||
MatchingContext::new(MatchingMode::Normal, None, None, doc.quirks_mode());
|
||||
let mut ctx = MatchingContext::new(
|
||||
MatchingMode::Normal,
|
||||
None,
|
||||
None,
|
||||
doc.quirks_mode(),
|
||||
NeedsSelectorFlags::No,
|
||||
);
|
||||
Ok(self
|
||||
.traverse_preorder(ShadowIncluding::No)
|
||||
.filter_map(DomRoot::downcast)
|
||||
|
|
|
@ -358,10 +358,6 @@ impl<'dom, LayoutDataType: LayoutDataTrait> style::dom::TElement
|
|||
false
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
self.element.insert_selector_flags(flags);
|
||||
}
|
||||
|
||||
fn has_animations(&self, context: &SharedStyleContext) -> bool {
|
||||
// This is not used for pseudo elements currently so we can pass None.
|
||||
return self.has_css_animations(context, /* pseudo_element = */ None) ||
|
||||
|
@ -569,15 +565,11 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
|||
false
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(
|
||||
fn match_non_ts_pseudo_class(
|
||||
&self,
|
||||
pseudo_class: &NonTSPseudoClass,
|
||||
_: &mut MatchingContext<Self::Impl>,
|
||||
_: &mut F,
|
||||
) -> bool
|
||||
where
|
||||
F: FnMut(&Self, ElementSelectorFlags),
|
||||
{
|
||||
) -> bool {
|
||||
match *pseudo_class {
|
||||
// https://github.com/servo/servo/issues/8718
|
||||
NonTSPseudoClass::Link | NonTSPseudoClass::AnyLink => self.is_link(),
|
||||
|
@ -666,6 +658,10 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
|||
fn is_html_element_in_html_document(&self) -> bool {
|
||||
self.element.is_html_element() && self.as_node().owner_doc().is_html_document()
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
self.element.insert_selector_flags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
/// A wrapper around elements that ensures layout can only
|
||||
|
@ -854,15 +850,11 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
|||
}
|
||||
}
|
||||
|
||||
fn match_non_ts_pseudo_class<F>(
|
||||
fn match_non_ts_pseudo_class(
|
||||
&self,
|
||||
_: &NonTSPseudoClass,
|
||||
_: &mut MatchingContext<Self::Impl>,
|
||||
_: &mut F,
|
||||
) -> bool
|
||||
where
|
||||
F: FnMut(&Self, ElementSelectorFlags),
|
||||
{
|
||||
) -> bool {
|
||||
// NB: This could maybe be implemented
|
||||
warn!("ServoThreadSafeLayoutElement::match_non_ts_pseudo_class called");
|
||||
false
|
||||
|
@ -903,6 +895,10 @@ impl<'dom, LayoutDataType: LayoutDataTrait> ::selectors::Element
|
|||
warn!("ServoThreadSafeLayoutElement::is_root called");
|
||||
false
|
||||
}
|
||||
|
||||
fn set_selector_flags(&self, flags: ElementSelectorFlags) {
|
||||
self.element.element.insert_selector_flags(flags);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'dom, LayoutDataType: LayoutDataTrait> GetStyleAndOpaqueLayoutData<'dom>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue