Fix style system build with recent changes.

This commit is contained in:
Emilio Cobos Álvarez 2019-06-23 13:13:21 +02:00
parent ed2e9ce482
commit add08518cd
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
7 changed files with 43 additions and 30 deletions

View file

@ -57,10 +57,10 @@ use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect};
use style::properties::{style_structs, ComputedValues}; 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 as ComputedImage; use style::values::computed::image::{Image, ImageLayer};
use style::values::computed::{Gradient, LengthOrAuto}; use style::values::computed::{Gradient, LengthOrAuto};
use style::values::generics::background::BackgroundSize; use style::values::generics::background::BackgroundSize;
use style::values::generics::image::{GradientKind, Image, 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::{Either, RGBA};
use style_traits::ToCss; use style_traits::ToCss;
@ -726,9 +726,13 @@ impl Fragment {
// http://www.w3.org/TR/CSS21/colors.html#background // http://www.w3.org/TR/CSS21/colors.html#background
let background = style.get_background(); let background = style.get_background();
for (i, background_image) in background.background_image.0.iter().enumerate().rev() { for (i, background_image) in background.background_image.0.iter().enumerate().rev() {
let background_image = match *background_image {
ImageLayer::None => continue,
ImageLayer::Image(ref image) => image,
};
match *background_image { match *background_image {
Either::First(_) => {}, Image::Gradient(ref gradient) => {
Either::Second(Image::Gradient(ref gradient)) => {
self.build_display_list_for_background_gradient( self.build_display_list_for_background_gradient(
state, state,
display_list_section, display_list_section,
@ -738,7 +742,7 @@ impl Fragment {
i, i,
); );
}, },
Either::Second(Image::Url(ref image_url)) => { Image::Url(ref image_url) => {
if let Some(url) = image_url.url() { if let Some(url) = image_url.url() {
let webrender_image = state.layout_context.get_webrender_image_for_url( let webrender_image = state.layout_context.get_webrender_image_for_url(
self.node, self.node,
@ -757,7 +761,7 @@ impl Fragment {
} }
} }
}, },
Either::Second(Image::PaintWorklet(ref paint_worklet)) => { Image::PaintWorklet(ref paint_worklet) => {
let bounding_box = self.border_box - style.logical_border_width(); let bounding_box = self.border_box - style.logical_border_width();
let bounding_box_size = bounding_box.size.to_physical(style.writing_mode); let bounding_box_size = bounding_box.size.to_physical(style.writing_mode);
let background_size = let background_size =
@ -790,10 +794,10 @@ impl Fragment {
); );
} }
}, },
Either::Second(Image::Rect(_)) => { Image::Rect(_) => {
// TODO: Implement `-moz-image-rect` // TODO: Implement `-moz-image-rect`
}, },
Either::Second(Image::Element(_)) => { Image::Element(_) => {
// TODO: Implement `-moz-element` // TODO: Implement `-moz-element`
}, },
} }
@ -978,7 +982,7 @@ impl Fragment {
}; };
DisplayItem::Gradient(CommonDisplayItem::with_data(base, item, stops)) DisplayItem::Gradient(CommonDisplayItem::with_data(base, item, stops))
}, },
GradientKind::Radial(shape, center, _angle) => { GradientKind::Radial(shape, center) => {
let (gradient, stops) = gradient::radial( let (gradient, stops) = gradient::radial(
style, style,
placement.tile_size, placement.tile_size,
@ -1115,7 +1119,7 @@ impl Fragment {
let border_radius = border::radii(bounds, border_style_struct); let border_radius = border::radii(bounds, border_style_struct);
let border_widths = border.to_physical(style.writing_mode); let border_widths = border.to_physical(style.writing_mode);
if let Either::Second(ref image) = border_style_struct.border_image_source { if let ImageLayer::Image(ref image) = border_style_struct.border_image_source {
if self if self
.build_display_list_for_border_image( .build_display_list_for_border_image(
state, state,
@ -1173,7 +1177,7 @@ impl Fragment {
style: &ComputedValues, style: &ComputedValues,
base: BaseDisplayItem, base: BaseDisplayItem,
bounds: Rect<Au>, bounds: Rect<Au>,
image: &ComputedImage, image: &Image,
border_width: SideOffsets2D<Au>, border_width: SideOffsets2D<Au>,
) -> Option<()> { ) -> Option<()> {
let border_style_struct = style.get_border(); let border_style_struct = style.get_border();
@ -1227,7 +1231,7 @@ impl Fragment {
stops = linear_stops; stops = linear_stops;
NinePatchBorderSource::Gradient(wr_gradient) NinePatchBorderSource::Gradient(wr_gradient)
}, },
GradientKind::Radial(shape, center, _angle) => { GradientKind::Radial(shape, center) => {
let (wr_gradient, radial_stops) = gradient::radial( let (wr_gradient, radial_stops) = gradient::radial(
style, style,
border_image_area, border_image_area,

View file

@ -9,7 +9,6 @@ use style::properties::ComputedValues;
use style::values::computed::image::{EndingShape, LineDirection}; use style::values::computed::image::{EndingShape, LineDirection};
use style::values::computed::{Angle, GradientItem, LengthPercentage, Percentage, Position}; use style::values::computed::{Angle, GradientItem, LengthPercentage, Percentage, Position};
use style::values::generics::image::{Circle, ColorStop, Ellipse, ShapeExtent}; use style::values::generics::image::{Circle, ColorStop, Ellipse, ShapeExtent};
use style::values::specified::position::{X, Y};
use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient}; use webrender_api::{ExtendMode, Gradient, GradientBuilder, GradientStop, RadialGradient};
/// A helper data structure for gradients. /// A helper data structure for gradients.
@ -227,15 +226,17 @@ pub fn linear(
direction: LineDirection, direction: LineDirection,
repeating: bool, repeating: bool,
) -> (Gradient, Vec<GradientStop>) { ) -> (Gradient, Vec<GradientStop>) {
use style::values::specified::position::HorizontalPositionKeyword::*;
use style::values::specified::position::VerticalPositionKeyword::*;
let angle = match direction { let angle = match direction {
LineDirection::Angle(angle) => angle.radians(), LineDirection::Angle(angle) => angle.radians(),
LineDirection::Horizontal(x) => match x { LineDirection::Horizontal(x) => match x {
X::Left => Angle::from_degrees(270.).radians(), Left => Angle::from_degrees(270.).radians(),
X::Right => Angle::from_degrees(90.).radians(), Right => Angle::from_degrees(90.).radians(),
}, },
LineDirection::Vertical(y) => match y { LineDirection::Vertical(y) => match y {
Y::Top => Angle::from_degrees(0.).radians(), Top => Angle::from_degrees(0.).radians(),
Y::Bottom => Angle::from_degrees(180.).radians(), Bottom => Angle::from_degrees(180.).radians(),
}, },
LineDirection::Corner(horizontal, vertical) => { LineDirection::Corner(horizontal, vertical) => {
// This the angle for one of the diagonals of the box. Our angle // This the angle for one of the diagonals of the box. Our angle
@ -243,10 +244,10 @@ pub fn linear(
// two perpendicular angles. // two perpendicular angles.
let atan = (size.height.to_f32_px() / size.width.to_f32_px()).atan(); let atan = (size.height.to_f32_px() / size.width.to_f32_px()).atan();
match (horizontal, vertical) { match (horizontal, vertical) {
(X::Right, Y::Bottom) => ::std::f32::consts::PI - atan, (Right, Bottom) => ::std::f32::consts::PI - atan,
(X::Left, Y::Bottom) => ::std::f32::consts::PI + atan, (Left, Bottom) => ::std::f32::consts::PI + atan,
(X::Right, Y::Top) => atan, (Right, Top) => atan,
(X::Left, Y::Top) => -atan, (Left, Top) => -atan,
} }
}, },
}; };

View file

@ -510,6 +510,10 @@ impl<'le> TElement for ServoLayoutElement<'le> {
*self.element.namespace() == ns!(svg) *self.element.namespace() == ns!(svg)
} }
fn has_part_attr(&self) -> bool {
false
}
fn style_attribute(&self) -> Option<ArcBorrow<StyleLocked<PropertyDeclarationBlock>>> { fn style_attribute(&self) -> Option<ArcBorrow<StyleLocked<PropertyDeclarationBlock>>> {
unsafe { unsafe {
(*self.element.style_attribute()) (*self.element.style_attribute())

View file

@ -132,8 +132,7 @@ use style::selector_parser::{
use style::shared_lock::{Locked, SharedRwLock}; use style::shared_lock::{Locked, SharedRwLock};
use style::thread_state; use style::thread_state;
use style::values::generics::NonNegative; use style::values::generics::NonNegative;
use style::values::{computed, specified}; use style::values::{computed, specified, CSSFloat};
use style::values::{CSSFloat, Either};
use style::CaseSensitivityExt; use style::CaseSensitivityExt;
use xml5ever::serialize as xmlSerialize; use xml5ever::serialize as xmlSerialize;
use xml5ever::serialize::SerializeOpts as XmlSerializeOpts; use xml5ever::serialize::SerializeOpts as XmlSerializeOpts;
@ -684,7 +683,7 @@ impl LayoutElementHelpers for LayoutDom<Element> {
hints.push(from_declaration( hints.push(from_declaration(
shared_lock, shared_lock,
PropertyDeclaration::BackgroundImage(background_image::SpecifiedValue( PropertyDeclaration::BackgroundImage(background_image::SpecifiedValue(
vec![Either::Second(specified::Image::for_cascade(url.into()))].into(), vec![specified::ImageLayer::Image(specified::Image::for_cascade(url.into()))].into(),
)), )),
)); ));
} }

View file

@ -237,10 +237,17 @@ partial interface CSSStyleDeclaration {
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString counter-reset; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString counter-reset;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowBlock;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-block;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowInline;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-inline;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowX; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowX;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-x; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-x;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowY; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowY;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-y; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-y;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowWrap; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflowWrap;
[CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-wrap; [CEReactions, SetterThrows] attribute [TreatNullAs=EmptyString] DOMString overflow-wrap;

View file

@ -35,10 +35,9 @@ use crate::thread_state::{self, ThreadState};
use crate::{Atom, LocalName, Namespace, WeakAtom}; use crate::{Atom, LocalName, Namespace, WeakAtom};
use fallible::FallibleVec; use fallible::FallibleVec;
use hashglobe::FailedAllocationError; use hashglobe::FailedAllocationError;
use malloc_size_of::MallocSizeOf;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use malloc_size_of::MallocUnconditionalShallowSizeOf; use malloc_size_of::{MallocShallowSizeOf, MallocSizeOfOps, MallocUnconditionalShallowSizeOf};
#[cfg(feature = "gecko")]
use malloc_size_of::{MallocShallowSizeOf, MallocSizeOf, MallocSizeOfOps};
use selectors::attr::{CaseSensitivity, NamespaceConstraint}; use selectors::attr::{CaseSensitivity, NamespaceConstraint};
use selectors::bloom::BloomFilter; use selectors::bloom::BloomFilter;
use selectors::matching::VisitedHandlingMode; use selectors::matching::VisitedHandlingMode;

View file

@ -693,8 +693,7 @@ fn notify_paint_worklet<E>(context: &StyleContext<E>, data: &ElementData)
where where
E: TElement, E: TElement,
{ {
use crate::values::generics::image::Image; use crate::values::generics::image::{GenericImageLayer, Image};
use crate::values::Either;
use style_traits::ToCss; use style_traits::ToCss;
// We speculatively evaluate any paint worklets during styling. // We speculatively evaluate any paint worklets during styling.
@ -704,7 +703,7 @@ where
if let Some(ref values) = data.styles.primary { if let Some(ref values) = data.styles.primary {
for image in &values.get_background().background_image.0 { for image in &values.get_background().background_image.0 {
let (name, arguments) = match *image { let (name, arguments) = match *image {
Either::Second(Image::PaintWorklet(ref worklet)) => { GenericImageLayer::Image(Image::PaintWorklet(ref worklet)) => {
(&worklet.name, &worklet.arguments) (&worklet.name, &worklet.arguments)
}, },
_ => continue, _ => continue,