diff --git a/components/layout/display_list/gradient.rs b/components/layout/display_list/gradient.rs index db5208eadac..9b19ee48299 100644 --- a/components/layout/display_list/gradient.rs +++ b/components/layout/display_list/gradient.rs @@ -12,7 +12,7 @@ use style::values::computed::image::{EndingShape, LineDirection}; use style::values::computed::{Angle, GradientItem, LengthPercentage, Percentage, Position}; use style::values::generics::image::EndingShape as GenericEndingShape; use style::values::generics::image::GradientItem as GenericGradientItem; -use style::values::generics::image::{Circle, 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}; @@ -92,7 +92,14 @@ fn convert_gradient_stops( let mut stop_items = gradient_items .iter() .filter_map(|item| match *item { - GenericGradientItem::ColorStop(ref stop) => Some(*stop), + GenericGradientItem::SimpleColorStop(color) => Some(ColorStop { + color, + position: None, + }), + GenericGradientItem::ComplexColorStop { color, position } => Some(ColorStop { + color, + position: Some(position), + }), _ => None, }) .collect::>(); diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index ff62cc79638..ccc3de5ec7e 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -61,8 +61,8 @@ use style::selector_parser::RestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage; use style::str::char_is_whitespace; use style::values::computed::counters::ContentItem; -use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, Size}; -use style::values::generics::box_::{Perspective, VerticalAlign}; +use style::values::computed::{LengthPercentage, LengthPercentageOrAuto, Size, VerticalAlign}; +use style::values::generics::box_::{Perspective, VerticalAlignKeyword}; use style::values::generics::transform; use style::Zero; use webrender_api::{self, LayoutTransform}; @@ -2397,47 +2397,49 @@ impl Fragment { // FIXME(#5624, pcwalton): This passes our current reftests but isn't the right thing // to do. match style.get_box().vertical_align { - VerticalAlign::Baseline => {}, - VerticalAlign::Middle => { - let font_metrics = - with_thread_local_font_context(layout_context, |font_context| { - text::font_metrics_for_style(font_context, self.style.clone_font()) - }); - offset += (content_inline_metrics.ascent - - content_inline_metrics.space_below_baseline - - font_metrics.x_height) - .scale_by(0.5) - }, - VerticalAlign::Sub => { - offset += minimum_line_metrics - .space_needed() - .scale_by(FONT_SUBSCRIPT_OFFSET_RATIO) - }, - VerticalAlign::Super => { - offset -= minimum_line_metrics - .space_needed() - .scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO) - }, - VerticalAlign::TextTop => { - offset = self.content_inline_metrics(layout_context).ascent - - minimum_line_metrics.space_above_baseline - }, - VerticalAlign::TextBottom => { - offset = minimum_line_metrics.space_below_baseline - - self.content_inline_metrics(layout_context) - .space_below_baseline - }, - VerticalAlign::Top => { - if let Some(actual_line_metrics) = actual_line_metrics { - offset = - content_inline_metrics.ascent - actual_line_metrics.space_above_baseline - } - }, - VerticalAlign::Bottom => { - if let Some(actual_line_metrics) = actual_line_metrics { - offset = actual_line_metrics.space_below_baseline - - content_inline_metrics.space_below_baseline - } + VerticalAlign::Keyword(kw) => match kw { + VerticalAlignKeyword::Baseline => {}, + VerticalAlignKeyword::Middle => { + let font_metrics = + with_thread_local_font_context(layout_context, |font_context| { + text::font_metrics_for_style(font_context, self.style.clone_font()) + }); + offset += (content_inline_metrics.ascent - + content_inline_metrics.space_below_baseline - + font_metrics.x_height) + .scale_by(0.5) + }, + VerticalAlignKeyword::Sub => { + offset += minimum_line_metrics + .space_needed() + .scale_by(FONT_SUBSCRIPT_OFFSET_RATIO) + }, + VerticalAlignKeyword::Super => { + offset -= minimum_line_metrics + .space_needed() + .scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO) + }, + VerticalAlignKeyword::TextTop => { + offset = self.content_inline_metrics(layout_context).ascent - + minimum_line_metrics.space_above_baseline + }, + VerticalAlignKeyword::TextBottom => { + offset = minimum_line_metrics.space_below_baseline - + self.content_inline_metrics(layout_context) + .space_below_baseline + }, + VerticalAlignKeyword::Top => { + if let Some(actual_line_metrics) = actual_line_metrics { + offset = content_inline_metrics.ascent - + actual_line_metrics.space_above_baseline + } + }, + VerticalAlignKeyword::Bottom => { + if let Some(actual_line_metrics) = actual_line_metrics { + offset = actual_line_metrics.space_below_baseline - + content_inline_metrics.space_below_baseline + } + }, }, VerticalAlign::Length(ref lp) => { offset -= lp.to_used_value(minimum_line_metrics.space_needed()); @@ -3087,15 +3089,22 @@ impl Fragment { /// Returns true if any of the inline styles associated with this fragment have /// `vertical-align` set to `top` or `bottom`. pub fn is_vertically_aligned_to_top_or_bottom(&self) -> bool { - match self.style.get_box().vertical_align { - VerticalAlign::Top | VerticalAlign::Bottom => return true, - _ => {}, + fn is_top_or_bottom(v: &VerticalAlign) -> bool { + match *v { + VerticalAlign::Keyword(VerticalAlignKeyword::Top) | + VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => true, + _ => false, + } } + + if is_top_or_bottom(&self.style.get_box().vertical_align) { + return true; + } + if let Some(ref inline_context) = self.inline_context { for node in &inline_context.nodes { - match node.style.get_box().vertical_align { - VerticalAlign::Top | VerticalAlign::Bottom => return true, - _ => {}, + if is_top_or_bottom(&node.style.get_box().vertical_align) { + return true; } } } diff --git a/components/layout/inline.rs b/components/layout/inline.rs index bef95a64f96..f4dacefc5ef 100644 --- a/components/layout/inline.rs +++ b/components/layout/inline.rs @@ -41,7 +41,7 @@ use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::properties::ComputedValues; use style::servo::restyle_damage::ServoRestyleDamage; use style::values::computed::box_::VerticalAlign; -use style::values::generics::box_::VerticalAlign as GenericVerticalAlign; +use style::values::generics::box_::VerticalAlignKeyword; use style::values::specified::text::TextOverflowSide; use unicode_bidi as bidi; @@ -1269,13 +1269,13 @@ impl InlineFlow { let mut largest_block_size_for_top_fragments = Au(0); let mut largest_block_size_for_bottom_fragments = Au(0); - // We use `VerticalAlign::Baseline` here because `vertical-align` must + // We use `VerticalAlign::baseline()` here because `vertical-align` must // not apply to the inside of inline blocks. update_line_metrics_for_fragment( &mut line_metrics, &inline_metrics, style.get_box().display, - GenericVerticalAlign::Baseline, + VerticalAlign::baseline(), &mut largest_block_size_for_top_fragments, &mut largest_block_size_for_bottom_fragments, ); @@ -1322,11 +1322,20 @@ impl InlineFlow { largest_block_size_for_top_fragments: &mut Au, largest_block_size_for_bottom_fragments: &mut Au, ) { + // FIXME(emilio): This should probably be handled. + let vertical_align_value = match vertical_align_value { + VerticalAlign::Keyword(kw) => kw, + VerticalAlign::Length(..) => { + *line_metrics = line_metrics.new_metrics_for_fragment(inline_metrics); + return; + }, + }; + match (display_value, vertical_align_value) { - (Display::Inline, GenericVerticalAlign::Top) | - (Display::Block, GenericVerticalAlign::Top) | - (Display::InlineFlex, GenericVerticalAlign::Top) | - (Display::InlineBlock, GenericVerticalAlign::Top) + (Display::Inline, VerticalAlignKeyword::Top) | + (Display::Block, VerticalAlignKeyword::Top) | + (Display::InlineFlex, VerticalAlignKeyword::Top) | + (Display::InlineBlock, VerticalAlignKeyword::Top) if inline_metrics.space_above_baseline >= Au(0) => { *largest_block_size_for_top_fragments = max( @@ -1334,10 +1343,10 @@ impl InlineFlow { inline_metrics.space_above_baseline + inline_metrics.space_below_baseline, ) }, - (Display::Inline, GenericVerticalAlign::Bottom) | - (Display::Block, GenericVerticalAlign::Bottom) | - (Display::InlineFlex, GenericVerticalAlign::Bottom) | - (Display::InlineBlock, GenericVerticalAlign::Bottom) + (Display::Inline, VerticalAlignKeyword::Bottom) | + (Display::Block, VerticalAlignKeyword::Bottom) | + (Display::InlineFlex, VerticalAlignKeyword::Bottom) | + (Display::InlineBlock, VerticalAlignKeyword::Bottom) if inline_metrics.space_below_baseline >= Au(0) => { *largest_block_size_for_bottom_fragments = max( diff --git a/components/layout/table_cell.rs b/components/layout/table_cell.rs index 682a1c38ec4..ec79f9f4540 100644 --- a/components/layout/table_cell.rs +++ b/components/layout/table_cell.rs @@ -23,7 +23,7 @@ use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMo use style::properties::ComputedValues; use style::values::computed::length::Size; use style::values::computed::Color; -use style::values::generics::box_::VerticalAlign; +use style::values::generics::box_::{VerticalAlign, VerticalAlignKeyword}; use style::values::specified::BorderStyle; #[allow(unsafe_code)] @@ -138,11 +138,11 @@ impl TableCellFlow { self.block_flow.fragment.border_padding.block_start_end(); let kids_self_gap = self_size - kids_size; - // This offset should also account for VerticalAlign::Baseline. + // This offset should also account for VerticalAlign::baseline. // Need max cell ascent from the first row of this cell. let offset = match self.block_flow.fragment.style().get_box().vertical_align { - VerticalAlign::Middle => kids_self_gap / 2, - VerticalAlign::Bottom => kids_self_gap, + VerticalAlign::Keyword(VerticalAlignKeyword::Middle) => kids_self_gap / 2, + VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => kids_self_gap, _ => Au(0), }; if offset == Au(0) { diff --git a/components/layout/text.rs b/components/layout/text.rs index b26e531e670..199bd7e07f2 100644 --- a/components/layout/text.rs +++ b/components/layout/text.rs @@ -21,13 +21,13 @@ use std::collections::LinkedList; use std::mem; use std::sync::Arc; use style::computed_values::text_rendering::T as TextRendering; -use style::computed_values::text_transform::T as TextTransform; use style::computed_values::white_space::T as WhiteSpace; use style::computed_values::word_break::T as WordBreak; use style::logical_geometry::{LogicalSize, WritingMode}; use style::properties::style_structs::Font as FontStyleStruct; use style::properties::ComputedValues; use style::values::generics::text::LineHeight; +use style::values::specified::text::{TextTransform, TextTransformCase}; use unicode_bidi as bidi; use unicode_script::{get_script, Script}; use xi_unicode::LineBreakLeafIter; @@ -738,23 +738,23 @@ fn apply_style_transform_if_necessary( last_whitespace: bool, is_first_run: bool, ) { - match text_transform { - TextTransform::None => {}, - TextTransform::Uppercase => { + match text_transform.case_ { + TextTransformCase::None => {}, + TextTransformCase::Uppercase => { let original = string[first_character_position..].to_owned(); string.truncate(first_character_position); for ch in original.chars().flat_map(|ch| ch.to_uppercase()) { string.push(ch); } }, - TextTransform::Lowercase => { + TextTransformCase::Lowercase => { let original = string[first_character_position..].to_owned(); string.truncate(first_character_position); for ch in original.chars().flat_map(|ch| ch.to_lowercase()) { string.push(ch); } }, - TextTransform::Capitalize => { + TextTransformCase::Capitalize => { let original = string[first_character_position..].to_owned(); string.truncate(first_character_position); diff --git a/components/layout_thread/dom_wrapper.rs b/components/layout_thread/dom_wrapper.rs index 88eedef7d17..301a7500713 100644 --- a/components/layout_thread/dom_wrapper.rs +++ b/components/layout_thread/dom_wrapper.rs @@ -972,6 +972,11 @@ impl<'le> ::selectors::Element for ServoLayoutElement<'le> { } } + #[inline] + fn is_part(&self, _name: &Atom) -> bool { + false + } + #[inline] fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { unsafe { self.element.has_class_for_layout(name, case_sensitivity) } @@ -1484,6 +1489,12 @@ impl<'le> ::selectors::Element for ServoThreadSafeLayoutElement<'le> { false } + #[inline] + fn is_part(&self, _name: &Atom) -> bool { + debug!("ServoThreadSafeLayoutElement::is_part called"); + false + } + fn has_class(&self, _name: &Atom, _case_sensitivity: CaseSensitivity) -> bool { debug!("ServoThreadSafeLayoutElement::has_class called"); false diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs index 2d12e93774d..1b918c0537b 100644 --- a/components/script/dom/element.rs +++ b/components/script/dom/element.rs @@ -3075,6 +3075,10 @@ impl<'a> SelectorsElement for DomRoot { .map_or(false, |atom| case_sensitivity.eq_atom(id, atom)) } + fn is_part(&self, _name: &Atom) -> bool { + false + } + fn has_class(&self, name: &Atom, case_sensitivity: CaseSensitivity) -> bool { Element::has_class(&**self, name, case_sensitivity) }