mirror of
https://github.com/servo/servo.git
synced 2025-08-30 01:28:21 +01:00
Auto merge of #19108 - emilio:qsa, r=xidorn,bz
stylo: querySelector{,All} optimizations. Bug: 1410624 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19108) <!-- Reviewable:end -->
This commit is contained in:
commit
a0cd781bdc
8 changed files with 371 additions and 60 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue