mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #16804 - hiikezoe:allow-unitless-length-for-smil, r=birtles
Allow unitless length for smil This is a PR for https://bugzilla.mozilla.org/show_bug.cgi?id=1363574 - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes do not require tests because it's for stylo <!-- 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/16804) <!-- Reviewable:end -->
This commit is contained in:
commit
f7d67b8624
4 changed files with 1041 additions and 839 deletions
|
@ -4,7 +4,6 @@ pub use nsstring::{nsACString, nsAString, nsString};
|
||||||
type nsACString_internal = nsACString;
|
type nsACString_internal = nsACString;
|
||||||
type nsAString_internal = nsAString;
|
type nsAString_internal = nsAString;
|
||||||
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
use gecko_bindings::structs::mozilla::css::GridTemplateAreasValue;
|
||||||
#[allow(unused_imports)]
|
|
||||||
use gecko_bindings::structs::mozilla::css::ImageValue;
|
use gecko_bindings::structs::mozilla::css::ImageValue;
|
||||||
use gecko_bindings::structs::mozilla::css::URLValue;
|
use gecko_bindings::structs::mozilla::css::URLValue;
|
||||||
use gecko_bindings::structs::mozilla::Side;
|
use gecko_bindings::structs::mozilla::Side;
|
||||||
|
@ -1815,7 +1814,8 @@ extern "C" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
pub fn Servo_ParseProperty(property: nsCSSPropertyID,
|
pub fn Servo_ParseProperty(property: nsCSSPropertyID,
|
||||||
value: *const nsACString,
|
value: *const nsACString,
|
||||||
data: *mut RawGeckoURLExtraData)
|
data: *mut RawGeckoURLExtraData,
|
||||||
|
length_parsing_mode: LengthParsingMode)
|
||||||
-> RawServoDeclarationBlockStrong;
|
-> RawServoDeclarationBlockStrong;
|
||||||
}
|
}
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1117,24 +1117,33 @@ pub extern "C" fn Servo_StyleSet_Drop(data: RawServoStyleSetOwned) {
|
||||||
let _ = data.into_box::<PerDocumentStyleData>();
|
let _ = data.into_box::<PerDocumentStyleData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parse_property(property_id: PropertyId,
|
||||||
|
value: *const nsACString,
|
||||||
|
data: *mut URLExtraData,
|
||||||
|
length_parsing_mode: structs::LengthParsingMode) -> Result<ParsedDeclaration, ()> {
|
||||||
|
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
||||||
|
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
||||||
|
let length_parsing_mode = match length_parsing_mode {
|
||||||
|
structs::LengthParsingMode::Default => LengthParsingMode::Default,
|
||||||
|
structs::LengthParsingMode::SVG => LengthParsingMode::SVG,
|
||||||
|
};
|
||||||
|
|
||||||
|
parse_one_declaration(property_id,
|
||||||
|
value,
|
||||||
|
url_data,
|
||||||
|
&RustLogReporter,
|
||||||
|
length_parsing_mode,
|
||||||
|
QuirksMode::NoQuirks)
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString,
|
pub extern "C" fn Servo_ParseProperty(property: nsCSSPropertyID, value: *const nsACString,
|
||||||
data: *mut URLExtraData)
|
data: *mut URLExtraData,
|
||||||
|
length_parsing_mode: structs::LengthParsingMode)
|
||||||
-> RawServoDeclarationBlockStrong {
|
-> RawServoDeclarationBlockStrong {
|
||||||
let id = get_property_id_from_nscsspropertyid!(property,
|
let id = get_property_id_from_nscsspropertyid!(property,
|
||||||
RawServoDeclarationBlockStrong::null());
|
RawServoDeclarationBlockStrong::null());
|
||||||
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
match parse_property(id, value, data, length_parsing_mode) {
|
||||||
|
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
|
||||||
let reporter = RustLogReporter;
|
|
||||||
let context = ParserContext::new(Origin::Author,
|
|
||||||
url_data,
|
|
||||||
&reporter,
|
|
||||||
Some(CssRuleType::Style),
|
|
||||||
LengthParsingMode::Default,
|
|
||||||
QuirksMode::NoQuirks);
|
|
||||||
|
|
||||||
match ParsedDeclaration::parse(id, &context, &mut Parser::new(value)) {
|
|
||||||
Ok(parsed) => {
|
Ok(parsed) => {
|
||||||
let global_style_data = &*GLOBAL_STYLE_DATA;
|
let global_style_data = &*GLOBAL_STYLE_DATA;
|
||||||
let mut block = PropertyDeclarationBlock::new();
|
let mut block = PropertyDeclarationBlock::new();
|
||||||
|
@ -1293,20 +1302,14 @@ pub extern "C" fn Servo_DeclarationBlock_GetPropertyIsImportant(declarations: Ra
|
||||||
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
|
fn set_property(declarations: RawServoDeclarationBlockBorrowed, property_id: PropertyId,
|
||||||
value: *const nsACString, is_important: bool, data: *mut URLExtraData,
|
value: *const nsACString, is_important: bool, data: *mut URLExtraData,
|
||||||
length_parsing_mode: structs::LengthParsingMode) -> bool {
|
length_parsing_mode: structs::LengthParsingMode) -> bool {
|
||||||
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
match parse_property(property_id, value, data, length_parsing_mode) {
|
||||||
let url_data = unsafe { RefPtr::from_ptr_ref(&data) };
|
Ok(parsed) => {
|
||||||
let length_parsing_mode = match length_parsing_mode {
|
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
||||||
structs::LengthParsingMode::Default => LengthParsingMode::Default,
|
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
||||||
structs::LengthParsingMode::SVG => LengthParsingMode::SVG,
|
parsed.expand_set_into(decls, importance)
|
||||||
};
|
})
|
||||||
if let Ok(parsed) = parse_one_declaration(property_id, value, url_data, &RustLogReporter,
|
},
|
||||||
length_parsing_mode, QuirksMode::NoQuirks) {
|
Err(_) => false,
|
||||||
let importance = if is_important { Importance::Important } else { Importance::Normal };
|
|
||||||
write_locked_arc(declarations, |decls: &mut PropertyDeclarationBlock| {
|
|
||||||
parsed.expand_set_into(decls, importance)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1824,21 +1827,9 @@ pub extern "C" fn Servo_DeclarationBlock_SetTextDecorationColorOverride(declarat
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn Servo_CSSSupports2(property: *const nsACString, value: *const nsACString) -> bool {
|
pub extern "C" fn Servo_CSSSupports2(property: *const nsACString, value: *const nsACString) -> bool {
|
||||||
let property = unsafe { property.as_ref().unwrap().as_str_unchecked() };
|
let id = get_property_id_from_property!(property, false);
|
||||||
let id = if let Ok(id) = PropertyId::parse(property.into()) {
|
|
||||||
id
|
|
||||||
} else {
|
|
||||||
return false
|
|
||||||
};
|
|
||||||
let value = unsafe { value.as_ref().unwrap().as_str_unchecked() };
|
|
||||||
|
|
||||||
let url_data = unsafe { dummy_url_data() };
|
parse_property(id, value, unsafe { DUMMY_URL_DATA }, structs::LengthParsingMode::Default).is_ok()
|
||||||
parse_one_declaration(id,
|
|
||||||
&value,
|
|
||||||
url_data,
|
|
||||||
&RustLogReporter,
|
|
||||||
LengthParsingMode::Default,
|
|
||||||
QuirksMode::NoQuirks).is_ok()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue