mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Auto merge of #20639 - emilio:gecko-sync, r=emilio
style: Sync changes from mozilla-central. See each commit for details.
This commit is contained in:
commit
1fe0f32059
1 changed files with 32 additions and 1 deletions
|
@ -6,7 +6,7 @@ use cssparser::{ParseErrorKind, Parser, ParserInput, SourceLocation};
|
|||
use cssparser::ToCss as ParserToCss;
|
||||
use env_logger::Builder;
|
||||
use malloc_size_of::MallocSizeOfOps;
|
||||
use selectors::NthIndexCache;
|
||||
use selectors::{NthIndexCache, SelectorList};
|
||||
use selectors::matching::{MatchingContext, MatchingMode, matches_selector};
|
||||
use servo_arc::{Arc, ArcBorrow, RawOffsetArc};
|
||||
use smallvec::SmallVec;
|
||||
|
@ -1902,6 +1902,37 @@ pub extern "C" fn Servo_StyleRule_SelectorMatchesElement(
|
|||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_StyleRule_SetSelectorText(
|
||||
sheet: RawServoStyleSheetContentsBorrowed,
|
||||
rule: RawServoStyleRuleBorrowed,
|
||||
text: *const nsAString,
|
||||
) -> bool {
|
||||
let value_str = (*text).to_string();
|
||||
|
||||
write_locked_arc(rule, |rule: &mut StyleRule| {
|
||||
use style::selector_parser::SelectorParser;
|
||||
|
||||
let contents = StylesheetContents::as_arc(&sheet);
|
||||
let namespaces = contents.namespaces.read();
|
||||
let url_data = contents.url_data.read();
|
||||
let parser = SelectorParser {
|
||||
stylesheet_origin: contents.origin,
|
||||
namespaces: &namespaces,
|
||||
url_data: Some(&url_data),
|
||||
};
|
||||
|
||||
let mut parser_input = ParserInput::new(&value_str);
|
||||
match SelectorList::parse(&parser, &mut Parser::new(&mut parser_input)) {
|
||||
Ok(selectors) => {
|
||||
rule.selectors = selectors;
|
||||
true
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub unsafe extern "C" fn Servo_SelectorList_Closest(
|
||||
element: RawGeckoElementBorrowed,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue