From dc82366f7272dc71c0296002817159e6b6f88f53 Mon Sep 17 00:00:00 2001 From: Glenn Watson Date: Fri, 21 Jul 2017 12:50:38 +1000 Subject: [PATCH] Update WR (switch to new text-decorations API in WR). This only makes use of the "Solid" text decoration type, which matches the existing support. WR now supports dotted, dashed and wavy text decorations, but supporting those will need some extra work in Servo to pass through the correct values. --- Cargo.lock | 4 ++-- components/gfx/display_list/mod.rs | 3 ++- components/layout/display_list_builder.rs | 7 ++++--- components/layout/webrender_helpers.rs | 12 ++++++++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b5f6aaa139e..16fbec91af0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3465,7 +3465,7 @@ dependencies = [ [[package]] name = "webrender" version = "0.48.0" -source = "git+https://github.com/servo/webrender#b83c200c657f6b6fb17d09f329ba77803420b46a" +source = "git+https://github.com/servo/webrender#8fd634882111415a65da67e947f26eb170234f2f" dependencies = [ "app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3494,7 +3494,7 @@ dependencies = [ [[package]] name = "webrender_api" version = "0.48.0" -source = "git+https://github.com/servo/webrender#b83c200c657f6b6fb17d09f329ba77803420b46a" +source = "git+https://github.com/servo/webrender#8fd634882111415a65da67e947f26eb170234f2f" dependencies = [ "app_units 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", "bincode 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/components/gfx/display_list/mod.rs b/components/gfx/display_list/mod.rs index 69074e89a12..22d37d05cc3 100644 --- a/components/gfx/display_list/mod.rs +++ b/components/gfx/display_list/mod.rs @@ -1146,7 +1146,8 @@ pub struct LineDisplayItem { pub color: ColorF, /// The line segment style. - pub style: border_style::T + #[ignore_heap_size_of = "enum type in webrender"] + pub style: webrender_api::LineStyle, } /// Paints a box shadow per CSS-BACKGROUNDS. diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs index d61d3bfbf6e..f585d32eb8e 100644 --- a/components/layout/display_list_builder.rs +++ b/components/layout/display_list_builder.rs @@ -71,7 +71,7 @@ use style_traits::CSSPixel; use style_traits::cursor::Cursor; use table_cell::CollapsedBordersForCell; use webrender_api::{ClipId, ColorF, ComplexClipRegion, GradientStop, LocalClip, RepeatMode}; -use webrender_api::{ScrollPolicy, TransformStyle}; +use webrender_api::{LineStyle, ScrollPolicy, TransformStyle}; use webrender_helpers::{ToBorderRadius, ToMixBlendMode, ToRectF, ToTransformStyle}; trait ResolvePercentage { @@ -1651,7 +1651,7 @@ impl FragmentDisplayListBuilding for Fragment { state.add_display_item(DisplayItem::Line(box LineDisplayItem { base: base, color: ColorF::rgb(0, 200, 0), - style: border_style::T::dashed, + style: LineStyle::Dashed, })); } @@ -2217,9 +2217,10 @@ impl FragmentDisplayListBuilding for Fragment { self.style.get_cursor(Cursor::Default), DisplayListSection::Content); - state.add_display_item(DisplayItem::SolidColor(box SolidColorDisplayItem { + state.add_display_item(DisplayItem::Line(box LineDisplayItem { base: base, color: color.to_gfx_color(), + style: LineStyle::Solid, })); } diff --git a/components/layout/webrender_helpers.rs b/components/layout/webrender_helpers.rs index 29236533f80..b2521ff159d 100644 --- a/components/layout/webrender_helpers.rs +++ b/components/layout/webrender_helpers.rs @@ -432,8 +432,16 @@ impl WebRenderDisplayItemConverter for DisplayItem { rect.size, webrender_api::LayoutSize::zero()); } - DisplayItem::Line(..) => { - println!("TODO DisplayItem::Line"); + DisplayItem::Line(ref item) => { + let box_bounds = item.base.bounds.to_rectf(); + builder.push_line(Some(item.base.local_clip), + box_bounds.origin.y + box_bounds.size.height, + box_bounds.origin.x, + box_bounds.origin.x + box_bounds.size.width, + webrender_api::LineOrientation::Horizontal, + box_bounds.size.height, + item.color, + item.style); } DisplayItem::BoxShadow(ref item) => { let rect = item.base.bounds.to_rectf();