mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Further changes required by Servo
This commit is contained in:
parent
04282ff04c
commit
07dbd9d637
5 changed files with 26 additions and 23 deletions
|
@ -96,19 +96,15 @@ impl CSSStyleRuleMethods for CSSStyleRule {
|
|||
|
||||
// https://drafts.csswg.org/cssom/#dom-cssstylerule-selectortext
|
||||
fn SetSelectorText(&self, value: DOMString) {
|
||||
let contents = &self.cssrule.parent_stylesheet().style_stylesheet().contents;
|
||||
// It's not clear from the spec if we should use the stylesheet's namespaces.
|
||||
// https://github.com/w3c/csswg-drafts/issues/1511
|
||||
let namespaces = self
|
||||
.cssrule
|
||||
.parent_stylesheet()
|
||||
.style_stylesheet()
|
||||
.contents
|
||||
.namespaces
|
||||
.read();
|
||||
let namespaces = contents.namespaces.read();
|
||||
let url_data = contents.url_data.read();
|
||||
let parser = SelectorParser {
|
||||
stylesheet_origin: Origin::Author,
|
||||
namespaces: &namespaces,
|
||||
url_data: None,
|
||||
url_data: &url_data,
|
||||
};
|
||||
let mut css_parser = CssParserInput::new(&*value);
|
||||
let mut css_parser = CssParser::new(&mut css_parser);
|
||||
|
|
|
@ -2700,12 +2700,14 @@ impl ElementMethods for Element {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-element-matches
|
||||
fn Matches(&self, selectors: DOMString) -> Fallible<bool> {
|
||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||
let doc = document_from_node(self);
|
||||
let url = doc.url();
|
||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
||||
Err(_) => return Err(Error::Syntax),
|
||||
Ok(selectors) => selectors,
|
||||
};
|
||||
|
||||
let quirks_mode = document_from_node(self).quirks_mode();
|
||||
let quirks_mode = doc.quirks_mode();
|
||||
let element = DomRoot::from_ref(self);
|
||||
|
||||
Ok(dom_apis::element_matches(&element, &selectors, quirks_mode))
|
||||
|
@ -2718,12 +2720,14 @@ impl ElementMethods for Element {
|
|||
|
||||
// https://dom.spec.whatwg.org/#dom-element-closest
|
||||
fn Closest(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||
let doc = document_from_node(self);
|
||||
let url = doc.url();
|
||||
let selectors = match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
||||
Err(_) => return Err(Error::Syntax),
|
||||
Ok(selectors) => selectors,
|
||||
};
|
||||
|
||||
let quirks_mode = document_from_node(self).quirks_mode();
|
||||
let quirks_mode = doc.quirks_mode();
|
||||
Ok(dom_apis::element_closest(
|
||||
DomRoot::from_ref(self),
|
||||
&selectors,
|
||||
|
|
|
@ -949,18 +949,15 @@ impl Node {
|
|||
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
|
||||
pub fn query_selector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Element>>> {
|
||||
// Step 1.
|
||||
match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||
let doc = self.owner_doc();
|
||||
match SelectorParser::parse_author_origin_no_namespace(&selectors, &doc.url()) {
|
||||
// Step 2.
|
||||
Err(_) => Err(Error::Syntax),
|
||||
// Step 3.
|
||||
Ok(selectors) => {
|
||||
// FIXME(bholley): Consider an nth-index cache here.
|
||||
let mut ctx = MatchingContext::new(
|
||||
MatchingMode::Normal,
|
||||
None,
|
||||
None,
|
||||
self.owner_doc().quirks_mode(),
|
||||
);
|
||||
let mut ctx =
|
||||
MatchingContext::new(MatchingMode::Normal, None, None, doc.quirks_mode());
|
||||
Ok(self
|
||||
.traverse_preorder(ShadowIncluding::No)
|
||||
.filter_map(DomRoot::downcast)
|
||||
|
@ -975,7 +972,8 @@ impl Node {
|
|||
/// whilst iterating, otherwise the iterator may be invalidated.
|
||||
pub fn query_selector_iter(&self, selectors: DOMString) -> Fallible<QuerySelectorIterator> {
|
||||
// Step 1.
|
||||
match SelectorParser::parse_author_origin_no_namespace(&selectors) {
|
||||
let url = self.owner_doc().url();
|
||||
match SelectorParser::parse_author_origin_no_namespace(&selectors, &url) {
|
||||
// Step 2.
|
||||
Err(_) => Err(Error::Syntax),
|
||||
// Step 3.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue