style: Allow disabling invalidation-based querySelector from C++

Rust compile times are hard.

MozReview-Commit-ID: 9Xhtf7f3Vzv
This commit is contained in:
Emilio Cobos Álvarez 2017-10-30 19:23:59 +01:00
parent 931aae9760
commit bfabd9f855
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
2 changed files with 32 additions and 2 deletions

View file

@ -1693,17 +1693,27 @@ pub unsafe extern "C" fn Servo_SelectorList_Matches(
pub unsafe extern "C" fn Servo_SelectorList_QueryFirst(
node: RawGeckoNodeBorrowed,
selectors: RawServoSelectorListBorrowed,
may_use_invalidation: bool,
) -> *const structs::RawGeckoElement {
use std::borrow::Borrow;
use style::dom_apis::{self, QueryFirst};
use style::dom_apis::{self, MayUseInvalidation, QueryFirst};
let node = GeckoNode(node);
let selectors = ::selectors::SelectorList::from_ffi(selectors).borrow();
let mut result = None;
let may_use_invalidation =
if may_use_invalidation {
MayUseInvalidation::Yes
} else {
MayUseInvalidation::No
};
dom_apis::query_selector::<GeckoElement, QueryFirst>(
node,
&selectors,
&mut result,
may_use_invalidation,
);
result.map_or(ptr::null(), |e| e.0)
@ -1714,19 +1724,28 @@ pub unsafe extern "C" fn Servo_SelectorList_QueryAll(
node: RawGeckoNodeBorrowed,
selectors: RawServoSelectorListBorrowed,
content_list: *mut structs::nsSimpleContentList,
may_use_invalidation: bool,
) {
use smallvec::SmallVec;
use std::borrow::Borrow;
use style::dom_apis::{self, QueryAll};
use style::dom_apis::{self, MayUseInvalidation, QueryAll};
let node = GeckoNode(node);
let selectors = ::selectors::SelectorList::from_ffi(selectors).borrow();
let mut result = SmallVec::new();
let may_use_invalidation =
if may_use_invalidation {
MayUseInvalidation::Yes
} else {
MayUseInvalidation::No
};
dom_apis::query_selector::<GeckoElement, QueryAll>(
node,
&selectors,
&mut result,
may_use_invalidation,
);
if !result.is_empty() {