mirror of
https://github.com/servo/servo.git
synced 2025-08-18 11:55:39 +01:00
Thread ParseError return values through CSS parsing.
This commit is contained in:
parent
58e39bfffa
commit
27ae1ef2e7
121 changed files with 2133 additions and 1505 deletions
|
@ -16,7 +16,7 @@ gecko_debug = ["style/gecko_debug"]
|
|||
|
||||
[dependencies]
|
||||
atomic_refcell = "0.1"
|
||||
cssparser = "0.13.7"
|
||||
cssparser = "0.14.0"
|
||||
env_logger = {version = "0.4", default-features = false} # disable `regex` to reduce code size
|
||||
libc = "0.2"
|
||||
log = {version = "0.3.5", features = ["release_max_level_info"]}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use atomic_refcell::AtomicRefMut;
|
||||
use cssparser::Parser;
|
||||
use cssparser::{Parser, ParserInput};
|
||||
use cssparser::ToCss as ParserToCss;
|
||||
use env_logger::LogBuilder;
|
||||
use selectors::Element;
|
||||
|
@ -1228,7 +1228,8 @@ pub extern "C" fn Servo_Keyframe_GetKeyText(keyframe: RawServoKeyframeBorrowed,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_Keyframe_SetKeyText(keyframe: RawServoKeyframeBorrowed, text: *const nsACString) -> bool {
|
||||
let text = unsafe { text.as_ref().unwrap().as_str_unchecked() };
|
||||
if let Ok(selector) = Parser::new(&text).parse_entirely(KeyframeSelector::parse) {
|
||||
let mut input = ParserInput::new(&text);
|
||||
if let Ok(selector) = Parser::new(&mut input).parse_entirely(KeyframeSelector::parse) {
|
||||
write_locked_arc(keyframe, |keyframe: &mut Keyframe| {
|
||||
keyframe.selector = selector;
|
||||
});
|
||||
|
@ -1603,7 +1604,8 @@ pub extern "C" fn Servo_ParseEasing(easing: *const nsAString,
|
|||
PARSING_MODE_DEFAULT,
|
||||
QuirksMode::NoQuirks);
|
||||
let easing = unsafe { (*easing).to_string() };
|
||||
match transition_timing_function::single_value::parse(&context, &mut Parser::new(&easing)) {
|
||||
let mut input = ParserInput::new(&easing);
|
||||
match transition_timing_function::single_value::parse(&context, &mut Parser::new(&mut input)) {
|
||||
Ok(parsed_easing) => {
|
||||
*output = parsed_easing.into();
|
||||
true
|
||||
|
@ -1779,7 +1781,7 @@ macro_rules! get_property_id_from_property {
|
|||
let property = unsafe { $property.as_ref().unwrap().as_str_unchecked() };
|
||||
match PropertyId::parse(Cow::Borrowed(property)) {
|
||||
Ok(property_id) => property_id,
|
||||
Err(()) => { return $ret; }
|
||||
Err(_) => { return $ret; }
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
@ -1911,7 +1913,8 @@ pub extern "C" fn Servo_MediaList_GetText(list: RawServoMediaListBorrowed, resul
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_MediaList_SetText(list: RawServoMediaListBorrowed, text: *const nsACString) {
|
||||
let text = unsafe { text.as_ref().unwrap().as_str_unchecked() };
|
||||
let mut parser = Parser::new(&text);
|
||||
let mut input = ParserInput::new(&text);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
let url_data = unsafe { dummy_url_data() };
|
||||
let reporter = RustLogReporter;
|
||||
let context = ParserContext::new_for_cssom(url_data, &reporter, Some(CssRuleType::Media),
|
||||
|
@ -2294,12 +2297,13 @@ pub extern "C" fn Servo_DeclarationBlock_SetColorValue(declarations:
|
|||
pub extern "C" fn Servo_DeclarationBlock_SetFontFamily(declarations:
|
||||
RawServoDeclarationBlockBorrowed,
|
||||
value: *const nsAString) {
|
||||
use cssparser::Parser;
|
||||
use cssparser::{Parser, ParserInput};
|
||||
use style::properties::PropertyDeclaration;
|
||||
use style::properties::longhands::font_family::SpecifiedValue as FontFamily;
|
||||
|
||||
let string = unsafe { (*value).to_string() };
|
||||
let mut parser = Parser::new(&string);
|
||||
let mut input = ParserInput::new(&string);
|
||||
let mut parser = Parser::new(&mut input);
|
||||
if let Ok(family) = FontFamily::parse(&mut parser) {
|
||||
if parser.is_exhausted() {
|
||||
let decl = PropertyDeclaration::FontFamily(Box::new(family));
|
||||
|
@ -2371,7 +2375,8 @@ pub extern "C" fn Servo_CSSSupports2(property: *const nsACString,
|
|||
#[no_mangle]
|
||||
pub extern "C" fn Servo_CSSSupports(cond: *const nsACString) -> bool {
|
||||
let condition = unsafe { cond.as_ref().unwrap().as_str_unchecked() };
|
||||
let mut input = Parser::new(&condition);
|
||||
let mut input = ParserInput::new(&condition);
|
||||
let mut input = Parser::new(&mut input);
|
||||
let cond = input.parse_entirely(|i| parse_condition_or_declaration(i));
|
||||
if let Ok(cond) = cond {
|
||||
let url_data = unsafe { dummy_url_data() };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue