style: Hook QuerySelector into stylo.

Bug: 1410624
MozReview-Commit-ID: 4uKWN9uqi3r
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
Emilio Cobos Álvarez 2017-10-21 14:54:43 +02:00
parent 6d78e9ba54
commit 6ae8bdee61
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 33 additions and 3 deletions

View file

@ -148,6 +148,12 @@ impl<'ln> GeckoNode<'ln> {
(self.0).mBoolFlags
}
/// Owner document quirks mode getter.
#[inline]
pub fn owner_document_quirks_mode(&self) -> QuirksMode {
self.owner_doc().mCompatMode.into()
}
#[inline]
fn get_bool_flag(&self, flag: nsINode_BooleanFlag) -> bool {
self.bool_flags() & (1u32 << flag as u32) != 0
@ -625,8 +631,9 @@ impl<'le> GeckoElement<'le> {
}
/// Owner document quirks mode getter.
#[inline]
pub fn owner_document_quirks_mode(&self) -> QuirksMode {
self.as_node().owner_doc().mCompatMode.into()
self.as_node().owner_document_quirks_mode()
}
/// Only safe to call on the main thread, with exclusive access to the element and

View file

@ -29,9 +29,9 @@ use style::gecko::global_style_data::{GLOBAL_STYLE_DATA, GlobalStyleData, STYLE_
use style::gecko::restyle_damage::GeckoRestyleDamage;
use style::gecko::selector_parser::PseudoElement;
use style::gecko::traversal::RecalcStyleOnly;
use style::gecko::wrapper::GeckoElement;
use style::gecko::wrapper::{GeckoElement, GeckoNode};
use style::gecko_bindings::bindings;
use style::gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoElementBorrowedOrNull};
use style::gecko_bindings::bindings::{RawGeckoElementBorrowed, RawGeckoElementBorrowedOrNull, RawGeckoNodeBorrowed};
use style::gecko_bindings::bindings::{RawGeckoKeyframeListBorrowed, RawGeckoKeyframeListBorrowedMut};
use style::gecko_bindings::bindings::{RawServoDeclarationBlockBorrowed, RawServoDeclarationBlockStrong};
use style::gecko_bindings::bindings::{RawServoDocumentRule, RawServoDocumentRuleBorrowed};
@ -1614,6 +1614,29 @@ pub unsafe extern "C" fn Servo_SelectorList_Matches(
)
}
#[no_mangle]
pub unsafe extern "C" fn Servo_SelectorList_QueryFirst(
node: RawGeckoNodeBorrowed,
selectors: RawServoSelectorListBorrowed,
) -> *const structs::RawGeckoElement {
use std::borrow::Borrow;
use style::dom_apis::{self, QuerySelectorResult, QuerySelectorKind};
let node = GeckoNode(node);
let selectors = ::selectors::SelectorList::from_ffi(selectors).borrow();
let mut result = QuerySelectorResult::new();
dom_apis::query_selector::<GeckoElement>(
node,
&selectors,
&mut result,
QuerySelectorKind::First,
node.owner_document_quirks_mode(),
);
result.first()
.map_or(ptr::null(), |e| e.0)
}
#[no_mangle]
pub extern "C" fn Servo_ImportRule_GetHref(rule: RawServoImportRuleBorrowed, result: *mut nsAString) {
read_locked_arc(rule, |rule: &ImportRule| {