style: Fix Servo build, and rustfmt recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-09-12 22:44:31 +02:00
parent 9eaadc6860
commit cd3b0c23fa
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
15 changed files with 90 additions and 60 deletions

View file

@ -61,11 +61,11 @@ use style::properties::{style_structs, ComputedValues};
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::computed::effects::SimpleShadow; use style::values::computed::effects::SimpleShadow;
use style::values::computed::image::{Image, ImageLayer}; use style::values::computed::image::{Image, ImageLayer};
use style::values::computed::{Gradient, LengthOrAuto}; use style::values::computed::{ClipRectOrAuto, Gradient, LengthOrAuto};
use style::values::generics::background::BackgroundSize; use style::values::generics::background::BackgroundSize;
use style::values::generics::image::{GradientKind, PaintWorklet}; use style::values::generics::image::{GradientKind, PaintWorklet};
use style::values::specified::ui::CursorKind; use style::values::specified::ui::CursorKind;
use style::values::{Either, RGBA}; use style::values::RGBA;
use style_traits::ToCss; use style_traits::ToCss;
use webrender_api::units::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D}; use webrender_api::units::{LayoutRect, LayoutSize, LayoutTransform, LayoutVector2D};
use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF}; use webrender_api::{self, BorderDetails, BorderRadius, BorderSide, BoxShadowClipMode, ColorF};
@ -2632,8 +2632,8 @@ impl BlockFlow {
) { ) {
// Account for `clip` per CSS 2.1 § 11.1.2. // Account for `clip` per CSS 2.1 § 11.1.2.
let style_clip_rect = match self.fragment.style().get_effects().clip { let style_clip_rect = match self.fragment.style().get_effects().clip {
Either::First(style_clip_rect) => style_clip_rect, ClipRectOrAuto::Rect(ref r) => r,
_ => return, ClipRectOrAuto::Auto => return,
}; };
// CSS `clip` should only apply to position:absolute or positione:fixed elements. // CSS `clip` should only apply to position:absolute or positione:fixed elements.

View file

@ -1497,11 +1497,10 @@ impl LayoutThread {
// Create a layout context for use throughout the following passes. // Create a layout context for use throughout the following passes.
let mut layout_context = self.build_layout_context(guards.clone(), true, &map); let mut layout_context = self.build_layout_context(guards.clone(), true, &map);
let pool;
let (thread_pool, num_threads) = if self.parallel_flag { let (thread_pool, num_threads) = if self.parallel_flag {
( pool = STYLE_THREAD_POOL.pool();
STYLE_THREAD_POOL.style_thread_pool.as_ref(), (pool.as_ref(), STYLE_THREAD_POOL.num_threads)
STYLE_THREAD_POOL.num_threads,
)
} else { } else {
(None, 1) (None, 1)
}; };
@ -1859,8 +1858,10 @@ impl LayoutThread {
|| { || {
let profiler_metadata = self.profiler_metadata(); let profiler_metadata = self.profiler_metadata();
let pool;
let thread_pool = if self.parallel_flag { let thread_pool = if self.parallel_flag {
STYLE_THREAD_POOL.style_thread_pool.as_ref() pool = STYLE_THREAD_POOL.pool();
pool.as_ref()
} else { } else {
None None
}; };

View file

@ -829,9 +829,7 @@ impl<'le> GeckoElement<'le> {
#[inline] #[inline]
fn is_in_anonymous_subtree(&self) -> bool { fn is_in_anonymous_subtree(&self) -> bool {
unsafe { unsafe { bindings::Gecko_IsInAnonymousSubtree(self.0) }
bindings::Gecko_IsInAnonymousSubtree(self.0)
}
} }
/// Returns true if this node is the shadow root of an use-element shadow tree. /// Returns true if this node is the shadow root of an use-element shadow tree.

View file

@ -10,10 +10,10 @@ use crate::gecko_bindings::bindings;
use crate::parallel::STYLE_THREAD_STACK_SIZE_KB; use crate::parallel::STYLE_THREAD_STACK_SIZE_KB;
use crate::shared_lock::SharedRwLock; use crate::shared_lock::SharedRwLock;
use crate::thread_state; use crate::thread_state;
use parking_lot::{RwLock, RwLockReadGuard};
use rayon; use rayon;
use std::env; use std::env;
use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::atomic::{AtomicUsize, Ordering};
use parking_lot::{RwLock, RwLockReadGuard};
/// Global style data /// Global style data
pub struct GlobalStyleData { pub struct GlobalStyleData {

View file

@ -16,7 +16,9 @@ use crate::parser::{Parse, ParserContext};
use crate::servo::media_queries::MEDIA_FEATURES; use crate::servo::media_queries::MEDIA_FEATURES;
use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase}; use crate::str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use crate::values::computed::{self, ToComputedValue}; use crate::values::computed::{self, ToComputedValue};
use crate::values::specified::{Integer, NonNegativeNumber, Length, Number, Resolution}; #[cfg(feature = "gecko")]
use crate::values::specified::NonNegativeNumber;
use crate::values::specified::{Integer, Length, Number, Resolution};
use crate::values::{serialize_atom_identifier, CSSFloat}; use crate::values::{serialize_atom_identifier, CSSFloat};
use crate::{Atom, Zero}; use crate::{Atom, Zero};
use cssparser::{Parser, Token}; use cssparser::{Parser, Token};
@ -429,9 +431,11 @@ impl MediaFeatureExpression {
eval(device, expect!(Integer).cloned(), self.range_or_operator) eval(device, expect!(Integer).cloned(), self.range_or_operator)
}, },
Evaluator::Float(eval) => eval(device, expect!(Float).cloned(), self.range_or_operator), Evaluator::Float(eval) => eval(device, expect!(Float).cloned(), self.range_or_operator),
Evaluator::NumberRatio(eval) => { Evaluator::NumberRatio(eval) => eval(
eval(device, expect!(NumberRatio).cloned(), self.range_or_operator) device,
}, expect!(NumberRatio).cloned(),
self.range_or_operator,
),
Evaluator::Resolution(eval) => { Evaluator::Resolution(eval) => {
let computed = expect!(Resolution).map(|specified| { let computed = expect!(Resolution).map(|specified| {
computed::Context::for_media_query_evaluation(device, quirks_mode, |context| { computed::Context::for_media_query_evaluation(device, quirks_mode, |context| {
@ -530,19 +534,25 @@ impl MediaExpressionValue {
MediaExpressionValue::Float(number.get()) MediaExpressionValue::Float(number.get())
}, },
Evaluator::NumberRatio(..) => { Evaluator::NumberRatio(..) => {
if static_prefs::pref!("layout.css.aspect-ratio-number.enabled") { #[cfg(feature = "gecko")]
let a = NonNegativeNumber::parse(context, input)?.0.get(); {
let b = match input.try_parse(|input| input.expect_delim('/')) { if static_prefs::pref!("layout.css.aspect-ratio-number.enabled") {
Ok(()) => NonNegativeNumber::parse(context, input)?.0.get(), let a = NonNegativeNumber::parse(context, input)?.0.get();
_ => 1.0, let b = match input.try_parse(|input| input.expect_delim('/')) {
}; Ok(()) => NonNegativeNumber::parse(context, input)?.0.get(),
MediaExpressionValue::NumberRatio(AspectRatio(a, b)) _ => 1.0,
} else { };
let a = Integer::parse_positive(context, input)?; return Ok(MediaExpressionValue::NumberRatio(AspectRatio(a, b)));
input.expect_delim('/')?; }
let b = Integer::parse_positive(context, input)?;
MediaExpressionValue::NumberRatio(AspectRatio(a.value() as CSSFloat, b.value() as CSSFloat))
} }
let a = Integer::parse_positive(context, input)?;
input.expect_delim('/')?;
let b = Integer::parse_positive(context, input)?;
MediaExpressionValue::NumberRatio(AspectRatio(
a.value() as CSSFloat,
b.value() as CSSFloat,
))
}, },
Evaluator::Resolution(..) => { Evaluator::Resolution(..) => {
MediaExpressionValue::Resolution(Resolution::parse(context, input)?) MediaExpressionValue::Resolution(Resolution::parse(context, input)?)

View file

@ -797,6 +797,7 @@ class PropertyRestrictions:
+ PropertyRestrictions.shorthand(data, "outline") + PropertyRestrictions.shorthand(data, "outline")
+ PropertyRestrictions.shorthand(data, "font")) + PropertyRestrictions.shorthand(data, "font"))
class CountedUnknownProperty: class CountedUnknownProperty:
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name

View file

@ -73,6 +73,7 @@
} }
impl<'a> ToCss for LonghandsToSerialize<'a> { impl<'a> ToCss for LonghandsToSerialize<'a> {
#[allow(unused)]
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write { fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result where W: fmt::Write {
use crate::values::specified::TextDecorationLine; use crate::values::specified::TextDecorationLine;

View file

@ -9,11 +9,15 @@ use crate::gecko_bindings::sugar::refptr::RefPtr;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use crate::gecko_bindings::{bindings, structs}; use crate::gecko_bindings::{bindings, structs};
use crate::values::animated::{ToAnimatedValue, ToAnimatedZero}; use crate::values::animated::{ToAnimatedValue, ToAnimatedZero};
use crate::values::computed::{Angle, Context, Integer, Length, NonNegativeLength, NonNegativePercentage}; use crate::values::computed::{
Angle, Context, Integer, Length, NonNegativeLength, NonNegativePercentage,
};
use crate::values::computed::{Number, Percentage, ToComputedValue}; use crate::values::computed::{Number, Percentage, ToComputedValue};
use crate::values::generics::{font as generics, NonNegative};
use crate::values::generics::font::{FeatureTagValue, FontSettings, VariationValue}; use crate::values::generics::font::{FeatureTagValue, FontSettings, VariationValue};
use crate::values::specified::font::{self as specified, KeywordInfo, MAX_FONT_WEIGHT, MIN_FONT_WEIGHT}; use crate::values::generics::{font as generics, NonNegative};
use crate::values::specified::font::{
self as specified, KeywordInfo, MAX_FONT_WEIGHT, MIN_FONT_WEIGHT,
};
use crate::values::specified::length::{FontBaseSize, NoCalcLength}; use crate::values::specified::length::{FontBaseSize, NoCalcLength};
use crate::values::CSSFloat; use crate::values::CSSFloat;
use crate::Atom; use crate::Atom;

View file

@ -118,7 +118,9 @@ impl<I> Deref for CounterSetOrReset<I> {
ToShmem, ToShmem,
)] )]
#[repr(transparent)] #[repr(transparent)]
pub struct GenericCounters<I>(#[css(iterable, if_empty = "none")] crate::OwnedSlice<GenericCounterPair<I>>); pub struct GenericCounters<I>(
#[css(iterable, if_empty = "none")] crate::OwnedSlice<GenericCounterPair<I>>,
);
pub use self::GenericCounters as Counters; pub use self::GenericCounters as Counters;
#[cfg(feature = "servo")] #[cfg(feature = "servo")]

View file

@ -171,7 +171,6 @@ impl Parse for FontTag {
} }
} }
/// A generic value for the `font-style` property. /// A generic value for the `font-style` property.
/// ///
/// https://drafts.csswg.org/css-fonts-4/#font-style-prop /// https://drafts.csswg.org/css-fonts-4/#font-style-prop

View file

@ -309,4 +309,10 @@ impl<L> ClipRectOrAuto<L> {
pub fn auto() -> Self { pub fn auto() -> Self {
ClipRectOrAuto::Auto ClipRectOrAuto::Auto
} }
/// Returns whether this value is the `auto` value.
#[inline]
pub fn is_auto(&self) -> bool {
matches!(*self, ClipRectOrAuto::Auto)
}
} }

View file

@ -8,8 +8,8 @@
use crate::computed_values::list_style_type::T as ListStyleType; use crate::computed_values::list_style_type::T as ListStyleType;
use crate::parser::{Parse, ParserContext}; use crate::parser::{Parse, ParserContext};
use crate::values::generics::counters as generics; use crate::values::generics::counters as generics;
use crate::values::generics::counters::GenericCounterIncrement;
use crate::values::generics::counters::CounterPair; use crate::values::generics::counters::CounterPair;
use crate::values::generics::counters::GenericCounterIncrement;
use crate::values::generics::counters::GenericCounterSetOrReset; use crate::values::generics::counters::GenericCounterSetOrReset;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use crate::values::generics::CounterStyle; use crate::values::generics::CounterStyle;

View file

@ -12,8 +12,8 @@ use crate::values::computed::font::{FamilyName, FontFamilyList, FontStyleAngle,
use crate::values::computed::{font as computed, Length, NonNegativeLength}; use crate::values::computed::{font as computed, Length, NonNegativeLength};
use crate::values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage}; use crate::values::computed::{Angle as ComputedAngle, Percentage as ComputedPercentage};
use crate::values::computed::{CSSPixelLength, Context, ToComputedValue}; use crate::values::computed::{CSSPixelLength, Context, ToComputedValue};
use crate::values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
use crate::values::generics::font::VariationValue; use crate::values::generics::font::VariationValue;
use crate::values::generics::font::{self as generics, FeatureTagValue, FontSettings, FontTag};
use crate::values::generics::NonNegative; use crate::values::generics::NonNegative;
use crate::values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX}; use crate::values::specified::length::{FontBaseSize, AU_PER_PT, AU_PER_PX};
use crate::values::specified::{AllowQuirks, Angle, Integer, LengthPercentage}; use crate::values::specified::{AllowQuirks, Angle, Integer, LengthPercentage};
@ -877,19 +877,17 @@ impl ToComputedValue for KeywordSize {
impl FontSize { impl FontSize {
/// <https://html.spec.whatwg.org/multipage/#rules-for-parsing-a-legacy-font-size> /// <https://html.spec.whatwg.org/multipage/#rules-for-parsing-a-legacy-font-size>
pub fn from_html_size(size: u8) -> Self { pub fn from_html_size(size: u8) -> Self {
FontSize::Keyword( FontSize::Keyword(KeywordInfo::new(match size {
KeywordInfo::new(match size { // If value is less than 1, let it be 1.
// If value is less than 1, let it be 1. 0 | 1 => KeywordSize::XSmall,
0 | 1 => KeywordSize::XSmall, 2 => KeywordSize::Small,
2 => KeywordSize::Small, 3 => KeywordSize::Medium,
3 => KeywordSize::Medium, 4 => KeywordSize::Large,
4 => KeywordSize::Large, 5 => KeywordSize::XLarge,
5 => KeywordSize::XLarge, 6 => KeywordSize::XXLarge,
6 => KeywordSize::XXLarge, // If value is greater than 7, let it be 7.
// If value is greater than 7, let it be 7. _ => KeywordSize::XXXLarge,
_ => KeywordSize::XXXLarge, }))
})
)
} }
/// Compute it against a given base font size /// Compute it against a given base font size
@ -924,9 +922,7 @@ impl FontSize {
FontSize::Length(LengthPercentage::Length(NoCalcLength::Absolute(ref l))) => { FontSize::Length(LengthPercentage::Length(NoCalcLength::Absolute(ref l))) => {
context.maybe_zoom_text(l.to_computed_value(context)) context.maybe_zoom_text(l.to_computed_value(context))
}, },
FontSize::Length(LengthPercentage::Length(ref l)) => { FontSize::Length(LengthPercentage::Length(ref l)) => l.to_computed_value(context),
l.to_computed_value(context)
},
FontSize::Length(LengthPercentage::Percentage(pc)) => { FontSize::Length(LengthPercentage::Percentage(pc)) => {
// If the parent font was keyword-derived, this is too. // If the parent font was keyword-derived, this is too.
// Tack the % onto the factor // Tack the % onto the factor
@ -983,8 +979,7 @@ impl FontSize {
}, },
FontSize::Larger => { FontSize::Larger => {
info = compose_keyword(LARGER_FONT_SIZE_RATIO); info = compose_keyword(LARGER_FONT_SIZE_RATIO);
FontRelativeLength::Em(LARGER_FONT_SIZE_RATIO) FontRelativeLength::Em(LARGER_FONT_SIZE_RATIO).to_computed_value(context, base_size)
.to_computed_value(context, base_size)
}, },
FontSize::System(_) => { FontSize::System(_) => {
@ -994,7 +989,13 @@ impl FontSize {
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
context.cached_system_font.as_ref().unwrap().font_size.size.0 context
.cached_system_font
.as_ref()
.unwrap()
.font_size
.size
.0
} }
}, },
}; };
@ -1115,7 +1116,15 @@ pub enum VariantAlternates {
} }
#[derive( #[derive(
Clone, Debug, Default, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToResolvedValue, ToShmem, Clone,
Debug,
Default,
MallocSizeOf,
PartialEq,
SpecifiedValueInfo,
ToCss,
ToResolvedValue,
ToShmem,
)] )]
#[repr(transparent)] #[repr(transparent)]
/// List of Variant Alternates /// List of Variant Alternates
@ -1190,7 +1199,7 @@ impl Parse for FontVariantAlternates {
.try(|input| input.expect_ident_matching("normal")) .try(|input| input.expect_ident_matching("normal"))
.is_ok() .is_ok()
{ {
return Ok(FontVariantAlternates::Value(Default::default())) return Ok(FontVariantAlternates::Value(Default::default()));
} }
let mut alternates = Vec::new(); let mut alternates = Vec::new();

View file

@ -706,7 +706,7 @@ impl ClipRectOrAuto {
allow_quirks: AllowQuirks, allow_quirks: AllowQuirks,
) -> Result<Self, ParseError<'i>> { ) -> Result<Self, ParseError<'i>> {
if let Ok(v) = input.try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) { if let Ok(v) = input.try(|i| ClipRect::parse_quirky(context, i, allow_quirks)) {
return Ok(generics::GenericClipRectOrAuto::Rect(v)) return Ok(generics::GenericClipRectOrAuto::Rect(v));
} }
input.expect_ident_matching("auto")?; input.expect_ident_matching("auto")?;
Ok(generics::GenericClipRectOrAuto::Auto) Ok(generics::GenericClipRectOrAuto::Auto)

View file

@ -89,8 +89,7 @@ impl ToComputedValue for LineHeight {
GenericLineHeight::Length(ref non_negative_lp) => { GenericLineHeight::Length(ref non_negative_lp) => {
let result = match non_negative_lp.0 { let result = match non_negative_lp.0 {
LengthPercentage::Length(NoCalcLength::Absolute(ref abs)) => { LengthPercentage::Length(NoCalcLength::Absolute(ref abs)) => {
context context.maybe_zoom_text(abs.to_computed_value(context))
.maybe_zoom_text(abs.to_computed_value(context))
}, },
LengthPercentage::Length(ref length) => length.to_computed_value(context), LengthPercentage::Length(ref length) => length.to_computed_value(context),
LengthPercentage::Percentage(ref p) => FontRelativeLength::Em(p.0) LengthPercentage::Percentage(ref p) => FontRelativeLength::Em(p.0)