Auto merge of #17219 - upsuper:currentcolor, r=Manishearth,birtles

Support interpolation between currentcolor and numeric color

This is the Servo side change of [bug 1345709](https://bugzilla.mozilla.org/show_bug.cgi?id=1345709).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/17219)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-07 21:03:52 -07:00 committed by GitHub
commit 24e944ad94
40 changed files with 828 additions and 700 deletions

View file

@ -14,7 +14,6 @@ app_units = "0.4.1"
atomic_refcell = "0.1"
bitflags = "0.7"
canvas_traits = {path = "../canvas_traits"}
cssparser = "0.13.7"
euclid = "0.13"
fnv = "1.0"
gfx = {path = "../gfx"}

View file

@ -422,8 +422,7 @@ pub trait FragmentDisplayListBuilding {
bounds: &Rect<Au>,
stops: &[GradientItem],
direction: &LineDirection,
repeating: bool,
style: &ServoComputedValues)
repeating: bool)
-> display_list::Gradient;
fn convert_radial_gradient(&self,
@ -431,8 +430,7 @@ pub trait FragmentDisplayListBuilding {
stops: &[GradientItem],
shape: &EndingShape,
center: &Position,
repeating: bool,
style: &ServoComputedValues)
repeating: bool)
-> display_list::RadialGradient;
/// Adds the display items necessary to paint the background linear gradient of this fragment
@ -634,8 +632,7 @@ fn build_border_radius_for_inner_rect(outer_rect: &Rect<Au>,
}
fn convert_gradient_stops(gradient_items: &[GradientItem],
total_length: Au,
style: &ServoComputedValues) -> Vec<GradientStop> {
total_length: Au) -> Vec<GradientStop> {
// Determine the position of each stop per CSS-IMAGES § 3.4.
// Only keep the color stops, discard the color interpolation hints.
@ -722,7 +719,7 @@ fn convert_gradient_stops(gradient_items: &[GradientItem],
};
stops.push(GradientStop {
offset: offset,
color: style.resolve_color(stop.color).to_gfx_color()
color: stop.color.to_gfx_color()
})
}
stops
@ -1192,8 +1189,7 @@ impl FragmentDisplayListBuilding for Fragment {
bounds: &Rect<Au>,
stops: &[GradientItem],
direction: &LineDirection,
repeating: bool,
style: &ServoComputedValues)
repeating: bool)
-> display_list::Gradient {
let angle = match *direction {
LineDirection::Angle(angle) => angle.radians(),
@ -1234,7 +1230,7 @@ impl FragmentDisplayListBuilding for Fragment {
let length = Au::from_f32_px(
(delta.x.to_f32_px() * 2.0).hypot(delta.y.to_f32_px() * 2.0));
let mut stops = convert_gradient_stops(stops, length, style);
let mut stops = convert_gradient_stops(stops, length);
// Only clamped gradients need to be fixed because in repeating gradients
// there is no "first" or "last" stop because they repeat infinitly in
@ -1258,8 +1254,7 @@ impl FragmentDisplayListBuilding for Fragment {
stops: &[GradientItem],
shape: &EndingShape,
center: &Position,
repeating: bool,
style: &ServoComputedValues)
repeating: bool)
-> display_list::RadialGradient {
let center = Point2D::new(center.horizontal.to_used_value(bounds.size.width),
center.vertical.to_used_value(bounds.size.height));
@ -1278,7 +1273,7 @@ impl FragmentDisplayListBuilding for Fragment {
},
};
let mut stops = convert_gradient_stops(stops, radius.width, style);
let mut stops = convert_gradient_stops(stops, radius.width);
// Repeating gradients have no last stops that can be ignored. So
// fixup is not necessary but may actually break the gradient.
if !repeating {
@ -1322,8 +1317,7 @@ impl FragmentDisplayListBuilding for Fragment {
let gradient = self.convert_linear_gradient(&bounds,
&gradient.items[..],
angle_or_corner,
gradient.repeating,
style);
gradient.repeating);
DisplayItem::Gradient(box GradientDisplayItem {
base: base,
gradient: gradient,
@ -1334,8 +1328,7 @@ impl FragmentDisplayListBuilding for Fragment {
&gradient.items[..],
shape,
center,
gradient.repeating,
style);
gradient.repeating);
DisplayItem::RadialGradient(box RadialGradientDisplayItem {
base: base,
gradient: gradient,
@ -1459,8 +1452,7 @@ impl FragmentDisplayListBuilding for Fragment {
let grad = self.convert_linear_gradient(&bounds,
&gradient.items[..],
&angle_or_corner,
gradient.repeating,
style);
gradient.repeating);
state.add_display_item(DisplayItem::Border(box BorderDisplayItem {
base: base,
@ -1478,8 +1470,7 @@ impl FragmentDisplayListBuilding for Fragment {
&gradient.items[..],
shape,
center,
gradient.repeating,
style);
gradient.repeating);
state.add_display_item(DisplayItem::Border(box BorderDisplayItem {
base: base,
border_widths: border.to_physical(style.writing_mode),

View file

@ -16,7 +16,6 @@ extern crate atomic_refcell;
extern crate bitflags;
extern crate canvas_traits;
extern crate core;
extern crate cssparser;
extern crate euclid;
extern crate fnv;
extern crate gfx;

View file

@ -9,7 +9,6 @@
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer, MarginsMayCollapseFlag};
use context::LayoutContext;
use cssparser::Color;
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState};
use euclid::{Point2D, Rect, SideOffsets2D, Size2D};
use flow::{self, Flow, FlowClass, IS_ABSOLUTELY_POSITIONED, OpaqueFlow};
@ -22,6 +21,7 @@ use std::fmt;
use style::computed_values::{border_collapse, border_top_style, vertical_align};
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ServoComputedValues;
use style::values::computed::Color;
use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance};

View file

@ -9,7 +9,6 @@
use app_units::Au;
use block::{BlockFlow, ISizeAndMarginsComputer};
use context::LayoutContext;
use cssparser::{Color, RGBA};
use display_list_builder::{BlockFlowDisplayListBuilding, BorderPaintingMode, DisplayListBuildState};
use euclid::Point2D;
use flow::{self, EarlyAbsolutePositionInfo, Flow, FlowClass, ImmutableFlowUtils, OpaqueFlow};
@ -26,7 +25,7 @@ use style::computed_values::{border_collapse, border_spacing, border_top_style};
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ServoComputedValues;
use style::servo::restyle_damage::{REFLOW, REFLOW_OUT_OF_FLOW};
use style::values::computed::LengthOrPercentageOrAuto;
use style::values::computed::{Color, LengthOrPercentageOrAuto};
use table::{ColumnComputedInlineSize, ColumnIntrinsicInlineSize, InternalTable, VecExt};
use table_cell::{CollapsedBordersForCell, TableCellFlow};
@ -606,7 +605,7 @@ impl CollapsedBorder {
CollapsedBorder {
style: border_top_style::T::none,
width: Au(0),
color: Color::RGBA(RGBA::transparent()),
color: Color::transparent(),
provenance: CollapsedBorderProvenance::FromTable,
}
}