mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Refactor querySelector to be generic over the query type, and implement a tree-walking variant of it.
Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
4f997bf333
commit
2274fd7ef3
2 changed files with 162 additions and 53 deletions
|
@ -1620,21 +1620,19 @@ pub unsafe extern "C" fn Servo_SelectorList_QueryFirst(
|
|||
selectors: RawServoSelectorListBorrowed,
|
||||
) -> *const structs::RawGeckoElement {
|
||||
use std::borrow::Borrow;
|
||||
use style::dom_apis::{self, QuerySelectorResult, QuerySelectorKind};
|
||||
use style::dom_apis::{self, QueryFirst};
|
||||
|
||||
let node = GeckoNode(node);
|
||||
let selectors = ::selectors::SelectorList::from_ffi(selectors).borrow();
|
||||
let mut result = QuerySelectorResult::new();
|
||||
dom_apis::query_selector::<GeckoElement>(
|
||||
let mut result = None;
|
||||
dom_apis::query_selector::<GeckoElement, QueryFirst>(
|
||||
node,
|
||||
&selectors,
|
||||
&mut result,
|
||||
QuerySelectorKind::First,
|
||||
node.owner_document_quirks_mode(),
|
||||
);
|
||||
|
||||
result.first()
|
||||
.map_or(ptr::null(), |e| e.0)
|
||||
result.map_or(ptr::null(), |e| e.0)
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue