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:
bors-servo 2018-04-15 08:31:39 -04:00 committed by GitHub
commit 1fe0f32059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,