mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use more WebRender types in gfx/display_list
This uses floating-point (Layout) coordinates in where possible. Replace NormalBorder struct with WebRender equivalent. Remove ToPointF and ToRectF traits. Convert border RepeatKeyword with ToLayout. Add some definitions to malloc_size_of for WebRender types.
This commit is contained in:
parent
8612a87ed2
commit
8c7c5f6e79
10 changed files with 181 additions and 240 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -1779,7 +1779,6 @@ dependencies = [
|
||||||
name = "metrics_tests"
|
name = "metrics_tests"
|
||||||
version = "0.0.1"
|
version = "0.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"euclid 0.16.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
|
||||||
"gfx 0.0.1",
|
"gfx 0.0.1",
|
||||||
"gfx_traits 0.0.1",
|
"gfx_traits 0.0.1",
|
||||||
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"ipc-channel 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -1788,8 +1787,8 @@ dependencies = [
|
||||||
"net_traits 0.0.1",
|
"net_traits 0.0.1",
|
||||||
"profile_traits 0.0.1",
|
"profile_traits 0.0.1",
|
||||||
"servo_url 0.0.1",
|
"servo_url 0.0.1",
|
||||||
"style 0.0.1",
|
|
||||||
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
"time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"webrender_api 0.56.1 (git+https://github.com/servo/webrender)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -26,15 +26,17 @@ use range::Range;
|
||||||
use servo_geometry::max_rect;
|
use servo_geometry::max_rect;
|
||||||
use std::cmp::{self, Ordering};
|
use std::cmp::{self, Ordering};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
use std::f32;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use style::computed_values::{border_style, image_rendering};
|
|
||||||
use style::values::computed::Filter;
|
use style::values::computed::Filter;
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
use text::TextRun;
|
use text::TextRun;
|
||||||
use text::glyph::ByteIndex;
|
use text::glyph::ByteIndex;
|
||||||
use webrender_api::{self, BoxShadowClipMode, ClipId, ColorF, GradientStop, LocalClip, MixBlendMode};
|
use webrender_api::{BoxShadowClipMode, ClipId, ColorF, ExtendMode, GradientStop, ImageKey};
|
||||||
use webrender_api::{ScrollPolicy, ScrollSensitivity, StickyOffsetBounds, TransformStyle};
|
use webrender_api::{ImageRendering, LayoutPoint, LayoutRect, LayoutSize, LayoutVector2D};
|
||||||
|
use webrender_api::{LineStyle, LocalClip, MixBlendMode, NormalBorder, RepeatMode, ScrollPolicy};
|
||||||
|
use webrender_api::{ScrollSensitivity, StickyOffsetBounds, TransformStyle};
|
||||||
|
|
||||||
pub use style::dom::OpaqueNode;
|
pub use style::dom::OpaqueNode;
|
||||||
|
|
||||||
|
@ -442,7 +444,11 @@ impl BaseDisplayItem {
|
||||||
node: OpaqueNode(0),
|
node: OpaqueNode(0),
|
||||||
pointing: None,
|
pointing: None,
|
||||||
},
|
},
|
||||||
local_clip: LocalClip::from(max_rect().to_rectf()),
|
// Create a rectangle of maximal size.
|
||||||
|
local_clip: LocalClip::from(LayoutRect::new(
|
||||||
|
LayoutPoint::new(f32::MIN / 2.0, f32::MIN / 2.0),
|
||||||
|
LayoutSize::new(f32::MAX, f32::MAX),
|
||||||
|
)),
|
||||||
section: DisplayListSection::Content,
|
section: DisplayListSection::Content,
|
||||||
stacking_context_id: StackingContextId::root(),
|
stacking_context_id: StackingContextId::root(),
|
||||||
clipping_and_scrolling: ClippingAndScrolling::simple(ClipScrollNodeIndex(0)),
|
clipping_and_scrolling: ClippingAndScrolling::simple(ClipScrollNodeIndex(0)),
|
||||||
|
@ -699,15 +705,15 @@ pub struct ImageDisplayItem {
|
||||||
/// The dimensions to which the image display item should be stretched. If this is smaller than
|
/// The dimensions to which the image display item should be stretched. If this is smaller than
|
||||||
/// the bounds of this display item, then the image will be repeated in the appropriate
|
/// the bounds of this display item, then the image will be repeated in the appropriate
|
||||||
/// direction to tile the entire bounds.
|
/// direction to tile the entire bounds.
|
||||||
pub stretch_size: Size2D<Au>,
|
pub stretch_size: LayoutSize,
|
||||||
|
|
||||||
/// The amount of space to add to the right and bottom part of each tile, when the image
|
/// The amount of space to add to the right and bottom part of each tile, when the image
|
||||||
/// is tiled.
|
/// is tiled.
|
||||||
pub tile_spacing: Size2D<Au>,
|
pub tile_spacing: LayoutSize,
|
||||||
|
|
||||||
/// The algorithm we should use to stretch the image. See `image_rendering` in CSS-IMAGES-3 §
|
/// The algorithm we should use to stretch the image. See `image_rendering` in CSS-IMAGES-3 §
|
||||||
/// 5.3.
|
/// 5.3.
|
||||||
pub image_rendering: image_rendering::T,
|
pub image_rendering: ImageRendering,
|
||||||
}
|
}
|
||||||
/// Paints an iframe.
|
/// Paints an iframe.
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||||
|
@ -720,16 +726,16 @@ pub struct IframeDisplayItem {
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||||
pub struct Gradient {
|
pub struct Gradient {
|
||||||
/// The start point of the gradient (computed during display list construction).
|
/// The start point of the gradient (computed during display list construction).
|
||||||
pub start_point: Point2D<Au>,
|
pub start_point: LayoutPoint,
|
||||||
|
|
||||||
/// The end point of the gradient (computed during display list construction).
|
/// The end point of the gradient (computed during display list construction).
|
||||||
pub end_point: Point2D<Au>,
|
pub end_point: LayoutPoint,
|
||||||
|
|
||||||
/// A list of color stops.
|
/// A list of color stops.
|
||||||
pub stops: Vec<GradientStop>,
|
pub stops: Vec<GradientStop>,
|
||||||
|
|
||||||
/// True if gradient repeats infinitly.
|
/// Whether the gradient is repeated or clamped.
|
||||||
pub repeating: bool,
|
pub extend_mode: ExtendMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||||
|
@ -747,24 +753,24 @@ pub struct GradientDisplayItem {
|
||||||
/// the same gradient.
|
/// the same gradient.
|
||||||
///
|
///
|
||||||
/// Without tiles, the tile will be the same size as the background.
|
/// Without tiles, the tile will be the same size as the background.
|
||||||
pub tile: Size2D<Au>,
|
pub tile: LayoutSize,
|
||||||
pub tile_spacing: Size2D<Au>,
|
pub tile_spacing: LayoutSize,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Paints a radial gradient.
|
/// Paints a radial gradient.
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||||
pub struct RadialGradient {
|
pub struct RadialGradient {
|
||||||
/// The center point of the gradient.
|
/// The center point of the gradient.
|
||||||
pub center: Point2D<Au>,
|
pub center: LayoutPoint,
|
||||||
|
|
||||||
/// The radius of the gradient with an x and an y component.
|
/// The radius of the gradient with an x and an y component.
|
||||||
pub radius: Size2D<Au>,
|
pub radius: LayoutSize,
|
||||||
|
|
||||||
/// A list of color stops.
|
/// A list of color stops.
|
||||||
pub stops: Vec<GradientStop>,
|
pub stops: Vec<GradientStop>,
|
||||||
|
|
||||||
/// True if gradient repeats infinitly.
|
/// Whether the gradient is repeated or clamped.
|
||||||
pub repeating: bool,
|
pub extend_mode: ExtendMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
||||||
|
@ -782,21 +788,8 @@ pub struct RadialGradientDisplayItem {
|
||||||
/// the same gradient.
|
/// the same gradient.
|
||||||
///
|
///
|
||||||
/// Without tiles, the tile will be the same size as the background.
|
/// Without tiles, the tile will be the same size as the background.
|
||||||
pub tile: Size2D<Au>,
|
pub tile: LayoutSize,
|
||||||
pub tile_spacing: Size2D<Au>,
|
pub tile_spacing: LayoutSize,
|
||||||
}
|
|
||||||
|
|
||||||
/// A normal border, supporting CSS border styles.
|
|
||||||
#[derive(Clone, Deserialize, MallocSizeOf, Serialize)]
|
|
||||||
pub struct NormalBorder {
|
|
||||||
/// Border colors.
|
|
||||||
pub color: SideOffsets2D<ColorF>,
|
|
||||||
|
|
||||||
/// Border styles.
|
|
||||||
pub style: SideOffsets2D<border_style::T>,
|
|
||||||
|
|
||||||
/// Border radii.
|
|
||||||
pub radius: BorderRadii<Au>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A border that is made of image segments.
|
/// A border that is made of image segments.
|
||||||
|
@ -815,10 +808,10 @@ pub struct ImageBorder {
|
||||||
pub fill: bool,
|
pub fill: bool,
|
||||||
|
|
||||||
/// How to repeat or stretch horizontal edges (border-image-repeat).
|
/// How to repeat or stretch horizontal edges (border-image-repeat).
|
||||||
pub repeat_horizontal: webrender_api::RepeatMode,
|
pub repeat_horizontal: RepeatMode,
|
||||||
|
|
||||||
/// How to repeat or stretch vertical edges (border-image-repeat).
|
/// How to repeat or stretch vertical edges (border-image-repeat).
|
||||||
pub repeat_vertical: webrender_api::RepeatMode,
|
pub repeat_vertical: RepeatMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A border that is made of linear gradient
|
/// A border that is made of linear gradient
|
||||||
|
@ -934,8 +927,7 @@ pub struct LineDisplayItem {
|
||||||
pub color: ColorF,
|
pub color: ColorF,
|
||||||
|
|
||||||
/// The line segment style.
|
/// The line segment style.
|
||||||
#[ignore_malloc_size_of = "enum type in webrender"]
|
pub style: LineStyle,
|
||||||
pub style: webrender_api::LineStyle,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Paints a box shadow per CSS-BACKGROUNDS.
|
/// Paints a box shadow per CSS-BACKGROUNDS.
|
||||||
|
@ -945,25 +937,24 @@ pub struct BoxShadowDisplayItem {
|
||||||
pub base: BaseDisplayItem,
|
pub base: BaseDisplayItem,
|
||||||
|
|
||||||
/// The dimensions of the box that we're placing a shadow around.
|
/// The dimensions of the box that we're placing a shadow around.
|
||||||
pub box_bounds: Rect<Au>,
|
pub box_bounds: LayoutRect,
|
||||||
|
|
||||||
/// The offset of this shadow from the box.
|
/// The offset of this shadow from the box.
|
||||||
pub offset: Vector2D<Au>,
|
pub offset: LayoutVector2D,
|
||||||
|
|
||||||
/// The color of this shadow.
|
/// The color of this shadow.
|
||||||
pub color: ColorF,
|
pub color: ColorF,
|
||||||
|
|
||||||
/// The blur radius for this shadow.
|
/// The blur radius for this shadow.
|
||||||
pub blur_radius: Au,
|
pub blur_radius: f32,
|
||||||
|
|
||||||
/// The spread radius of this shadow.
|
/// The spread radius of this shadow.
|
||||||
pub spread_radius: Au,
|
pub spread_radius: f32,
|
||||||
|
|
||||||
/// The border radius of this shadow.
|
/// The border radius of this shadow.
|
||||||
pub border_radius: BorderRadii<Au>,
|
pub border_radius: BorderRadii<Au>,
|
||||||
|
|
||||||
/// How we should clip the result.
|
/// How we should clip the result.
|
||||||
#[ignore_malloc_size_of = "enum type in webrender"]
|
|
||||||
pub clip_mode: BoxShadowClipMode,
|
pub clip_mode: BoxShadowClipMode,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -974,13 +965,13 @@ pub struct PushTextShadowDisplayItem {
|
||||||
pub base: BaseDisplayItem,
|
pub base: BaseDisplayItem,
|
||||||
|
|
||||||
/// The offset of this shadow from the text.
|
/// The offset of this shadow from the text.
|
||||||
pub offset: Vector2D<Au>,
|
pub offset: LayoutVector2D,
|
||||||
|
|
||||||
/// The color of this shadow.
|
/// The color of this shadow.
|
||||||
pub color: ColorF,
|
pub color: ColorF,
|
||||||
|
|
||||||
/// The blur radius for this shadow.
|
/// The blur radius for this shadow.
|
||||||
pub blur_radius: Au,
|
pub blur_radius: f32,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Defines a text shadow that affects all items until the next PopTextShadow.
|
/// Defines a text shadow that affects all items until the next PopTextShadow.
|
||||||
|
@ -1118,7 +1109,7 @@ pub struct WebRenderImageInfo {
|
||||||
pub width: u32,
|
pub width: u32,
|
||||||
pub height: u32,
|
pub height: u32,
|
||||||
pub format: PixelFormat,
|
pub format: PixelFormat,
|
||||||
pub key: Option<webrender_api::ImageKey>,
|
pub key: Option<ImageKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WebRenderImageInfo {
|
impl WebRenderImageInfo {
|
||||||
|
@ -1152,28 +1143,3 @@ impl SimpleMatrixDetection for Transform3D<f32> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait ToPointF {
|
|
||||||
fn to_pointf(&self) -> webrender_api::LayoutPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToPointF for Point2D<Au> {
|
|
||||||
fn to_pointf(&self) -> webrender_api::LayoutPoint {
|
|
||||||
webrender_api::LayoutPoint::new(self.x.to_f32_px(), self.y.to_f32_px())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
trait ToRectF {
|
|
||||||
fn to_rectf(&self) -> webrender_api::LayoutRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToRectF for Rect<Au> {
|
|
||||||
fn to_rectf(&self) -> webrender_api::LayoutRect {
|
|
||||||
let x = self.origin.x.to_f32_px();
|
|
||||||
let y = self.origin.y.to_f32_px();
|
|
||||||
let w = self.size.width.to_f32_px();
|
|
||||||
let h = self.size.height.to_f32_px();
|
|
||||||
let point = webrender_api::LayoutPoint::new(x, y);
|
|
||||||
let size = webrender_api::LayoutSize::new(w, h);
|
|
||||||
webrender_api::LayoutRect::new(point, size)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ use style::values::generics::image::EndingShape as GenericEndingShape;
|
||||||
use style::values::generics::image::GradientItem as GenericGradientItem;
|
use style::values::generics::image::GradientItem as GenericGradientItem;
|
||||||
use style::values::specified::background::RepeatKeyword;
|
use style::values::specified::background::RepeatKeyword;
|
||||||
use style::values::specified::position::{X, Y};
|
use style::values::specified::position::{X, Y};
|
||||||
use webrender_api::GradientStop;
|
use webrender_api::{ExtendMode, GradientStop};
|
||||||
|
|
||||||
/// A helper data structure for gradients.
|
/// A helper data structure for gradients.
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
|
@ -370,6 +370,14 @@ fn convert_gradient_stops(gradient_items: &[GradientItem], total_length: Au) ->
|
||||||
stops
|
stops
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn as_gradient_extend_mode(repeating: bool) -> ExtendMode {
|
||||||
|
if repeating {
|
||||||
|
ExtendMode::Repeat
|
||||||
|
} else {
|
||||||
|
ExtendMode::Clamp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn convert_linear_gradient(
|
pub fn convert_linear_gradient(
|
||||||
size: Size2D<Au>,
|
size: Size2D<Au>,
|
||||||
stops: &[GradientItem],
|
stops: &[GradientItem],
|
||||||
|
@ -431,10 +439,10 @@ pub fn convert_linear_gradient(
|
||||||
let center = Point2D::new(size.width / 2, size.height / 2);
|
let center = Point2D::new(size.width / 2, size.height / 2);
|
||||||
|
|
||||||
display_list::Gradient {
|
display_list::Gradient {
|
||||||
start_point: center - delta,
|
start_point: (center - delta).to_layout(),
|
||||||
end_point: center + delta,
|
end_point: (center + delta).to_layout(),
|
||||||
stops: stops,
|
stops: stops,
|
||||||
repeating: repeating,
|
extend_mode: as_gradient_extend_mode(repeating),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,10 +481,10 @@ pub fn convert_radial_gradient(
|
||||||
}
|
}
|
||||||
|
|
||||||
display_list::RadialGradient {
|
display_list::RadialGradient {
|
||||||
center: center,
|
center: center.to_layout(),
|
||||||
radius: radius,
|
radius: radius.to_layout(),
|
||||||
stops: stops,
|
stops: stops,
|
||||||
repeating: repeating,
|
extend_mode: as_gradient_extend_mode(repeating),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ use gfx::display_list::{BorderRadii, BoxShadowDisplayItem, ClipScrollNode};
|
||||||
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingAndScrolling};
|
||||||
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
use gfx::display_list::{ClippingRegion, DisplayItem, DisplayItemMetadata, DisplayList};
|
||||||
use gfx::display_list::{DisplayListSection, GradientDisplayItem, IframeDisplayItem, ImageBorder};
|
use gfx::display_list::{DisplayListSection, GradientDisplayItem, IframeDisplayItem, ImageBorder};
|
||||||
use gfx::display_list::{ImageDisplayItem, LineDisplayItem, NormalBorder, OpaqueNode};
|
use gfx::display_list::{ImageDisplayItem, LineDisplayItem, OpaqueNode};
|
||||||
use gfx::display_list::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
|
use gfx::display_list::{PopAllTextShadowsDisplayItem, PushTextShadowDisplayItem};
|
||||||
use gfx::display_list::{RadialGradientDisplayItem, SolidColorDisplayItem, StackingContext};
|
use gfx::display_list::{RadialGradientDisplayItem, SolidColorDisplayItem, StackingContext};
|
||||||
use gfx::display_list::{StackingContextType, StickyFrameData, TextDisplayItem, TextOrientation};
|
use gfx::display_list::{StackingContextType, StickyFrameData, TextDisplayItem, TextOrientation};
|
||||||
|
@ -56,14 +56,12 @@ use style::computed_values::background_clip::single_value::T as BackgroundClip;
|
||||||
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
use style::computed_values::background_origin::single_value::T as BackgroundOrigin;
|
||||||
use style::computed_values::border_style::T as BorderStyle;
|
use style::computed_values::border_style::T as BorderStyle;
|
||||||
use style::computed_values::cursor;
|
use style::computed_values::cursor;
|
||||||
use style::computed_values::image_rendering::T as ImageRendering;
|
|
||||||
use style::computed_values::overflow_x::T as StyleOverflow;
|
use style::computed_values::overflow_x::T as StyleOverflow;
|
||||||
use style::computed_values::pointer_events::T as PointerEvents;
|
use style::computed_values::pointer_events::T as PointerEvents;
|
||||||
use style::computed_values::position::T as StylePosition;
|
use style::computed_values::position::T as StylePosition;
|
||||||
use style::computed_values::visibility::T as Visibility;
|
use style::computed_values::visibility::T as Visibility;
|
||||||
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
use style::logical_geometry::{LogicalMargin, LogicalPoint, LogicalRect, LogicalSize, WritingMode};
|
||||||
use style::properties::ComputedValues;
|
use style::properties::ComputedValues;
|
||||||
use style::properties::longhands::border_image_repeat::computed_value::RepeatKeyword;
|
|
||||||
use style::properties::style_structs;
|
use style::properties::style_structs;
|
||||||
use style::servo::restyle_damage::ServoRestyleDamage;
|
use style::servo::restyle_damage::ServoRestyleDamage;
|
||||||
use style::values::{Either, RGBA};
|
use style::values::{Either, RGBA};
|
||||||
|
@ -76,8 +74,9 @@ use style_traits::CSSPixel;
|
||||||
use style_traits::ToCss;
|
use style_traits::ToCss;
|
||||||
use style_traits::cursor::Cursor;
|
use style_traits::cursor::Cursor;
|
||||||
use table_cell::CollapsedBordersForCell;
|
use table_cell::CollapsedBordersForCell;
|
||||||
use webrender_api::{BoxShadowClipMode, ClipId, ClipMode, ColorF, ComplexClipRegion, LineStyle};
|
use webrender_api::{self, BoxShadowClipMode, ClipId, ClipMode, ColorF, ComplexClipRegion};
|
||||||
use webrender_api::{LocalClip, RepeatMode, ScrollPolicy, ScrollSensitivity, StickyOffsetBounds};
|
use webrender_api::{ImageRendering, LayoutSize, LayoutVector2D, LineStyle};
|
||||||
|
use webrender_api::{LocalClip, NormalBorder, ScrollPolicy, ScrollSensitivity, StickyOffsetBounds};
|
||||||
|
|
||||||
trait ResolvePercentage {
|
trait ResolvePercentage {
|
||||||
fn resolve(&self, length: u32) -> u32;
|
fn resolve(&self, length: u32) -> u32;
|
||||||
|
@ -92,15 +91,6 @@ impl ResolvePercentage for NumberOrPercentage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn convert_repeat_mode(from: RepeatKeyword) -> RepeatMode {
|
|
||||||
match from {
|
|
||||||
RepeatKeyword::Stretch => RepeatMode::Stretch,
|
|
||||||
RepeatKeyword::Repeat => RepeatMode::Repeat,
|
|
||||||
RepeatKeyword::Round => RepeatMode::Round,
|
|
||||||
RepeatKeyword::Space => RepeatMode::Space,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn establishes_containing_block_for_absolute(
|
fn establishes_containing_block_for_absolute(
|
||||||
flags: StackingContextCollectionFlags,
|
flags: StackingContextCollectionFlags,
|
||||||
positioning: StylePosition,
|
positioning: StylePosition,
|
||||||
|
@ -825,6 +815,17 @@ fn calculate_inner_bounds(mut bounds: Rect<Au>, offsets: SideOffsets2D<Au>) -> R
|
||||||
bounds
|
bounds
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn simple_normal_border(color: ColorF, style: webrender_api::BorderStyle) -> NormalBorder {
|
||||||
|
let side = webrender_api::BorderSide { color, style };
|
||||||
|
NormalBorder {
|
||||||
|
left: side,
|
||||||
|
right: side,
|
||||||
|
top: side,
|
||||||
|
bottom: side,
|
||||||
|
radius: webrender_api::BorderRadius::zero(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn calculate_inner_border_radii(
|
fn calculate_inner_border_radii(
|
||||||
mut radii: BorderRadii<Au>,
|
mut radii: BorderRadii<Au>,
|
||||||
offsets: SideOffsets2D<Au>,
|
offsets: SideOffsets2D<Au>,
|
||||||
|
@ -1129,9 +1130,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
base: base,
|
base: base,
|
||||||
webrender_image: webrender_image,
|
webrender_image: webrender_image,
|
||||||
image_data: None,
|
image_data: None,
|
||||||
stretch_size: placement.tile_size,
|
stretch_size: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing,
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
image_rendering: style.get_inheritedbox().image_rendering.clone(),
|
image_rendering: style.get_inheritedbox().image_rendering.to_layout(),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1227,8 +1228,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
DisplayItem::Gradient(Box::new(GradientDisplayItem {
|
DisplayItem::Gradient(Box::new(GradientDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
gradient: gradient,
|
gradient: gradient,
|
||||||
tile: placement.tile_size,
|
tile: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing,
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
GradientKind::Radial(shape, center, _angle) => {
|
GradientKind::Radial(shape, center, _angle) => {
|
||||||
|
@ -1242,8 +1243,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
DisplayItem::RadialGradient(Box::new(RadialGradientDisplayItem {
|
DisplayItem::RadialGradient(Box::new(RadialGradientDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
gradient: gradient,
|
gradient: gradient,
|
||||||
tile: placement.tile_size,
|
tile: placement.tile_size.to_layout(),
|
||||||
tile_spacing: placement.tile_spacing,
|
tile_spacing: placement.tile_spacing.to_layout(),
|
||||||
}))
|
}))
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1279,18 +1280,18 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
let border_radius = build_border_radius(absolute_bounds, style.get_border());
|
let border_radius = build_border_radius(absolute_bounds, style.get_border());
|
||||||
state.add_display_item(DisplayItem::BoxShadow(Box::new(BoxShadowDisplayItem {
|
state.add_display_item(DisplayItem::BoxShadow(Box::new(BoxShadowDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
box_bounds: *absolute_bounds,
|
box_bounds: absolute_bounds.to_layout(),
|
||||||
color: box_shadow
|
color: box_shadow
|
||||||
.base
|
.base
|
||||||
.color
|
.color
|
||||||
.unwrap_or(style.get_color().color)
|
.unwrap_or(style.get_color().color)
|
||||||
.to_layout(),
|
.to_layout(),
|
||||||
offset: Vector2D::new(
|
offset: LayoutVector2D::new(
|
||||||
Au::from(box_shadow.base.horizontal),
|
box_shadow.base.horizontal.px(),
|
||||||
Au::from(box_shadow.base.vertical),
|
box_shadow.base.vertical.px(),
|
||||||
),
|
),
|
||||||
blur_radius: Au::from(box_shadow.base.blur),
|
blur_radius: box_shadow.base.blur.px(),
|
||||||
spread_radius: Au::from(box_shadow.spread),
|
spread_radius: box_shadow.spread.px(),
|
||||||
border_radius,
|
border_radius,
|
||||||
clip_mode: if box_shadow.inset {
|
clip_mode: if box_shadow.inset {
|
||||||
BoxShadowClipMode::Inset
|
BoxShadowClipMode::Inset
|
||||||
|
@ -1373,20 +1374,31 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
display_list_section,
|
display_list_section,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
let border_radius = build_border_radius(&bounds, border_style_struct);
|
||||||
|
|
||||||
match border_style_struct.border_image_source {
|
match border_style_struct.border_image_source {
|
||||||
Either::First(_) => {
|
Either::First(_) => {
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
border_widths: border.to_physical(style.writing_mode),
|
border_widths: border.to_physical(style.writing_mode),
|
||||||
details: BorderDetails::Normal(NormalBorder {
|
details: BorderDetails::Normal(NormalBorder {
|
||||||
color: SideOffsets2D::new(
|
left: webrender_api::BorderSide {
|
||||||
colors.top.to_layout(),
|
color: colors.left.to_layout(),
|
||||||
colors.right.to_layout(),
|
style: border_style.left.to_layout(),
|
||||||
colors.bottom.to_layout(),
|
},
|
||||||
colors.left.to_layout(),
|
right: webrender_api::BorderSide {
|
||||||
),
|
color: colors.right.to_layout(),
|
||||||
style: border_style,
|
style: border_style.right.to_layout(),
|
||||||
radius: build_border_radius(&bounds, border_style_struct),
|
},
|
||||||
|
top: webrender_api::BorderSide {
|
||||||
|
color: colors.top.to_layout(),
|
||||||
|
style: border_style.top.to_layout(),
|
||||||
|
},
|
||||||
|
bottom: webrender_api::BorderSide {
|
||||||
|
color: colors.bottom.to_layout(),
|
||||||
|
style: border_style.bottom.to_layout(),
|
||||||
|
},
|
||||||
|
radius: border_radius.to_border_radius(),
|
||||||
}),
|
}),
|
||||||
})));
|
})));
|
||||||
},
|
},
|
||||||
|
@ -1432,6 +1444,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
self.get_webrender_image_for_paint_worklet(state, style, paint_worklet, size);
|
self.get_webrender_image_for_paint_worklet(state, style, paint_worklet, size);
|
||||||
if let Some(webrender_image) = webrender_image {
|
if let Some(webrender_image) = webrender_image {
|
||||||
let corners = &border_style_struct.border_image_slice.offsets;
|
let corners = &border_style_struct.border_image_slice.offsets;
|
||||||
|
let border_image_repeat = &border_style_struct.border_image_repeat;
|
||||||
|
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
|
@ -1447,12 +1460,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
),
|
),
|
||||||
// TODO(gw): Support border-image-outset
|
// TODO(gw): Support border-image-outset
|
||||||
outset: SideOffsets2D::zero(),
|
outset: SideOffsets2D::zero(),
|
||||||
repeat_horizontal: convert_repeat_mode(
|
repeat_horizontal: border_image_repeat.0.to_layout(),
|
||||||
border_style_struct.border_image_repeat.0,
|
repeat_vertical: border_image_repeat.1.to_layout(),
|
||||||
),
|
|
||||||
repeat_vertical: convert_repeat_mode(
|
|
||||||
border_style_struct.border_image_repeat.1,
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
@ -1472,6 +1481,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
);
|
);
|
||||||
if let Some(webrender_image) = webrender_image {
|
if let Some(webrender_image) = webrender_image {
|
||||||
let corners = &border_style_struct.border_image_slice.offsets;
|
let corners = &border_style_struct.border_image_slice.offsets;
|
||||||
|
let border_image_repeat = &border_style_struct.border_image_repeat;
|
||||||
|
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
|
@ -1487,12 +1497,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
),
|
),
|
||||||
// TODO(gw): Support border-image-outset
|
// TODO(gw): Support border-image-outset
|
||||||
outset: SideOffsets2D::zero(),
|
outset: SideOffsets2D::zero(),
|
||||||
repeat_horizontal: convert_repeat_mode(
|
repeat_horizontal: border_image_repeat.0.to_layout(),
|
||||||
border_style_struct.border_image_repeat.0,
|
repeat_vertical: border_image_repeat.1.to_layout(),
|
||||||
),
|
|
||||||
repeat_vertical: convert_repeat_mode(
|
|
||||||
border_style_struct.border_image_repeat.1,
|
|
||||||
),
|
|
||||||
}),
|
}),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
@ -1544,11 +1550,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
border_widths: SideOffsets2D::new_all_same(width),
|
border_widths: SideOffsets2D::new_all_same(width),
|
||||||
details: BorderDetails::Normal(NormalBorder {
|
details: BorderDetails::Normal(simple_normal_border(color, outline_style.to_layout())),
|
||||||
color: SideOffsets2D::new_all_same(color),
|
|
||||||
style: SideOffsets2D::new_all_same(outline_style),
|
|
||||||
radius: Default::default(),
|
|
||||||
}),
|
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1575,11 +1577,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
||||||
details: BorderDetails::Normal(NormalBorder {
|
details: BorderDetails::Normal(simple_normal_border(
|
||||||
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
|
ColorF::rgb(0, 0, 200),
|
||||||
style: SideOffsets2D::new_all_same(BorderStyle::Solid),
|
webrender_api::BorderStyle::Solid,
|
||||||
radius: Default::default(),
|
)),
|
||||||
}),
|
|
||||||
})));
|
})));
|
||||||
|
|
||||||
// Draw a rectangle representing the baselines.
|
// Draw a rectangle representing the baselines.
|
||||||
|
@ -1623,11 +1624,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
border_widths: SideOffsets2D::new_all_same(Au::from_px(1)),
|
||||||
details: BorderDetails::Normal(NormalBorder {
|
details: BorderDetails::Normal(simple_normal_border(
|
||||||
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
|
ColorF::rgb(0, 0, 200),
|
||||||
style: SideOffsets2D::new_all_same(BorderStyle::Solid),
|
webrender_api::BorderStyle::Solid,
|
||||||
radius: Default::default(),
|
)),
|
||||||
}),
|
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1996,9 +1996,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
base: base,
|
base: base,
|
||||||
webrender_image: WebRenderImageInfo::from_image(image),
|
webrender_image: WebRenderImageInfo::from_image(image),
|
||||||
image_data: Some(Arc::new(image.bytes.clone())),
|
image_data: Some(Arc::new(image.bytes.clone())),
|
||||||
stretch_size: stacking_relative_content_box.size,
|
stretch_size: stacking_relative_content_box.size.to_layout(),
|
||||||
tile_spacing: Size2D::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
image_rendering: self.style.get_inheritedbox().image_rendering.clone(),
|
image_rendering: self.style.get_inheritedbox().image_rendering.to_layout(),
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -2037,8 +2037,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
key: Some(image_key),
|
key: Some(image_key),
|
||||||
},
|
},
|
||||||
image_data: None,
|
image_data: None,
|
||||||
stretch_size: stacking_relative_content_box.size,
|
stretch_size: stacking_relative_content_box.size.to_layout(),
|
||||||
tile_spacing: Size2D::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
image_rendering: ImageRendering::Auto,
|
image_rendering: ImageRendering::Auto,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -2160,8 +2160,8 @@ impl FragmentDisplayListBuilding for Fragment {
|
||||||
state.add_display_item(DisplayItem::PushTextShadow(Box::new(
|
state.add_display_item(DisplayItem::PushTextShadow(Box::new(
|
||||||
PushTextShadowDisplayItem {
|
PushTextShadowDisplayItem {
|
||||||
base: base.clone(),
|
base: base.clone(),
|
||||||
blur_radius: Au::from(shadow.blur),
|
blur_radius: shadow.blur.px(),
|
||||||
offset: Vector2D::new(Au::from(shadow.horizontal), Au::from(shadow.vertical)),
|
offset: LayoutVector2D::new(shadow.horizontal.px(), shadow.vertical.px()),
|
||||||
color: shadow
|
color: shadow
|
||||||
.color
|
.color
|
||||||
.unwrap_or(self.style().get_color().color)
|
.unwrap_or(self.style().get_color().color)
|
||||||
|
@ -3141,11 +3141,10 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
|
||||||
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
state.add_display_item(DisplayItem::Border(Box::new(BorderDisplayItem {
|
||||||
base: base,
|
base: base,
|
||||||
border_widths: SideOffsets2D::new_all_same(Au::from_px(2)),
|
border_widths: SideOffsets2D::new_all_same(Au::from_px(2)),
|
||||||
details: BorderDetails::Normal(NormalBorder {
|
details: BorderDetails::Normal(simple_normal_border(
|
||||||
color: SideOffsets2D::new_all_same(color),
|
color,
|
||||||
style: SideOffsets2D::new_all_same(BorderStyle::Solid),
|
webrender_api::BorderStyle::Solid,
|
||||||
radius: BorderRadii::all_same(Au(0)),
|
)),
|
||||||
}),
|
|
||||||
})));
|
})));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ use euclid::{Point2D, Rect, SideOffsets2D, Size2D, Vector2D};
|
||||||
use style::computed_values::image_rendering::T as ImageRendering;
|
use style::computed_values::image_rendering::T as ImageRendering;
|
||||||
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
use style::computed_values::mix_blend_mode::T as MixBlendMode;
|
||||||
use style::computed_values::transform_style::T as TransformStyle;
|
use style::computed_values::transform_style::T as TransformStyle;
|
||||||
|
use style::properties::longhands::border_image_repeat::RepeatKeyword;
|
||||||
use style::values::RGBA;
|
use style::values::RGBA;
|
||||||
use style::values::computed::{BorderStyle, Filter};
|
use style::values::computed::{BorderStyle, Filter};
|
||||||
use style::values::generics::effects::Filter as GenericFilter;
|
use style::values::generics::effects::Filter as GenericFilter;
|
||||||
|
@ -150,3 +151,15 @@ impl ToLayout for Vector2D<Au> {
|
||||||
wr::LayoutVector2D::new(self.x.to_f32_px(), self.y.to_f32_px())
|
wr::LayoutVector2D::new(self.x.to_f32_px(), self.y.to_f32_px())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ToLayout for RepeatKeyword {
|
||||||
|
type Type = wr::RepeatMode;
|
||||||
|
fn to_layout(&self) -> Self::Type {
|
||||||
|
match *self {
|
||||||
|
RepeatKeyword::Stretch => wr::RepeatMode::Stretch,
|
||||||
|
RepeatKeyword::Repeat => wr::RepeatMode::Repeat,
|
||||||
|
RepeatKeyword::Round => wr::RepeatMode::Round,
|
||||||
|
RepeatKeyword::Space => wr::RepeatMode::Space,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingRegion,
|
||||||
use gfx::display_list::{DisplayList, StackingContextType};
|
use gfx::display_list::{DisplayList, StackingContextType};
|
||||||
use msg::constellation_msg::PipelineId;
|
use msg::constellation_msg::PipelineId;
|
||||||
use webrender_api::{self, ClipAndScrollInfo, ClipId, ClipMode, ComplexClipRegion};
|
use webrender_api::{self, ClipAndScrollInfo, ClipId, ClipMode, ComplexClipRegion};
|
||||||
use webrender_api::{DisplayListBuilder, ExtendMode, LayoutTransform};
|
use webrender_api::{DisplayListBuilder, LayoutTransform};
|
||||||
|
|
||||||
pub trait WebRenderDisplayListConverter {
|
pub trait WebRenderDisplayListConverter {
|
||||||
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
|
fn convert_to_webrender(&self, pipeline_id: PipelineId) -> DisplayListBuilder;
|
||||||
|
@ -160,12 +160,12 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
},
|
},
|
||||||
DisplayItem::Image(ref item) => {
|
DisplayItem::Image(ref item) => {
|
||||||
if let Some(id) = item.webrender_image.key {
|
if let Some(id) = item.webrender_image.key {
|
||||||
if item.stretch_size.width > Au(0) && item.stretch_size.height > Au(0) {
|
if item.stretch_size.width > 0.0 && item.stretch_size.height > 0.0 {
|
||||||
builder.push_image(
|
builder.push_image(
|
||||||
&self.prim_info(),
|
&self.prim_info(),
|
||||||
item.stretch_size.to_layout(),
|
item.stretch_size,
|
||||||
item.tile_spacing.to_layout(),
|
item.tile_spacing,
|
||||||
item.image_rendering.to_layout(),
|
item.image_rendering,
|
||||||
webrender_api::AlphaType::PremultipliedAlpha,
|
webrender_api::AlphaType::PremultipliedAlpha,
|
||||||
id,
|
id,
|
||||||
);
|
);
|
||||||
|
@ -177,30 +177,7 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
|
|
||||||
let details = match item.details {
|
let details = match item.details {
|
||||||
BorderDetails::Normal(ref border) => {
|
BorderDetails::Normal(ref border) => {
|
||||||
let left = webrender_api::BorderSide {
|
webrender_api::BorderDetails::Normal(*border)
|
||||||
color: border.color.left,
|
|
||||||
style: border.style.left.to_layout(),
|
|
||||||
};
|
|
||||||
let top = webrender_api::BorderSide {
|
|
||||||
color: border.color.top,
|
|
||||||
style: border.style.top.to_layout(),
|
|
||||||
};
|
|
||||||
let right = webrender_api::BorderSide {
|
|
||||||
color: border.color.right,
|
|
||||||
style: border.style.right.to_layout(),
|
|
||||||
};
|
|
||||||
let bottom = webrender_api::BorderSide {
|
|
||||||
color: border.color.bottom,
|
|
||||||
style: border.style.bottom.to_layout(),
|
|
||||||
};
|
|
||||||
let radius = border.radius.to_border_radius();
|
|
||||||
webrender_api::BorderDetails::Normal(webrender_api::NormalBorder {
|
|
||||||
left: left,
|
|
||||||
top: top,
|
|
||||||
right: right,
|
|
||||||
bottom: bottom,
|
|
||||||
radius: radius,
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
BorderDetails::Image(ref image) => match image.image.key {
|
BorderDetails::Image(ref image) => match image.image.key {
|
||||||
None => return,
|
None => return,
|
||||||
|
@ -220,34 +197,24 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BorderDetails::Gradient(ref gradient) => {
|
BorderDetails::Gradient(ref gradient) => {
|
||||||
let extend_mode = if gradient.gradient.repeating {
|
|
||||||
ExtendMode::Repeat
|
|
||||||
} else {
|
|
||||||
ExtendMode::Clamp
|
|
||||||
};
|
|
||||||
webrender_api::BorderDetails::Gradient(webrender_api::GradientBorder {
|
webrender_api::BorderDetails::Gradient(webrender_api::GradientBorder {
|
||||||
gradient: builder.create_gradient(
|
gradient: builder.create_gradient(
|
||||||
gradient.gradient.start_point.to_layout(),
|
gradient.gradient.start_point,
|
||||||
gradient.gradient.end_point.to_layout(),
|
gradient.gradient.end_point,
|
||||||
gradient.gradient.stops.clone(),
|
gradient.gradient.stops.clone(),
|
||||||
extend_mode,
|
gradient.gradient.extend_mode,
|
||||||
),
|
),
|
||||||
outset: gradient.outset,
|
outset: gradient.outset,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
BorderDetails::RadialGradient(ref gradient) => {
|
BorderDetails::RadialGradient(ref gradient) => {
|
||||||
let extend_mode = if gradient.gradient.repeating {
|
|
||||||
ExtendMode::Repeat
|
|
||||||
} else {
|
|
||||||
ExtendMode::Clamp
|
|
||||||
};
|
|
||||||
webrender_api::BorderDetails::RadialGradient(
|
webrender_api::BorderDetails::RadialGradient(
|
||||||
webrender_api::RadialGradientBorder {
|
webrender_api::RadialGradientBorder {
|
||||||
gradient: builder.create_radial_gradient(
|
gradient: builder.create_radial_gradient(
|
||||||
gradient.gradient.center.to_layout(),
|
gradient.gradient.center,
|
||||||
gradient.gradient.radius.to_layout(),
|
gradient.gradient.radius,
|
||||||
gradient.gradient.stops.clone(),
|
gradient.gradient.stops.clone(),
|
||||||
extend_mode,
|
gradient.gradient.extend_mode,
|
||||||
),
|
),
|
||||||
outset: gradient.outset,
|
outset: gradient.outset,
|
||||||
},
|
},
|
||||||
|
@ -258,45 +225,26 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
builder.push_border(&self.prim_info(), widths, details);
|
builder.push_border(&self.prim_info(), widths, details);
|
||||||
},
|
},
|
||||||
DisplayItem::Gradient(ref item) => {
|
DisplayItem::Gradient(ref item) => {
|
||||||
let start_point = item.gradient.start_point.to_layout();
|
|
||||||
let end_point = item.gradient.end_point.to_layout();
|
|
||||||
let extend_mode = if item.gradient.repeating {
|
|
||||||
ExtendMode::Repeat
|
|
||||||
} else {
|
|
||||||
ExtendMode::Clamp
|
|
||||||
};
|
|
||||||
let gradient = builder.create_gradient(
|
let gradient = builder.create_gradient(
|
||||||
start_point,
|
item.gradient.start_point,
|
||||||
end_point,
|
item.gradient.end_point,
|
||||||
item.gradient.stops.clone(),
|
item.gradient.stops.clone(),
|
||||||
extend_mode,
|
item.gradient.extend_mode,
|
||||||
);
|
|
||||||
builder.push_gradient(
|
|
||||||
&self.prim_info(),
|
|
||||||
gradient,
|
|
||||||
item.tile.to_layout(),
|
|
||||||
item.tile_spacing.to_layout(),
|
|
||||||
);
|
);
|
||||||
|
builder.push_gradient(&self.prim_info(), gradient, item.tile, item.tile_spacing);
|
||||||
},
|
},
|
||||||
DisplayItem::RadialGradient(ref item) => {
|
DisplayItem::RadialGradient(ref item) => {
|
||||||
let center = item.gradient.center.to_layout();
|
|
||||||
let radius = item.gradient.radius.to_layout();
|
|
||||||
let extend_mode = if item.gradient.repeating {
|
|
||||||
ExtendMode::Repeat
|
|
||||||
} else {
|
|
||||||
ExtendMode::Clamp
|
|
||||||
};
|
|
||||||
let gradient = builder.create_radial_gradient(
|
let gradient = builder.create_radial_gradient(
|
||||||
center,
|
item.gradient.center,
|
||||||
radius,
|
item.gradient.radius,
|
||||||
item.gradient.stops.clone(),
|
item.gradient.stops.clone(),
|
||||||
extend_mode,
|
item.gradient.extend_mode,
|
||||||
);
|
);
|
||||||
builder.push_radial_gradient(
|
builder.push_radial_gradient(
|
||||||
&self.prim_info(),
|
&self.prim_info(),
|
||||||
gradient,
|
gradient,
|
||||||
item.tile.to_layout(),
|
item.tile,
|
||||||
item.tile_spacing.to_layout(),
|
item.tile_spacing,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
DisplayItem::Line(ref item) => {
|
DisplayItem::Line(ref item) => {
|
||||||
|
@ -310,14 +258,13 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
DisplayItem::BoxShadow(ref item) => {
|
DisplayItem::BoxShadow(ref item) => {
|
||||||
let box_bounds = item.box_bounds.to_layout();
|
|
||||||
builder.push_box_shadow(
|
builder.push_box_shadow(
|
||||||
&self.prim_info(),
|
&self.prim_info(),
|
||||||
box_bounds,
|
item.box_bounds,
|
||||||
item.offset.to_layout(),
|
item.offset,
|
||||||
item.color,
|
item.color,
|
||||||
item.blur_radius.to_f32_px(),
|
item.blur_radius,
|
||||||
item.spread_radius.to_f32_px(),
|
item.spread_radius,
|
||||||
item.border_radius.to_border_radius(),
|
item.border_radius.to_border_radius(),
|
||||||
item.clip_mode,
|
item.clip_mode,
|
||||||
);
|
);
|
||||||
|
@ -326,8 +273,8 @@ impl WebRenderDisplayItemConverter for DisplayItem {
|
||||||
builder.push_shadow(
|
builder.push_shadow(
|
||||||
&self.prim_info(),
|
&self.prim_info(),
|
||||||
webrender_api::Shadow {
|
webrender_api::Shadow {
|
||||||
blur_radius: item.blur_radius.to_f32_px(),
|
blur_radius: item.blur_radius,
|
||||||
offset: item.offset.to_layout(),
|
offset: item.offset,
|
||||||
color: item.color,
|
color: item.color,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -715,6 +715,10 @@ impl MallocSizeOf for url::Host {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::BorderStyle);
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::BoxShadowClipMode);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::ClipAndScrollInfo);
|
malloc_size_of_is_0!(webrender_api::ClipAndScrollInfo);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
@ -722,14 +726,22 @@ malloc_size_of_is_0!(webrender_api::ClipId);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::ColorF);
|
malloc_size_of_is_0!(webrender_api::ColorF);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::ExtendMode);
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::GradientStop);
|
malloc_size_of_is_0!(webrender_api::GradientStop);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::ImageKey);
|
malloc_size_of_is_0!(webrender_api::ImageKey);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::ImageRendering);
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::LineStyle);
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::LocalClip);
|
malloc_size_of_is_0!(webrender_api::LocalClip);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::MixBlendMode);
|
malloc_size_of_is_0!(webrender_api::MixBlendMode);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
|
malloc_size_of_is_0!(webrender_api::NormalBorder);
|
||||||
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::RepeatMode);
|
malloc_size_of_is_0!(webrender_api::RepeatMode);
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
malloc_size_of_is_0!(webrender_api::ScrollPolicy);
|
malloc_size_of_is_0!(webrender_api::ScrollPolicy);
|
||||||
|
|
|
@ -10,7 +10,6 @@ path = "lib.rs"
|
||||||
doctest = false
|
doctest = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
euclid = "0.16"
|
|
||||||
gfx = {path = "../../../components/gfx"}
|
gfx = {path = "../../../components/gfx"}
|
||||||
gfx_traits = {path = "../../../components/gfx_traits"}
|
gfx_traits = {path = "../../../components/gfx_traits"}
|
||||||
ipc-channel = "0.9"
|
ipc-channel = "0.9"
|
||||||
|
@ -19,5 +18,5 @@ msg = {path = "../../../components/msg"}
|
||||||
net_traits = {path = "../../../components/net_traits"}
|
net_traits = {path = "../../../components/net_traits"}
|
||||||
profile_traits = {path = "../../../components/profile_traits"}
|
profile_traits = {path = "../../../components/profile_traits"}
|
||||||
servo_url = {path = "../../../components/url"}
|
servo_url = {path = "../../../components/url"}
|
||||||
style = {path = "../../../components/style"}
|
|
||||||
time = "0.1.12"
|
time = "0.1.12"
|
||||||
|
webrender_api = {git = "https://github.com/servo/webrender"}
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#![cfg(test)]
|
#![cfg(test)]
|
||||||
|
|
||||||
extern crate euclid;
|
|
||||||
extern crate gfx;
|
extern crate gfx;
|
||||||
extern crate gfx_traits;
|
extern crate gfx_traits;
|
||||||
extern crate ipc_channel;
|
extern crate ipc_channel;
|
||||||
|
@ -13,8 +12,8 @@ extern crate msg;
|
||||||
extern crate net_traits;
|
extern crate net_traits;
|
||||||
extern crate profile_traits;
|
extern crate profile_traits;
|
||||||
extern crate servo_url;
|
extern crate servo_url;
|
||||||
extern crate style;
|
|
||||||
extern crate time;
|
extern crate time;
|
||||||
|
extern crate webrender_api;
|
||||||
|
|
||||||
mod interactive_time;
|
mod interactive_time;
|
||||||
mod paint_time;
|
mod paint_time;
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
use euclid::Size2D;
|
|
||||||
use gfx::display_list::{BaseDisplayItem, WebRenderImageInfo};
|
use gfx::display_list::{BaseDisplayItem, WebRenderImageInfo};
|
||||||
use gfx::display_list::{DisplayItem, DisplayList, ImageDisplayItem};
|
use gfx::display_list::{DisplayItem, DisplayList, ImageDisplayItem};
|
||||||
use gfx_traits::Epoch;
|
use gfx_traits::Epoch;
|
||||||
|
@ -12,8 +11,8 @@ use msg::constellation_msg::TEST_PIPELINE_ID;
|
||||||
use net_traits::image::base::PixelFormat;
|
use net_traits::image::base::PixelFormat;
|
||||||
use profile_traits::time::{ProfilerChan, TimerMetadata};
|
use profile_traits::time::{ProfilerChan, TimerMetadata};
|
||||||
use servo_url::ServoUrl;
|
use servo_url::ServoUrl;
|
||||||
use style::computed_values::image_rendering::T as ImageRendering;
|
|
||||||
use time;
|
use time;
|
||||||
|
use webrender_api::{ImageRendering, LayoutSize};
|
||||||
|
|
||||||
struct DummyProfilerMetadataFactory {}
|
struct DummyProfilerMetadataFactory {}
|
||||||
impl ProfilerMetadataFactory for DummyProfilerMetadataFactory {
|
impl ProfilerMetadataFactory for DummyProfilerMetadataFactory {
|
||||||
|
@ -128,8 +127,8 @@ fn test_first_contentful_paint_setter() {
|
||||||
key: None,
|
key: None,
|
||||||
},
|
},
|
||||||
image_data: None,
|
image_data: None,
|
||||||
stretch_size: Size2D::zero(),
|
stretch_size: LayoutSize::zero(),
|
||||||
tile_spacing: Size2D::zero(),
|
tile_spacing: LayoutSize::zero(),
|
||||||
image_rendering: ImageRendering::Auto,
|
image_rendering: ImageRendering::Auto,
|
||||||
}));
|
}));
|
||||||
let display_list = DisplayList {
|
let display_list = DisplayList {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue