mirror of
https://github.com/servo/servo.git
synced 2025-08-08 15:05:35 +01:00
Format remaining files
This commit is contained in:
parent
bf47f90da6
commit
cb07debcb6
252 changed files with 5944 additions and 3744 deletions
|
@ -32,7 +32,6 @@ use values::computed::box_::TransitionProperty;
|
|||
use values::generics::box_::AnimationIterationCount;
|
||||
use values::generics::easing::{StepPosition, TimingFunction as GenericTimingFunction};
|
||||
|
||||
|
||||
/// This structure represents a keyframes animation current iteration state.
|
||||
///
|
||||
/// If the iteration count is infinite, there's no other state, otherwise we
|
||||
|
@ -316,7 +315,8 @@ impl PropertyAnimation {
|
|||
old_style,
|
||||
new_style,
|
||||
)
|
||||
}).collect(),
|
||||
})
|
||||
.collect(),
|
||||
TransitionProperty::Longhand(longhand_id) => {
|
||||
let animation = PropertyAnimation::from_longhand(
|
||||
longhand_id,
|
||||
|
@ -367,8 +367,9 @@ impl PropertyAnimation {
|
|||
let mut current_step = (time * (steps as f64)).floor() as i32;
|
||||
|
||||
if pos == StepPosition::Start ||
|
||||
pos == StepPosition::JumpStart ||
|
||||
pos == StepPosition::JumpBoth {
|
||||
pos == StepPosition::JumpStart ||
|
||||
pos == StepPosition::JumpBoth
|
||||
{
|
||||
current_step = current_step + 1;
|
||||
}
|
||||
|
||||
|
@ -472,7 +473,8 @@ pub fn start_transitions_if_applicable(
|
|||
duration: box_style.transition_duration_mod(i).seconds() as f64,
|
||||
property_animation,
|
||||
},
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
had_animations = true;
|
||||
}
|
||||
|
@ -759,7 +761,8 @@ where
|
|||
} else {
|
||||
None
|
||||
}
|
||||
}).unwrap_or(animation.steps.len() - 1);
|
||||
})
|
||||
.unwrap_or(animation.steps.len() - 1);
|
||||
},
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
|
|
@ -67,7 +67,8 @@ fn find_python() -> String {
|
|||
"python2.7"
|
||||
} else {
|
||||
"python"
|
||||
}.to_owned()
|
||||
}
|
||||
.to_owned()
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
|
|
|
@ -284,7 +284,8 @@ mod bindings {
|
|||
let macro_name = captures.get(1).unwrap().as_str().to_string();
|
||||
let type_name = captures.get(2).unwrap().as_str().to_string();
|
||||
(macro_name, type_name)
|
||||
}).collect()
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn get_borrowed_types() -> Vec<(bool, String)> {
|
||||
|
@ -419,7 +420,8 @@ mod bindings {
|
|||
servo,
|
||||
if generic { "<T>" } else { "" }
|
||||
))
|
||||
}).get_builder();
|
||||
})
|
||||
.get_builder();
|
||||
write_binding_file(builder, STRUCTS_FILE, &fixups);
|
||||
}
|
||||
|
||||
|
@ -467,7 +469,8 @@ mod bindings {
|
|||
filter: env::var("STYLO_BUILD_FILTER")
|
||||
.ok()
|
||||
.unwrap_or_else(|| "bindgen".to_owned()),
|
||||
})).expect("Failed to set logger.");
|
||||
}))
|
||||
.expect("Failed to set logger.");
|
||||
|
||||
true
|
||||
} else {
|
||||
|
@ -486,7 +489,8 @@ mod bindings {
|
|||
.handle_common(&mut fixups)
|
||||
.handle_str_items("whitelist-functions", |b, item| b.whitelist_function(item))
|
||||
.handle_str_items("structs-types", |mut builder, ty| {
|
||||
builder = builder.blacklist_type(ty)
|
||||
builder = builder
|
||||
.blacklist_type(ty)
|
||||
.raw_line(format!("use gecko_bindings::structs::{};", ty));
|
||||
structs_types.insert(ty);
|
||||
// TODO this is hacky, figure out a better way to do it without
|
||||
|
@ -504,10 +508,14 @@ mod bindings {
|
|||
.handle_table_items("array-types", |builder, item| {
|
||||
let cpp_type = item["cpp-type"].as_str().unwrap();
|
||||
let rust_type = item["rust-type"].as_str().unwrap();
|
||||
builder
|
||||
.raw_line(format!(concat!("pub type nsTArrayBorrowed_{}<'a> = ",
|
||||
"&'a mut ::gecko_bindings::structs::nsTArray<{}>;"),
|
||||
cpp_type, rust_type))
|
||||
builder.raw_line(format!(
|
||||
concat!(
|
||||
"pub type nsTArrayBorrowed_{}<'a> = ",
|
||||
"&'a mut ::gecko_bindings::structs::nsTArray<{}>;"
|
||||
),
|
||||
cpp_type,
|
||||
rust_type
|
||||
))
|
||||
})
|
||||
.handle_str_items("servo-immutable-borrow-types", |b, ty| b.borrowed_type(ty))
|
||||
// Right now the only immutable borrow types are ones which we import
|
||||
|
@ -529,7 +537,8 @@ mod bindings {
|
|||
.raw_line(format!(
|
||||
"pub type {0}Strong = ::gecko_bindings::sugar::ownership::Strong<{0}>;",
|
||||
ty
|
||||
)).borrowed_type(ty)
|
||||
))
|
||||
.borrowed_type(ty)
|
||||
.zero_size_type(ty, &structs_types);
|
||||
}
|
||||
for ty in get_boxed_types().iter() {
|
||||
|
@ -538,14 +547,16 @@ mod bindings {
|
|||
.raw_line(format!(
|
||||
"pub type {0}Owned = ::gecko_bindings::sugar::ownership::Owned<{0}>;",
|
||||
ty
|
||||
)).blacklist_type(format!("{}OwnedOrNull", ty))
|
||||
))
|
||||
.blacklist_type(format!("{}OwnedOrNull", ty))
|
||||
.raw_line(format!(
|
||||
concat!(
|
||||
"pub type {0}OwnedOrNull = ",
|
||||
"::gecko_bindings::sugar::ownership::OwnedOrNull<{0}>;"
|
||||
),
|
||||
ty
|
||||
)).mutable_borrowed_type(ty)
|
||||
))
|
||||
.mutable_borrowed_type(ty)
|
||||
.zero_size_type(ty, &structs_types);
|
||||
}
|
||||
write_binding_file(builder, BINDINGS_FILE, &fixups);
|
||||
|
@ -622,7 +633,8 @@ mod bindings {
|
|||
println!("cargo:rerun-if-changed={}", dir.display());
|
||||
copy_dir(&dir, &*OUTDIR_PATH, |path| {
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
}).expect("Fail to copy generated files to out dir");
|
||||
})
|
||||
.expect("Fail to copy generated files to out dir");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -502,7 +502,8 @@ impl Parse for Ranges {
|
|||
}
|
||||
}
|
||||
Ok(opt_start..opt_end)
|
||||
}).map(Ranges)
|
||||
})
|
||||
.map(Ranges)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -631,11 +631,8 @@ impl<'a> CustomPropertiesBuilder<'a> {
|
|||
// environment variable here, perform substitution here instead
|
||||
// of forcing a full traversal in `substitute_all` afterwards.
|
||||
let value = if !has_references && unparsed_value.references_environment {
|
||||
let result = substitute_references_in_value(
|
||||
unparsed_value,
|
||||
&map,
|
||||
&self.environment,
|
||||
);
|
||||
let result =
|
||||
substitute_references_in_value(unparsed_value, &map, &self.environment);
|
||||
match result {
|
||||
Ok(new_value) => Arc::new(new_value),
|
||||
Err(..) => {
|
||||
|
@ -886,11 +883,7 @@ fn substitute_all(custom_properties_map: &mut CustomPropertiesMap, environment:
|
|||
// Now we have shown that this variable is not in a loop, and
|
||||
// all of its dependencies should have been resolved. We can
|
||||
// start substitution now.
|
||||
let result = substitute_references_in_value(
|
||||
&value,
|
||||
&context.map,
|
||||
&context.environment,
|
||||
);
|
||||
let result = substitute_references_in_value(&value, &context.map, &context.environment);
|
||||
|
||||
match result {
|
||||
Ok(computed_value) => {
|
||||
|
|
|
@ -338,7 +338,10 @@ fn local_name_matches<E>(element: E, local_name: &LocalName<E::Impl>) -> bool
|
|||
where
|
||||
E: TElement,
|
||||
{
|
||||
let LocalName { ref name, ref lower_name } = *local_name;
|
||||
let LocalName {
|
||||
ref name,
|
||||
ref lower_name,
|
||||
} = *local_name;
|
||||
if element.is_html_element_in_html_document() {
|
||||
element.local_name() == lower_name.borrow()
|
||||
} else {
|
||||
|
@ -543,23 +546,15 @@ where
|
|||
let case_sensitivity = quirks_mode.classes_and_ids_case_sensitivity();
|
||||
collect_all_elements::<E, Q, _>(root, results, |element| {
|
||||
element.has_class(class, case_sensitivity) &&
|
||||
matching::matches_selector_list(
|
||||
selector_list,
|
||||
&element,
|
||||
matching_context,
|
||||
)
|
||||
matching::matches_selector_list(selector_list, &element, matching_context)
|
||||
});
|
||||
}
|
||||
},
|
||||
SimpleFilter::LocalName(ref local_name) => {
|
||||
collect_all_elements::<E, Q, _>(root, results, |element| {
|
||||
local_name_matches(element, local_name) &&
|
||||
matching::matches_selector_list(
|
||||
selector_list,
|
||||
&element,
|
||||
matching_context,
|
||||
)
|
||||
matching::matches_selector_list(selector_list, &element, matching_context)
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -55,7 +55,10 @@ impl OneOrMoreSeparated for Source {
|
|||
pub enum FontFaceSourceListComponent {
|
||||
Url(*const ::gecko_bindings::structs::mozilla::css::URLValue),
|
||||
Local(*mut ::gecko_bindings::structs::nsAtom),
|
||||
FormatHint { length: usize, utf8_bytes: *const u8 },
|
||||
FormatHint {
|
||||
length: usize,
|
||||
utf8_bytes: *const u8,
|
||||
},
|
||||
}
|
||||
|
||||
/// A `UrlSource` represents a font-face source that has been specified with a
|
||||
|
@ -133,7 +136,7 @@ macro_rules! impl_range {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/// The font-weight descriptor:
|
||||
|
@ -192,10 +195,7 @@ impl FontStretchRange {
|
|||
}
|
||||
}
|
||||
|
||||
let (min, max) = sort_range(
|
||||
compute_stretch(&self.0),
|
||||
compute_stretch(&self.1),
|
||||
);
|
||||
let (min, max) = sort_range(compute_stretch(&self.0), compute_stretch(&self.1));
|
||||
ComputedFontStretchRange(min, max)
|
||||
}
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ impl FontStyle {
|
|||
SpecifiedFontStyle::compute_angle_degrees(second),
|
||||
);
|
||||
ComputedFontStyleDescriptor::Oblique(min, max)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -340,7 +340,8 @@ impl<'a> FontFace<'a> {
|
|||
} else {
|
||||
true
|
||||
}
|
||||
}).cloned()
|
||||
})
|
||||
.cloned()
|
||||
.collect(),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -113,13 +113,15 @@ impl From<nsStyleCoord_CalcValue> for NonNegativeLengthOrPercentageOrAuto {
|
|||
use style_traits::values::specified::AllowedNumericType;
|
||||
use values::generics::NonNegative;
|
||||
NonNegative(if other.mLength < 0 || other.mPercent < 0. {
|
||||
LengthOrPercentageOrAuto::Calc(
|
||||
CalcLengthOrPercentage::with_clamping_mode(
|
||||
Au(other.mLength).into(),
|
||||
if other.mHasPercent { Some(Percentage(other.mPercent)) } else { None },
|
||||
AllowedNumericType::NonNegative,
|
||||
)
|
||||
)
|
||||
LengthOrPercentageOrAuto::Calc(CalcLengthOrPercentage::with_clamping_mode(
|
||||
Au(other.mLength).into(),
|
||||
if other.mHasPercent {
|
||||
Some(Percentage(other.mPercent))
|
||||
} else {
|
||||
None
|
||||
},
|
||||
AllowedNumericType::NonNegative,
|
||||
))
|
||||
} else {
|
||||
other.into()
|
||||
})
|
||||
|
@ -625,7 +627,8 @@ impl nsStyleImage {
|
|||
position: LengthOrPercentage::from_gecko_style_coord(&stop.mLocation),
|
||||
})
|
||||
}
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
|
||||
let compat_mode = if gecko_gradient.mMozLegacySyntax {
|
||||
CompatMode::Moz
|
||||
|
@ -718,7 +721,8 @@ pub mod basic_shape {
|
|||
match other.mType {
|
||||
StyleShapeSourceType::URL => unsafe {
|
||||
let shape_image = &*other.__bindgen_anon_1.mShapeImage.as_ref().mPtr;
|
||||
let other_url = RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _);
|
||||
let other_url =
|
||||
RefPtr::new(*shape_image.__bindgen_anon_1.mURLValue.as_ref() as *mut _);
|
||||
let url = ComputedUrl::from_url_value(other_url);
|
||||
ShapeSource::ImageOrUrl(url)
|
||||
},
|
||||
|
|
|
@ -305,15 +305,15 @@ bitflags! {
|
|||
}
|
||||
|
||||
fn primary_pointer_capabilities(device: &Device) -> PointerCapabilities {
|
||||
PointerCapabilities::from_bits_truncate(
|
||||
unsafe { bindings::Gecko_MediaFeatures_PrimaryPointerCapabilities(device.document()) }
|
||||
)
|
||||
PointerCapabilities::from_bits_truncate(unsafe {
|
||||
bindings::Gecko_MediaFeatures_PrimaryPointerCapabilities(device.document())
|
||||
})
|
||||
}
|
||||
|
||||
fn all_pointer_capabilities(device: &Device) -> PointerCapabilities {
|
||||
PointerCapabilities::from_bits_truncate(
|
||||
unsafe { bindings::Gecko_MediaFeatures_AllPointerCapabilities(device.document()) }
|
||||
)
|
||||
PointerCapabilities::from_bits_truncate(unsafe {
|
||||
bindings::Gecko_MediaFeatures_AllPointerCapabilities(device.document())
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, FromPrimitive, Parse, ToCss)]
|
||||
|
|
|
@ -3,29 +3,29 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/*
|
||||
* This file contains a helper macro includes all supported non-tree-structural
|
||||
* pseudo-classes.
|
||||
*
|
||||
* This file contains a helper macro includes all supported non-tree-structural
|
||||
* pseudo-classes.
|
||||
*
|
||||
|
||||
* FIXME: Find a way to autogenerate this file.
|
||||
*
|
||||
* Expected usage is as follows:
|
||||
* ```
|
||||
* macro_rules! pseudo_class_macro{
|
||||
* ([$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*]) => {
|
||||
* // do stuff
|
||||
* }
|
||||
* }
|
||||
* apply_non_ts_list!(pseudo_class_macro)
|
||||
* ```
|
||||
*
|
||||
* $gecko_type can be either "_" or an ident in Gecko's CSSPseudoClassType.
|
||||
* $state can be either "_" or an expression of type ElementState. If present,
|
||||
* the semantics are that the pseudo-class matches if any of the bits in
|
||||
* $state are set on the element.
|
||||
* $flags can be either "_" or an expression of type NonTSPseudoClassFlag,
|
||||
* see selector_parser.rs for more details.
|
||||
*/
|
||||
* FIXME: Find a way to autogenerate this file.
|
||||
*
|
||||
* Expected usage is as follows:
|
||||
* ```
|
||||
* macro_rules! pseudo_class_macro{
|
||||
* ([$(($css:expr, $name:ident, $gecko_type:tt, $state:tt, $flags:tt),)*]) => {
|
||||
* // do stuff
|
||||
* }
|
||||
* }
|
||||
* apply_non_ts_list!(pseudo_class_macro)
|
||||
* ```
|
||||
*
|
||||
* $gecko_type can be either "_" or an ident in Gecko's CSSPseudoClassType.
|
||||
* $state can be either "_" or an expression of type ElementState. If present,
|
||||
* the semantics are that the pseudo-class matches if any of the bits in
|
||||
* $state are set on the element.
|
||||
* $flags can be either "_" or an expression of type NonTSPseudoClassFlag,
|
||||
* see selector_parser.rs for more details.
|
||||
*/
|
||||
|
||||
macro_rules! apply_non_ts_list {
|
||||
($apply_macro:ident) => {
|
||||
|
|
|
@ -123,10 +123,7 @@ impl SpecifiedUrl {
|
|||
|
||||
fn from_css_url_with_cors(url: CssUrl, cors: CORSMode) -> Self {
|
||||
let url_value = unsafe {
|
||||
let ptr = bindings::Gecko_URLValue_Create(
|
||||
url.0.clone().into_strong(),
|
||||
cors,
|
||||
);
|
||||
let ptr = bindings::Gecko_URLValue_Create(url.0.clone().into_strong(), cors);
|
||||
// We do not expect Gecko_URLValue_Create returns null.
|
||||
debug_assert!(!ptr.is_null());
|
||||
RefPtr::from_addrefed(ptr)
|
||||
|
@ -261,11 +258,7 @@ impl ToCss for ComputedUrl {
|
|||
where
|
||||
W: Write,
|
||||
{
|
||||
serialize_computed_url(
|
||||
&self.0.url_value,
|
||||
dest,
|
||||
bindings::Gecko_GetComputedURLSpec,
|
||||
)
|
||||
serialize_computed_url(&self.0.url_value, dest, bindings::Gecko_GetComputedURLSpec)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -537,7 +537,8 @@ impl CounterStyleOrNone {
|
|||
.map(|symbol| match *symbol {
|
||||
Symbol::String(ref s) => nsCStr::from(s),
|
||||
Symbol::Ident(_) => unreachable!("Should not have identifier in symbols()"),
|
||||
}).collect();
|
||||
})
|
||||
.collect();
|
||||
let symbols: Vec<_> = symbols
|
||||
.iter()
|
||||
.map(|symbol| symbol as &nsACString as *const _)
|
||||
|
|
|
@ -937,7 +937,8 @@ impl<'le> GeckoElement<'le> {
|
|||
.animate(
|
||||
to.as_ref().unwrap(),
|
||||
Procedure::Interpolate { progress: 0.5 },
|
||||
).is_ok()
|
||||
)
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1278,7 +1279,8 @@ impl<'le> TElement for GeckoElement<'le> {
|
|||
Some(
|
||||
Locked::<PropertyDeclarationBlock>::as_arc(
|
||||
&*(&raw as *const &structs::RawServoDeclarationBlock),
|
||||
).borrow_arc(),
|
||||
)
|
||||
.borrow_arc(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -234,9 +234,13 @@ impl nsCSSValue {
|
|||
}
|
||||
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_List);
|
||||
let list: &mut structs::nsCSSValueList = &mut unsafe {
|
||||
self.mValue.mList.as_ref() // &*nsCSSValueList_heap
|
||||
.as_mut().expect("List pointer should be non-null")
|
||||
}._base;
|
||||
self.mValue
|
||||
.mList
|
||||
.as_ref() // &*nsCSSValueList_heap
|
||||
.as_mut()
|
||||
.expect("List pointer should be non-null")
|
||||
}
|
||||
._base;
|
||||
for (item, new_value) in list.into_iter().zip(values) {
|
||||
*item = new_value;
|
||||
}
|
||||
|
@ -255,9 +259,13 @@ impl nsCSSValue {
|
|||
}
|
||||
debug_assert_eq!(self.mUnit, nsCSSUnit::eCSSUnit_PairList);
|
||||
let mut item_ptr = &mut unsafe {
|
||||
self.mValue.mPairList.as_ref() // &*nsCSSValuePairList_heap
|
||||
.as_mut().expect("List pointer should be non-null")
|
||||
}._base as *mut structs::nsCSSValuePairList;
|
||||
self.mValue
|
||||
.mPairList
|
||||
.as_ref() // &*nsCSSValuePairList_heap
|
||||
.as_mut()
|
||||
.expect("List pointer should be non-null")
|
||||
}
|
||||
._base as *mut structs::nsCSSValuePairList;
|
||||
while let Some(item) = unsafe { item_ptr.as_mut() } {
|
||||
let value = values.next().expect("Values shouldn't have been exhausted");
|
||||
item.mXValue = value.0;
|
||||
|
|
|
@ -117,7 +117,9 @@ impl<T> nsTArray<T> {
|
|||
I: ExactSizeIterator + Iterator<Item = T>,
|
||||
{
|
||||
debug_assert!(iter.len() <= 0xFFFFFFFF);
|
||||
unsafe { self.set_len_pod(iter.len() as u32); }
|
||||
unsafe {
|
||||
self.set_len_pod(iter.len() as u32);
|
||||
}
|
||||
self.iter_mut().zip(iter).for_each(|(r, v)| *r = v);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,7 +84,8 @@ pub extern crate servo_arc;
|
|||
#[cfg(feature = "servo")]
|
||||
#[macro_use]
|
||||
extern crate servo_atoms;
|
||||
#[cfg(feature = "servo")] extern crate servo_channel;
|
||||
#[cfg(feature = "servo")]
|
||||
extern crate servo_channel;
|
||||
#[cfg(feature = "servo")]
|
||||
extern crate servo_config;
|
||||
#[cfg(feature = "servo")]
|
||||
|
|
|
@ -224,7 +224,8 @@ trait PrivateMatchMethods: TElement {
|
|||
context,
|
||||
RuleInclusion::All,
|
||||
PseudoElementResolution::IfApplicable,
|
||||
).cascade_style_and_visited_with_default_parents(inputs);
|
||||
)
|
||||
.cascade_style_and_visited_with_default_parents(inputs);
|
||||
|
||||
Some(style.0)
|
||||
}
|
||||
|
@ -618,14 +619,12 @@ trait PrivateMatchMethods: TElement {
|
|||
|
||||
match *running_animation {
|
||||
Animation::Transition(..) => unreachable!(),
|
||||
Animation::Keyframes(_, _, _, ref mut state) => {
|
||||
match update {
|
||||
AnimationUpdate::Regular => {},
|
||||
AnimationUpdate::AnimationCanceled => {
|
||||
state.expired = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Animation::Keyframes(_, _, _, ref mut state) => match update {
|
||||
AnimationUpdate::Regular => {},
|
||||
AnimationUpdate::AnimationCanceled => {
|
||||
state.expired = true;
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,7 +130,8 @@ impl MediaQuery {
|
|||
let ident = input.expect_ident().map_err(|_| ())?;
|
||||
let media_type = MediaQueryType::parse(&ident)?;
|
||||
Ok((qualifier, Some(media_type)))
|
||||
}).unwrap_or_default();
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let condition = if explicit_media_type.is_none() {
|
||||
Some(MediaCondition::parse(context, input)?)
|
||||
|
|
|
@ -526,7 +526,8 @@ impl RuleTree {
|
|||
path,
|
||||
guards,
|
||||
&mut dummy,
|
||||
).expect("Should return a valid rule node")
|
||||
)
|
||||
.expect("Should return a valid rule node")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,9 +120,8 @@ unsafe impl Sync for OpaqueComputedValues {}
|
|||
|
||||
impl OpaqueComputedValues {
|
||||
fn from(cv: &ComputedValues) -> Self {
|
||||
let p = unsafe {
|
||||
NonNull::new_unchecked(cv as *const ComputedValues as *const () as *mut ())
|
||||
};
|
||||
let p =
|
||||
unsafe { NonNull::new_unchecked(cv as *const ComputedValues as *const () as *mut ()) };
|
||||
OpaqueComputedValues(p)
|
||||
}
|
||||
|
||||
|
@ -204,7 +203,8 @@ impl ValidationData {
|
|||
let values =
|
||||
OpaqueComputedValues::from(parent.borrow_data().unwrap().styles.primary());
|
||||
values
|
||||
}).clone()
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Computes the revalidation results if needed, and returns it.
|
||||
|
|
|
@ -713,12 +713,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
if self.style.pseudo.is_some() {
|
||||
return;
|
||||
}
|
||||
let is_html_select_element =
|
||||
element.map_or(false, |e| e.is_html_element() && e.local_name() == &*local_name!("select"));
|
||||
let is_html_select_element = element.map_or(false, |e| {
|
||||
e.is_html_element() && e.local_name() == &*local_name!("select")
|
||||
});
|
||||
if !is_html_select_element {
|
||||
return;
|
||||
}
|
||||
self.style.mutate_inherited_text().set_line_height(LineHeight::normal());
|
||||
self.style
|
||||
.mutate_inherited_text()
|
||||
.set_line_height(LineHeight::normal());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -120,7 +120,8 @@ macro_rules! parse_quoted_or_unquoted_string {
|
|||
.parse_entirely(|input| {
|
||||
let string = input.expect_string()?;
|
||||
Ok($url_matching_function(string.as_ref().to_owned()))
|
||||
}).or_else(|_: ParseError| {
|
||||
})
|
||||
.or_else(|_: ParseError| {
|
||||
while let Ok(_) = input.next() {}
|
||||
Ok($url_matching_function(input.slice_from(start).to_string()))
|
||||
})
|
||||
|
|
|
@ -89,7 +89,8 @@ impl DeepCloneWithLock for KeyframesRule {
|
|||
Arc::new(
|
||||
lock.wrap(x.read_with(guard).deep_clone_with_lock(lock, guard, params)),
|
||||
)
|
||||
}).collect(),
|
||||
})
|
||||
.collect(),
|
||||
vendor_prefix: self.vendor_prefix.clone(),
|
||||
source_location: self.source_location.clone(),
|
||||
}
|
||||
|
@ -327,7 +328,8 @@ impl KeyframesStep {
|
|||
let (declaration, _) = guard
|
||||
.get(PropertyDeclarationId::Longhand(
|
||||
LonghandId::AnimationTimingFunction,
|
||||
)).unwrap();
|
||||
))
|
||||
.unwrap();
|
||||
match *declaration {
|
||||
PropertyDeclaration::AnimationTimingFunction(ref value) => {
|
||||
// Use the first value.
|
||||
|
@ -499,7 +501,8 @@ pub fn parse_keyframe_list(
|
|||
shared_lock: shared_lock,
|
||||
declarations: &mut declarations,
|
||||
},
|
||||
).filter_map(Result::ok)
|
||||
)
|
||||
.filter_map(Result::ok)
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,8 @@ impl fmt::Debug for UrlExtraData {
|
|||
.field(
|
||||
"referrer",
|
||||
&DebugURI(self.0.mReferrer.raw::<structs::nsIURI>()),
|
||||
).finish()
|
||||
)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,9 +172,7 @@ impl SupportsCondition {
|
|||
}
|
||||
|
||||
/// <https://drafts.csswg.org/css-conditional-3/#supports_condition_in_parens>
|
||||
fn parse_in_parens<'i, 't>(
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
fn parse_in_parens<'i, 't>(input: &mut Parser<'i, 't>) -> Result<Self, ParseError<'i>> {
|
||||
// Whitespace is normally taken care of in `Parser::next`,
|
||||
// but we want to not include it in `pos` for the SupportsCondition::FutureSyntax cases.
|
||||
while input.try(Parser::expect_whitespace).is_ok() {}
|
||||
|
@ -183,9 +181,8 @@ impl SupportsCondition {
|
|||
// FIXME: remove clone() when lifetimes are non-lexical
|
||||
match input.next()?.clone() {
|
||||
Token::ParenthesisBlock => {
|
||||
let nested = input.try(|input| {
|
||||
input.parse_nested_block(parse_condition_or_declaration)
|
||||
});
|
||||
let nested =
|
||||
input.try(|input| input.parse_nested_block(parse_condition_or_declaration));
|
||||
if nested.is_ok() {
|
||||
return nested;
|
||||
}
|
||||
|
@ -209,11 +206,7 @@ impl SupportsCondition {
|
|||
}
|
||||
|
||||
/// Evaluate a supports condition
|
||||
pub fn eval(
|
||||
&self,
|
||||
cx: &ParserContext,
|
||||
namespaces: &Namespaces,
|
||||
) -> bool {
|
||||
pub fn eval(&self, cx: &ParserContext, namespaces: &Namespaces) -> bool {
|
||||
match *self {
|
||||
SupportsCondition::Not(ref cond) => !cond.eval(cx, namespaces),
|
||||
SupportsCondition::Parenthesized(ref cond) => cond.eval(cx, namespaces),
|
||||
|
@ -300,7 +293,7 @@ impl ToCss for SupportsCondition {
|
|||
dest.write_str("selector(")?;
|
||||
selector.to_css(dest)?;
|
||||
dest.write_str(")")
|
||||
}
|
||||
},
|
||||
SupportsCondition::MozBoolPref(ref name) => {
|
||||
dest.write_str("-moz-bool-pref(")?;
|
||||
let name =
|
||||
|
@ -328,51 +321,51 @@ impl ToCss for RawSelector {
|
|||
|
||||
impl RawSelector {
|
||||
/// Tries to evaluate a `selector()` function.
|
||||
pub fn eval(
|
||||
&self,
|
||||
context: &ParserContext,
|
||||
namespaces: &Namespaces,
|
||||
) -> bool {
|
||||
pub fn eval(&self, context: &ParserContext, namespaces: &Namespaces) -> bool {
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
if unsafe { !::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled } {
|
||||
if unsafe {
|
||||
!::gecko_bindings::structs::StaticPrefs_sVarCache_layout_css_supports_selector_enabled
|
||||
} {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
let mut input = ParserInput::new(&self.0);
|
||||
let mut input = Parser::new(&mut input);
|
||||
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let parser = SelectorParser {
|
||||
namespaces,
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
url_data: Some(context.url_data),
|
||||
};
|
||||
input
|
||||
.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let parser = SelectorParser {
|
||||
namespaces,
|
||||
stylesheet_origin: context.stylesheet_origin,
|
||||
url_data: Some(context.url_data),
|
||||
};
|
||||
|
||||
#[allow(unused_variables)]
|
||||
let selector = Selector::<SelectorImpl>::parse(&parser, input)
|
||||
.map_err(|_| input.new_custom_error(()))?;
|
||||
#[allow(unused_variables)]
|
||||
let selector = Selector::<SelectorImpl>::parse(&parser, input)
|
||||
.map_err(|_| input.new_custom_error(()))?;
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::Component;
|
||||
#[cfg(feature = "gecko")]
|
||||
{
|
||||
use selector_parser::PseudoElement;
|
||||
use selectors::parser::Component;
|
||||
|
||||
let has_any_unknown_webkit_pseudo =
|
||||
selector.has_pseudo_element() &&
|
||||
selector.iter_raw_match_order().any(|component| {
|
||||
matches!(
|
||||
*component,
|
||||
Component::PseudoElement(PseudoElement::UnknownWebkit(..))
|
||||
)
|
||||
});
|
||||
if has_any_unknown_webkit_pseudo {
|
||||
return Err(input.new_custom_error(()));
|
||||
let has_any_unknown_webkit_pseudo = selector.has_pseudo_element() && selector
|
||||
.iter_raw_match_order()
|
||||
.any(|component| {
|
||||
matches!(
|
||||
*component,
|
||||
Component::PseudoElement(PseudoElement::UnknownWebkit(..))
|
||||
)
|
||||
});
|
||||
if has_any_unknown_webkit_pseudo {
|
||||
return Err(input.new_custom_error(()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}).is_ok()
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,20 +405,22 @@ impl Declaration {
|
|||
|
||||
let mut input = ParserInput::new(&self.0);
|
||||
let mut input = Parser::new(&mut input);
|
||||
input.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let prop = input.expect_ident_cloned().unwrap();
|
||||
input.expect_colon().unwrap();
|
||||
input
|
||||
.parse_entirely(|input| -> Result<(), CssParseError<()>> {
|
||||
let prop = input.expect_ident_cloned().unwrap();
|
||||
input.expect_colon().unwrap();
|
||||
|
||||
let id =
|
||||
PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?;
|
||||
let id =
|
||||
PropertyId::parse(&prop, context).map_err(|_| input.new_custom_error(()))?;
|
||||
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
|
||||
.map_err(|_| input.new_custom_error(()))
|
||||
})?;
|
||||
let _ = input.try(parse_important);
|
||||
Ok(())
|
||||
}).is_ok()
|
||||
let mut declarations = SourcePropertyDeclaration::new();
|
||||
input.parse_until_before(Delimiter::Bang, |input| {
|
||||
PropertyDeclaration::parse_into(&mut declarations, id, &context, input)
|
||||
.map_err(|_| input.new_custom_error(()))
|
||||
})?;
|
||||
let _ = input.try(parse_important);
|
||||
Ok(())
|
||||
})
|
||||
.is_ok()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -517,7 +517,8 @@ impl Stylist {
|
|||
self.stylesheets.iter(),
|
||||
guards,
|
||||
&self.device,
|
||||
).finish(),
|
||||
)
|
||||
.finish(),
|
||||
};
|
||||
|
||||
self.viewport_constraints =
|
||||
|
@ -1017,7 +1018,8 @@ impl Stylist {
|
|||
stylesheets.clone(),
|
||||
guards,
|
||||
&device,
|
||||
).finish(),
|
||||
)
|
||||
.finish(),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1535,7 +1537,6 @@ impl Stylist {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
results
|
||||
}
|
||||
|
||||
|
|
|
@ -361,7 +361,8 @@ where
|
|||
context,
|
||||
rule_inclusion,
|
||||
PseudoElementResolution::IfApplicable,
|
||||
).resolve_primary_style(
|
||||
)
|
||||
.resolve_primary_style(
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &**s),
|
||||
);
|
||||
|
@ -382,10 +383,12 @@ where
|
|||
context,
|
||||
rule_inclusion,
|
||||
PseudoElementResolution::Force,
|
||||
).resolve_style(
|
||||
)
|
||||
.resolve_style(
|
||||
style.as_ref().map(|s| &**s),
|
||||
layout_parent_style.as_ref().map(|s| &**s),
|
||||
).into()
|
||||
)
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Calculates the style for a single node.
|
||||
|
|
|
@ -143,7 +143,9 @@ impl<'a> FontSettingTagIter<'a> {
|
|||
impl<'a> Iterator for FontSettingTagIter<'a> {
|
||||
type Item = Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>;
|
||||
|
||||
fn next(&mut self) -> Option<Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>> {
|
||||
fn next(
|
||||
&mut self,
|
||||
) -> Option<Result<(&'a ComputedVariationValue, &'a ComputedVariationValue), ()>> {
|
||||
match (
|
||||
FontSettingTagIter::next_tag(&mut self.a_state),
|
||||
FontSettingTagIter::next_tag(&mut self.b_state),
|
||||
|
|
|
@ -23,9 +23,15 @@ impl Animate for CalcLengthOrPercentage {
|
|||
Ok(Some(this.animate(&other, procedure)?))
|
||||
};
|
||||
|
||||
let length = self.unclamped_length().animate(&other.unclamped_length(), procedure)?;
|
||||
let length = self
|
||||
.unclamped_length()
|
||||
.animate(&other.unclamped_length(), procedure)?;
|
||||
let percentage = animate_percentage_half(self.percentage, other.percentage)?;
|
||||
Ok(CalcLengthOrPercentage::with_clamping_mode(length, percentage, self.clamping_mode))
|
||||
Ok(CalcLengthOrPercentage::with_clamping_mode(
|
||||
length,
|
||||
percentage,
|
||||
self.clamping_mode,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,16 +38,16 @@ enum PropertyCategory {
|
|||
impl PropertyCategory {
|
||||
fn of(id: &PropertyId) -> Self {
|
||||
match *id {
|
||||
PropertyId::Shorthand(..) |
|
||||
PropertyId::ShorthandAlias(..) => PropertyCategory::Shorthand,
|
||||
PropertyId::Longhand(id) |
|
||||
PropertyId::LonghandAlias(id, ..) => {
|
||||
PropertyId::Shorthand(..) | PropertyId::ShorthandAlias(..) => {
|
||||
PropertyCategory::Shorthand
|
||||
},
|
||||
PropertyId::Longhand(id) | PropertyId::LonghandAlias(id, ..) => {
|
||||
if id.is_logical() {
|
||||
PropertyCategory::LogicalLonghand
|
||||
} else {
|
||||
PropertyCategory::PhysicalLonghand
|
||||
}
|
||||
}
|
||||
},
|
||||
PropertyId::Custom(..) => PropertyCategory::Custom,
|
||||
}
|
||||
}
|
||||
|
@ -81,9 +81,9 @@ pub fn compare_property_priority(a: &PropertyId, b: &PropertyId) -> cmp::Orderin
|
|||
// name.
|
||||
let subprop_count_a = a.longhands().count();
|
||||
let subprop_count_b = b.longhands().count();
|
||||
subprop_count_a.cmp(&subprop_count_b).then_with(|| {
|
||||
a.idl_name_sort_order().cmp(&b.idl_name_sort_order())
|
||||
})
|
||||
subprop_count_a
|
||||
.cmp(&subprop_count_b)
|
||||
.then_with(|| a.idl_name_sort_order().cmp(&b.idl_name_sort_order()))
|
||||
}
|
||||
|
||||
/// Animate from one value to another.
|
||||
|
|
|
@ -32,13 +32,11 @@ fn to_number_or_percentage(
|
|||
value: &SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number>,
|
||||
) -> Result<NumberOrPercentage, ()> {
|
||||
Ok(match *value {
|
||||
SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => {
|
||||
match *l {
|
||||
LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()),
|
||||
LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p),
|
||||
LengthOrPercentage::Calc(..) => return Err(()),
|
||||
}
|
||||
}
|
||||
SvgLengthOrPercentageOrNumber::LengthOrPercentage(ref l) => match *l {
|
||||
LengthOrPercentage::Length(ref l) => NumberOrPercentage::Number(l.px()),
|
||||
LengthOrPercentage::Percentage(ref p) => NumberOrPercentage::Percentage(*p),
|
||||
LengthOrPercentage::Calc(..) => return Err(()),
|
||||
},
|
||||
SvgLengthOrPercentageOrNumber::Number(ref n) => NumberOrPercentage::Number(*n),
|
||||
})
|
||||
}
|
||||
|
@ -50,22 +48,15 @@ impl Animate for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
|||
let other = to_number_or_percentage(other)?;
|
||||
|
||||
match (this, other) {
|
||||
(
|
||||
NumberOrPercentage::Number(ref this),
|
||||
NumberOrPercentage::Number(ref other),
|
||||
) => {
|
||||
Ok(SvgLengthOrPercentageOrNumber::Number(
|
||||
this.animate(other, procedure)?
|
||||
))
|
||||
},
|
||||
(NumberOrPercentage::Number(ref this), NumberOrPercentage::Number(ref other)) => Ok(
|
||||
SvgLengthOrPercentageOrNumber::Number(this.animate(other, procedure)?),
|
||||
),
|
||||
(
|
||||
NumberOrPercentage::Percentage(ref this),
|
||||
NumberOrPercentage::Percentage(ref other),
|
||||
) => {
|
||||
Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Percentage(this.animate(other, procedure)?)
|
||||
))
|
||||
},
|
||||
) => Ok(SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::Percentage(this.animate(other, procedure)?),
|
||||
)),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -73,8 +64,7 @@ impl Animate for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
|||
|
||||
impl ComputeSquaredDistance for SvgLengthOrPercentageOrNumber<LengthOrPercentage, Number> {
|
||||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
to_number_or_percentage(self)?
|
||||
.compute_squared_distance(&to_number_or_percentage(other)?)
|
||||
to_number_or_percentage(self)?.compute_squared_distance(&to_number_or_percentage(other)?)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,9 +95,9 @@ where
|
|||
return Err(());
|
||||
}
|
||||
match (self, other) {
|
||||
(&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => {
|
||||
Ok(SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?))
|
||||
},
|
||||
(&SVGStrokeDashArray::Values(ref this), &SVGStrokeDashArray::Values(ref other)) => Ok(
|
||||
SVGStrokeDashArray::Values(this.animate_repeatable_list(other, procedure)?),
|
||||
),
|
||||
_ => Err(()),
|
||||
}
|
||||
}
|
||||
|
@ -135,11 +125,12 @@ where
|
|||
#[inline]
|
||||
fn to_animated_zero(&self) -> Result<Self, ()> {
|
||||
match *self {
|
||||
SVGStrokeDashArray::Values(ref values) => {
|
||||
Ok(SVGStrokeDashArray::Values(
|
||||
values.iter().map(ToAnimatedZero::to_animated_zero).collect::<Result<Vec<_>, _>>()?,
|
||||
))
|
||||
}
|
||||
SVGStrokeDashArray::Values(ref values) => Ok(SVGStrokeDashArray::Values(
|
||||
values
|
||||
.iter()
|
||||
.map(ToAnimatedZero::to_animated_zero)
|
||||
.collect::<Result<Vec<_>, _>>()?,
|
||||
)),
|
||||
SVGStrokeDashArray::ContextValue => Ok(SVGStrokeDashArray::ContextValue),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,6 +92,7 @@ impl ComputeSquaredDistance for Angle {
|
|||
fn compute_squared_distance(&self, other: &Self) -> Result<SquaredDistance, ()> {
|
||||
// Use the formula for calculating the distance between angles defined in SVG:
|
||||
// https://www.w3.org/TR/SVG/animate.html#complexDistances
|
||||
self.radians64().compute_squared_distance(&other.radians64())
|
||||
self.radians64()
|
||||
.compute_squared_distance(&other.radians64())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,12 +207,12 @@ impl ToCss for CalcLengthOrPercentage {
|
|||
if length.px() == 0. && self.clamping_mode.clamp(p.0) == p.0 {
|
||||
return p.to_css(dest);
|
||||
}
|
||||
}
|
||||
},
|
||||
None => {
|
||||
if self.clamping_mode.clamp(length.px()) == length.px() {
|
||||
return length.to_css(dest);
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
dest.write_str("calc(")?;
|
||||
|
@ -950,8 +950,18 @@ pub type NonNegativeLengthOrPercentageOrNormal = Either<NonNegativeLengthOrPerce
|
|||
/// block-size, and inline-size.
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Parse, PartialEq, SpecifiedValueInfo,
|
||||
ToComputedValue, ToCss)]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum ExtremumLength {
|
||||
MozMaxContent,
|
||||
MozMinContent,
|
||||
|
|
|
@ -24,7 +24,8 @@ impl Quotes {
|
|||
"\u{2018}".to_owned().into_boxed_str(),
|
||||
"\u{2019}".to_owned().into_boxed_str(),
|
||||
),
|
||||
].into_boxed_slice(),
|
||||
]
|
||||
.into_boxed_slice(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ impl SVGLength {
|
|||
/// `0px`
|
||||
pub fn zero() -> Self {
|
||||
generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
LengthOrPercentage::zero()
|
||||
LengthOrPercentage::zero(),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ impl SVGWidth {
|
|||
pub fn one() -> Self {
|
||||
use values::generics::NonNegative;
|
||||
generic::SVGLength::Length(generic::SvgLengthOrPercentageOrNumber::LengthOrPercentage(
|
||||
NonNegative(LengthOrPercentage::one())
|
||||
NonNegative(LengthOrPercentage::one()),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -307,7 +307,8 @@ where
|
|||
this.0.animate(&other.0, procedure)?,
|
||||
this.1.animate(&other.1, procedure)?,
|
||||
))
|
||||
}).collect::<Result<Vec<_>, _>>()?;
|
||||
})
|
||||
.collect::<Result<Vec<_>, _>>()?;
|
||||
Ok(Polygon {
|
||||
fill: self.fill,
|
||||
coordinates,
|
||||
|
@ -333,7 +334,8 @@ where
|
|||
let d1 = this.0.compute_squared_distance(&other.0)?;
|
||||
let d2 = this.1.compute_squared_distance(&other.1)?;
|
||||
Ok(d1 + d2)
|
||||
}).sum()
|
||||
})
|
||||
.sum()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,9 @@ use parser::ParserContext;
|
|||
use values::CSSFloat;
|
||||
|
||||
/// A generic easing function.
|
||||
#[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss)]
|
||||
#[derive(
|
||||
Clone, Copy, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToComputedValue, ToCss,
|
||||
)]
|
||||
#[value_info(ty = "TIMING_FUNCTION")]
|
||||
#[repr(u8, C)]
|
||||
pub enum TimingFunction<Integer, Number> {
|
||||
|
|
|
@ -45,7 +45,7 @@ pub enum MozLength<LengthOrPercentageOrAuto> {
|
|||
SpecifiedValueInfo,
|
||||
ToAnimatedZero,
|
||||
ToComputedValue,
|
||||
ToCss
|
||||
ToCss,
|
||||
)]
|
||||
pub enum MaxLength<LengthOrPercentageOrNone> {
|
||||
LengthOrPercentageOrNone(LengthOrPercentageOrNone),
|
||||
|
|
|
@ -71,8 +71,20 @@ impl<ImageUrl: ToCss, Number: ToCss> ToCss for CursorImage<ImageUrl, Number> {
|
|||
/// A generic value for `scrollbar-color` property.
|
||||
///
|
||||
/// https://drafts.csswg.org/css-scrollbars-1/#scrollbar-color
|
||||
#[derive(Animate, Clone, ComputeSquaredDistance, Copy, Debug, MallocSizeOf, PartialEq,
|
||||
SpecifiedValueInfo, ToAnimatedValue, ToAnimatedZero, ToComputedValue, ToCss)]
|
||||
#[derive(
|
||||
Animate,
|
||||
Clone,
|
||||
ComputeSquaredDistance,
|
||||
Copy,
|
||||
Debug,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToAnimatedValue,
|
||||
ToAnimatedZero,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
)]
|
||||
pub enum ScrollbarColor<Color> {
|
||||
/// `auto`
|
||||
Auto,
|
||||
|
@ -82,7 +94,7 @@ pub enum ScrollbarColor<Color> {
|
|||
thumb: Color,
|
||||
/// Second `<color>`, for color of the scrollbar track.
|
||||
track: Color,
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
impl<Color> Default for ScrollbarColor<Color> {
|
||||
|
|
|
@ -152,11 +152,7 @@ impl Parse for Angle {
|
|||
|
||||
impl Angle {
|
||||
/// Parse an `<angle>` value given a value and an unit.
|
||||
pub fn parse_dimension(
|
||||
value: CSSFloat,
|
||||
unit: &str,
|
||||
was_calc: bool,
|
||||
) -> Result<Angle, ()> {
|
||||
pub fn parse_dimension(value: CSSFloat, unit: &str, was_calc: bool) -> Result<Angle, ()> {
|
||||
let value = match_ignore_ascii_case! { unit,
|
||||
"deg" => AngleDimension::Deg(value),
|
||||
"grad" => AngleDimension::Grad(value),
|
||||
|
@ -200,7 +196,8 @@ impl Angle {
|
|||
return input.parse_nested_block(|i| CalcNode::parse_angle(context, i))
|
||||
},
|
||||
_ => Err(()),
|
||||
}.map_err(|()| input.new_unexpected_token_error(token.clone()))
|
||||
}
|
||||
.map_err(|()| input.new_unexpected_token_error(token.clone()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,8 @@ impl Ellipse {
|
|||
ShapeRadius::parse(context, i)?,
|
||||
ShapeRadius::parse(context, i)?,
|
||||
))
|
||||
}).unwrap_or_default();
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let position = if input.try(|i| i.expect_ident_matching("at")).is_ok() {
|
||||
Position::parse(context, input)?
|
||||
} else {
|
||||
|
@ -422,7 +423,8 @@ impl Polygon {
|
|||
let fill = FillRule::parse(i)?;
|
||||
i.expect_comma()?; // only eat the comma if there is something before it
|
||||
Ok(fill)
|
||||
}).unwrap_or_default();
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
let buf = input.parse_comma_separated(|i| {
|
||||
Ok(PolygonCoord(
|
||||
|
@ -459,7 +461,8 @@ impl Path {
|
|||
let fill = FillRule::parse(i)?;
|
||||
i.expect_comma()?;
|
||||
Ok(fill)
|
||||
}).unwrap_or_default();
|
||||
})
|
||||
.unwrap_or_default();
|
||||
let path = SVGPathData::parse(context, input)?;
|
||||
Ok(Path { fill, path })
|
||||
}
|
||||
|
|
|
@ -92,7 +92,8 @@ impl ToComputedValue for BorderSideWidth {
|
|||
BorderSideWidth::Medium => Length::from_px(3.).to_computed_value(context),
|
||||
BorderSideWidth::Thick => Length::from_px(5.).to_computed_value(context),
|
||||
BorderSideWidth::Length(ref length) => length.to_computed_value(context),
|
||||
}.into()
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -182,7 +183,8 @@ impl Parse for BorderSpacing {
|
|||
) -> Result<Self, ParseError<'i>> {
|
||||
Size::parse_with(context, input, |context, input| {
|
||||
Length::parse_non_negative_quirky(context, input, AllowQuirks::Yes).map(From::from)
|
||||
}).map(GenericBorderSpacing)
|
||||
})
|
||||
.map(GenericBorderSpacing)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -529,8 +529,7 @@ impl CalcNode {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<CSSInteger, ParseError<'i>> {
|
||||
Self::parse_number(context, input)
|
||||
.map(|n| n.round() as CSSInteger)
|
||||
Self::parse_number(context, input).map(|n| n.round() as CSSInteger)
|
||||
}
|
||||
|
||||
/// Convenience parsing function for `<length> | <percentage>`.
|
||||
|
|
|
@ -93,7 +93,8 @@ impl Content {
|
|||
.try(|input| {
|
||||
input.expect_comma()?;
|
||||
ListStyleType::parse(input)
|
||||
}).unwrap_or(ListStyleType::Decimal)
|
||||
})
|
||||
.unwrap_or(ListStyleType::Decimal)
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
|
@ -102,7 +103,8 @@ impl Content {
|
|||
.try(|input| {
|
||||
input.expect_comma()?;
|
||||
CounterStyleOrNone::parse(context, input)
|
||||
}).unwrap_or(CounterStyleOrNone::decimal())
|
||||
})
|
||||
.unwrap_or(CounterStyleOrNone::decimal())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -74,10 +74,9 @@ impl Parse for TimingFunction {
|
|||
Ok(GenericTimingFunction::Steps(steps, position))
|
||||
},
|
||||
_ => Err(()),
|
||||
}).map_err(|()| {
|
||||
location.new_custom_error(
|
||||
StyleParseErrorKind::UnexpectedFunction(function.clone())
|
||||
)
|
||||
})
|
||||
.map_err(|()| {
|
||||
location.new_custom_error(StyleParseErrorKind::UnexpectedFunction(function.clone()))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -733,7 +733,8 @@ impl ToComputedValue for KeywordSize {
|
|||
KeywordSize::XLarge => Au::from_px(FONT_MEDIUM_PX) * 3 / 2,
|
||||
KeywordSize::XXLarge => Au::from_px(FONT_MEDIUM_PX) * 2,
|
||||
KeywordSize::XXXLarge => Au::from_px(FONT_MEDIUM_PX) * 3,
|
||||
}.into()
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -837,7 +838,8 @@ impl FontSize {
|
|||
6 => KeywordSize::XXLarge,
|
||||
// If value is greater than 7, let it be 7.
|
||||
_ => KeywordSize::XXXLarge,
|
||||
}.into(),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -906,7 +908,8 @@ impl FontSize {
|
|||
.to_computed_value_zoomed(
|
||||
context,
|
||||
FontBaseSize::InheritedStyleButStripEmUnits,
|
||||
).length_component();
|
||||
)
|
||||
.length_component();
|
||||
|
||||
info = parent.keyword_info.map(|i| i.compose(ratio, abs.into()));
|
||||
}
|
||||
|
@ -2108,7 +2111,8 @@ impl ToComputedValue for FontLanguageOverride {
|
|||
String::from_utf8(buf.to_vec()).unwrap()
|
||||
} else {
|
||||
unsafe { String::from_utf8_unchecked(buf.to_vec()) }
|
||||
}.into_boxed_str(),
|
||||
}
|
||||
.into_boxed_str(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -189,7 +189,9 @@ impl Image {
|
|||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Image, ParseError<'i>> {
|
||||
if let Ok(url) = input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input)) {
|
||||
if let Ok(url) =
|
||||
input.try(|input| SpecifiedImageUrl::parse_with_cors_anonymous(context, input))
|
||||
{
|
||||
return Ok(generic::Image::Url(url));
|
||||
}
|
||||
Self::parse(context, input)
|
||||
|
@ -1023,7 +1025,8 @@ impl Parse for PaintWorklet {
|
|||
.try(|input| {
|
||||
input.expect_comma()?;
|
||||
input.parse_comma_separated(|input| SpecifiedValue::parse(input))
|
||||
}).unwrap_or(vec![]);
|
||||
})
|
||||
.unwrap_or(vec![]);
|
||||
Ok(PaintWorklet { name, arguments })
|
||||
})
|
||||
}
|
||||
|
|
|
@ -73,10 +73,12 @@ impl SourceSizeList {
|
|||
Some(ref v) => v.to_computed_value(context),
|
||||
None => Length::NoCalc(NoCalcLength::ViewportPercentage(
|
||||
ViewportPercentageLength::Vw(100.),
|
||||
)).to_computed_value(context),
|
||||
))
|
||||
.to_computed_value(context),
|
||||
},
|
||||
}
|
||||
}).into()
|
||||
})
|
||||
.into()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -563,7 +563,6 @@ impl ToAnimatedZero for ArcFlag {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// SVG Path parser.
|
||||
struct PathParser<'a> {
|
||||
chars: Peekable<Cloned<slice::Iter<'a, u8>>>,
|
||||
|
|
|
@ -613,30 +613,40 @@ impl TextEmphasisShapeKeyword {
|
|||
pub fn char(&self, fill: TextEmphasisFillMode) -> &str {
|
||||
let fill = fill == TextEmphasisFillMode::Filled;
|
||||
match *self {
|
||||
TextEmphasisShapeKeyword::Dot => if fill {
|
||||
"\u{2022}"
|
||||
} else {
|
||||
"\u{25e6}"
|
||||
TextEmphasisShapeKeyword::Dot => {
|
||||
if fill {
|
||||
"\u{2022}"
|
||||
} else {
|
||||
"\u{25e6}"
|
||||
}
|
||||
},
|
||||
TextEmphasisShapeKeyword::Circle => if fill {
|
||||
"\u{25cf}"
|
||||
} else {
|
||||
"\u{25cb}"
|
||||
TextEmphasisShapeKeyword::Circle => {
|
||||
if fill {
|
||||
"\u{25cf}"
|
||||
} else {
|
||||
"\u{25cb}"
|
||||
}
|
||||
},
|
||||
TextEmphasisShapeKeyword::DoubleCircle => if fill {
|
||||
"\u{25c9}"
|
||||
} else {
|
||||
"\u{25ce}"
|
||||
TextEmphasisShapeKeyword::DoubleCircle => {
|
||||
if fill {
|
||||
"\u{25c9}"
|
||||
} else {
|
||||
"\u{25ce}"
|
||||
}
|
||||
},
|
||||
TextEmphasisShapeKeyword::Triangle => if fill {
|
||||
"\u{25b2}"
|
||||
} else {
|
||||
"\u{25b3}"
|
||||
TextEmphasisShapeKeyword::Triangle => {
|
||||
if fill {
|
||||
"\u{25b2}"
|
||||
} else {
|
||||
"\u{25b3}"
|
||||
}
|
||||
},
|
||||
TextEmphasisShapeKeyword::Sesame => if fill {
|
||||
"\u{fe45}"
|
||||
} else {
|
||||
"\u{fe46}"
|
||||
TextEmphasisShapeKeyword::Sesame => {
|
||||
if fill {
|
||||
"\u{fe45}"
|
||||
} else {
|
||||
"\u{fe46}"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue