Auto merge of #19500 - emilio:camel-case-all-the-way, r=nox

style: Make all keywords CamelCase for consistency.

<!-- 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/19500)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-12-05 19:35:25 -06:00 committed by GitHub
commit b24778202a
61 changed files with 922 additions and 837 deletions

View file

@ -261,8 +261,8 @@ impl Font {
#[inline] #[inline]
pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { pub fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {
let codepoint = match self.variant { let codepoint = match self.variant {
font_variant_caps::T::small_caps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938 font_variant_caps::T::SmallCaps => codepoint.to_uppercase().next().unwrap(), //FIXME: #5938
font_variant_caps::T::normal => codepoint, font_variant_caps::T::Normal => codepoint,
}; };
self.handle.glyph_index(codepoint) self.handle.glyph_index(codepoint)
} }

View file

@ -20,7 +20,8 @@ use std::hash::{BuildHasherDefault, Hash, Hasher};
use std::rc::Rc; use std::rc::Rc;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT}; use std::sync::atomic::{AtomicUsize, Ordering, ATOMIC_USIZE_INIT};
use style::computed_values::{font_style, font_variant_caps}; use style::computed_values::font_style::T as FontStyle;
use style::computed_values::font_variant_caps::T as FontVariantCaps;
use style::properties::style_structs; use style::properties::style_structs;
use webrender_api; use webrender_api;
@ -78,14 +79,14 @@ impl FontContext {
template: Arc<FontTemplateData>, template: Arc<FontTemplateData>,
descriptor: FontTemplateDescriptor, descriptor: FontTemplateDescriptor,
pt_size: Au, pt_size: Au,
variant: font_variant_caps::T, variant: FontVariantCaps,
font_key: webrender_api::FontKey) -> Result<Font, ()> { font_key: webrender_api::FontKey) -> Result<Font, ()> {
// TODO: (Bug #3463): Currently we only support fake small-caps // TODO: (Bug #3463): Currently we only support fake small-caps
// painting. We should also support true small-caps (where the // painting. We should also support true small-caps (where the
// font supports it) in the future. // font supports it) in the future.
let actual_pt_size = match variant { let actual_pt_size = match variant {
font_variant_caps::T::small_caps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR), FontVariantCaps::SmallCaps => pt_size.scale_by(SMALL_CAPS_SCALE_FACTOR),
font_variant_caps::T::normal => pt_size, FontVariantCaps::Normal => pt_size,
}; };
let handle = FontHandle::new_from_template(&self.platform_handle, let handle = FontHandle::new_from_template(&self.platform_handle,
@ -130,8 +131,8 @@ impl FontContext {
let desc = FontTemplateDescriptor::new(style.font_weight, let desc = FontTemplateDescriptor::new(style.font_weight,
style.font_stretch, style.font_stretch,
style.font_style == font_style::T::italic || style.font_style == FontStyle::Italic ||
style.font_style == font_style::T::oblique); style.font_style == FontStyle::Oblique);
let mut fonts: SmallVec<[Rc<RefCell<Font>>; 8]> = SmallVec::new(); let mut fonts: SmallVec<[Rc<RefCell<Font>>; 8]> = SmallVec::new();

View file

@ -20,7 +20,8 @@ use platform::font_template::FontTemplateData;
use std::{mem, ptr}; use std::{mem, ptr};
use std::os::raw::{c_char, c_long}; use std::os::raw::{c_char, c_long};
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{font_stretch, font_weight}; use style::computed_values::font_stretch::T as FontStretch;
use style::computed_values::font_weight::T as FontWeight;
use super::c_str_to_string; use super::c_str_to_string;
use text::glyph::GlyphId; use text::glyph::GlyphId;
use text::util::fixed_to_float; use text::util::fixed_to_float;
@ -134,8 +135,8 @@ impl FontHandleMethods for FontHandle {
fn is_italic(&self) -> bool { fn is_italic(&self) -> bool {
unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 } unsafe { (*self.face).style_flags & FT_STYLE_FLAG_ITALIC as c_long != 0 }
} }
fn boldness(&self) -> font_weight::T { fn boldness(&self) -> FontWeight {
let default_weight = font_weight::T::normal(); let default_weight = FontWeight::normal();
if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD as c_long == 0 } { if unsafe { (*self.face).style_flags & FT_STYLE_FLAG_BOLD as c_long == 0 } {
default_weight default_weight
} else { } else {
@ -145,9 +146,9 @@ impl FontHandleMethods for FontHandle {
if valid { if valid {
let weight =(*os2).usWeightClass as i32; let weight =(*os2).usWeightClass as i32;
if weight < 10 { if weight < 10 {
font_weight::T::from_int(weight * 100).unwrap() FontWeight::from_int(weight * 100).unwrap()
} else if weight >= 100 && weight < 1000 { } else if weight >= 100 && weight < 1000 {
font_weight::T::from_int(weight / 100 * 100).unwrap() FontWeight::from_int(weight / 100 * 100).unwrap()
} else { } else {
default_weight default_weight
} }
@ -157,9 +158,9 @@ impl FontHandleMethods for FontHandle {
} }
} }
} }
fn stretchiness(&self) -> font_stretch::T { fn stretchiness(&self) -> FontStretch {
// TODO(pcwalton): Implement this. // TODO(pcwalton): Implement this.
font_stretch::T::normal FontStretch::Normal
} }
fn glyph_index(&self, codepoint: char) -> Option<GlyphId> { fn glyph_index(&self, codepoint: char) -> Option<GlyphId> {

View file

@ -21,7 +21,8 @@ use platform::macos::font_context::FontContextHandle;
use std::{fmt, ptr}; use std::{fmt, ptr};
use std::ops::Range; use std::ops::Range;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{font_stretch, font_weight}; use style::computed_values::font_stretch::T as FontStretch;
use style::computed_values::font_weight::T as FontWeight;
use text::glyph::GlyphId; use text::glyph::GlyphId;
const KERN_PAIR_LEN: usize = 6; const KERN_PAIR_LEN: usize = 6;
@ -210,29 +211,29 @@ impl FontHandleMethods for FontHandle {
self.ctfont.symbolic_traits().is_italic() self.ctfont.symbolic_traits().is_italic()
} }
fn boldness(&self) -> font_weight::T { fn boldness(&self) -> FontWeight {
let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0] let normalized = self.ctfont.all_traits().normalized_weight(); // [-1.0, 1.0]
let normalized = if normalized <= 0.0 { let normalized = if normalized <= 0.0 {
4.0 + normalized * 3.0 // [1.0, 4.0] 4.0 + normalized * 3.0 // [1.0, 4.0]
} else { } else {
4.0 + normalized * 5.0 // [4.0, 9.0] 4.0 + normalized * 5.0 // [4.0, 9.0]
}; // [1.0, 9.0], centered on 4.0 }; // [1.0, 9.0], centered on 4.0
font_weight::T::from_int(normalized.round() as i32 * 100).unwrap() FontWeight::from_int(normalized.round() as i32 * 100).unwrap()
} }
fn stretchiness(&self) -> font_stretch::T { fn stretchiness(&self) -> FontStretch {
let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0] let normalized = self.ctfont.all_traits().normalized_width(); // [-1.0, 1.0]
let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0] let normalized = (normalized + 1.0) / 2.0 * 9.0; // [0.0, 9.0]
match normalized { match normalized {
v if v < 1.0 => font_stretch::T::ultra_condensed, v if v < 1.0 => FontStretch::UltraCondensed,
v if v < 2.0 => font_stretch::T::extra_condensed, v if v < 2.0 => FontStretch::ExtraCondensed,
v if v < 3.0 => font_stretch::T::condensed, v if v < 3.0 => FontStretch::Condensed,
v if v < 4.0 => font_stretch::T::semi_condensed, v if v < 4.0 => FontStretch::SemiCondensed,
v if v < 5.0 => font_stretch::T::normal, v if v < 5.0 => FontStretch::Normal,
v if v < 6.0 => font_stretch::T::semi_expanded, v if v < 6.0 => FontStretch::SemiExpanded,
v if v < 7.0 => font_stretch::T::expanded, v if v < 7.0 => FontStretch::Expanded,
v if v < 8.0 => font_stretch::T::extra_expanded, v if v < 8.0 => FontStretch::ExtraExpanded,
_ => font_stretch::T::ultra_expanded, _ => FontStretch::UltraExpanded,
} }
} }

View file

@ -16,7 +16,8 @@ use platform::font_template::FontTemplateData;
use platform::windows::font_context::FontContextHandle; use platform::windows::font_context::FontContextHandle;
use platform::windows::font_list::font_from_atom; use platform::windows::font_list::font_from_atom;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{font_stretch, font_weight}; use style::computed_values::font_stretch::T as StyleFontStretch;
use style::computed_values::font_weight::T as StyleFontWeight;
use text::glyph::GlyphId; use text::glyph::GlyphId;
use truetype; use truetype;
@ -94,8 +95,8 @@ fn get_family_face_indices(records: &[truetype::naming_table::Record]) -> Option
struct FontInfo { struct FontInfo {
family_name: String, family_name: String,
face_name: String, face_name: String,
weight: font_weight::T, weight: StyleFontWeight,
stretch: font_stretch::T, stretch: StyleFontStretch,
style: FontStyle, style: FontStyle,
} }
@ -155,19 +156,21 @@ impl FontInfo {
}, },
}; };
let weight = font_weight::T:: let weight =
from_int(min(9, max(1, weight_val as i32 / 100)) * 100).unwrap(); StyleFontWeight::from_int(
min(9, max(1, weight_val as i32 / 100)) * 100
).unwrap();
let stretch = match min(9, max(1, width_val)) { let stretch = match min(9, max(1, width_val)) {
1 => font_stretch::T::ultra_condensed, 1 => StyleFontStretch::UltraCondensed,
2 => font_stretch::T::extra_condensed, 2 => StyleFontStretch::ExtraCondensed,
3 => font_stretch::T::condensed, 3 => StyleFontStretch::Condensed,
4 => font_stretch::T::semi_condensed, 4 => StyleFontStretch::SemiCondensed,
5 => font_stretch::T::normal, 5 => StyleFontStretch::Normal,
6 => font_stretch::T::semi_expanded, 6 => StyleFontStretch::SemiExpanded,
7 => font_stretch::T::expanded, 7 => StyleFontStretch::Expanded,
8 => font_stretch::T::extra_expanded, 8 => StyleFontStretch::ExtraExpanded,
9 => font_stretch::T::ultra_expanded, 9 => StyleFontStretch::UltraExpanded,
_ => return Err(()), _ => return Err(()),
}; };
@ -188,7 +191,7 @@ impl FontInfo {
fn new_from_font(font: &Font) -> Result<FontInfo, ()> { fn new_from_font(font: &Font) -> Result<FontInfo, ()> {
let style = font.style(); let style = font.style();
let weight = font_weight::T(match font.weight() { let weight = StyleFontWeight(match font.weight() {
FontWeight::Thin => 100, FontWeight::Thin => 100,
FontWeight::ExtraLight => 200, FontWeight::ExtraLight => 200,
FontWeight::Light => 300, FontWeight::Light => 300,
@ -204,16 +207,16 @@ impl FontInfo {
FontWeight::ExtraBlack => 900, FontWeight::ExtraBlack => 900,
}); });
let stretch = match font.stretch() { let stretch = match font.stretch() {
FontStretch::Undefined => font_stretch::T::normal, FontStretch::Undefined => StyleFontStretch::Normal,
FontStretch::UltraCondensed => font_stretch::T::ultra_condensed, FontStretch::UltraCondensed => StyleFontStretch::UltraCondensed,
FontStretch::ExtraCondensed => font_stretch::T::extra_condensed, FontStretch::ExtraCondensed => StyleFontStretch::ExtraCondensed,
FontStretch::Condensed => font_stretch::T::condensed, FontStretch::Condensed => StyleFontStretch::Condensed,
FontStretch::SemiCondensed => font_stretch::T::semi_condensed, FontStretch::SemiCondensed => StyleFontStretch::SemiCondensed,
FontStretch::Normal => font_stretch::T::normal, FontStretch::Normal => StyleFontStretch::Normal,
FontStretch::SemiExpanded => font_stretch::T::semi_expanded, FontStretch::SemiExpanded => StyleFontStretch::SemiExpanded,
FontStretch::Expanded => font_stretch::T::expanded, FontStretch::Expanded => StyleFontStretch::Expanded,
FontStretch::ExtraExpanded => font_stretch::T::extra_expanded, FontStretch::ExtraExpanded => StyleFontStretch::ExtraExpanded,
FontStretch::UltraExpanded => font_stretch::T::ultra_expanded, FontStretch::UltraExpanded => StyleFontStretch::UltraExpanded,
}; };
Ok(FontInfo { Ok(FontInfo {
@ -300,11 +303,11 @@ impl FontHandleMethods for FontHandle {
} }
} }
fn boldness(&self) -> font_weight::T { fn boldness(&self) -> StyleFontWeight {
self.info.weight self.info.weight
} }
fn stretchiness(&self) -> font_stretch::T { fn stretchiness(&self) -> StyleFontStretch {
self.info.stretch self.info.stretch
} }

View file

@ -48,8 +48,12 @@ use servo_geometry::max_rect;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fmt; use std::fmt;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{box_sizing, display, float, overflow_x}; use style::computed_values::box_sizing::T as BoxSizing;
use style::computed_values::{position, text_align}; use style::computed_values::display::T as Display;
use style::computed_values::float::T as Float;
use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::position::T as Position;
use style::computed_values::text_align::T as TextAlign;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
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;
@ -352,8 +356,8 @@ impl CandidateBSizeIterator {
// If the style includes `box-sizing: border-box`, subtract the border and padding. // If the style includes `box-sizing: border-box`, subtract the border and padding.
let adjustment_for_box_sizing = match fragment.style.get_position().box_sizing { let adjustment_for_box_sizing = match fragment.style.get_position().box_sizing {
box_sizing::T::border_box => fragment.border_padding.block_start_end(), BoxSizing::BorderBox => fragment.border_padding.block_start_end(),
box_sizing::T::content_box => Au(0), BoxSizing::ContentBox => Au(0),
}; };
return CandidateBSizeIterator { return CandidateBSizeIterator {
@ -1344,8 +1348,8 @@ impl BlockFlow {
// Calculate non-auto block size to pass to children. // Calculate non-auto block size to pass to children.
let box_border = match self.fragment.style().get_position().box_sizing { let box_border = match self.fragment.style().get_position().box_sizing {
box_sizing::T::border_box => self.fragment.border_padding.block_start_end(), BoxSizing::BorderBox => self.fragment.border_padding.block_start_end(),
box_sizing::T::content_box => Au(0), BoxSizing::ContentBox => Au(0),
}; };
let parent_container_size = self.explicit_block_containing_size(shared_context); let parent_container_size = self.explicit_block_containing_size(shared_context);
// https://drafts.csswg.org/css-ui-3/#box-sizing // https://drafts.csswg.org/css-ui-3/#box-sizing
@ -1434,20 +1438,20 @@ impl BlockFlow {
return FormattingContextType::Other return FormattingContextType::Other
} }
let style = self.fragment.style(); let style = self.fragment.style();
if style.get_box().float != float::T::none { if style.get_box().float != Float::None {
return FormattingContextType::Other return FormattingContextType::Other
} }
match style.get_box().display { match style.get_box().display {
display::T::table_cell | Display::TableCell |
display::T::table_caption | Display::TableCaption |
display::T::table_row_group | Display::TableRowGroup |
display::T::table | Display::Table |
display::T::inline_block | Display::InlineBlock |
display::T::flex => { Display::Flex => {
FormattingContextType::Other FormattingContextType::Other
} }
_ if style.get_box().overflow_x != overflow_x::T::visible || _ if style.get_box().overflow_x != StyleOverflow::Visible ||
style.get_box().overflow_y != overflow_x::T::visible || style.get_box().overflow_y != StyleOverflow::Visible ||
style.is_multicol() => { style.is_multicol() => {
FormattingContextType::Block FormattingContextType::Block
} }
@ -1531,8 +1535,8 @@ impl BlockFlow {
if let MaybeAuto::Specified(size) = MaybeAuto::from_style(specified_inline_size, if let MaybeAuto::Specified(size) = MaybeAuto::from_style(specified_inline_size,
container_size) { container_size) {
match self.fragment.style().get_position().box_sizing { match self.fragment.style().get_position().box_sizing {
box_sizing::T::border_box => size, BoxSizing::BorderBox => size,
box_sizing::T::content_box => BoxSizing::ContentBox =>
size + self.fragment.border_padding.inline_start_end(), size + self.fragment.border_padding.inline_start_end(),
} }
} else { } else {
@ -1561,8 +1565,8 @@ impl BlockFlow {
} }
fn is_inline_block_or_inline_flex(&self) -> bool { fn is_inline_block_or_inline_flex(&self) -> bool {
self.fragment.style().get_box().display == display::T::inline_block || self.fragment.style().get_box().display == Display::InlineBlock ||
self.fragment.style().get_box().display == display::T::inline_flex self.fragment.style().get_box().display == Display::InlineFlex
} }
/// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is /// Computes the content portion (only) of the intrinsic inline sizes of this flow. This is
@ -1631,21 +1635,21 @@ impl BlockFlow {
} }
match (float_kind, child_base.flags.contains(FlowFlags::CONTAINS_TEXT_OR_REPLACED_FRAGMENTS)) { match (float_kind, child_base.flags.contains(FlowFlags::CONTAINS_TEXT_OR_REPLACED_FRAGMENTS)) {
(float::T::none, true) => { (Float::None, true) => {
computation.content_intrinsic_sizes.preferred_inline_size = computation.content_intrinsic_sizes.preferred_inline_size =
max(computation.content_intrinsic_sizes.preferred_inline_size, max(computation.content_intrinsic_sizes.preferred_inline_size,
child_base.intrinsic_inline_sizes.preferred_inline_size); child_base.intrinsic_inline_sizes.preferred_inline_size);
} }
(float::T::none, false) => { (Float::None, false) => {
preferred_inline_size_of_children_without_text_or_replaced_fragments = max( preferred_inline_size_of_children_without_text_or_replaced_fragments = max(
preferred_inline_size_of_children_without_text_or_replaced_fragments, preferred_inline_size_of_children_without_text_or_replaced_fragments,
child_base.intrinsic_inline_sizes.preferred_inline_size) child_base.intrinsic_inline_sizes.preferred_inline_size)
} }
(float::T::left, _) => { (Float::Left, _) => {
left_float_width_accumulator = left_float_width_accumulator + left_float_width_accumulator = left_float_width_accumulator +
child_base.intrinsic_inline_sizes.preferred_inline_size; child_base.intrinsic_inline_sizes.preferred_inline_size;
} }
(float::T::right, _) => { (Float::Right, _) => {
right_float_width_accumulator = right_float_width_accumulator + right_float_width_accumulator = right_float_width_accumulator +
child_base.intrinsic_inline_sizes.preferred_inline_size; child_base.intrinsic_inline_sizes.preferred_inline_size;
} }
@ -1669,8 +1673,8 @@ impl BlockFlow {
pub fn overflow_style_may_require_clip_scroll_node(&self) -> bool { pub fn overflow_style_may_require_clip_scroll_node(&self) -> bool {
match (self.fragment.style().get_box().overflow_x, match (self.fragment.style().get_box().overflow_x,
self.fragment.style().get_box().overflow_y) { self.fragment.style().get_box().overflow_y) {
(overflow_x::T::auto, _) | (overflow_x::T::scroll, _) | (overflow_x::T::hidden, _) | (StyleOverflow::Auto, _) | (StyleOverflow::Scroll, _) | (StyleOverflow::Hidden, _) |
(_, overflow_x::T::auto) | (_, overflow_x::T::scroll) | (_, overflow_x::T::hidden) => (_, StyleOverflow::Auto) | (_, StyleOverflow::Scroll) | (_, StyleOverflow::Hidden) =>
true, true,
(_, _) => false, (_, _) => false,
} }
@ -2098,7 +2102,7 @@ impl Flow for BlockFlow {
} }
/// The 'position' property of this flow. /// The 'position' property of this flow.
fn positioning(&self) -> position::T { fn positioning(&self) -> Position {
self.fragment.style.get_box().position self.fragment.style.get_box().position
} }
@ -2209,7 +2213,7 @@ pub struct ISizeConstraintInput {
pub inline_end_margin: MaybeAuto, pub inline_end_margin: MaybeAuto,
pub inline_start: MaybeAuto, pub inline_start: MaybeAuto,
pub inline_end: MaybeAuto, pub inline_end: MaybeAuto,
pub text_align: text_align::T, pub text_align: TextAlign,
pub available_inline_size: Au, pub available_inline_size: Au,
} }
@ -2219,7 +2223,7 @@ impl ISizeConstraintInput {
inline_end_margin: MaybeAuto, inline_end_margin: MaybeAuto,
inline_start: MaybeAuto, inline_start: MaybeAuto,
inline_end: MaybeAuto, inline_end: MaybeAuto,
text_align: text_align::T, text_align: TextAlign,
available_inline_size: Au) available_inline_size: Au)
-> ISizeConstraintInput { -> ISizeConstraintInput {
ISizeConstraintInput { ISizeConstraintInput {
@ -2298,12 +2302,12 @@ pub trait ISizeAndMarginsComputer {
shared_context); shared_context);
let style = block.fragment.style(); let style = block.fragment.style();
match (computed_inline_size, style.get_position().box_sizing) { match (computed_inline_size, style.get_position().box_sizing) {
(MaybeAuto::Specified(size), box_sizing::T::border_box) => { (MaybeAuto::Specified(size), BoxSizing::BorderBox) => {
computed_inline_size = computed_inline_size =
MaybeAuto::Specified(size - block.fragment.border_padding.inline_start_end()) MaybeAuto::Specified(size - block.fragment.border_padding.inline_start_end())
} }
(MaybeAuto::Auto, box_sizing::T::border_box) | (MaybeAuto::Auto, BoxSizing::BorderBox) |
(_, box_sizing::T::content_box) => {} (_, BoxSizing::ContentBox) => {}
} }
let margin = style.logical_margin(); let margin = style.logical_margin();
@ -2499,15 +2503,15 @@ pub trait ISizeAndMarginsComputer {
MaybeAuto::Specified(margin_end)) => { MaybeAuto::Specified(margin_end)) => {
// servo_left, servo_right, and servo_center are used to implement // servo_left, servo_right, and servo_center are used to implement
// the "align descendants" rule in HTML5 § 14.2. // the "align descendants" rule in HTML5 § 14.2.
if block_align == text_align::T::servo_center { if block_align == TextAlign::ServoCenter {
// Ignore any existing margins, and make the inline-start and // Ignore any existing margins, and make the inline-start and
// inline-end margins equal. // inline-end margins equal.
let margin = (available_inline_size - inline_size).scale_by(0.5); let margin = (available_inline_size - inline_size).scale_by(0.5);
(margin, inline_size, margin) (margin, inline_size, margin)
} else { } else {
let ignore_end_margin = match block_align { let ignore_end_margin = match block_align {
text_align::T::servo_left => block_mode.is_bidi_ltr(), TextAlign::ServoLeft => block_mode.is_bidi_ltr(),
text_align::T::servo_right => !block_mode.is_bidi_ltr(), TextAlign::ServoRight => !block_mode.is_bidi_ltr(),
_ => parent_has_same_direction, _ => parent_has_same_direction,
}; };
if ignore_end_margin { if ignore_end_margin {

View file

@ -43,9 +43,13 @@ use std::marker::PhantomData;
use std::mem; use std::mem;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use style::computed_values::{caption_side, display, empty_cells, float, list_style_position}; use style::computed_values::caption_side::T as CaptionSide;
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::computed_values::position; use style::computed_values::display::T as Display;
use style::computed_values::empty_cells::T as EmptyCells;
use style::computed_values::float::T as Float;
use style::computed_values::list_style_position::T as ListStylePosition;
use style::computed_values::position::T as Position;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::Direction; use style::logical_geometry::Direction;
use style::properties::ComputedValues; use style::properties::ComputedValues;
@ -862,7 +866,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// If the node is positioned, then it's the containing block for all absolutely- // If the node is positioned, then it's the containing block for all absolutely-
// positioned descendants. // positioned descendants.
if node_style.get_box().position != position::T::static_ { if node_style.get_box().position != Position::Static {
fragment_accumulator.fragments fragment_accumulator.fragments
.absolute_descendants .absolute_descendants
.mark_as_having_reached_containing_block(); .mark_as_having_reached_containing_block();
@ -925,11 +929,14 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
} }
/// Build the fragment for an inline-block or inline-flex, based on the `display` flag /// Build the fragment for an inline-block or inline-flex, based on the `display` flag
fn build_fragment_for_inline_block_or_inline_flex(&mut self, node: &ConcreteThreadSafeLayoutNode, fn build_fragment_for_inline_block_or_inline_flex(
display: display::T) -> ConstructionResult { &mut self,
node: &ConcreteThreadSafeLayoutNode,
display: Display,
) -> ConstructionResult {
let block_flow_result = match display { let block_flow_result = match display {
display::T::inline_block => self.build_flow_for_block(node, None), Display::InlineBlock => self.build_flow_for_block(node, None),
display::T::inline_flex => self.build_flow_for_flex(node, None), Display::InlineFlex => self.build_flow_for_flex(node, None),
_ => panic!("The flag should be inline-block or inline-flex") _ => panic!("The flag should be inline-block or inline-flex")
}; };
let (block_flow, abs_descendants) = match block_flow_result { let (block_flow, abs_descendants) = match block_flow_result {
@ -1017,7 +1024,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
fn place_table_caption_under_table_wrapper_on_side(&mut self, fn place_table_caption_under_table_wrapper_on_side(&mut self,
table_wrapper_flow: &mut FlowRef, table_wrapper_flow: &mut FlowRef,
node: &ConcreteThreadSafeLayoutNode, node: &ConcreteThreadSafeLayoutNode,
side: caption_side::T) { side: CaptionSide) {
// Only flows that are table captions are matched here. // Only flows that are table captions are matched here.
for kid in node.children() { for kid in node.children() {
match kid.get_construction_result() { match kid.get_construction_result() {
@ -1078,7 +1085,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
/// Builds a flow for a node with `display: table`. This yields a `TableWrapperFlow` with /// Builds a flow for a node with `display: table`. This yields a `TableWrapperFlow` with
/// possibly other `TableCaptionFlow`s or `TableFlow`s underneath it. /// possibly other `TableCaptionFlow`s or `TableFlow`s underneath it.
fn build_flow_for_table(&mut self, node: &ConcreteThreadSafeLayoutNode, float_value: float::T) fn build_flow_for_table(&mut self, node: &ConcreteThreadSafeLayoutNode, float_value: Float)
-> ConstructionResult { -> ConstructionResult {
let mut legalizer = Legalizer::new(); let mut legalizer = Legalizer::new();
@ -1115,7 +1122,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// value of `caption-side`. // value of `caption-side`.
self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow,
node, node,
caption_side::T::top); CaptionSide::Top);
if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result { if let ConstructionResult::Flow(table_flow, table_abs_descendants) = construction_result {
legalizer.add_child(self.style_context(), &mut wrapper_flow, table_flow); legalizer.add_child(self.style_context(), &mut wrapper_flow, table_flow);
@ -1125,7 +1132,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// If the value of `caption-side` is `bottom`, place it now. // If the value of `caption-side` is `bottom`, place it now.
self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow, self.place_table_caption_under_table_wrapper_on_side(&mut wrapper_flow,
node, node,
caption_side::T::bottom); CaptionSide::Bottom);
// The flow is done. // The flow is done.
legalizer.finish(&mut wrapper_flow); legalizer.finish(&mut wrapper_flow);
@ -1180,12 +1187,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true // Determine if the table cell should be hidden. Per CSS 2.1 § 17.6.1.1, this will be true
// if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to // if the cell has any in-flow elements (even empty ones!) and has `empty-cells` set to
// `hide`. // `hide`.
let hide = node.style(self.style_context()).get_inheritedtable().empty_cells == empty_cells::T::hide && let hide = node.style(self.style_context()).get_inheritedtable().empty_cells == EmptyCells::Hide &&
node.children().all(|kid| { node.children().all(|kid| {
let position = kid.style(self.style_context()).get_box().position; let position = kid.style(self.style_context()).get_box().position;
!kid.is_content() || !kid.is_content() ||
position == position::T::absolute || position == Position::Absolute ||
position == position::T::fixed position == Position::Fixed
}); });
let flow = FlowRef::new(Arc::new( let flow = FlowRef::new(Arc::new(
@ -1197,7 +1204,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
/// possibly other `BlockFlow`s or `InlineFlow`s underneath it. /// possibly other `BlockFlow`s or `InlineFlow`s underneath it.
fn build_flow_for_list_item(&mut self, fn build_flow_for_list_item(&mut self,
node: &ConcreteThreadSafeLayoutNode, node: &ConcreteThreadSafeLayoutNode,
flotation: float::T) flotation: Float)
-> ConstructionResult { -> ConstructionResult {
let flotation = FloatKind::from_property(flotation); let flotation = FloatKind::from_property(flotation);
let marker_fragments = match node.style(self.style_context()).get_list().list_style_image { let marker_fragments = match node.style(self.style_context()).get_list().list_style_image {
@ -1243,11 +1250,11 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
let mut initial_fragments = IntermediateInlineFragments::new(); let mut initial_fragments = IntermediateInlineFragments::new();
let main_fragment = self.build_fragment_for_block(node); let main_fragment = self.build_fragment_for_block(node);
let flow = match node.style(self.style_context()).get_list().list_style_position { let flow = match node.style(self.style_context()).get_list().list_style_position {
list_style_position::T::outside => { ListStylePosition::Outside => {
Arc::new(ListItemFlow::from_fragments_and_flotation( Arc::new(ListItemFlow::from_fragments_and_flotation(
main_fragment, marker_fragments, flotation)) main_fragment, marker_fragments, flotation))
} }
list_style_position::T::inside => { ListStylePosition::Inside => {
for marker_fragment in marker_fragments { for marker_fragment in marker_fragments {
initial_fragments.fragments.push_back(marker_fragment) initial_fragments.fragments.push_back(marker_fragment)
} }
@ -1327,7 +1334,7 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
// If the node has display: none, it's possible that we haven't even // If the node has display: none, it's possible that we haven't even
// styled the children once, so we need to bailout early here. // styled the children once, so we need to bailout early here.
if node.style(self.style_context()).get_box().clone_display() == display::T::none { if node.style(self.style_context()).get_box().clone_display() == Display::None {
return false; return false;
} }
@ -1466,8 +1473,7 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Pseudo-element. // Pseudo-element.
let style = node.style(self.style_context()); let style = node.style(self.style_context());
let display = match node.get_pseudo_element_type() { let display = match node.get_pseudo_element_type() {
PseudoElementType::Normal PseudoElementType::Normal => Display::Inline,
=> display::T::inline,
PseudoElementType::Before(maybe_display) | PseudoElementType::Before(maybe_display) |
PseudoElementType::After(maybe_display) | PseudoElementType::After(maybe_display) |
PseudoElementType::DetailsContent(maybe_display) | PseudoElementType::DetailsContent(maybe_display) |
@ -1480,13 +1486,13 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
let style = node.style(self.style_context()); let style = node.style(self.style_context());
let original_display = style.get_box()._servo_display_for_hypothetical_box; let original_display = style.get_box()._servo_display_for_hypothetical_box;
let munged_display = match original_display { let munged_display = match original_display {
display::T::inline | display::T::inline_block => original_display, Display::Inline | Display::InlineBlock => original_display,
_ => style.get_box().display, _ => style.get_box().display,
}; };
(munged_display, style.get_box().float, style.get_box().position) (munged_display, style.get_box().float, style.get_box().position)
} }
Some(LayoutNodeType::Text) => Some(LayoutNodeType::Text) =>
(display::T::inline, float::T::none, position::T::static_), (Display::Inline, Float::None, Position::Static),
}; };
debug!("building flow for node: {:?} {:?} {:?} {:?}", display, float, positioning, node.type_id()); debug!("building flow for node: {:?} {:?} {:?} {:?}", display, float, positioning, node.type_id());
@ -1494,12 +1500,12 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Switch on display and floatedness. // Switch on display and floatedness.
match (display, float, positioning) { match (display, float, positioning) {
// `display: none` contributes no flow construction result. // `display: none` contributes no flow construction result.
(display::T::none, _, _) => { (Display::None, _, _) => {
self.set_flow_construction_result(node, ConstructionResult::None); self.set_flow_construction_result(node, ConstructionResult::None);
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table, float_value, _) => { (Display::Table, float_value, _) => {
let construction_result = self.build_flow_for_table(node, float_value); let construction_result = self.build_flow_for_table(node, float_value);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
@ -1510,22 +1516,22 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// positioned, but inline we shouldn't try to construct a block // positioned, but inline we shouldn't try to construct a block
// flow here - instead, let it match the inline case // flow here - instead, let it match the inline case
// below. // below.
(display::T::block, _, position::T::absolute) | (Display::Block, _, Position::Absolute) |
(display::T::block, _, position::T::fixed) => { (Display::Block, _, Position::Fixed) => {
let construction_result = self.build_flow_for_block(node, None); let construction_result = self.build_flow_for_block(node, None);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// List items contribute their own special flows. // List items contribute their own special flows.
(display::T::list_item, float_value, _) => { (Display::ListItem, float_value, _) => {
let construction_result = self.build_flow_for_list_item(node, float_value); let construction_result = self.build_flow_for_list_item(node, float_value);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Inline items that are absolutely-positioned contribute inline fragment construction // Inline items that are absolutely-positioned contribute inline fragment construction
// results with a hypothetical fragment. // results with a hypothetical fragment.
(display::T::inline, _, position::T::absolute) | (Display::Inline, _, Position::Absolute) |
(display::T::inline_block, _, position::T::absolute) => { (Display::InlineBlock, _, Position::Absolute) => {
let construction_result = let construction_result =
self.build_fragment_for_absolutely_positioned_inline(node); self.build_fragment_for_absolutely_positioned_inline(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
@ -1534,66 +1540,66 @@ impl<'a, ConcreteThreadSafeLayoutNode> PostorderNodeMutTraversal<ConcreteThreadS
// Inline items contribute inline fragment construction results. // Inline items contribute inline fragment construction results.
// //
// FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content. // FIXME(pcwalton, #3307): This is not sufficient to handle floated generated content.
(display::T::inline, float::T::none, _) => { (Display::Inline, Float::None, _) => {
let construction_result = self.build_fragments_for_inline(node); let construction_result = self.build_fragments_for_inline(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Inline-block items contribute inline fragment construction results. // Inline-block items contribute inline fragment construction results.
(display::T::inline_block, float::T::none, _) => { (Display::InlineBlock, Float::None, _) => {
let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_block); Display::InlineBlock);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_caption, _, _) => { (Display::TableCaption, _, _) => {
let construction_result = self.build_flow_for_table_caption(node); let construction_result = self.build_flow_for_table_caption(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_column_group, _, _) => { (Display::TableColumnGroup, _, _) => {
let construction_result = self.build_flow_for_table_colgroup(node); let construction_result = self.build_flow_for_table_colgroup(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_column, _, _) => { (Display::TableColumn, _, _) => {
let construction_result = self.build_fragments_for_table_column(node); let construction_result = self.build_fragments_for_table_column(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_row_group, _, _) | (Display::TableRowGroup, _, _) |
(display::T::table_header_group, _, _) | (Display::TableHeaderGroup, _, _) |
(display::T::table_footer_group, _, _) => { (Display::TableFooterGroup, _, _) => {
let construction_result = self.build_flow_for_table_rowgroup(node); let construction_result = self.build_flow_for_table_rowgroup(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_row, _, _) => { (Display::TableRow, _, _) => {
let construction_result = self.build_flow_for_table_row(node); let construction_result = self.build_flow_for_table_row(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Table items contribute table flow construction results. // Table items contribute table flow construction results.
(display::T::table_cell, _, _) => { (Display::TableCell, _, _) => {
let construction_result = self.build_flow_for_table_cell(node); let construction_result = self.build_flow_for_table_cell(node);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
// Flex items contribute flex flow construction results. // Flex items contribute flex flow construction results.
(display::T::flex, float_value, _) => { (Display::Flex, float_value, _) => {
let float_kind = FloatKind::from_property(float_value); let float_kind = FloatKind::from_property(float_value);
let construction_result = self.build_flow_for_flex(node, float_kind); let construction_result = self.build_flow_for_flex(node, float_kind);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
(display::T::inline_flex, _, _) => { (Display::InlineFlex, _, _) => {
let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node, let construction_result = self.build_fragment_for_inline_block_or_inline_flex(node,
display::T::inline_flex); Display::InlineFlex);
self.set_flow_construction_result(node, construction_result) self.set_flow_construction_result(node, construction_result)
} }
@ -1810,16 +1816,16 @@ fn bidi_control_chars(style: &ServoArc<ComputedValues>) -> Option<(&'static str,
// See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi // See the table in http://dev.w3.org/csswg/css-writing-modes/#unicode-bidi
match (unicode_bidi, direction) { match (unicode_bidi, direction) {
(normal, _) => None, (Normal, _) => None,
(embed, ltr) => Some(("\u{202A}", "\u{202C}")), (Embed, Ltr) => Some(("\u{202A}", "\u{202C}")),
(embed, rtl) => Some(("\u{202B}", "\u{202C}")), (Embed, Rtl) => Some(("\u{202B}", "\u{202C}")),
(isolate, ltr) => Some(("\u{2066}", "\u{2069}")), (Isolate, Ltr) => Some(("\u{2066}", "\u{2069}")),
(isolate, rtl) => Some(("\u{2067}", "\u{2069}")), (Isolate, Rtl) => Some(("\u{2067}", "\u{2069}")),
(bidi_override, ltr) => Some(("\u{202D}", "\u{202C}")), (BidiOverride, Ltr) => Some(("\u{202D}", "\u{202C}")),
(bidi_override, rtl) => Some(("\u{202E}", "\u{202C}")), (BidiOverride, Rtl) => Some(("\u{202E}", "\u{202C}")),
(isolate_override, ltr) => Some(("\u{2068}\u{202D}", "\u{202C}\u{2069}")), (IsolateOverride, Ltr) => Some(("\u{2068}\u{202D}", "\u{202C}\u{2069}")),
(isolate_override, rtl) => Some(("\u{2068}\u{202E}", "\u{202C}\u{2069}")), (IsolateOverride, Rtl) => Some(("\u{2068}\u{202E}", "\u{202C}\u{2069}")),
(plaintext, _) => Some(("\u{2068}", "\u{2069}")), (Plaintext, _) => Some(("\u{2068}", "\u{2069}")),
} }
} }

View file

@ -49,8 +49,13 @@ use std::default::Default;
use std::mem; use std::mem;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{background_attachment, background_clip, background_origin}; use style::computed_values::{background_attachment, background_clip, background_origin};
use style::computed_values::{border_style, cursor}; use style::computed_values::border_style::T as BorderStyle;
use style::computed_values::{image_rendering, overflow_x, pointer_events, position, visibility}; 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::pointer_events::T as PointerEvents;
use style::computed_values::position::T as StylePosition;
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::longhands::border_image_repeat::computed_value::RepeatKeyword;
@ -104,10 +109,10 @@ fn convert_repeat_mode(from: RepeatKeyword) -> RepeatMode {
} }
fn establishes_containing_block_for_absolute(flags: StackingContextCollectionFlags, fn establishes_containing_block_for_absolute(flags: StackingContextCollectionFlags,
positioning: position::T) positioning: StylePosition)
-> bool { -> bool {
!flags.contains(StackingContextCollectionFlags::NEVER_CREATES_CONTAINING_BLOCK) && !flags.contains(StackingContextCollectionFlags::NEVER_CREATES_CONTAINING_BLOCK) &&
position::T::static_ != positioning StylePosition::Static != positioning
} }
trait RgbColor { trait RgbColor {
@ -967,15 +972,15 @@ impl FragmentDisplayListBuilding for Fragment {
background.background_image.0.len() - 1); background.background_image.0.len() - 1);
match *color_clip { match *color_clip {
background_clip::single_value::T::border_box => {} background_clip::single_value::T::BorderBox => {}
background_clip::single_value::T::padding_box => { background_clip::single_value::T::PaddingBox => {
let border = style.logical_border_width().to_physical(style.writing_mode); let border = style.logical_border_width().to_physical(style.writing_mode);
bounds.origin.x = bounds.origin.x + border.left; bounds.origin.x = bounds.origin.x + border.left;
bounds.origin.y = bounds.origin.y + border.top; bounds.origin.y = bounds.origin.y + border.top;
bounds.size.width = bounds.size.width - border.horizontal(); bounds.size.width = bounds.size.width - border.horizontal();
bounds.size.height = bounds.size.height - border.vertical(); bounds.size.height = bounds.size.height - border.vertical();
} }
background_clip::single_value::T::content_box => { background_clip::single_value::T::ContentBox => {
let border_padding = self.border_padding.to_physical(style.writing_mode); let border_padding = self.border_padding.to_physical(style.writing_mode);
bounds.origin.x = bounds.origin.x + border_padding.left; bounds.origin.x = bounds.origin.x + border_padding.left;
bounds.origin.y = bounds.origin.y + border_padding.top; bounds.origin.y = bounds.origin.y + border_padding.top;
@ -1144,13 +1149,13 @@ impl FragmentDisplayListBuilding for Fragment {
// Use 'background-origin' to get the origin value. // Use 'background-origin' to get the origin value.
let origin = get_cyclic(&background.background_origin.0, index); let origin = get_cyclic(&background.background_origin.0, index);
let (mut origin_x, mut origin_y) = match *origin { let (mut origin_x, mut origin_y) = match *origin {
background_origin::single_value::T::padding_box => { background_origin::single_value::T::PaddingBox => {
(Au(0), Au(0)) (Au(0), Au(0))
} }
background_origin::single_value::T::border_box => { background_origin::single_value::T::BorderBox => {
(-border.left, -border.top) (-border.left, -border.top)
} }
background_origin::single_value::T::content_box => { background_origin::single_value::T::ContentBox => {
let border_padding = self.border_padding.to_physical(self.style.writing_mode); let border_padding = self.border_padding.to_physical(self.style.writing_mode);
(border_padding.left - border.left, border_padding.top - border.top) (border_padding.left - border.left, border_padding.top - border.top)
} }
@ -1159,10 +1164,10 @@ impl FragmentDisplayListBuilding for Fragment {
// Use `background-attachment` to get the initial virtual origin // Use `background-attachment` to get the initial virtual origin
let attachment = get_cyclic(&background.background_attachment.0, index); let attachment = get_cyclic(&background.background_attachment.0, index);
let (virtual_origin_x, virtual_origin_y) = match *attachment { let (virtual_origin_x, virtual_origin_y) = match *attachment {
background_attachment::single_value::T::scroll => { background_attachment::single_value::T::Scroll => {
(absolute_bounds.origin.x, absolute_bounds.origin.y) (absolute_bounds.origin.x, absolute_bounds.origin.y)
} }
background_attachment::single_value::T::fixed => { background_attachment::single_value::T::Fixed => {
// If the background-attachment value for this image is fixed, then // If the background-attachment value for this image is fixed, then
// 'background-origin' has no effect. // 'background-origin' has no effect.
origin_x = Au(0); origin_x = Au(0);
@ -1703,8 +1708,8 @@ impl FragmentDisplayListBuilding for Fragment {
} }
let outline_style = match style.get_outline().outline_style { let outline_style = match style.get_outline().outline_style {
Either::First(_auto) => border_style::T::solid, Either::First(_auto) => BorderStyle::Solid,
Either::Second(border_style::T::none) => return, Either::Second(BorderStyle::None) => return,
Either::Second(border_style) => border_style Either::Second(border_style) => border_style
}; };
@ -1756,7 +1761,7 @@ impl FragmentDisplayListBuilding for Fragment {
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(NormalBorder {
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)), color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid), style: SideOffsets2D::new_all_same(BorderStyle::Solid),
radius: Default::default(), radius: Default::default(),
}), }),
}))); })));
@ -1796,7 +1801,7 @@ impl FragmentDisplayListBuilding for Fragment {
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(NormalBorder {
color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)), color: SideOffsets2D::new_all_same(ColorF::rgb(0, 0, 200)),
style: SideOffsets2D::new_all_same(border_style::T::solid), style: SideOffsets2D::new_all_same(BorderStyle::Solid),
radius: Default::default(), radius: Default::default(),
}), }),
}))); })));
@ -1880,7 +1885,7 @@ impl FragmentDisplayListBuilding for Fragment {
display_list_section: DisplayListSection, display_list_section: DisplayListSection,
clip: &Rect<Au>) { clip: &Rect<Au>) {
self.restyle_damage.remove(ServoRestyleDamage::REPAINT); self.restyle_damage.remove(ServoRestyleDamage::REPAINT);
if self.style().get_inheritedbox().visibility != visibility::T::visible { if self.style().get_inheritedbox().visibility != Visibility::Visible {
return return
} }
@ -2174,7 +2179,7 @@ impl FragmentDisplayListBuilding for Fragment {
image_data: None, image_data: None,
stretch_size: stacking_relative_content_box.size, stretch_size: stacking_relative_content_box.size,
tile_spacing: Size2D::zero(), tile_spacing: Size2D::zero(),
image_rendering: image_rendering::T::auto, image_rendering: ImageRendering::Auto,
})); }));
state.add_display_item(display_item); state.add_display_item(display_item);
@ -2518,9 +2523,9 @@ impl SavedStackingContextCollectionState {
fn push_clip(&mut self, fn push_clip(&mut self,
state: &mut StackingContextCollectionState, state: &mut StackingContextCollectionState,
clip: &Rect<Au>, clip: &Rect<Au>,
positioning: position::T) { positioning: StylePosition) {
let mut clip = *clip; let mut clip = *clip;
if positioning != position::T::fixed { if positioning != StylePosition::Fixed {
if let Some(old_clip) = state.clip_stack.last() { if let Some(old_clip) = state.clip_stack.last() {
clip = old_clip.intersection(&clip).unwrap_or_else(Rect::zero); clip = old_clip.intersection(&clip).unwrap_or_else(Rect::zero);
} }
@ -2529,7 +2534,7 @@ impl SavedStackingContextCollectionState {
state.clip_stack.push(clip); state.clip_stack.push(clip);
self.clips_pushed += 1; self.clips_pushed += 1;
if position::T::absolute == positioning { if StylePosition::Absolute == positioning {
state.containing_block_clip_stack.push(clip); state.containing_block_clip_stack.push(clip);
self.containing_block_clips_pushed += 1; self.containing_block_clips_pushed += 1;
} }
@ -2659,13 +2664,13 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
// If this block is absolutely positioned, we should be clipped and positioned by // If this block is absolutely positioned, we should be clipped and positioned by
// the scroll root of our nearest ancestor that establishes a containing block. // the scroll root of our nearest ancestor that establishes a containing block.
let containing_clipping_and_scrolling = match self.positioning() { let containing_clipping_and_scrolling = match self.positioning() {
position::T::absolute => { StylePosition::Absolute => {
preserved_state.switch_to_containing_block_clip(state); preserved_state.switch_to_containing_block_clip(state);
state.current_clipping_and_scrolling = state.containing_block_clipping_and_scrolling; state.current_clipping_and_scrolling = state.containing_block_clipping_and_scrolling;
state.containing_block_clipping_and_scrolling state.containing_block_clipping_and_scrolling
} }
position::T::fixed => { StylePosition::Fixed => {
preserved_state.push_clip(state, &max_rect(), position::T::fixed); preserved_state.push_clip(state, &max_rect(), StylePosition::Fixed);
state.current_clipping_and_scrolling state.current_clipping_and_scrolling
} }
_ => state.current_clipping_and_scrolling, _ => state.current_clipping_and_scrolling,
@ -2703,7 +2708,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
} }
match self.positioning() { match self.positioning() {
position::T::absolute | position::T::relative | position::T::fixed => StylePosition::Absolute | StylePosition::Relative | StylePosition::Fixed =>
state.containing_block_clipping_and_scrolling = state.current_clipping_and_scrolling, state.containing_block_clipping_and_scrolling = state.current_clipping_and_scrolling,
_ => {} _ => {}
} }
@ -2714,7 +2719,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
fn setup_clip_scroll_node_for_position(&mut self, fn setup_clip_scroll_node_for_position(&mut self,
state: &mut StackingContextCollectionState, state: &mut StackingContextCollectionState,
border_box: &Rect<Au>) { border_box: &Rect<Au>) {
if self.positioning() != position::T::sticky { if self.positioning() != StylePosition::Sticky {
return; return;
} }
@ -2791,8 +2796,8 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
self.base.overflow.scroll.origin != Point2D::zero() || self.base.overflow.scroll.origin != Point2D::zero() ||
self.base.overflow.scroll.size.width > content_box.size.width || self.base.overflow.scroll.size.width > content_box.size.width ||
self.base.overflow.scroll.size.height > content_box.size.height || self.base.overflow.scroll.size.height > content_box.size.height ||
overflow_x::T::hidden == self.fragment.style.get_box().overflow_x || StyleOverflow::Hidden == self.fragment.style.get_box().overflow_x ||
overflow_x::T::hidden == self.fragment.style.get_box().overflow_y; StyleOverflow::Hidden == self.fragment.style.get_box().overflow_y;
self.mark_scrolling_overflow(has_scrolling_overflow); self.mark_scrolling_overflow(has_scrolling_overflow);
if !has_scrolling_overflow { if !has_scrolling_overflow {
@ -2805,8 +2810,8 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
let new_clip_scroll_node_id = ClipId::new(self.fragment.unique_id(IdType::OverflowClip), let new_clip_scroll_node_id = ClipId::new(self.fragment.unique_id(IdType::OverflowClip),
state.pipeline_id.to_webrender()); state.pipeline_id.to_webrender());
let sensitivity = if overflow_x::T::hidden == self.fragment.style.get_box().overflow_x && let sensitivity = if StyleOverflow::Hidden == self.fragment.style.get_box().overflow_x &&
overflow_x::T::hidden == self.fragment.style.get_box().overflow_y { StyleOverflow::Hidden == self.fragment.style.get_box().overflow_y {
ScrollSensitivity::Script ScrollSensitivity::Script
} else { } else {
ScrollSensitivity::ScriptAndInputEvents ScrollSensitivity::ScriptAndInputEvents
@ -2852,7 +2857,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
// CSS `clip` should only apply to position:absolute or positione:fixed elements. // CSS `clip` should only apply to position:absolute or positione:fixed elements.
// CSS Masking Appendix A: "Applies to: Absolutely positioned elements." // CSS Masking Appendix A: "Applies to: Absolutely positioned elements."
match self.positioning() { match self.positioning() {
position::T::absolute | position::T::fixed => {} StylePosition::Absolute | StylePosition::Fixed => {}
_ => return, _ => return,
} }
@ -2891,7 +2896,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
state: &mut StackingContextCollectionState state: &mut StackingContextCollectionState
) { ) {
let creation_mode = if self.base.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) || let creation_mode = if self.base.flags.contains(FlowFlags::IS_ABSOLUTELY_POSITIONED) ||
self.fragment.style.get_box().position != position::T::static_ { self.fragment.style.get_box().position != StylePosition::Static {
StackingContextType::PseudoPositioned StackingContextType::PseudoPositioned
} else { } else {
assert!(self.base.flags.is_float()); assert!(self.base.flags.is_float());
@ -2997,7 +3002,7 @@ impl BlockFlowDisplayListBuilding for BlockFlow {
return BlockStackingContextType::PseudoStackingContext return BlockStackingContextType::PseudoStackingContext
} }
if self.fragment.style.get_box().position != position::T::static_ { if self.fragment.style.get_box().position != StylePosition::Static {
return BlockStackingContextType::PseudoStackingContext return BlockStackingContextType::PseudoStackingContext
} }
@ -3176,7 +3181,7 @@ impl BaseFlowDisplayListBuilding for BaseFlow {
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(NormalBorder {
color: SideOffsets2D::new_all_same(color), color: SideOffsets2D::new_all_same(color),
style: SideOffsets2D::new_all_same(border_style::T::solid), style: SideOffsets2D::new_all_same(BorderStyle::Solid),
radius: BorderRadii::all_same(Au(0)), radius: BorderRadii::all_same(Au(0)),
}), }),
}))); })));
@ -3194,9 +3199,9 @@ impl ComputedValuesCursorUtility for ComputedValues {
#[inline] #[inline]
fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> { fn get_cursor(&self, default_cursor: Cursor) -> Option<Cursor> {
match (self.get_pointing().pointer_events, self.get_pointing().cursor) { match (self.get_pointing().pointer_events, self.get_pointing().cursor) {
(pointer_events::T::none, _) => None, (PointerEvents::None, _) => None,
(pointer_events::T::auto, cursor::Keyword::Auto) => Some(default_cursor), (PointerEvents::Auto, cursor::Keyword::Auto) => Some(default_cursor),
(pointer_events::T::auto, cursor::Keyword::Cursor(cursor)) => Some(cursor), (PointerEvents::Auto, cursor::Keyword::Cursor(cursor)) => Some(cursor),
} }
} }
} }

View file

@ -21,7 +21,11 @@ use model::{AdjoiningMargins, CollapsibleMargins};
use model::{IntrinsicISizes, MaybeAuto, SizeConstraint}; use model::{IntrinsicISizes, MaybeAuto, SizeConstraint};
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::ops::Range; use std::ops::Range;
use style::computed_values::{align_content, align_self, flex_direction, flex_wrap, justify_content}; use style::computed_values::align_content::T as AlignContent;
use style::computed_values::align_self::T as AlignSelf;
use style::computed_values::flex_direction::T as FlexDirection;
use style::computed_values::flex_wrap::T as FlexWrap;
use style::computed_values::justify_content::T as JustifyContent;
use style::logical_geometry::{Direction, LogicalSize}; use style::logical_geometry::{Direction, LogicalSize};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -366,18 +370,18 @@ impl FlexFlow {
{ {
let style = fragment.style(); let style = fragment.style();
let (mode, reverse) = match style.get_position().flex_direction { let (mode, reverse) = match style.get_position().flex_direction {
flex_direction::T::row => (Direction::Inline, false), FlexDirection::Row => (Direction::Inline, false),
flex_direction::T::row_reverse => (Direction::Inline, true), FlexDirection::RowReverse => (Direction::Inline, true),
flex_direction::T::column => (Direction::Block, false), FlexDirection::Column => (Direction::Block, false),
flex_direction::T::column_reverse => (Direction::Block, true), FlexDirection::ColumnReverse => (Direction::Block, true),
}; };
main_mode = mode; main_mode = mode;
main_reverse = main_reverse =
reverse == style.writing_mode.is_bidi_ltr(); reverse == style.writing_mode.is_bidi_ltr();
let (wrappable, reverse) = match fragment.style.get_position().flex_wrap { let (wrappable, reverse) = match fragment.style.get_position().flex_wrap {
flex_wrap::T::nowrap => (false, false), FlexWrap::Nowrap => (false, false),
flex_wrap::T::wrap => (true, false), FlexWrap::Wrap => (true, false),
flex_wrap::T::wrap_reverse => (true, true), FlexWrap::WrapReverse => (true, true),
}; };
is_wrappable = wrappable; is_wrappable = wrappable;
// TODO(stshine): Handle vertical writing mode. // TODO(stshine): Handle vertical writing mode.
@ -582,14 +586,14 @@ impl FlexFlow {
let mut cur_i = inline_start_content_edge; let mut cur_i = inline_start_content_edge;
let item_interval = if line.free_space >= Au(0) && line.auto_margin_count == 0 { let item_interval = if line.free_space >= Au(0) && line.auto_margin_count == 0 {
match self.block_flow.fragment.style().get_position().justify_content { match self.block_flow.fragment.style().get_position().justify_content {
justify_content::T::space_between => { JustifyContent::SpaceBetween => {
if item_count == 1 { if item_count == 1 {
Au(0) Au(0)
} else { } else {
line.free_space / (item_count - 1) line.free_space / (item_count - 1)
} }
} }
justify_content::T::space_around => { JustifyContent::SpaceAround => {
line.free_space / item_count line.free_space / item_count
} }
_ => Au(0), _ => Au(0),
@ -600,10 +604,10 @@ impl FlexFlow {
match self.block_flow.fragment.style().get_position().justify_content { match self.block_flow.fragment.style().get_position().justify_content {
// Overflow equally in both ends of line. // Overflow equally in both ends of line.
justify_content::T::center | justify_content::T::space_around => { JustifyContent::Center | JustifyContent::SpaceAround => {
cur_i += (line.free_space - item_interval * (item_count - 1)) / 2; cur_i += (line.free_space - item_interval * (item_count - 1)) / 2;
} }
justify_content::T::flex_end => { JustifyContent::FlexEnd => {
cur_i += line.free_space; cur_i += line.free_space;
} }
_ => {} _ => {}
@ -709,21 +713,21 @@ impl FlexFlow {
let free_space = container_block_size - total_cross_size; let free_space = container_block_size - total_cross_size;
total_cross_size = container_block_size; total_cross_size = container_block_size;
if line_align == align_content::T::stretch && free_space > Au(0) { if line_align == AlignContent::Stretch && free_space > Au(0) {
for line in self.lines.iter_mut() { for line in self.lines.iter_mut() {
line.cross_size += free_space / line_count; line.cross_size += free_space / line_count;
} }
} }
line_interval = match line_align { line_interval = match line_align {
align_content::T::space_between => { AlignContent::SpaceBetween => {
if line_count <= 1 { if line_count <= 1 {
Au(0) Au(0)
} else { } else {
free_space / (line_count - 1) free_space / (line_count - 1)
} }
} }
align_content::T::space_around => { AlignContent::SpaceAround => {
if line_count == 0 { if line_count == 0 {
Au(0) Au(0)
} else { } else {
@ -734,10 +738,10 @@ impl FlexFlow {
}; };
match line_align { match line_align {
align_content::T::center | align_content::T::space_around => { AlignContent::Center | AlignContent::SpaceAround => {
cur_b += (free_space - line_interval * (line_count - 1)) / 2; cur_b += (free_space - line_interval * (line_count - 1)) / 2;
} }
align_content::T::flex_end => { AlignContent::FlexEnd => {
cur_b += free_space; cur_b += free_space;
} }
_ => {} _ => {}
@ -772,7 +776,7 @@ impl FlexFlow {
} }
let self_align = block.fragment.style().get_position().align_self; let self_align = block.fragment.style().get_position().align_self;
if self_align == align_self::T::stretch && if self_align == AlignSelf::Stretch &&
block.fragment.style().content_block_size() == LengthOrPercentageOrAuto::Auto { block.fragment.style().content_block_size() == LengthOrPercentageOrAuto::Auto {
free_space = Au(0); free_space = Au(0);
block.base.block_container_explicit_block_size = Some(line.cross_size); block.base.block_container_explicit_block_size = Some(line.cross_size);
@ -793,8 +797,8 @@ impl FlexFlow {
// TODO(stshine): support baseline alignment. // TODO(stshine): support baseline alignment.
if free_space != Au(0) { if free_space != Au(0) {
let flex_cross = match self_align { let flex_cross = match self_align {
align_self::T::flex_end => free_space, AlignSelf::FlexEnd => free_space,
align_self::T::center => free_space / 2, AlignSelf::Center => free_space / 2,
_ => Au(0), _ => Au(0),
}; };
block.base.position.start.b += block.base.position.start.b +=

View file

@ -8,7 +8,7 @@ use flow::{self, Flow, FlowFlags, ImmutableFlowUtils};
use persistent_list::PersistentList; use persistent_list::PersistentList;
use std::cmp::{max, min}; use std::cmp::{max, min};
use std::fmt; use std::fmt;
use style::computed_values::float; use style::computed_values::float::T as StyleFloat;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::values::computed::LengthOrPercentageOrAuto; use style::values::computed::LengthOrPercentageOrAuto;
@ -20,11 +20,11 @@ pub enum FloatKind {
} }
impl FloatKind { impl FloatKind {
pub fn from_property(property: float::T) -> Option<FloatKind> { pub fn from_property(property: StyleFloat) -> Option<FloatKind> {
match property { match property {
float::T::none => None, StyleFloat::None => None,
float::T::left => Some(FloatKind::Left), StyleFloat::Left => Some(FloatKind::Left),
float::T::right => Some(FloatKind::Right), StyleFloat::Right => Some(FloatKind::Right),
} }
} }
} }
@ -513,9 +513,9 @@ impl SpeculatedFloatPlacement {
} }
match base_flow.flags.float_kind() { match base_flow.flags.float_kind() {
float::T::none => {} StyleFloat::None => {}
float::T::left => self.left = self.left + float_inline_size, StyleFloat::Left => self.left = self.left + float_inline_size,
float::T::right => self.right = self.right + float_inline_size, StyleFloat::Right => self.right = self.right + float_inline_size,
} }
} }

View file

@ -49,7 +49,11 @@ use std::iter::Zip;
use std::slice::IterMut; use std::slice::IterMut;
use std::sync::Arc; use std::sync::Arc;
use std::sync::atomic::Ordering; use std::sync::atomic::Ordering;
use style::computed_values::{clear, float, overflow_x, position, text_align}; use style::computed_values::clear::T as Clear;
use style::computed_values::float::T as Float;
use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::position::T as Position;
use style::computed_values::text_align::T as TextAlign;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
@ -277,13 +281,13 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
&base(self).early_absolute_position_info.relative_containing_block_size, &base(self).early_absolute_position_info.relative_containing_block_size,
base(self).early_absolute_position_info.relative_containing_block_mode, base(self).early_absolute_position_info.relative_containing_block_mode,
CoordinateSystem::Own); CoordinateSystem::Own);
if overflow_x::T::visible != self.as_block().fragment.style.get_box().overflow_x { if StyleOverflow::Visible != self.as_block().fragment.style.get_box().overflow_x {
overflow.paint.origin.x = Au(0); overflow.paint.origin.x = Au(0);
overflow.paint.size.width = border_box.size.width; overflow.paint.size.width = border_box.size.width;
overflow.scroll.origin.x = Au(0); overflow.scroll.origin.x = Au(0);
overflow.scroll.size.width = border_box.size.width; overflow.scroll.size.width = border_box.size.width;
} }
if overflow_x::T::visible != self.as_block().fragment.style.get_box().overflow_y { if StyleOverflow::Visible != self.as_block().fragment.style.get_box().overflow_y {
overflow.paint.origin.y = Au(0); overflow.paint.origin.y = Au(0);
overflow.paint.size.height = border_box.size.height; overflow.paint.size.height = border_box.size.height;
overflow.scroll.origin.y = Au(0); overflow.scroll.origin.y = Au(0);
@ -391,13 +395,13 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
} }
/// The 'position' property of this flow. /// The 'position' property of this flow.
fn positioning(&self) -> position::T { fn positioning(&self) -> Position {
position::T::static_ Position::Static
} }
/// Return true if this flow has position 'fixed'. /// Return true if this flow has position 'fixed'.
fn is_fixed(&self) -> bool { fn is_fixed(&self) -> bool {
self.positioning() == position::T::fixed self.positioning() == Position::Fixed
} }
fn contains_positioned_fragments(&self) -> bool { fn contains_positioned_fragments(&self) -> bool {
@ -406,7 +410,7 @@ pub trait Flow: HasBaseFlow + fmt::Debug + Sync + Send + 'static {
} }
fn contains_relatively_positioned_fragments(&self) -> bool { fn contains_relatively_positioned_fragments(&self) -> bool {
self.positioning() == position::T::relative self.positioning() == Position::Relative
} }
/// Returns true if this is an absolute containing block. /// Returns true if this is an absolute containing block.
@ -647,24 +651,24 @@ static TEXT_ALIGN_SHIFT: usize = 11;
impl FlowFlags { impl FlowFlags {
#[inline] #[inline]
pub fn text_align(self) -> text_align::T { pub fn text_align(self) -> TextAlign {
text_align::T::from_u32((self & FlowFlags::TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap() TextAlign::from_u32((self & FlowFlags::TEXT_ALIGN).bits() >> TEXT_ALIGN_SHIFT).unwrap()
} }
#[inline] #[inline]
pub fn set_text_align(&mut self, value: text_align::T) { pub fn set_text_align(&mut self, value: TextAlign) {
*self = (*self & !FlowFlags::TEXT_ALIGN) | *self = (*self & !FlowFlags::TEXT_ALIGN) |
FlowFlags::from_bits(value.to_u32() << TEXT_ALIGN_SHIFT).unwrap(); FlowFlags::from_bits(value.to_u32() << TEXT_ALIGN_SHIFT).unwrap();
} }
#[inline] #[inline]
pub fn float_kind(&self) -> float::T { pub fn float_kind(&self) -> Float {
if self.contains(FlowFlags::FLOATS_LEFT) { if self.contains(FlowFlags::FLOATS_LEFT) {
float::T::left Float::Left
} else if self.contains(FlowFlags::FLOATS_RIGHT) { } else if self.contains(FlowFlags::FLOATS_RIGHT) {
float::T::right Float::Right
} else { } else {
float::T::none Float::None
} }
} }
@ -990,7 +994,7 @@ impl BaseFlow {
match style { match style {
Some(style) => { Some(style) => {
match style.get_box().position { match style.get_box().position {
position::T::absolute | position::T::fixed => { Position::Absolute | Position::Fixed => {
flags.insert(FlowFlags::IS_ABSOLUTELY_POSITIONED); flags.insert(FlowFlags::IS_ABSOLUTELY_POSITIONED);
let logical_position = style.logical_position(); let logical_position = style.logical_position();
@ -1008,17 +1012,17 @@ impl BaseFlow {
if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary { if force_nonfloated == ForceNonfloatedFlag::FloatIfNecessary {
match style.get_box().float { match style.get_box().float {
float::T::none => {} Float::None => {}
float::T::left => flags.insert(FlowFlags::FLOATS_LEFT), Float::Left => flags.insert(FlowFlags::FLOATS_LEFT),
float::T::right => flags.insert(FlowFlags::FLOATS_RIGHT), Float::Right => flags.insert(FlowFlags::FLOATS_RIGHT),
} }
} }
match style.get_box().clear { match style.get_box().clear {
clear::T::none => {} Clear::None => {}
clear::T::left => flags.insert(FlowFlags::CLEARS_LEFT), Clear::Left => flags.insert(FlowFlags::CLEARS_LEFT),
clear::T::right => flags.insert(FlowFlags::CLEARS_RIGHT), Clear::Right => flags.insert(FlowFlags::CLEARS_RIGHT),
clear::T::both => { Clear::Both => {
flags.insert(FlowFlags::CLEARS_LEFT); flags.insert(FlowFlags::CLEARS_LEFT);
flags.insert(FlowFlags::CLEARS_RIGHT); flags.insert(FlowFlags::CLEARS_RIGHT);
} }

View file

@ -40,10 +40,20 @@ use std::borrow::ToOwned;
use std::cmp::{Ordering, max, min}; use std::cmp::{Ordering, max, min};
use std::collections::LinkedList; use std::collections::LinkedList;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use style::computed_values::{border_collapse, box_sizing, clear, color, display, mix_blend_mode}; use style::computed_values::border_collapse::T as BorderCollapse;
use style::computed_values::{overflow_wrap, overflow_x, position, text_decoration_line}; use style::computed_values::box_sizing::T as BoxSizing;
use style::computed_values::{transform_style, white_space, word_break}; use style::computed_values::clear::T as Clear;
use style::computed_values::color::T as Color;
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::computed_values::display::T as Display;
use style::computed_values::mix_blend_mode::T as MixBlendMode;
use style::computed_values::overflow_wrap::T as OverflowWrap;
use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::position::T as Position;
use style::computed_values::text_decoration_line::T as TextDecorationLine;
use style::computed_values::transform_style::T as TransformStyle;
use style::computed_values::white_space::T as WhiteSpace;
use style::computed_values::word_break::T as WordBreak;
use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{Direction, LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
@ -866,7 +876,7 @@ impl Fragment {
let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_PADDING | let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_PADDING |
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inheritedtable().border_collapse ==
border_collapse::T::separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
base_quantities base_quantities
@ -876,7 +886,7 @@ impl Fragment {
let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS | let base_quantities = QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_MARGINS |
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inheritedtable().border_collapse ==
border_collapse::T::separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
base_quantities base_quantities
@ -886,7 +896,7 @@ impl Fragment {
let base_quantities = let base_quantities =
QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED; QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED;
if self.style.get_inheritedtable().border_collapse == if self.style.get_inheritedtable().border_collapse ==
border_collapse::T::separate { BorderCollapse::Separate {
base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER base_quantities | QuantitiesIncludedInIntrinsicInlineSizes::INTRINSIC_INLINE_SIZE_INCLUDES_BORDER
} else { } else {
base_quantities base_quantities
@ -964,7 +974,7 @@ impl Fragment {
specified = min(specified, max) specified = min(specified, max)
} }
if self.style.get_position().box_sizing == box_sizing::T::border_box { if self.style.get_position().box_sizing == BoxSizing::BorderBox {
specified = max(Au(0), specified - border_padding); specified = max(Au(0), specified - border_padding);
} }
} }
@ -1164,7 +1174,7 @@ impl Fragment {
Direction::Block => (self.style.min_block_size(), self.style.max_block_size()) Direction::Block => (self.style.min_block_size(), self.style.max_block_size())
}; };
let border = if self.style().get_position().box_sizing == box_sizing::T::border_box { let border = if self.style().get_position().box_sizing == BoxSizing::BorderBox {
Some(self.border_padding.start_end(direction)) Some(self.border_padding.start_end(direction))
} else { } else {
None None
@ -1224,10 +1234,10 @@ impl Fragment {
/// 'box-sizing: border-box'. The `border_padding` field must have been initialized. /// 'box-sizing: border-box'. The `border_padding` field must have been initialized.
pub fn box_sizing_boundary(&self, direction: Direction) -> Au { pub fn box_sizing_boundary(&self, direction: Direction) -> Au {
match (self.style().get_position().box_sizing, direction) { match (self.style().get_position().box_sizing, direction) {
(box_sizing::T::border_box, Direction::Inline) => { (BoxSizing::BorderBox, Direction::Inline) => {
self.border_padding.inline_start_end() self.border_padding.inline_start_end()
} }
(box_sizing::T::border_box, Direction::Block) => { (BoxSizing::BorderBox, Direction::Block) => {
self.border_padding.block_start_end() self.border_padding.block_start_end()
} }
_ => Au(0) _ => Au(0)
@ -1320,8 +1330,8 @@ impl Fragment {
containing_block_inline_size: Au) { containing_block_inline_size: Au) {
// Compute border. // Compute border.
let border = match self.style.get_inheritedtable().border_collapse { let border = match self.style.get_inheritedtable().border_collapse {
border_collapse::T::separate => self.border_width(), BorderCollapse::Separate => self.border_width(),
border_collapse::T::collapse => LogicalMargin::zero(self.style.writing_mode), BorderCollapse::Collapse => LogicalMargin::zero(self.style.writing_mode),
}; };
// Compute padding from the fragment's style. // Compute padding from the fragment's style.
@ -1382,7 +1392,7 @@ impl Fragment {
} }
// Go over the ancestor fragments and add all relative offsets (if any). // Go over the ancestor fragments and add all relative offsets (if any).
let mut rel_pos = if self.style().get_box().position == position::T::relative { let mut rel_pos = if self.style().get_box().position == Position::Relative {
from_style(self.style(), containing_block_size) from_style(self.style(), containing_block_size)
} else { } else {
LogicalSize::zero(self.style.writing_mode) LogicalSize::zero(self.style.writing_mode)
@ -1390,7 +1400,7 @@ impl Fragment {
if let Some(ref inline_fragment_context) = self.inline_context { if let Some(ref inline_fragment_context) = self.inline_context {
for node in &inline_fragment_context.nodes { for node in &inline_fragment_context.nodes {
if node.style.get_box().position == position::T::relative { if node.style.get_box().position == Position::Relative {
rel_pos = rel_pos + from_style(&*node.style, containing_block_size); rel_pos = rel_pos + from_style(&*node.style, containing_block_size);
} }
} }
@ -1406,10 +1416,10 @@ impl Fragment {
pub fn clear(&self) -> Option<ClearType> { pub fn clear(&self) -> Option<ClearType> {
let style = self.style(); let style = self.style();
match style.get_box().clear { match style.get_box().clear {
clear::T::none => None, Clear::None => None,
clear::T::left => Some(ClearType::Left), Clear::Left => Some(ClearType::Left),
clear::T::right => Some(ClearType::Right), Clear::Right => Some(ClearType::Right),
clear::T::both => Some(ClearType::Both), Clear::Both => Some(ClearType::Both),
} }
} }
@ -1423,11 +1433,11 @@ impl Fragment {
&*self.selected_style &*self.selected_style
} }
pub fn white_space(&self) -> white_space::T { pub fn white_space(&self) -> WhiteSpace {
self.style().get_inheritedtext().white_space self.style().get_inheritedtext().white_space
} }
pub fn color(&self) -> color::T { pub fn color(&self) -> Color {
self.style().get_color().color self.style().get_color().color
} }
@ -1438,7 +1448,7 @@ impl Fragment {
/// CSS 2.1 § 16.3.1. Unfortunately, computing this properly doesn't really fit into Servo's /// CSS 2.1 § 16.3.1. Unfortunately, computing this properly doesn't really fit into Servo's
/// model. Therefore, this is a best lower bound approximation, but the end result may actually /// model. Therefore, this is a best lower bound approximation, but the end result may actually
/// have the various decoration flags turned on afterward. /// have the various decoration flags turned on afterward.
pub fn text_decoration_line(&self) -> text_decoration_line::T { pub fn text_decoration_line(&self) -> TextDecorationLine {
self.style().get_text().text_decoration_line self.style().get_text().text_decoration_line
} }
@ -1654,13 +1664,13 @@ impl Fragment {
let mut flags = SplitOptions::empty(); let mut flags = SplitOptions::empty();
if starts_line { if starts_line {
flags.insert(SplitOptions::STARTS_LINE); flags.insert(SplitOptions::STARTS_LINE);
if self.style().get_inheritedtext().overflow_wrap == overflow_wrap::T::break_word { if self.style().get_inheritedtext().overflow_wrap == OverflowWrap::BreakWord {
flags.insert(SplitOptions::RETRY_AT_CHARACTER_BOUNDARIES) flags.insert(SplitOptions::RETRY_AT_CHARACTER_BOUNDARIES)
} }
} }
match self.style().get_inheritedtext().word_break { match self.style().get_inheritedtext().word_break {
word_break::T::normal | word_break::T::keep_all => { WordBreak::Normal | WordBreak::KeepAll => {
// Break at normal word boundaries. keep-all forbids soft wrap opportunities. // Break at normal word boundaries. keep-all forbids soft wrap opportunities.
let natural_word_breaking_strategy = let natural_word_breaking_strategy =
text_fragment_info.run.natural_word_slices_in_range(&text_fragment_info.range); text_fragment_info.run.natural_word_slices_in_range(&text_fragment_info.range);
@ -1669,7 +1679,7 @@ impl Fragment {
max_inline_size, max_inline_size,
flags) flags)
} }
word_break::T::break_all => { WordBreak::BreakAll => {
// Break at character boundaries. // Break at character boundaries.
let character_breaking_strategy = let character_breaking_strategy =
text_fragment_info.run.character_slices_in_range(&text_fragment_info.range); text_fragment_info.run.character_slices_in_range(&text_fragment_info.range);
@ -2205,7 +2215,7 @@ impl Fragment {
match (flow.baseline_offset_of_last_line_box_in_flow(), match (flow.baseline_offset_of_last_line_box_in_flow(),
style.get_box().overflow_y) { style.get_box().overflow_y) {
// Case A // Case A
(Some(baseline_offset), overflow_x::T::visible) => baseline_offset, (Some(baseline_offset), StyleOverflow::Visible) => baseline_offset,
// Case B // Case B
_ => border_box_block_size + end_margin, _ => border_box_block_size + end_margin,
}; };
@ -2519,7 +2529,7 @@ impl Fragment {
return true return true
} }
if self.style().get_effects().mix_blend_mode != mix_blend_mode::T::normal { if self.style().get_effects().mix_blend_mode != MixBlendMode::Normal {
return true return true
} }
@ -2527,21 +2537,21 @@ impl Fragment {
return true; return true;
} }
if self.style().get_box().transform_style == transform_style::T::preserve_3d || if self.style().get_box().transform_style == TransformStyle::Preserve3d ||
self.style().overrides_transform_style() { self.style().overrides_transform_style() {
return true return true
} }
// Fixed position and sticky position always create stacking contexts. // Fixed position and sticky position always create stacking contexts.
if self.style().get_box().position == position::T::fixed || if self.style().get_box().position == Position::Fixed ||
self.style().get_box().position == position::T::sticky { self.style().get_box().position == Position::Sticky {
return true return true
} }
// Statically positioned fragments don't establish stacking contexts if the previous // Statically positioned fragments don't establish stacking contexts if the previous
// conditions are not fulfilled. Furthermore, z-index doesn't apply to statically // conditions are not fulfilled. Furthermore, z-index doesn't apply to statically
// positioned fragments. // positioned fragments.
if self.style().get_box().position == position::T::static_ { if self.style().get_box().position == Position::Static {
return false; return false;
} }
@ -2556,7 +2566,7 @@ impl Fragment {
// from the value specified in the style. // from the value specified in the style.
pub fn effective_z_index(&self) -> i32 { pub fn effective_z_index(&self) -> i32 {
match self.style().get_box().position { match self.style().get_box().position {
position::T::static_ => {}, Position::Static => {},
_ => return self.style().get_position().z_index.integer_or(0), _ => return self.style().get_position().z_index.integer_or(0),
} }
@ -2565,7 +2575,7 @@ impl Fragment {
} }
match self.style().get_box().display { match self.style().get_box().display {
display::T::flex => self.style().get_position().z_index.integer_or(0), Display::Flex => self.style().get_position().z_index.integer_or(0),
_ => 0, _ => 0,
} }
} }
@ -2779,12 +2789,12 @@ impl Fragment {
/// Returns true if this node *or any of the nodes within its inline fragment context* have /// Returns true if this node *or any of the nodes within its inline fragment context* have
/// non-`static` `position`. /// non-`static` `position`.
pub fn is_positioned(&self) -> bool { pub fn is_positioned(&self) -> bool {
if self.style.get_box().position != position::T::static_ { if self.style.get_box().position != Position::Static {
return true return true
} }
if let Some(ref inline_context) = self.inline_context { if let Some(ref inline_context) = self.inline_context {
for node in inline_context.nodes.iter() { for node in inline_context.nodes.iter() {
if node.style.get_box().position != position::T::static_ { if node.style.get_box().position != Position::Static {
return true return true
} }
} }
@ -2794,7 +2804,7 @@ impl Fragment {
/// Returns true if this node is absolutely positioned. /// Returns true if this node is absolutely positioned.
pub fn is_absolutely_positioned(&self) -> bool { pub fn is_absolutely_positioned(&self) -> bool {
self.style.get_box().position == position::T::absolute self.style.get_box().position == Position::Absolute
} }
pub fn is_inline_absolute(&self) -> bool { pub fn is_inline_absolute(&self) -> bool {

View file

@ -15,8 +15,9 @@ use gfx::display_list::OpaqueNode;
use script_layout_interface::wrapper_traits::PseudoElementType; use script_layout_interface::wrapper_traits::PseudoElementType;
use smallvec::SmallVec; use smallvec::SmallVec;
use std::collections::{HashMap, LinkedList}; use std::collections::{HashMap, LinkedList};
use style::computed_values::{display, list_style_type};
use style::computed_values::content::ContentItem; use style::computed_values::content::ContentItem;
use style::computed_values::display::T as Display;
use style::computed_values::list_style_type::T as ListStyleType;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -157,8 +158,8 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
} }
let mut list_style_type = fragment.style().get_list().list_style_type; let mut list_style_type = fragment.style().get_list().list_style_type;
if fragment.style().get_box().display != display::T::list_item { if fragment.style().get_box().display != Display::ListItem {
list_style_type = list_style_type::T::none list_style_type = ListStyleType::None
} }
let mut new_info = None; let mut new_info = None;
@ -254,14 +255,14 @@ impl<'a, 'b> ResolveGeneratedContentFragmentMutator<'a, 'b> {
fn reset_and_increment_counters_as_necessary(&mut self, fragment: &mut Fragment) { fn reset_and_increment_counters_as_necessary(&mut self, fragment: &mut Fragment) {
let mut list_style_type = fragment.style().get_list().list_style_type; let mut list_style_type = fragment.style().get_list().list_style_type;
if !self.is_block || fragment.style().get_box().display != display::T::list_item { if !self.is_block || fragment.style().get_box().display != Display::ListItem {
list_style_type = list_style_type::T::none list_style_type = ListStyleType::None
} }
match list_style_type { match list_style_type {
list_style_type::T::disc | list_style_type::T::none | list_style_type::T::circle | ListStyleType::Disc | ListStyleType::None | ListStyleType::Circle |
list_style_type::T::square | list_style_type::T::disclosure_open | ListStyleType::Square | ListStyleType::DisclosureOpen |
list_style_type::T::disclosure_closed => {} ListStyleType::DisclosureClosed => {}
_ => self.traversal.list_item.increment(self.level, 1), _ => self.traversal.list_item.increment(self.level, 1),
} }
@ -369,7 +370,7 @@ impl Counter {
node: OpaqueNode, node: OpaqueNode,
pseudo: PseudoElementType<()>, pseudo: PseudoElementType<()>,
style: ::ServoArc<ComputedValues>, style: ::ServoArc<ComputedValues>,
list_style_type: list_style_type::T, list_style_type: ListStyleType,
mode: RenderingMode) mode: RenderingMode)
-> Option<SpecificFragmentInfo> { -> Option<SpecificFragmentInfo> {
let mut string = String::new(); let mut string = String::new();
@ -458,71 +459,72 @@ fn render_text(layout_context: &LayoutContext,
/// Appends string that represents the value rendered using the system appropriate for the given /// Appends string that represents the value rendered using the system appropriate for the given
/// `list-style-type` onto the given string. /// `list-style-type` onto the given string.
fn push_representation(value: i32, list_style_type: list_style_type::T, accumulator: &mut String) { fn push_representation(value: i32, list_style_type: ListStyleType, accumulator: &mut String) {
match list_style_type { match list_style_type {
list_style_type::T::none => {} ListStyleType::None => {}
list_style_type::T::disc | ListStyleType::Disc |
list_style_type::T::circle | ListStyleType::Circle |
list_style_type::T::square | ListStyleType::Square |
list_style_type::T::disclosure_open | ListStyleType::DisclosureOpen |
list_style_type::T::disclosure_closed => { ListStyleType::DisclosureClosed => {
accumulator.push(static_representation(list_style_type)) accumulator.push(static_representation(list_style_type))
} }
list_style_type::T::decimal => push_numeric_representation(value, &DECIMAL, accumulator), ListStyleType::Decimal => push_numeric_representation(value, &DECIMAL, accumulator),
list_style_type::T::arabic_indic => { ListStyleType::ArabicIndic => {
push_numeric_representation(value, &ARABIC_INDIC, accumulator) push_numeric_representation(value, &ARABIC_INDIC, accumulator)
} }
list_style_type::T::bengali => push_numeric_representation(value, &BENGALI, accumulator), ListStyleType::Bengali => push_numeric_representation(value, &BENGALI, accumulator),
list_style_type::T::cambodian | list_style_type::T::khmer => { ListStyleType::Cambodian |
ListStyleType::Khmer => {
push_numeric_representation(value, &CAMBODIAN, accumulator) push_numeric_representation(value, &CAMBODIAN, accumulator)
} }
list_style_type::T::cjk_decimal => { ListStyleType::CjkDecimal => {
push_numeric_representation(value, &CJK_DECIMAL, accumulator) push_numeric_representation(value, &CJK_DECIMAL, accumulator)
} }
list_style_type::T::devanagari => { ListStyleType::Devanagari => {
push_numeric_representation(value, &DEVANAGARI, accumulator) push_numeric_representation(value, &DEVANAGARI, accumulator)
} }
list_style_type::T::gujarati => push_numeric_representation(value, &GUJARATI, accumulator), ListStyleType::Gujarati => push_numeric_representation(value, &GUJARATI, accumulator),
list_style_type::T::gurmukhi => push_numeric_representation(value, &GURMUKHI, accumulator), ListStyleType::Gurmukhi => push_numeric_representation(value, &GURMUKHI, accumulator),
list_style_type::T::kannada => push_numeric_representation(value, &KANNADA, accumulator), ListStyleType::Kannada => push_numeric_representation(value, &KANNADA, accumulator),
list_style_type::T::lao => push_numeric_representation(value, &LAO, accumulator), ListStyleType::Lao => push_numeric_representation(value, &LAO, accumulator),
list_style_type::T::malayalam => { ListStyleType::Malayalam => {
push_numeric_representation(value, &MALAYALAM, accumulator) push_numeric_representation(value, &MALAYALAM, accumulator)
} }
list_style_type::T::mongolian => { ListStyleType::Mongolian => {
push_numeric_representation(value, &MONGOLIAN, accumulator) push_numeric_representation(value, &MONGOLIAN, accumulator)
} }
list_style_type::T::myanmar => push_numeric_representation(value, &MYANMAR, accumulator), ListStyleType::Myanmar => push_numeric_representation(value, &MYANMAR, accumulator),
list_style_type::T::oriya => push_numeric_representation(value, &ORIYA, accumulator), ListStyleType::Oriya => push_numeric_representation(value, &ORIYA, accumulator),
list_style_type::T::persian => push_numeric_representation(value, &PERSIAN, accumulator), ListStyleType::Persian => push_numeric_representation(value, &PERSIAN, accumulator),
list_style_type::T::telugu => push_numeric_representation(value, &TELUGU, accumulator), ListStyleType::Telugu => push_numeric_representation(value, &TELUGU, accumulator),
list_style_type::T::thai => push_numeric_representation(value, &THAI, accumulator), ListStyleType::Thai => push_numeric_representation(value, &THAI, accumulator),
list_style_type::T::tibetan => push_numeric_representation(value, &TIBETAN, accumulator), ListStyleType::Tibetan => push_numeric_representation(value, &TIBETAN, accumulator),
list_style_type::T::lower_alpha => { ListStyleType::LowerAlpha => {
push_alphabetic_representation(value, &LOWER_ALPHA, accumulator) push_alphabetic_representation(value, &LOWER_ALPHA, accumulator)
} }
list_style_type::T::upper_alpha => { ListStyleType::UpperAlpha => {
push_alphabetic_representation(value, &UPPER_ALPHA, accumulator) push_alphabetic_representation(value, &UPPER_ALPHA, accumulator)
} }
list_style_type::T::cjk_earthly_branch => { ListStyleType::CjkEarthlyBranch => {
push_alphabetic_representation(value, &CJK_EARTHLY_BRANCH, accumulator) push_alphabetic_representation(value, &CJK_EARTHLY_BRANCH, accumulator)
} }
list_style_type::T::cjk_heavenly_stem => { ListStyleType::CjkHeavenlyStem => {
push_alphabetic_representation(value, &CJK_HEAVENLY_STEM, accumulator) push_alphabetic_representation(value, &CJK_HEAVENLY_STEM, accumulator)
} }
list_style_type::T::lower_greek => { ListStyleType::LowerGreek => {
push_alphabetic_representation(value, &LOWER_GREEK, accumulator) push_alphabetic_representation(value, &LOWER_GREEK, accumulator)
} }
list_style_type::T::hiragana => { ListStyleType::Hiragana => {
push_alphabetic_representation(value, &HIRAGANA, accumulator) push_alphabetic_representation(value, &HIRAGANA, accumulator)
} }
list_style_type::T::hiragana_iroha => { ListStyleType::HiraganaIroha => {
push_alphabetic_representation(value, &HIRAGANA_IROHA, accumulator) push_alphabetic_representation(value, &HIRAGANA_IROHA, accumulator)
} }
list_style_type::T::katakana => { ListStyleType::Katakana => {
push_alphabetic_representation(value, &KATAKANA, accumulator) push_alphabetic_representation(value, &KATAKANA, accumulator)
} }
list_style_type::T::katakana_iroha => { ListStyleType::KatakanaIroha => {
push_alphabetic_representation(value, &KATAKANA_IROHA, accumulator) push_alphabetic_representation(value, &KATAKANA_IROHA, accumulator)
} }
} }
@ -530,13 +532,13 @@ fn push_representation(value: i32, list_style_type: list_style_type::T, accumula
/// Returns the static character that represents the value rendered using the given list-style, if /// Returns the static character that represents the value rendered using the given list-style, if
/// possible. /// possible.
pub fn static_representation(list_style_type: list_style_type::T) -> char { pub fn static_representation(list_style_type: ListStyleType) -> char {
match list_style_type { match list_style_type {
list_style_type::T::disc => '•', ListStyleType::Disc => '•',
list_style_type::T::circle => '◦', ListStyleType::Circle => '◦',
list_style_type::T::square => '▪', ListStyleType::Square => '▪',
list_style_type::T::disclosure_open => '▾', ListStyleType::DisclosureOpen => '▾',
list_style_type::T::disclosure_closed => '‣', ListStyleType::DisclosureClosed => '‣',
_ => panic!("No static representation for this list-style-type!"), _ => panic!("No static representation for this list-style-type!"),
} }
} }

View file

@ -3,7 +3,7 @@
* 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 flow::{self, FlowFlags, Flow}; use flow::{self, FlowFlags, Flow};
use style::computed_values::float; use style::computed_values::float::T as Float;
use style::selector_parser::RestyleDamage; use style::selector_parser::RestyleDamage;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -61,7 +61,7 @@ impl<'a> LayoutDamageComputation for &'a mut Flow {
} }
let self_base = flow::mut_base(self); let self_base = flow::mut_base(self);
if self_base.flags.float_kind() != float::T::none && if self_base.flags.float_kind() != Float::None &&
self_base.restyle_damage.intersects(ServoRestyleDamage::REFLOW) { self_base.restyle_damage.intersects(ServoRestyleDamage::REFLOW) {
special_damage.insert(SpecialRestyleDamage::REFLOW_ENTIRE_DOCUMENT); special_damage.insert(SpecialRestyleDamage::REFLOW_ENTIRE_DOCUMENT);
} }

View file

@ -30,12 +30,17 @@ use std::{fmt, i32, isize, mem};
use std::cmp::max; use std::cmp::max;
use std::collections::VecDeque; use std::collections::VecDeque;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{display, overflow_x, position, text_align, text_justify}; use style::computed_values::display::T as Display;
use style::computed_values::{vertical_align, white_space}; use style::computed_values::overflow_x::T as StyleOverflow;
use style::computed_values::position::T as Position;
use style::computed_values::text_align::T as TextAlign;
use style::computed_values::text_justify::T as TextJustify;
use style::computed_values::white_space::T as WhiteSpace;
use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
use style::values::generics::box_::VerticalAlign; use style::values::computed::box_::VerticalAlign;
use style::values::generics::box_::VerticalAlign as GenericVerticalAlign;
use style::values::specified::text::TextOverflowSide; use style::values::specified::text::TextOverflowSide;
use text; use text;
use traversal::PreorderFlowTraversal; use traversal::PreorderFlowTraversal;
@ -715,7 +720,7 @@ impl LineBreaker {
let ellipsis = match (&fragment.style().get_text().text_overflow.second, let ellipsis = match (&fragment.style().get_text().text_overflow.second,
fragment.style().get_box().overflow_x) { fragment.style().get_box().overflow_x) {
(&TextOverflowSide::Clip, _) | (_, overflow_x::T::visible) => None, (&TextOverflowSide::Clip, _) | (_, StyleOverflow::Visible) => None,
(&TextOverflowSide::Ellipsis, _) => { (&TextOverflowSide::Ellipsis, _) => {
if fragment.margin_box_inline_size() > available_inline_size { if fragment.margin_box_inline_size() > available_inline_size {
Some("".to_string()) Some("".to_string())
@ -907,7 +912,7 @@ impl InlineFlow {
/// performs text justification if mandated by the style. /// performs text justification if mandated by the style.
fn set_inline_fragment_positions(fragments: &mut InlineFragments, fn set_inline_fragment_positions(fragments: &mut InlineFragments,
line: &Line, line: &Line,
line_align: text_align::T, line_align: TextAlign,
indentation: Au, indentation: Au,
is_last_line: bool) { is_last_line: bool) {
// Figure out how much inline-size we have. // Figure out how much inline-size we have.
@ -922,14 +927,14 @@ impl InlineFlow {
// Translate `left` and `right` to logical directions. // Translate `left` and `right` to logical directions.
let is_ltr = fragments.fragments[0].style().writing_mode.is_bidi_ltr(); let is_ltr = fragments.fragments[0].style().writing_mode.is_bidi_ltr();
let line_align = match (line_align, is_ltr) { let line_align = match (line_align, is_ltr) {
(text_align::T::left, true) | (TextAlign::Left, true) |
(text_align::T::servo_left, true) | (TextAlign::ServoLeft, true) |
(text_align::T::right, false) | (TextAlign::Right, false) |
(text_align::T::servo_right, false) => text_align::T::start, (TextAlign::ServoRight, false) => TextAlign::Start,
(text_align::T::left, false) | (TextAlign::Left, false) |
(text_align::T::servo_left, false) | (TextAlign::ServoLeft, false) |
(text_align::T::right, true) | (TextAlign::Right, true) |
(text_align::T::servo_right, true) => text_align::T::end, (TextAlign::ServoRight, true) => TextAlign::End,
_ => line_align _ => line_align
}; };
@ -937,22 +942,22 @@ impl InlineFlow {
// necessary. // necessary.
let mut inline_start_position_for_fragment = line.bounds.start.i + indentation; let mut inline_start_position_for_fragment = line.bounds.start.i + indentation;
match line_align { match line_align {
text_align::T::justify if !is_last_line && text_justify != text_justify::T::none => { TextAlign::Justify if !is_last_line && text_justify != TextJustify::None => {
InlineFlow::justify_inline_fragments(fragments, line, slack_inline_size) InlineFlow::justify_inline_fragments(fragments, line, slack_inline_size)
} }
text_align::T::justify | text_align::T::start => {} TextAlign::Justify | TextAlign::Start => {}
text_align::T::center | text_align::T::servo_center => { TextAlign::Center | TextAlign::ServoCenter => {
inline_start_position_for_fragment = inline_start_position_for_fragment + inline_start_position_for_fragment = inline_start_position_for_fragment +
slack_inline_size.scale_by(0.5) slack_inline_size.scale_by(0.5)
} }
text_align::T::end => { TextAlign::End => {
inline_start_position_for_fragment = inline_start_position_for_fragment + inline_start_position_for_fragment = inline_start_position_for_fragment +
slack_inline_size slack_inline_size
} }
text_align::T::left | TextAlign::Left |
text_align::T::servo_left | TextAlign::ServoLeft |
text_align::T::right | TextAlign::Right |
text_align::T::servo_right => unreachable!() TextAlign::ServoRight => unreachable!()
} }
// Lay out the fragments in visual order. // Lay out the fragments in visual order.
@ -1149,7 +1154,7 @@ impl InlineFlow {
update_line_metrics_for_fragment(&mut line_metrics, update_line_metrics_for_fragment(&mut line_metrics,
&inline_metrics, &inline_metrics,
style.get_box().display, style.get_box().display,
VerticalAlign::Baseline, GenericVerticalAlign::Baseline,
&mut largest_block_size_for_top_fragments, &mut largest_block_size_for_top_fragments,
&mut largest_block_size_for_bottom_fragments); &mut largest_block_size_for_bottom_fragments);
@ -1185,24 +1190,24 @@ impl InlineFlow {
fn update_line_metrics_for_fragment(line_metrics: &mut LineMetrics, fn update_line_metrics_for_fragment(line_metrics: &mut LineMetrics,
inline_metrics: &InlineMetrics, inline_metrics: &InlineMetrics,
display_value: display::T, display_value: Display,
vertical_align_value: vertical_align::T, vertical_align_value: VerticalAlign,
largest_block_size_for_top_fragments: &mut Au, largest_block_size_for_top_fragments: &mut Au,
largest_block_size_for_bottom_fragments: &mut Au) { largest_block_size_for_bottom_fragments: &mut Au) {
match (display_value, vertical_align_value) { match (display_value, vertical_align_value) {
(display::T::inline, VerticalAlign::Top) | (Display::Inline, GenericVerticalAlign::Top) |
(display::T::block, VerticalAlign::Top) | (Display::Block, GenericVerticalAlign::Top) |
(display::T::inline_flex, VerticalAlign::Top) | (Display::InlineFlex, GenericVerticalAlign::Top) |
(display::T::inline_block, VerticalAlign::Top) if (Display::InlineBlock, GenericVerticalAlign::Top) if
inline_metrics.space_above_baseline >= Au(0) => { inline_metrics.space_above_baseline >= Au(0) => {
*largest_block_size_for_top_fragments = max( *largest_block_size_for_top_fragments = max(
*largest_block_size_for_top_fragments, *largest_block_size_for_top_fragments,
inline_metrics.space_above_baseline + inline_metrics.space_below_baseline) inline_metrics.space_above_baseline + inline_metrics.space_below_baseline)
} }
(display::T::inline, VerticalAlign::Bottom) | (Display::Inline, GenericVerticalAlign::Bottom) |
(display::T::block, VerticalAlign::Bottom) | (Display::Block, GenericVerticalAlign::Bottom) |
(display::T::inline_flex, VerticalAlign::Bottom) | (Display::InlineFlex, GenericVerticalAlign::Bottom) |
(display::T::inline_block, VerticalAlign::Bottom) if (Display::InlineBlock, GenericVerticalAlign::Bottom) if
inline_metrics.space_below_baseline >= Au(0) => { inline_metrics.space_below_baseline >= Au(0) => {
*largest_block_size_for_bottom_fragments = max( *largest_block_size_for_bottom_fragments = max(
*largest_block_size_for_bottom_fragments, *largest_block_size_for_bottom_fragments,
@ -1321,11 +1326,11 @@ impl Flow for InlineFlow {
for fragment in &mut self.fragments.fragments { for fragment in &mut self.fragments.fragments {
let intrinsic_sizes_for_fragment = fragment.compute_intrinsic_inline_sizes().finish(); let intrinsic_sizes_for_fragment = fragment.compute_intrinsic_inline_sizes().finish();
match fragment.style.get_inheritedtext().white_space { match fragment.style.get_inheritedtext().white_space {
white_space::T::nowrap => { WhiteSpace::Nowrap => {
intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline( intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline(
&intrinsic_sizes_for_fragment) &intrinsic_sizes_for_fragment)
} }
white_space::T::pre => { WhiteSpace::Pre => {
intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline( intrinsic_sizes_for_nonbroken_run.union_nonbreaking_inline(
&intrinsic_sizes_for_fragment); &intrinsic_sizes_for_fragment);
@ -1340,8 +1345,8 @@ impl Flow for InlineFlow {
intrinsic_sizes_for_inline_run = IntrinsicISizesContribution::new(); intrinsic_sizes_for_inline_run = IntrinsicISizesContribution::new();
} }
} }
white_space::T::pre_wrap | WhiteSpace::PreWrap |
white_space::T::pre_line => { WhiteSpace::PreLine => {
// Flush the intrinsic sizes we were gathering up for the nonbroken run, if // Flush the intrinsic sizes we were gathering up for the nonbroken run, if
// necessary. // necessary.
intrinsic_sizes_for_inline_run.union_inline( intrinsic_sizes_for_inline_run.union_inline(
@ -1361,7 +1366,7 @@ impl Flow for InlineFlow {
intrinsic_sizes_for_inline_run = IntrinsicISizesContribution::new(); intrinsic_sizes_for_inline_run = IntrinsicISizesContribution::new();
} }
} }
white_space::T::normal => { WhiteSpace::Normal => {
// Flush the intrinsic sizes we were gathering up for the nonbroken run, if // Flush the intrinsic sizes we were gathering up for the nonbroken run, if
// necessary. // necessary.
intrinsic_sizes_for_inline_run.union_inline( intrinsic_sizes_for_inline_run.union_inline(
@ -1720,7 +1725,7 @@ impl Flow for InlineFlow {
fn contains_relatively_positioned_fragments(&self) -> bool { fn contains_relatively_positioned_fragments(&self) -> bool {
self.fragments.fragments.iter().any(|fragment| { self.fragments.fragments.iter().any(|fragment| {
fragment.style.get_box().position == position::T::relative fragment.style.get_box().position == Position::Relative
}) })
} }

View file

@ -19,7 +19,8 @@ use fragment::{CoordinateSystem, Fragment, FragmentBorderBoxIterator, GeneratedC
use fragment::Overflow; use fragment::Overflow;
use generated_content; use generated_content;
use inline::InlineFlow; use inline::InlineFlow;
use style::computed_values::{list_style_type, position}; use style::computed_values::list_style_type::T as ListStyleType;
use style::computed_values::position::T as Position;
use style::logical_geometry::LogicalSize; use style::logical_geometry::LogicalSize;
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -50,12 +51,12 @@ impl ListItemFlow {
if let Some(ref marker) = this.marker_fragments.first() { if let Some(ref marker) = this.marker_fragments.first() {
match marker.style().get_list().list_style_type { match marker.style().get_list().list_style_type {
list_style_type::T::disc | ListStyleType::Disc |
list_style_type::T::none | ListStyleType::None |
list_style_type::T::circle | ListStyleType::Circle |
list_style_type::T::square | ListStyleType::Square |
list_style_type::T::disclosure_open | ListStyleType::DisclosureOpen |
list_style_type::T::disclosure_closed => {} ListStyleType::DisclosureClosed => {}
_ => this.block_flow.base.restyle_damage.insert(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT), _ => this.block_flow.base.restyle_damage.insert(ServoRestyleDamage::RESOLVE_GENERATED_CONTENT),
} }
} }
@ -177,7 +178,7 @@ impl Flow for ListItemFlow {
} }
/// The 'position' property of this flow. /// The 'position' property of this flow.
fn positioning(&self) -> position::T { fn positioning(&self) -> Position {
self.block_flow.positioning() self.block_flow.positioning()
} }
@ -229,13 +230,16 @@ pub enum ListStyleTypeContent {
impl ListStyleTypeContent { impl ListStyleTypeContent {
/// Returns the content to be used for the given value of the `list-style-type` property. /// Returns the content to be used for the given value of the `list-style-type` property.
pub fn from_list_style_type(list_style_type: list_style_type::T) -> ListStyleTypeContent { pub fn from_list_style_type(list_style_type: ListStyleType) -> ListStyleTypeContent {
// Just to keep things simple, use a nonbreaking space (Unicode 0xa0) to provide the marker // Just to keep things simple, use a nonbreaking space (Unicode 0xa0) to provide the marker
// separation. // separation.
match list_style_type { match list_style_type {
list_style_type::T::none => ListStyleTypeContent::None, ListStyleType::None => ListStyleTypeContent::None,
list_style_type::T::disc | list_style_type::T::circle | list_style_type::T::square | ListStyleType::Disc |
list_style_type::T::disclosure_open | list_style_type::T::disclosure_closed => { ListStyleType::Circle |
ListStyleType::Square |
ListStyleType::DisclosureOpen |
ListStyleType::DisclosureClosed => {
let text = generated_content::static_representation(list_style_type); let text = generated_content::static_representation(list_style_type);
ListStyleTypeContent::StaticText(text) ListStyleTypeContent::StaticText(text)
} }

View file

@ -26,12 +26,12 @@ use sequential;
use std::cmp::{min, max}; use std::cmp::{min, max};
use std::ops::Deref; use std::ops::Deref;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use style::computed_values; use style::computed_values::display::T as Display;
use style::computed_values::position::T as Position;
use style::context::{StyleContext, ThreadLocalStyleContext}; use style::context::{StyleContext, ThreadLocalStyleContext};
use style::dom::TElement; use style::dom::TElement;
use style::logical_geometry::{WritingMode, BlockFlowDirection, InlineBaseDirection}; use style::logical_geometry::{WritingMode, BlockFlowDirection, InlineBaseDirection};
use style::properties::{style_structs, PropertyId, PropertyDeclarationId, LonghandId}; use style::properties::{style_structs, PropertyId, PropertyDeclarationId, LonghandId};
use style::properties::longhands::{display, position};
use style::selector_parser::PseudoElement; use style::selector_parser::PseudoElement;
use style_traits::ToCss; use style_traits::ToCss;
use webrender_api::ClipId; use webrender_api::ClipId;
@ -531,7 +531,7 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator {
}); });
// offsetParent returns null if the node is fixed. // offsetParent returns null if the node is fixed.
if fragment.style.get_box().position == computed_values::position::T::fixed { if fragment.style.get_box().position == Position::Fixed {
self.parent_nodes.clear(); self.parent_nodes.clear();
} }
} else if let Some(node) = fragment.inline_context.as_ref().and_then(|inline_context| { } else if let Some(node) = fragment.inline_context.as_ref().and_then(|inline_context| {
@ -579,15 +579,15 @@ impl FragmentBorderBoxIterator for ParentOffsetBorderBoxIterator {
// 2) Is static position *and* is a table or table cell // 2) Is static position *and* is a table or table cell
// 3) Is not static position // 3) Is not static position
(true, _, _) | (true, _, _) |
(false, computed_values::position::T::static_, &SpecificFragmentInfo::Table) | (false, Position::Static, &SpecificFragmentInfo::Table) |
(false, computed_values::position::T::static_, &SpecificFragmentInfo::TableCell) | (false, Position::Static, &SpecificFragmentInfo::TableCell) |
(false, computed_values::position::T::sticky, _) | (false, Position::Sticky, _) |
(false, computed_values::position::T::absolute, _) | (false, Position::Absolute, _) |
(false, computed_values::position::T::relative, _) | (false, Position::Relative, _) |
(false, computed_values::position::T::fixed, _) => true, (false, Position::Fixed, _) => true,
// Otherwise, it's not a valid parent // Otherwise, it's not a valid parent
(false, computed_values::position::T::static_, _) => false, (false, Position::Static, _) => false,
}; };
let parent_info = if is_valid_parent { let parent_info = if is_valid_parent {
@ -751,10 +751,10 @@ where
}; };
let positioned = match style.get_box().position { let positioned = match style.get_box().position {
position::computed_value::T::relative | Position::Relative |
position::computed_value::T::sticky | Position::Sticky |
position::computed_value::T::fixed | Position::Fixed |
position::computed_value::T::absolute => true, Position::Absolute => true,
_ => false _ => false
}; };
@ -804,7 +804,7 @@ where
LonghandId::MarginLeft | LonghandId::MarginRight | LonghandId::MarginLeft | LonghandId::MarginRight |
LonghandId::PaddingBottom | LonghandId::PaddingTop | LonghandId::PaddingBottom | LonghandId::PaddingTop |
LonghandId::PaddingLeft | LonghandId::PaddingRight LonghandId::PaddingLeft | LonghandId::PaddingRight
if applies && style.get_box().display != display::computed_value::T::none => { if applies && style.get_box().display != Display::None => {
let (margin_padding, side) = match longhand_id { let (margin_padding, side) = match longhand_id {
LonghandId::MarginBottom => (MarginPadding::Margin, Side::Bottom), LonghandId::MarginBottom => (MarginPadding::Margin, Side::Bottom),
LonghandId::MarginTop => (MarginPadding::Margin, Side::Top), LonghandId::MarginTop => (MarginPadding::Margin, Side::Top),
@ -827,13 +827,11 @@ where
}, },
LonghandId::Bottom | LonghandId::Top | LonghandId::Right | LonghandId::Left LonghandId::Bottom | LonghandId::Top | LonghandId::Right | LonghandId::Left
if applies && positioned && style.get_box().display != if applies && positioned && style.get_box().display != Display::None => {
display::computed_value::T::none => {
used_value_for_position_property(layout_el, layout_root, requested_node, longhand_id) used_value_for_position_property(layout_el, layout_root, requested_node, longhand_id)
} }
LonghandId::Width | LonghandId::Height LonghandId::Width | LonghandId::Height
if applies && style.get_box().display != if applies && style.get_box().display != Display::None => {
display::computed_value::T::none => {
used_value_for_position_property(layout_el, layout_root, requested_node, longhand_id) used_value_for_position_property(layout_el, layout_root, requested_node, longhand_id)
} }
// FIXME: implement used value computation for line-height // FIXME: implement used value computation for line-height

View file

@ -68,7 +68,7 @@ impl TableFlow {
pub fn from_fragment(fragment: Fragment) -> TableFlow { pub fn from_fragment(fragment: Fragment) -> TableFlow {
let mut block_flow = BlockFlow::from_fragment(fragment); let mut block_flow = BlockFlow::from_fragment(fragment);
let table_layout = let table_layout =
if block_flow.fragment().style().get_table().table_layout == table_layout::T::fixed { if block_flow.fragment().style().get_table().table_layout == table_layout::T::Fixed {
TableLayout::Fixed TableLayout::Fixed
} else { } else {
TableLayout::Auto TableLayout::Auto
@ -192,8 +192,8 @@ impl TableFlow {
pub fn spacing(&self) -> border_spacing::T { pub fn spacing(&self) -> border_spacing::T {
let style = self.block_flow.fragment.style(); let style = self.block_flow.fragment.style();
match style.get_inheritedtable().border_collapse { match style.get_inheritedtable().border_collapse {
border_collapse::T::separate => style.get_inheritedtable().border_spacing, border_collapse::T::Separate => style.get_inheritedtable().border_spacing,
border_collapse::T::collapse => border_spacing::T::zero(), border_collapse::T::Collapse => border_spacing::T::zero(),
} }
} }
@ -268,7 +268,7 @@ impl Flow for TableFlow {
.fragment .fragment
.style .style
.get_inheritedtable() .get_inheritedtable()
.border_collapse == border_collapse::T::collapse; .border_collapse == border_collapse::T::Collapse;
let table_inline_collapsed_borders = if collapsing_borders { let table_inline_collapsed_borders = if collapsing_borders {
Some(TableInlineCollapsedBorders { Some(TableInlineCollapsedBorders {
start: CollapsedBorder::inline_start(&*self.block_flow.fragment.style, start: CollapsedBorder::inline_start(&*self.block_flow.fragment.style,
@ -495,8 +495,8 @@ impl Flow for TableFlow {
.style .style
.get_inheritedtable() .get_inheritedtable()
.border_collapse { .border_collapse {
border_collapse::T::separate => BorderPaintingMode::Separate, border_collapse::T::Separate => BorderPaintingMode::Separate,
border_collapse::T::collapse => BorderPaintingMode::Hidden, border_collapse::T::Collapse => BorderPaintingMode::Hidden,
}; };
self.block_flow.build_display_list_for_block(state, border_painting_mode); self.block_flow.build_display_list_for_block(state, border_painting_mode);
@ -733,7 +733,7 @@ pub trait TableLikeFlow {
impl TableLikeFlow for BlockFlow { impl TableLikeFlow for BlockFlow {
fn assign_block_size_for_table_like_flow(&mut self, block_direction_spacing: Au) { fn assign_block_size_for_table_like_flow(&mut self, block_direction_spacing: Au) {
debug_assert!(self.fragment.style.get_inheritedtable().border_collapse == debug_assert!(self.fragment.style.get_inheritedtable().border_collapse ==
border_collapse::T::separate || block_direction_spacing == Au(0)); border_collapse::T::Separate || block_direction_spacing == Au(0));
if self.base.restyle_damage.contains(ServoRestyleDamage::REFLOW) { if self.base.restyle_damage.contains(ServoRestyleDamage::REFLOW) {
// Our current border-box position. // Our current border-box position.
@ -750,8 +750,8 @@ impl TableLikeFlow for BlockFlow {
let child_table_row = kid.as_table_row(); let child_table_row = kid.as_table_row();
current_block_offset = current_block_offset + current_block_offset = current_block_offset +
match self.fragment.style.get_inheritedtable().border_collapse { match self.fragment.style.get_inheritedtable().border_collapse {
border_collapse::T::separate => block_direction_spacing, border_collapse::T::Separate => block_direction_spacing,
border_collapse::T::collapse => { border_collapse::T::Collapse => {
child_table_row.collapsed_border_spacing.block_start child_table_row.collapsed_border_spacing.block_start
} }
} }

View file

@ -20,11 +20,12 @@ use layout_debug;
use model::MaybeAuto; use model::MaybeAuto;
use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode; use script_layout_interface::wrapper_traits::ThreadSafeLayoutNode;
use std::fmt; use std::fmt;
use style::computed_values::{border_collapse, border_top_style}; use style::computed_values::border_collapse::T as BorderCollapse;
use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode}; use style::logical_geometry::{LogicalMargin, LogicalRect, LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::values::computed::Color; use style::values::computed::Color;
use style::values::generics::box_::VerticalAlign; use style::values::generics::box_::VerticalAlign;
use style::values::specified::BorderStyle;
use table::InternalTable; use table::InternalTable;
use table_row::{CollapsedBorder, CollapsedBorderProvenance}; use table_row::{CollapsedBorder, CollapsedBorderProvenance};
@ -259,8 +260,8 @@ impl Flow for TableCellFlow {
.style .style
.get_inheritedtable() .get_inheritedtable()
.border_collapse { .border_collapse {
border_collapse::T::separate => BorderPaintingMode::Separate, BorderCollapse::Separate => BorderPaintingMode::Separate,
border_collapse::T::collapse => BorderPaintingMode::Collapse(&self.collapsed_borders), BorderCollapse::Collapse => BorderPaintingMode::Collapse(&self.collapsed_borders),
}; };
self.block_flow.build_display_list_for_block(state, border_painting_mode) self.block_flow.build_display_list_for_block(state, border_painting_mode)
@ -425,7 +426,7 @@ impl CollapsedBordersForCell {
pub fn adjust_border_colors_and_styles_for_painting( pub fn adjust_border_colors_and_styles_for_painting(
&self, &self,
border_colors: &mut SideOffsets2D<Color>, border_colors: &mut SideOffsets2D<Color>,
border_styles: &mut SideOffsets2D<border_top_style::T>, border_styles: &mut SideOffsets2D<BorderStyle>,
writing_mode: WritingMode) { writing_mode: WritingMode) {
let logical_border_colors = LogicalMargin::new(writing_mode, let logical_border_colors = LogicalMargin::new(writing_mode,
self.block_start_border.color, self.block_start_border.color,

View file

@ -23,7 +23,9 @@ use serde::{Serialize, Serializer};
use std::cmp::max; use std::cmp::max;
use std::fmt; use std::fmt;
use std::iter::{Enumerate, IntoIterator, Peekable}; use std::iter::{Enumerate, IntoIterator, Peekable};
use style::computed_values::{border_collapse, border_spacing, border_top_style}; use style::computed_values::border_collapse::T as BorderCollapse;
use style::computed_values::border_spacing::T as BorderSpacing;
use style::computed_values::border_top_style::T as BorderStyle;
use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode}; use style::logical_geometry::{LogicalSize, PhysicalSide, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::servo::restyle_damage::ServoRestyleDamage; use style::servo::restyle_damage::ServoRestyleDamage;
@ -54,7 +56,7 @@ pub struct TableRowFlow {
/// The spacing for this row, propagated down from the table during the inline-size assignment /// The spacing for this row, propagated down from the table during the inline-size assignment
/// phase. /// phase.
pub spacing: border_spacing::T, pub spacing: BorderSpacing,
/// The direction of the columns, propagated down from the table during the inline-size /// The direction of the columns, propagated down from the table during the inline-size
/// assignment phase. /// assignment phase.
@ -98,7 +100,7 @@ impl TableRowFlow {
cell_intrinsic_inline_sizes: Vec::new(), cell_intrinsic_inline_sizes: Vec::new(),
column_computed_inline_sizes: Vec::new(), column_computed_inline_sizes: Vec::new(),
incoming_rowspan: Vec::new(), incoming_rowspan: Vec::new(),
spacing: border_spacing::T::zero(), spacing: BorderSpacing::zero(),
table_writing_mode: writing_mode, table_writing_mode: writing_mode,
preliminary_collapsed_borders: CollapsedBordersForRow::new(), preliminary_collapsed_borders: CollapsedBordersForRow::new(),
final_collapsed_borders: CollapsedBordersForRow::new(), final_collapsed_borders: CollapsedBordersForRow::new(),
@ -259,7 +261,7 @@ impl Flow for TableRowFlow {
.fragment .fragment
.style() .style()
.get_inheritedtable() .get_inheritedtable()
.border_collapse == border_collapse::T::collapse; .border_collapse == BorderCollapse::Collapse;
let row_style = &*self.block_flow.fragment.style; let row_style = &*self.block_flow.fragment.style;
self.preliminary_collapsed_borders.reset( self.preliminary_collapsed_borders.reset(
CollapsedBorder::inline_start(&row_style, CollapsedBorder::inline_start(&row_style,
@ -408,13 +410,13 @@ impl Flow for TableRowFlow {
// Set up border collapse info. // Set up border collapse info.
let border_collapse_info = let border_collapse_info =
match self.block_flow.fragment.style().get_inheritedtable().border_collapse { match self.block_flow.fragment.style().get_inheritedtable().border_collapse {
border_collapse::T::collapse => { BorderCollapse::Collapse => {
Some(BorderCollapseInfoForChildTableCell { Some(BorderCollapseInfoForChildTableCell {
collapsed_borders_for_row: &self.final_collapsed_borders, collapsed_borders_for_row: &self.final_collapsed_borders,
collapsed_border_spacing_for_row: &self.collapsed_border_spacing, collapsed_border_spacing_for_row: &self.collapsed_border_spacing,
}) })
} }
border_collapse::T::separate => None, BorderCollapse::Separate => None,
}; };
// Push those inline sizes down to the cells. // Push those inline sizes down to the cells.
@ -473,8 +475,8 @@ impl Flow for TableRowFlow {
.style .style
.get_inheritedtable() .get_inheritedtable()
.border_collapse { .border_collapse {
border_collapse::T::separate => BorderPaintingMode::Separate, BorderCollapse::Separate => BorderPaintingMode::Separate,
border_collapse::T::collapse => BorderPaintingMode::Hidden, BorderCollapse::Collapse => BorderPaintingMode::Hidden,
}; };
self.block_flow.build_display_list_for_block(state, border_painting_mode); self.block_flow.build_display_list_for_block(state, border_painting_mode);
@ -578,7 +580,7 @@ impl CollapsedBorderSpacingForRow {
#[derive(Clone, Copy, Debug)] #[derive(Clone, Copy, Debug)]
pub struct CollapsedBorder { pub struct CollapsedBorder {
/// The style of the border. /// The style of the border.
pub style: border_top_style::T, pub style: BorderStyle,
/// The width of the border. /// The width of the border.
pub width: Au, pub width: Au,
/// The color of the border. /// The color of the border.
@ -615,7 +617,7 @@ impl CollapsedBorder {
/// Creates a collapsible border style for no border. /// Creates a collapsible border style for no border.
pub fn new() -> CollapsedBorder { pub fn new() -> CollapsedBorder {
CollapsedBorder { CollapsedBorder {
style: border_top_style::T::none, style: BorderStyle::None,
width: Au(0), width: Au(0),
color: Color::transparent(), color: Color::transparent(),
provenance: CollapsedBorderProvenance::FromTable, provenance: CollapsedBorderProvenance::FromTable,
@ -723,11 +725,11 @@ impl CollapsedBorder {
pub fn combine(&mut self, other: &CollapsedBorder) { pub fn combine(&mut self, other: &CollapsedBorder) {
match (self.style, other.style) { match (self.style, other.style) {
// Step 1. // Step 1.
(border_top_style::T::hidden, _) => {} (BorderStyle::Hidden, _) => {}
(_, border_top_style::T::hidden) => *self = *other, (_, BorderStyle::Hidden) => *self = *other,
// Step 2. // Step 2.
(border_top_style::T::none, _) => *self = *other, (BorderStyle::None, _) => *self = *other,
(_, border_top_style::T::none) => {} (_, BorderStyle::None) => {}
// Step 3. // Step 3.
_ if self.width > other.width => {} _ if self.width > other.width => {}
_ if self.width < other.width => *self = *other, _ if self.width < other.width => *self = *other,
@ -745,7 +747,7 @@ pub fn propagate_column_inline_sizes_to_child(
child_flow: &mut Flow, child_flow: &mut Flow,
table_writing_mode: WritingMode, table_writing_mode: WritingMode,
column_computed_inline_sizes: &[ColumnComputedInlineSize], column_computed_inline_sizes: &[ColumnComputedInlineSize],
border_spacing: &border_spacing::T, border_spacing: &BorderSpacing,
incoming_rowspan: &mut Vec<u32>) { incoming_rowspan: &mut Vec<u32>) {
// If the child is a row group or a row, the column inline-size and rowspan info should be copied from its // If the child is a row group or a row, the column inline-size and rowspan info should be copied from its
// parent. // parent.
@ -814,7 +816,7 @@ fn set_inline_position_of_child_flow(
row_writing_mode: WritingMode, row_writing_mode: WritingMode,
table_writing_mode: WritingMode, table_writing_mode: WritingMode,
column_computed_inline_sizes: &[ColumnComputedInlineSize], column_computed_inline_sizes: &[ColumnComputedInlineSize],
border_spacing: &border_spacing::T, border_spacing: &BorderSpacing,
border_collapse_info: &Option<BorderCollapseInfoForChildTableCell>, border_collapse_info: &Option<BorderCollapseInfoForChildTableCell>,
parent_content_inline_size: Au, parent_content_inline_size: Au,
inline_start_margin_edge: &mut Au, inline_start_margin_edge: &mut Au,

View file

@ -152,7 +152,7 @@ impl Flow for TableRowGroupFlow {
_writing_mode, _writing_mode,
_inline_start_margin_edge, _inline_start_margin_edge,
_inline_end_margin_edge| { _inline_end_margin_edge| {
if border_collapse == border_collapse::T::collapse { if border_collapse == border_collapse::T::Collapse {
let child_table_row = child_flow.as_mut_table_row(); let child_table_row = child_flow.as_mut_table_row();
child_table_row.populate_collapsed_border_spacing( child_table_row.populate_collapsed_border_spacing(
collapsed_inline_direction_border_widths_for_table, collapsed_inline_direction_border_widths_for_table,

View file

@ -67,7 +67,7 @@ impl TableWrapperFlow {
-> TableWrapperFlow { -> TableWrapperFlow {
let mut block_flow = BlockFlow::from_fragment_and_float_kind(fragment, float_kind); let mut block_flow = BlockFlow::from_fragment_and_float_kind(fragment, float_kind);
let table_layout = if block_flow.fragment().style().get_table().table_layout == let table_layout = if block_flow.fragment().style().get_table().table_layout ==
table_layout::T::fixed { table_layout::T::Fixed {
TableLayout::Fixed TableLayout::Fixed
} else { } else {
TableLayout::Auto TableLayout::Auto

View file

@ -22,8 +22,10 @@ use std::borrow::ToOwned;
use std::collections::LinkedList; use std::collections::LinkedList;
use std::mem; use std::mem;
use std::sync::Arc; use std::sync::Arc;
use style::computed_values::{text_rendering, text_transform}; use style::computed_values::text_rendering::T as TextRendering;
use style::computed_values::{word_break, white_space}; 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::logical_geometry::{LogicalSize, WritingMode};
use style::properties::ComputedValues; use style::properties::ComputedValues;
use style::properties::style_structs; use style::properties::style_structs;
@ -158,11 +160,11 @@ impl TextRunScanner {
let inherited_text_style = in_fragment.style().get_inheritedtext(); let inherited_text_style = in_fragment.style().get_inheritedtext();
fontgroup = font_context.layout_font_group_for_style(font_style); fontgroup = font_context.layout_font_group_for_style(font_style);
compression = match in_fragment.white_space() { compression = match in_fragment.white_space() {
white_space::T::normal | WhiteSpace::Normal |
white_space::T::nowrap => CompressionMode::CompressWhitespaceNewline, WhiteSpace::Nowrap => CompressionMode::CompressWhitespaceNewline,
white_space::T::pre | WhiteSpace::Pre |
white_space::T::pre_wrap => CompressionMode::CompressNone, WhiteSpace::PreWrap => CompressionMode::CompressNone,
white_space::T::pre_line => CompressionMode::CompressWhitespace, WhiteSpace::PreLine => CompressionMode::CompressWhitespace,
}; };
text_transform = inherited_text_style.text_transform; text_transform = inherited_text_style.text_transform;
letter_spacing = inherited_text_style.letter_spacing; letter_spacing = inherited_text_style.letter_spacing;
@ -293,11 +295,11 @@ impl TextRunScanner {
flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG); flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG);
} }
} }
if text_rendering == text_rendering::T::optimizespeed { if text_rendering == TextRendering::Optimizespeed {
flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG); flags.insert(ShapingFlags::IGNORE_LIGATURES_SHAPING_FLAG);
flags.insert(ShapingFlags::DISABLE_KERNING_SHAPING_FLAG) flags.insert(ShapingFlags::DISABLE_KERNING_SHAPING_FLAG)
} }
if word_break == word_break::T::keep_all { if word_break == WordBreak::KeepAll {
flags.insert(ShapingFlags::KEEP_ALL_FLAG); flags.insert(ShapingFlags::KEEP_ALL_FLAG);
} }
let options = ShapingOptions { let options = ShapingOptions {
@ -597,7 +599,7 @@ impl RunMapping {
run_info: &mut RunInfo, run_info: &mut RunInfo,
text: &str, text: &str,
compression: CompressionMode, compression: CompressionMode,
text_transform: text_transform::T, text_transform: TextTransform,
last_whitespace: &mut bool, last_whitespace: &mut bool,
start_position: &mut usize, start_position: &mut usize,
end_position: usize) { end_position: usize) {
@ -650,26 +652,26 @@ impl RunMapping {
/// use graphemes instead of characters. /// use graphemes instead of characters.
fn apply_style_transform_if_necessary(string: &mut String, fn apply_style_transform_if_necessary(string: &mut String,
first_character_position: usize, first_character_position: usize,
text_transform: text_transform::T, text_transform: TextTransform,
last_whitespace: bool, last_whitespace: bool,
is_first_run: bool) { is_first_run: bool) {
match text_transform { match text_transform {
text_transform::T::none => {} TextTransform::None => {}
text_transform::T::uppercase => { TextTransform::Uppercase => {
let original = string[first_character_position..].to_owned(); let original = string[first_character_position..].to_owned();
string.truncate(first_character_position); string.truncate(first_character_position);
for ch in original.chars().flat_map(|ch| ch.to_uppercase()) { for ch in original.chars().flat_map(|ch| ch.to_uppercase()) {
string.push(ch); string.push(ch);
} }
} }
text_transform::T::lowercase => { TextTransform::Lowercase => {
let original = string[first_character_position..].to_owned(); let original = string[first_character_position..].to_owned();
string.truncate(first_character_position); string.truncate(first_character_position);
for ch in original.chars().flat_map(|ch| ch.to_lowercase()) { for ch in original.chars().flat_map(|ch| ch.to_lowercase()) {
string.push(ch); string.push(ch);
} }
} }
text_transform::T::capitalize => { TextTransform::Capitalize => {
let original = string[first_character_position..].to_owned(); let original = string[first_character_position..].to_owned();
string.truncate(first_character_position); string.truncate(first_character_position);

View file

@ -13,7 +13,9 @@ use gfx::display_list::{BorderDetails, BorderRadii, BoxShadowClipMode, ClipScrol
use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingRegion, DisplayItem}; use gfx::display_list::{ClipScrollNodeIndex, ClipScrollNodeType, ClippingRegion, DisplayItem};
use gfx::display_list::{DisplayList, StackingContextType}; use gfx::display_list::{DisplayList, StackingContextType};
use msg::constellation_msg::PipelineId; use msg::constellation_msg::PipelineId;
use style::computed_values::{image_rendering, mix_blend_mode, transform_style}; use style::computed_values::image_rendering::T as ImageRendering;
use style::computed_values::mix_blend_mode::T as MixBlendMode;
use style::computed_values::transform_style::T as TransformStyle;
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;
use webrender_api::{self, ClipAndScrollInfo, ClipId, ClipMode, ComplexClipRegion}; use webrender_api::{self, ClipAndScrollInfo, ClipId, ClipMode, ComplexClipRegion};
@ -41,16 +43,16 @@ trait ToBorderStyle {
impl ToBorderStyle for BorderStyle { impl ToBorderStyle for BorderStyle {
fn to_border_style(&self) -> webrender_api::BorderStyle { fn to_border_style(&self) -> webrender_api::BorderStyle {
match *self { match *self {
BorderStyle::none => webrender_api::BorderStyle::None, BorderStyle::None => webrender_api::BorderStyle::None,
BorderStyle::solid => webrender_api::BorderStyle::Solid, BorderStyle::Solid => webrender_api::BorderStyle::Solid,
BorderStyle::double => webrender_api::BorderStyle::Double, BorderStyle::Double => webrender_api::BorderStyle::Double,
BorderStyle::dotted => webrender_api::BorderStyle::Dotted, BorderStyle::Dotted => webrender_api::BorderStyle::Dotted,
BorderStyle::dashed => webrender_api::BorderStyle::Dashed, BorderStyle::Dashed => webrender_api::BorderStyle::Dashed,
BorderStyle::hidden => webrender_api::BorderStyle::Hidden, BorderStyle::Hidden => webrender_api::BorderStyle::Hidden,
BorderStyle::groove => webrender_api::BorderStyle::Groove, BorderStyle::Groove => webrender_api::BorderStyle::Groove,
BorderStyle::ridge => webrender_api::BorderStyle::Ridge, BorderStyle::Ridge => webrender_api::BorderStyle::Ridge,
BorderStyle::inset => webrender_api::BorderStyle::Inset, BorderStyle::Inset => webrender_api::BorderStyle::Inset,
BorderStyle::outset => webrender_api::BorderStyle::Outset, BorderStyle::Outset => webrender_api::BorderStyle::Outset,
} }
} }
} }
@ -148,25 +150,25 @@ pub trait ToMixBlendMode {
fn to_mix_blend_mode(&self) -> webrender_api::MixBlendMode; fn to_mix_blend_mode(&self) -> webrender_api::MixBlendMode;
} }
impl ToMixBlendMode for mix_blend_mode::T { impl ToMixBlendMode for MixBlendMode {
fn to_mix_blend_mode(&self) -> webrender_api::MixBlendMode { fn to_mix_blend_mode(&self) -> webrender_api::MixBlendMode {
match *self { match *self {
mix_blend_mode::T::normal => webrender_api::MixBlendMode::Normal, MixBlendMode::Normal => webrender_api::MixBlendMode::Normal,
mix_blend_mode::T::multiply => webrender_api::MixBlendMode::Multiply, MixBlendMode::Multiply => webrender_api::MixBlendMode::Multiply,
mix_blend_mode::T::screen => webrender_api::MixBlendMode::Screen, MixBlendMode::Screen => webrender_api::MixBlendMode::Screen,
mix_blend_mode::T::overlay => webrender_api::MixBlendMode::Overlay, MixBlendMode::Overlay => webrender_api::MixBlendMode::Overlay,
mix_blend_mode::T::darken => webrender_api::MixBlendMode::Darken, MixBlendMode::Darken => webrender_api::MixBlendMode::Darken,
mix_blend_mode::T::lighten => webrender_api::MixBlendMode::Lighten, MixBlendMode::Lighten => webrender_api::MixBlendMode::Lighten,
mix_blend_mode::T::color_dodge => webrender_api::MixBlendMode::ColorDodge, MixBlendMode::ColorDodge => webrender_api::MixBlendMode::ColorDodge,
mix_blend_mode::T::color_burn => webrender_api::MixBlendMode::ColorBurn, MixBlendMode::ColorBurn => webrender_api::MixBlendMode::ColorBurn,
mix_blend_mode::T::hard_light => webrender_api::MixBlendMode::HardLight, MixBlendMode::HardLight => webrender_api::MixBlendMode::HardLight,
mix_blend_mode::T::soft_light => webrender_api::MixBlendMode::SoftLight, MixBlendMode::SoftLight => webrender_api::MixBlendMode::SoftLight,
mix_blend_mode::T::difference => webrender_api::MixBlendMode::Difference, MixBlendMode::Difference => webrender_api::MixBlendMode::Difference,
mix_blend_mode::T::exclusion => webrender_api::MixBlendMode::Exclusion, MixBlendMode::Exclusion => webrender_api::MixBlendMode::Exclusion,
mix_blend_mode::T::hue => webrender_api::MixBlendMode::Hue, MixBlendMode::Hue => webrender_api::MixBlendMode::Hue,
mix_blend_mode::T::saturation => webrender_api::MixBlendMode::Saturation, MixBlendMode::Saturation => webrender_api::MixBlendMode::Saturation,
mix_blend_mode::T::color => webrender_api::MixBlendMode::Color, MixBlendMode::Color => webrender_api::MixBlendMode::Color,
mix_blend_mode::T::luminosity => webrender_api::MixBlendMode::Luminosity, MixBlendMode::Luminosity => webrender_api::MixBlendMode::Luminosity,
} }
} }
} }
@ -175,12 +177,12 @@ trait ToImageRendering {
fn to_image_rendering(&self) -> webrender_api::ImageRendering; fn to_image_rendering(&self) -> webrender_api::ImageRendering;
} }
impl ToImageRendering for image_rendering::T { impl ToImageRendering for ImageRendering {
fn to_image_rendering(&self) -> webrender_api::ImageRendering { fn to_image_rendering(&self) -> webrender_api::ImageRendering {
match *self { match *self {
image_rendering::T::crisp_edges => webrender_api::ImageRendering::CrispEdges, ImageRendering::CrispEdges => webrender_api::ImageRendering::CrispEdges,
image_rendering::T::auto => webrender_api::ImageRendering::Auto, ImageRendering::Auto => webrender_api::ImageRendering::Auto,
image_rendering::T::pixelated => webrender_api::ImageRendering::Pixelated, ImageRendering::Pixelated => webrender_api::ImageRendering::Pixelated,
} }
} }
} }
@ -216,11 +218,11 @@ pub trait ToTransformStyle {
fn to_transform_style(&self) -> webrender_api::TransformStyle; fn to_transform_style(&self) -> webrender_api::TransformStyle;
} }
impl ToTransformStyle for transform_style::T { impl ToTransformStyle for TransformStyle {
fn to_transform_style(&self) -> webrender_api::TransformStyle { fn to_transform_style(&self) -> webrender_api::TransformStyle {
match *self { match *self {
transform_style::T::auto | transform_style::T::flat => webrender_api::TransformStyle::Flat, TransformStyle::Auto | TransformStyle::Flat => webrender_api::TransformStyle::Flat,
transform_style::T::preserve_3d => webrender_api::TransformStyle::Preserve3D, TransformStyle::Preserve3d => webrender_api::TransformStyle::Preserve3D,
} }
} }
} }

View file

@ -379,28 +379,28 @@ impl Element {
fn overflow_x_is_visible(&self) -> bool { fn overflow_x_is_visible(&self) -> bool {
let window = window_from_node(self); let window = window_from_node(self);
let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address()); let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address());
overflow_pair.x == overflow_x::computed_value::T::visible overflow_pair.x == overflow_x::computed_value::T::Visible
} }
// used value of overflow-y is "visible" // used value of overflow-y is "visible"
fn overflow_y_is_visible(&self) -> bool { fn overflow_y_is_visible(&self) -> bool {
let window = window_from_node(self); let window = window_from_node(self);
let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address()); let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address());
overflow_pair.y == overflow_y::computed_value::T::visible overflow_pair.y == overflow_y::computed_value::T::Visible
} }
// used value of overflow-x is "hidden" // used value of overflow-x is "hidden"
fn overflow_x_is_hidden(&self) -> bool { fn overflow_x_is_hidden(&self) -> bool {
let window = window_from_node(self); let window = window_from_node(self);
let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address()); let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address());
overflow_pair.x == overflow_x::computed_value::T::hidden overflow_pair.x == overflow_x::computed_value::T::Hidden
} }
// used value of overflow-y is "hidden" // used value of overflow-y is "hidden"
fn overflow_y_is_hidden(&self) -> bool { fn overflow_y_is_hidden(&self) -> bool {
let window = window_from_node(self); let window = window_from_node(self);
let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address()); let overflow_pair = window.overflow_query(self.upcast::<Node>().to_trusted_node_address());
overflow_pair.y == overflow_y::computed_value::T::hidden overflow_pair.y == overflow_y::computed_value::T::Hidden
} }
} }

View file

@ -17,7 +17,7 @@ use servo_arc::Arc;
use servo_url::ServoUrl; use servo_url::ServoUrl;
use std::fmt::Debug; use std::fmt::Debug;
use style::attr::AttrValue; use style::attr::AttrValue;
use style::computed_values::display; use style::computed_values::display::T as Display;
use style::context::SharedStyleContext; use style::context::SharedStyleContext;
use style::data::ElementData; use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, TNode}; use style::dom::{LayoutIterator, NodeInfo, TNode};
@ -197,7 +197,7 @@ pub trait ThreadSafeLayoutNode: Clone + Copy + Debug + GetLayoutData + NodeInfo
fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>; fn as_element(&self) -> Option<Self::ConcreteThreadSafeLayoutElement>;
#[inline] #[inline]
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>> { fn get_pseudo_element_type(&self) -> PseudoElementType<Option<Display>> {
self.as_element().map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type()) self.as_element().map_or(PseudoElementType::Normal, |el| el.get_pseudo_element_type())
} }
@ -304,7 +304,7 @@ pub trait ThreadSafeLayoutElement
/// Creates a new `ThreadSafeLayoutElement` for the same `LayoutElement` /// Creates a new `ThreadSafeLayoutElement` for the same `LayoutElement`
/// with a different pseudo-element type. /// with a different pseudo-element type.
fn with_pseudo(&self, pseudo: PseudoElementType<Option<display::T>>) -> Self; fn with_pseudo(&self, pseudo: PseudoElementType<Option<Display>>) -> Self;
/// Returns the type ID of this node. /// Returns the type ID of this node.
/// Returns `None` if this is a pseudo-element; otherwise, returns `Some`. /// Returns `None` if this is a pseudo-element; otherwise, returns `Some`.
@ -327,7 +327,7 @@ pub trait ThreadSafeLayoutElement
fn style_data(&self) -> AtomicRef<ElementData>; fn style_data(&self) -> AtomicRef<ElementData>;
#[inline] #[inline]
fn get_pseudo_element_type(&self) -> PseudoElementType<Option<display::T>>; fn get_pseudo_element_type(&self) -> PseudoElementType<Option<Display>>;
#[inline] #[inline]
fn get_before_pseudo(&self) -> Option<Self> { fn get_before_pseudo(&self) -> Option<Self> {
@ -364,7 +364,7 @@ pub trait ThreadSafeLayoutElement
let display = if self.get_attr(&ns!(), &local_name!("open")).is_some() { let display = if self.get_attr(&ns!(), &local_name!("open")).is_some() {
None // Specified by the stylesheet None // Specified by the stylesheet
} else { } else {
Some(display::T::none) Some(Display::None)
}; };
Some(self.with_pseudo(PseudoElementType::DetailsContent(display))) Some(self.with_pseudo(PseudoElementType::DetailsContent(display)))
} else { } else {

View file

@ -103,11 +103,11 @@ impl KeyframesAnimationState {
// Update the next iteration direction if applicable. // Update the next iteration direction if applicable.
match self.direction { match self.direction {
AnimationDirection::alternate | AnimationDirection::Alternate |
AnimationDirection::alternate_reverse => { AnimationDirection::AlternateReverse => {
self.current_direction = match self.current_direction { self.current_direction = match self.current_direction {
AnimationDirection::normal => AnimationDirection::reverse, AnimationDirection::Normal => AnimationDirection::Reverse,
AnimationDirection::reverse => AnimationDirection::normal, AnimationDirection::Reverse => AnimationDirection::Normal,
_ => unreachable!(), _ => unreachable!(),
}; };
} }
@ -551,15 +551,15 @@ pub fn maybe_start_animations(context: &SharedStyleContext,
let animation_direction = box_style.animation_direction_mod(i); let animation_direction = box_style.animation_direction_mod(i);
let initial_direction = match animation_direction { let initial_direction = match animation_direction {
AnimationDirection::normal | AnimationDirection::Normal |
AnimationDirection::alternate => AnimationDirection::normal, AnimationDirection::Alternate => AnimationDirection::Normal,
AnimationDirection::reverse | AnimationDirection::Reverse |
AnimationDirection::alternate_reverse => AnimationDirection::reverse, AnimationDirection::AlternateReverse => AnimationDirection::Reverse,
}; };
let running_state = match box_style.animation_play_state_mod(i) { let running_state = match box_style.animation_play_state_mod(i) {
AnimationPlayState::paused => KeyframesRunningState::Paused(0.), AnimationPlayState::Paused => KeyframesRunningState::Paused(0.),
AnimationPlayState::running => KeyframesRunningState::Running, AnimationPlayState::Running => KeyframesRunningState::Running,
}; };
@ -677,7 +677,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
let last_keyframe_position; let last_keyframe_position;
let target_keyframe_position; let target_keyframe_position;
match state.current_direction { match state.current_direction {
AnimationDirection::normal => { AnimationDirection::Normal => {
target_keyframe_position = target_keyframe_position =
animation.steps.iter().position(|step| { animation.steps.iter().position(|step| {
total_progress as f32 <= step.start_percentage.0 total_progress as f32 <= step.start_percentage.0
@ -687,7 +687,7 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
if pos != 0 { Some(pos - 1) } else { None } if pos != 0 { Some(pos - 1) } else { None }
}).unwrap_or(0); }).unwrap_or(0);
} }
AnimationDirection::reverse => { AnimationDirection::Reverse => {
target_keyframe_position = target_keyframe_position =
animation.steps.iter().rev().position(|step| { animation.steps.iter().rev().position(|step| {
total_progress as f32 <= 1. - step.start_percentage.0 total_progress as f32 <= 1. - step.start_percentage.0
@ -717,10 +717,10 @@ pub fn update_style_for_animation(context: &SharedStyleContext,
let relative_timespan = (target_keyframe.start_percentage.0 - last_keyframe.start_percentage.0).abs(); let relative_timespan = (target_keyframe.start_percentage.0 - last_keyframe.start_percentage.0).abs();
let relative_duration = relative_timespan as f64 * duration; let relative_duration = relative_timespan as f64 * duration;
let last_keyframe_ended_at = match state.current_direction { let last_keyframe_ended_at = match state.current_direction {
AnimationDirection::normal => { AnimationDirection::Normal => {
state.started_at + (total_duration * last_keyframe.start_percentage.0 as f64) state.started_at + (total_duration * last_keyframe.start_percentage.0 as f64)
} }
AnimationDirection::reverse => { AnimationDirection::Reverse => {
state.started_at + (total_duration * (1. - last_keyframe.start_percentage.0 as f64)) state.started_at + (total_duration * (1. - last_keyframe.start_percentage.0 as f64))
} }
_ => unreachable!(), _ => unreachable!(),

View file

@ -11,7 +11,7 @@ use invalidation::element::restyle_hints::RestyleHint;
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
use malloc_size_of::MallocSizeOfOps; use malloc_size_of::MallocSizeOfOps;
use properties::ComputedValues; use properties::ComputedValues;
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value::T as Display;
use rule_tree::StrongRuleNode; use rule_tree::StrongRuleNode;
use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage}; use selector_parser::{EAGER_PSEUDO_COUNT, PseudoElement, RestyleDamage};
use selectors::NthIndexCache; use selectors::NthIndexCache;
@ -169,7 +169,7 @@ impl ElementStyles {
/// Whether this element `display` value is `none`. /// Whether this element `display` value is `none`.
pub fn is_display_none(&self) -> bool { pub fn is_display_none(&self) -> bool {
self.primary().get_box().clone_display() == display::T::none self.primary().get_box().clone_display() == Display::None
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]

View file

@ -11,7 +11,7 @@
use cssparser::{ToCss, serialize_identifier}; use cssparser::{ToCss, serialize_identifier};
use gecko_bindings::structs::{self, CSSPseudoElementType}; use gecko_bindings::structs::{self, CSSPseudoElementType};
use properties::{ComputedValues, PropertyFlags}; use properties::{ComputedValues, PropertyFlags};
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value::T as Display;
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl}; use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt; use std::fmt;
use string_cache::Atom; use string_cache::Atom;
@ -161,7 +161,7 @@ impl PseudoElement {
/// Whether this pseudo-element should actually exist if it has /// Whether this pseudo-element should actually exist if it has
/// the given styles. /// the given styles.
pub fn should_exist(&self, style: &ComputedValues) -> bool { pub fn should_exist(&self, style: &ComputedValues) -> bool {
if style.get_box().clone_display() == display::T::none { if style.get_box().clone_display() == Display::None {
return false; return false;
} }

View file

@ -102,21 +102,21 @@ macro_rules! map_enum {
map_enum! { map_enum! {
font_style { font_style {
normal => NS_FONT_STYLE_NORMAL, Normal => NS_FONT_STYLE_NORMAL,
italic => NS_FONT_STYLE_ITALIC, Italic => NS_FONT_STYLE_ITALIC,
oblique => NS_FONT_STYLE_OBLIQUE, Oblique => NS_FONT_STYLE_OBLIQUE,
} }
font_stretch { font_stretch {
normal => NS_FONT_STRETCH_NORMAL, Normal => NS_FONT_STRETCH_NORMAL,
ultra_condensed => NS_FONT_STRETCH_ULTRA_CONDENSED, UltraCondensed => NS_FONT_STRETCH_ULTRA_CONDENSED,
extra_condensed => NS_FONT_STRETCH_EXTRA_CONDENSED, ExtraCondensed => NS_FONT_STRETCH_EXTRA_CONDENSED,
condensed => NS_FONT_STRETCH_CONDENSED, Condensed => NS_FONT_STRETCH_CONDENSED,
semi_condensed => NS_FONT_STRETCH_SEMI_CONDENSED, SemiCondensed => NS_FONT_STRETCH_SEMI_CONDENSED,
semi_expanded => NS_FONT_STRETCH_SEMI_EXPANDED, SemiExpanded => NS_FONT_STRETCH_SEMI_EXPANDED,
expanded => NS_FONT_STRETCH_EXPANDED, Expanded => NS_FONT_STRETCH_EXPANDED,
extra_expanded => NS_FONT_STRETCH_EXTRA_EXPANDED, ExtraExpanded => NS_FONT_STRETCH_EXTRA_EXPANDED,
ultra_expanded => NS_FONT_STRETCH_ULTRA_EXPANDED, UltraExpanded => NS_FONT_STRETCH_ULTRA_EXPANDED,
} }
} }

View file

@ -1446,7 +1446,7 @@ impl<'le> TElement for GeckoElement<'le> {
old_values: Option<&ComputedValues>, old_values: Option<&ComputedValues>,
new_values: &ComputedValues, new_values: &ComputedValues,
) -> bool { ) -> bool {
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value::T as Display;
let old_values = match old_values { let old_values = match old_values {
Some(v) => v, Some(v) => v,
@ -1462,8 +1462,8 @@ impl<'le> TElement for GeckoElement<'le> {
new_box_style.transition_property_count() > 0 && new_box_style.transition_property_count() > 0 &&
!transition_not_running && !transition_not_running &&
(new_display_style != display::T::none && (new_display_style != Display::None &&
old_display_style != display::T::none) old_display_style != Display::None)
} }
// Detect if there are any changes that require us to update transitions. // Detect if there are any changes that require us to update transitions.

View file

@ -42,34 +42,34 @@ bitflags!(
impl WritingMode { impl WritingMode {
/// Return a WritingMode bitflags from the relevant CSS properties. /// Return a WritingMode bitflags from the relevant CSS properties.
pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self { pub fn new(inheritedbox_style: &style_structs::InheritedBox) -> Self {
use properties::longhands::direction::computed_value::T as direction; use properties::longhands::direction::computed_value::T as Direction;
use properties::longhands::writing_mode::computed_value::T as writing_mode; use properties::longhands::writing_mode::computed_value::T as SpecifiedWritingMode;
let mut flags = WritingMode::empty(); let mut flags = WritingMode::empty();
match inheritedbox_style.clone_direction() { match inheritedbox_style.clone_direction() {
direction::ltr => {}, Direction::Ltr => {},
direction::rtl => { Direction::Rtl => {
flags.insert(WritingMode::RTL); flags.insert(WritingMode::RTL);
}, },
} }
match inheritedbox_style.clone_writing_mode() { match inheritedbox_style.clone_writing_mode() {
writing_mode::horizontal_tb => {}, SpecifiedWritingMode::HorizontalTb => {},
writing_mode::vertical_rl => { SpecifiedWritingMode::VerticalRl => {
flags.insert(WritingMode::VERTICAL); flags.insert(WritingMode::VERTICAL);
}, },
writing_mode::vertical_lr => { SpecifiedWritingMode::VerticalLr => {
flags.insert(WritingMode::VERTICAL); flags.insert(WritingMode::VERTICAL);
flags.insert(WritingMode::VERTICAL_LR); flags.insert(WritingMode::VERTICAL_LR);
}, },
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
writing_mode::sideways_rl => { SpecifiedWritingMode::SidewaysRl => {
flags.insert(WritingMode::VERTICAL); flags.insert(WritingMode::VERTICAL);
flags.insert(WritingMode::SIDEWAYS); flags.insert(WritingMode::SIDEWAYS);
}, },
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
writing_mode::sideways_lr => { SpecifiedWritingMode::SidewaysLr => {
flags.insert(WritingMode::VERTICAL); flags.insert(WritingMode::VERTICAL);
flags.insert(WritingMode::VERTICAL_LR); flags.insert(WritingMode::VERTICAL_LR);
flags.insert(WritingMode::LINE_INVERTED); flags.insert(WritingMode::LINE_INVERTED);
@ -79,18 +79,18 @@ impl WritingMode {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
use properties::longhands::text_orientation::computed_value::T as text_orientation; use properties::longhands::text_orientation::computed_value::T as TextOrientation;
// If FLAG_SIDEWAYS is already set, this means writing-mode is // If FLAG_SIDEWAYS is already set, this means writing-mode is
// either sideways-rl or sideways-lr, and for both of these values, // either sideways-rl or sideways-lr, and for both of these values,
// text-orientation has no effect. // text-orientation has no effect.
if !flags.intersects(WritingMode::SIDEWAYS) { if !flags.intersects(WritingMode::SIDEWAYS) {
match inheritedbox_style.clone_text_orientation() { match inheritedbox_style.clone_text_orientation() {
text_orientation::mixed => {}, TextOrientation::Mixed => {},
text_orientation::upright => { TextOrientation::Upright => {
flags.insert(WritingMode::UPRIGHT); flags.insert(WritingMode::UPRIGHT);
}, },
text_orientation::sideways => { TextOrientation::Sideways => {
flags.insert(WritingMode::SIDEWAYS); flags.insert(WritingMode::SIDEWAYS);
}, },
} }

View file

@ -13,7 +13,7 @@ use data::ElementData;
use dom::TElement; use dom::TElement;
use invalidation::element::restyle_hints::RestyleHint; use invalidation::element::restyle_hints::RestyleHint;
use properties::ComputedValues; use properties::ComputedValues;
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value::T as Display;
use rule_tree::{CascadeLevel, StrongRuleNode}; use rule_tree::{CascadeLevel, StrongRuleNode};
use selector_parser::{PseudoElement, RestyleDamage}; use selector_parser::{PseudoElement, RestyleDamage};
use selectors::matching::ElementSelectorFlags; use selectors::matching::ElementSelectorFlags;
@ -151,11 +151,11 @@ trait PrivateMatchMethods: TElement {
(context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) && (context.shared.traversal_flags.contains(TraversalFlags::ForCSSRuleChanges) &&
(has_new_animation_style || has_animations)) || (has_new_animation_style || has_animations)) ||
!old_box_style.animations_equals(new_box_style) || !old_box_style.animations_equals(new_box_style) ||
(old_display_style == display::T::none && (old_display_style == Display::None &&
new_display_style != display::T::none && new_display_style != Display::None &&
has_new_animation_style) || has_new_animation_style) ||
(old_display_style != display::T::none && (old_display_style != Display::None &&
new_display_style == display::T::none && new_display_style == Display::None &&
has_animations) has_animations)
}) })
} }
@ -179,8 +179,8 @@ trait PrivateMatchMethods: TElement {
let display_changed_from_none = old_values.map_or(false, |old| { let display_changed_from_none = old_values.map_or(false, |old| {
let old_display_style = old.get_box().clone_display(); let old_display_style = old.get_box().clone_display();
let new_display_style = new_values.get_box().clone_display(); let new_display_style = new_values.get_box().clone_display();
old_display_style == display::T::none && old_display_style == Display::None &&
new_display_style != display::T::none new_display_style != Display::None
}); });
if display_changed_from_none { if display_changed_from_none {
@ -363,7 +363,7 @@ trait PrivateMatchMethods: TElement {
// NOTE(emilio): Gecko has the special-case of -moz-binding, but // NOTE(emilio): Gecko has the special-case of -moz-binding, but
// that gets handled on the frame constructor when processing // that gets handled on the frame constructor when processing
// the reframe, so no need to handle that here. // the reframe, so no need to handle that here.
if old_display == display::T::none && old_display != new_display { if old_display == Display::None && old_display != new_display {
return ChildCascadeRequirement::MustCascadeChildren return ChildCascadeRequirement::MustCascadeChildren
} }

View file

@ -38,7 +38,7 @@ def to_rust_ident(name):
def to_camel_case(ident): def to_camel_case(ident):
return re.sub("(^|_|-)([a-z])", lambda m: m.group(2).upper(), ident.strip("_").strip("-")) return re.sub("(^|_|-)([a-z0-9])", lambda m: m.group(2).upper(), ident.strip("_").strip("-"))
def to_camel_case_lower(ident): def to_camel_case_lower(ident):

View file

@ -5,7 +5,7 @@
// `data` comes from components/style/properties.mako.rs; see build.rs for more details. // `data` comes from components/style/properties.mako.rs; see build.rs for more details.
<%! <%!
from data import to_rust_ident, to_camel_case, to_camel_case_lower from data import to_camel_case, to_camel_case_lower
from data import Keyword from data import Keyword
%> %>
<%namespace name="helpers" file="/helpers.mako.rs" /> <%namespace name="helpers" file="/helpers.mako.rs" />
@ -258,7 +258,7 @@ impl ComputedValuesInner {
#[inline] #[inline]
pub fn is_display_contents(&self) -> bool { pub fn is_display_contents(&self) -> bool {
self.get_box().clone_display() == longhands::display::computed_value::T::contents self.get_box().clone_display() == longhands::display::computed_value::T::Contents
} }
/// Returns true if the value of the `content` property would make a /// Returns true if the value of the `content` property would make a
@ -404,7 +404,7 @@ def set_gecko_property(ffi_name, expr):
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
let result = match v { let result = match v {
% for value in keyword.values_for('gecko'): % for value in keyword.values_for('gecko'):
Keyword::${to_rust_ident(value)} => Keyword::${to_camel_case(value)} =>
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)}, structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)},
% endfor % endfor
}; };
@ -437,7 +437,7 @@ def set_gecko_property(ffi_name, expr):
match ${get_gecko_property(gecko_ffi_name)} as ${cast_type} { match ${get_gecko_property(gecko_ffi_name)} as ${cast_type} {
% for value in keyword.values_for('gecko'): % for value in keyword.values_for('gecko'):
${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_rust_ident(value)}, ${keyword.casted_constant_name(value, cast_type)} => Keyword::${to_camel_case(value)},
% endfor % endfor
% if keyword.gecko_inexhaustive: % if keyword.gecko_inexhaustive:
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x), x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
@ -446,7 +446,7 @@ def set_gecko_property(ffi_name, expr):
% else: % else:
match ${get_gecko_property(gecko_ffi_name)} { match ${get_gecko_property(gecko_ffi_name)} {
% for value in keyword.values_for('gecko'): % for value in keyword.values_for('gecko'):
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)}, structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
% endfor % endfor
% if keyword.gecko_inexhaustive: % if keyword.gecko_inexhaustive:
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x), x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
@ -2348,7 +2348,7 @@ fn static_assert() {
// cast + static_asserts // cast + static_asserts
let result = match v { let result = match v {
% for value in border_style_keyword.values_for('gecko'): % for value in border_style_keyword.values_for('gecko'):
Either::Second(border_style::T::${to_rust_ident(value)}) => Either::Second(border_style::T::${to_camel_case(value)}) =>
structs::${border_style_keyword.gecko_constant(value)} ${border_style_keyword.maybe_cast("u8")}, structs::${border_style_keyword.gecko_constant(value)} ${border_style_keyword.maybe_cast("u8")},
% endfor % endfor
Either::First(Auto) => Either::First(Auto) =>
@ -2377,7 +2377,9 @@ fn static_assert() {
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
match ${get_gecko_property("mOutlineStyle")} ${border_style_keyword.maybe_cast("u32")} { match ${get_gecko_property("mOutlineStyle")} ${border_style_keyword.maybe_cast("u32")} {
% for value in border_style_keyword.values_for('gecko'): % for value in border_style_keyword.values_for('gecko'):
structs::${border_style_keyword.gecko_constant(value)} => Either::Second(border_style::T::${value}), structs::${border_style_keyword.gecko_constant(value)} => {
Either::Second(border_style::T::${to_camel_case(value)})
},
% endfor % endfor
structs::${border_style_keyword.gecko_constant('auto')} => Either::First(Auto), structs::${border_style_keyword.gecko_constant('auto')} => Either::First(Auto),
% if border_style_keyword.gecko_inexhaustive: % if border_style_keyword.gecko_inexhaustive:
@ -3065,7 +3067,7 @@ fn static_assert() {
for (gecko, servo) in self.gecko.mAnimations.iter_mut().zip(v.cycle()) { for (gecko, servo) in self.gecko.mAnimations.iter_mut().zip(v.cycle()) {
let result = match servo { let result = match servo {
% for value in keyword.gecko_values(): % for value in keyword.gecko_values():
Keyword::${to_rust_ident(value)} => Keyword::${to_camel_case(value)} =>
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)}, structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast(cast_type)},
% endfor % endfor
}; };
@ -3078,7 +3080,7 @@ fn static_assert() {
use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword; use properties::longhands::animation_${ident}::single_value::computed_value::T as Keyword;
match self.gecko.mAnimations[index].m${gecko_ffi_name} ${keyword.maybe_cast("u32")} { match self.gecko.mAnimations[index].m${gecko_ffi_name} ${keyword.maybe_cast("u32")} {
% for value in keyword.gecko_values(): % for value in keyword.gecko_values():
structs::${keyword.gecko_constant(value)} => Keyword::${to_rust_ident(value)}, structs::${keyword.gecko_constant(value)} => Keyword::${to_camel_case(value)},
% endfor % endfor
x => panic!("Found unexpected value for animation-${ident}: {:?}", x), x => panic!("Found unexpected value for animation-${ident}: {:?}", x),
} }
@ -3121,7 +3123,7 @@ fn static_assert() {
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
let result = match v { let result = match v {
% for value in display_keyword.values_for('gecko'): % for value in display_keyword.values_for('gecko'):
Keyword::${to_rust_ident(value)} => Keyword::${to_camel_case(value)} =>
structs::${display_keyword.gecko_constant(value)}, structs::${display_keyword.gecko_constant(value)},
% endfor % endfor
}; };
@ -3138,7 +3140,7 @@ fn static_assert() {
use properties::longhands::display::computed_value::T as Keyword; use properties::longhands::display::computed_value::T as Keyword;
let result = match v { let result = match v {
% for value in display_keyword.values_for('gecko'): % for value in display_keyword.values_for('gecko'):
Keyword::${to_rust_ident(value)} => Keyword::${to_camel_case(value)} =>
structs::${display_keyword.gecko_constant(value)}, structs::${display_keyword.gecko_constant(value)},
% endfor % endfor
}; };
@ -3162,7 +3164,7 @@ fn static_assert() {
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
self.gecko.mOverflowY = match v { self.gecko.mOverflowY = match v {
% for value in overflow_x.keyword.values_for('gecko'): % for value in overflow_x.keyword.values_for('gecko'):
BaseType::${to_rust_ident(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8, BaseType::${to_camel_case(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8,
% endfor % endfor
}; };
} }
@ -3172,7 +3174,7 @@ fn static_assert() {
// FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
match self.gecko.mOverflowY as u32 { match self.gecko.mOverflowY as u32 {
% for value in overflow_x.keyword.values_for('gecko'): % for value in overflow_x.keyword.values_for('gecko'):
structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_rust_ident(value)}, structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_camel_case(value)},
% endfor % endfor
x => panic!("Found unexpected value in style struct for overflow_y property: {}", x), x => panic!("Found unexpected value in style struct for overflow_y property: {}", x),
} }
@ -3228,11 +3230,11 @@ fn static_assert() {
use computed_values::page_break_${kind}::T; use computed_values::page_break_${kind}::T;
let result = match v { let result = match v {
T::auto => false, T::Auto => false,
T::always => true, T::Always => true,
T::avoid => false, T::Avoid => false,
T::left => true, T::Left => true,
T::right => true T::Right => true
}; };
self.gecko.mBreak${kind.title()} = result; self.gecko.mBreak${kind.title()} = result;
} }
@ -3244,10 +3246,7 @@ fn static_assert() {
pub fn clone_page_break_${kind}(&self) -> longhands::page_break_${kind}::computed_value::T { pub fn clone_page_break_${kind}(&self) -> longhands::page_break_${kind}::computed_value::T {
use computed_values::page_break_${kind}::T; use computed_values::page_break_${kind}::T;
match self.gecko.mBreak${kind.title()} { if self.gecko.mBreak${kind.title()} { T::Always } else { T::Auto }
true => T::always,
false => T::auto,
}
} }
% endfor % endfor
@ -3776,7 +3775,7 @@ fn static_assert() {
geckolayer.${field_name} = { geckolayer.${field_name} = {
match servo { match servo {
% for value in keyword.values_for("gecko"): % for value in keyword.values_for("gecko"):
Keyword::${to_rust_ident(value)} => Keyword::${to_camel_case(value)} =>
structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast('u8')}, structs::${keyword.gecko_constant(value)} ${keyword.maybe_cast('u8')},
% endfor % endfor
} }
@ -3805,7 +3804,7 @@ fn static_assert() {
% else: % else:
structs::${keyword.gecko_constant(value)} structs::${keyword.gecko_constant(value)}
% endif % endif
=> Keyword::${to_rust_ident(value)}, => Keyword::${to_camel_case(value)},
% endfor % endfor
x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x), x => panic!("Found unexpected value in style struct for ${ident} property: {:?}", x),
} }

View file

@ -441,7 +441,7 @@
use style_traits::ParseError; use style_traits::ParseError;
define_css_keyword_enum! { T: define_css_keyword_enum! { T:
% for value in keyword.values_for(product): % for value in keyword.values_for(product):
"${value}" => ${to_rust_ident(value)}, "${value}" => ${to_camel_case(value)},
% endfor % endfor
} }
@ -486,11 +486,11 @@
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
computed_value::T::${to_rust_ident(values.split()[0])} computed_value::T::${to_camel_case(values.split()[0])}
} }
#[inline] #[inline]
pub fn get_initial_specified_value() -> SpecifiedValue { pub fn get_initial_specified_value() -> SpecifiedValue {
SpecifiedValue::Keyword(computed_value::T::${to_rust_ident(values.split()[0])}) SpecifiedValue::Keyword(computed_value::T::${to_camel_case(values.split()[0])})
} }
impl SpecifiedValue { impl SpecifiedValue {
@ -510,6 +510,8 @@
<%def name="single_keyword(name, values, vector=False, **kwargs)"> <%def name="single_keyword(name, values, vector=False, **kwargs)">
<%call expr="single_keyword_computed(name, values, vector, **kwargs)"> <%call expr="single_keyword_computed(name, values, vector, **kwargs)">
// FIXME(emilio): WTF is this even trying to do? Those are no-ops,
// should be derived instead!
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T; type ComputedValue = computed_value::T;
@ -517,7 +519,7 @@
fn to_computed_value(&self, _context: &Context) -> computed_value::T { fn to_computed_value(&self, _context: &Context) -> computed_value::T {
match *self { match *self {
% for value in data.longhands_by_name[name].keyword.values_for(product): % for value in data.longhands_by_name[name].keyword.values_for(product):
SpecifiedValue::${to_rust_ident(value)} => computed_value::T::${to_rust_ident(value)}, SpecifiedValue::${to_camel_case(value)} => computed_value::T::${to_camel_case(value)},
% endfor % endfor
} }
} }
@ -525,7 +527,7 @@
fn from_computed_value(computed: &computed_value::T) -> Self { fn from_computed_value(computed: &computed_value::T) -> Self {
match *computed { match *computed {
% for value in data.longhands_by_name[name].keyword.values_for(product): % for value in data.longhands_by_name[name].keyword.values_for(product):
computed_value::T::${to_rust_ident(value)} => SpecifiedValue::${to_rust_ident(value)}, computed_value::T::${to_camel_case(value)} => SpecifiedValue::${to_camel_case(value)},
% endfor % endfor
} }
} }
@ -554,7 +556,7 @@
% endfor % endfor
match kw ${maybe_cast} { match kw ${maybe_cast} {
% for value in values: % for value in values:
${to_rust_ident(value).upper()} => ${type}::${to_rust_ident(value)}, ${to_rust_ident(value).upper()} => ${type}::${to_camel_case(value)},
% endfor % endfor
x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x), x => panic!("Found unexpected value in style struct for ${keyword.name} property: {:?}", x),
} }
@ -616,12 +618,12 @@
define_css_keyword_enum! { SpecifiedValue: define_css_keyword_enum! { SpecifiedValue:
values { values {
% for value in keyword.values_for(product) + (extra_specified or "").split(): % for value in keyword.values_for(product) + (extra_specified or "").split():
"${value}" => ${to_rust_ident(value)}, "${value}" => ${to_camel_case(value)},
% endfor % endfor
} }
aliases { aliases {
% for alias, value in keyword.aliases_for(product).iteritems(): % for alias, value in keyword.aliases_for(product).iteritems():
"${alias}" => ${to_rust_ident(value)}, "${alias}" => ${to_camel_case(value)},
% endfor % endfor
} }
} }
@ -631,17 +633,17 @@
pub mod computed_value { pub mod computed_value {
define_css_keyword_enum! { T: define_css_keyword_enum! { T:
% for value in data.longhands_by_name[name].keyword.values_for(product): % for value in data.longhands_by_name[name].keyword.values_for(product):
"${value}" => ${to_rust_ident(value)}, "${value}" => ${to_camel_case(value)},
% endfor % endfor
} }
} }
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
computed_value::T::${to_rust_ident(values.split()[0])} computed_value::T::${to_camel_case(values.split()[0])}
} }
#[inline] #[inline]
pub fn get_initial_specified_value() -> SpecifiedValue { pub fn get_initial_specified_value() -> SpecifiedValue {
SpecifiedValue::${to_rust_ident(values.split()[0])} SpecifiedValue::${to_camel_case(values.split()[0])}
} }
#[inline] #[inline]
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)

View file

@ -658,10 +658,10 @@ impl Animate for Visibility {
fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> { fn animate(&self, other: &Self, procedure: Procedure) -> Result<Self, ()> {
let (this_weight, other_weight) = procedure.weights(); let (this_weight, other_weight) = procedure.weights();
match (*self, *other) { match (*self, *other) {
(Visibility::visible, _) => { (Visibility::Visible, _) => {
Ok(if this_weight > 0.0 { *self } else { *other }) Ok(if this_weight > 0.0 { *self } else { *other })
}, },
(_, Visibility::visible) => { (_, Visibility::Visible) => {
Ok(if other_weight > 0.0 { *other } else { *self }) Ok(if other_weight > 0.0 { *other } else { *self })
}, },
_ => Err(()), _ => Err(()),
@ -763,7 +763,7 @@ impl Animate for FontStretch {
{ {
let from = f64::from(*self); let from = f64::from(*self);
let to = f64::from(*other); let to = f64::from(*other);
let normal = f64::from(FontStretch::normal); let normal = f64::from(FontStretch::Normal);
let (this_weight, other_weight) = procedure.weights(); let (this_weight, other_weight) = procedure.weights();
let result = (from - normal) * this_weight + (to - normal) * other_weight + normal; let result = (from - normal) * this_weight + (to - normal) * other_weight + normal;
Ok(result.into()) Ok(result.into())
@ -788,15 +788,15 @@ impl From<FontStretch> for f64 {
fn from(stretch: FontStretch) -> f64 { fn from(stretch: FontStretch) -> f64 {
use self::FontStretch::*; use self::FontStretch::*;
match stretch { match stretch {
ultra_condensed => 1.0, UltraCondensed => 1.0,
extra_condensed => 2.0, ExtraCondensed => 2.0,
condensed => 3.0, Condensed => 3.0,
semi_condensed => 4.0, SemiCondensed => 4.0,
normal => 5.0, Normal => 5.0,
semi_expanded => 6.0, SemiExpanded => 6.0,
expanded => 7.0, Expanded => 7.0,
extra_expanded => 8.0, ExtraExpanded => 8.0,
ultra_expanded => 9.0, UltraExpanded => 9.0,
} }
} }
} }
@ -806,8 +806,8 @@ impl Into<FontStretch> for f64 {
use properties::longhands::font_stretch::computed_value::T::*; use properties::longhands::font_stretch::computed_value::T::*;
let index = (self + 0.5).floor().min(9.0).max(1.0); let index = (self + 0.5).floor().min(9.0).max(1.0);
static FONT_STRETCH_ENUM_MAP: [FontStretch; 9] = static FONT_STRETCH_ENUM_MAP: [FontStretch; 9] =
[ ultra_condensed, extra_condensed, condensed, semi_condensed, normal, [ UltraCondensed, ExtraCondensed, Condensed, SemiCondensed, Normal,
semi_expanded, expanded, extra_expanded, ultra_expanded ]; SemiExpanded, Expanded, ExtraExpanded, UltraExpanded ];
FONT_STRETCH_ENUM_MAP[(index - 1.0) as usize] FONT_STRETCH_ENUM_MAP[(index - 1.0) as usize]
} }
} }

View file

@ -33,7 +33,7 @@
)} )}
${helpers.predefined_type("border-%s-style" % side_name, "BorderStyle", ${helpers.predefined_type("border-%s-style" % side_name, "BorderStyle",
"specified::BorderStyle::none", "specified::BorderStyle::None",
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"), alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-style"),
spec=maybe_logical_spec(side, "style"), spec=maybe_logical_spec(side, "style"),
flags="APPLIES_TO_FIRST_LETTER", flags="APPLIES_TO_FIRST_LETTER",

View file

@ -37,19 +37,20 @@
pub mod computed_value { pub mod computed_value {
pub use super::SpecifiedValue as T; pub use super::SpecifiedValue as T;
use super::SpecifiedValue as Display;
impl T { impl Display {
/// Returns whether this "display" value is the display of a flex or /// Returns whether this "display" value is the display of a flex or
/// grid container. /// grid container.
/// ///
/// This is used to implement various style fixups. /// This is used to implement various style fixups.
pub fn is_item_container(&self) -> bool { pub fn is_item_container(&self) -> bool {
matches!(*self, matches!(*self,
T::flex Display::Flex
| T::inline_flex | Display::InlineFlex
% if product == "gecko": % if product == "gecko":
| T::grid | Display::Grid
| T::inline_grid | Display::InlineGrid
% endif % endif
) )
} }
@ -59,11 +60,11 @@
/// line as itself. /// line as itself.
pub fn is_line_participant(&self) -> bool { pub fn is_line_participant(&self) -> bool {
matches!(*self, matches!(*self,
T::inline Display::Inline
% if product == "gecko": % if product == "gecko":
| T::contents | Display::Contents
| T::ruby | Display::Ruby
| T::ruby_base_container | Display::RubyBaseContainer
% endif % endif
) )
} }
@ -84,8 +85,8 @@
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
match (_old_display, _new_display) { match (_old_display, _new_display) {
(T::_webkit_box, T::_moz_box) | (Display::WebkitBox, Display::MozBox) |
(T::_webkit_inline_box, T::_moz_inline_box) => { (Display::WebkitInlineBox, Display::MozInlineBox) => {
return true; return true;
} }
_ => {}, _ => {},
@ -99,14 +100,20 @@
/// ruby. /// ruby.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn is_ruby_type(&self) -> bool { pub fn is_ruby_type(&self) -> bool {
matches!(*self, T::ruby | T::ruby_base | T::ruby_text | matches!(*self,
T::ruby_base_container | T::ruby_text_container) Display::Ruby |
Display::RubyBase |
Display::RubyText |
Display::RubyBaseContainer |
Display::RubyTextContainer)
} }
/// Returns whether this "display" value is a ruby level container. /// Returns whether this "display" value is a ruby level container.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn is_ruby_level_container(&self) -> bool { pub fn is_ruby_level_container(&self) -> bool {
matches!(*self, T::ruby_base_container | T::ruby_text_container) matches!(*self,
Display::RubyBaseContainer |
Display::RubyTextContainer)
} }
/// Convert this display into an equivalent block display. /// Convert this display into an equivalent block display.
@ -115,28 +122,36 @@
pub fn equivalent_block_display(&self, _is_root_element: bool) -> Self { pub fn equivalent_block_display(&self, _is_root_element: bool) -> Self {
match *self { match *self {
// Values that have a corresponding block-outside version. // Values that have a corresponding block-outside version.
T::inline_table => T::table, Display::InlineTable => Display::Table,
T::inline_flex => T::flex, Display::InlineFlex => Display::Flex,
% if product == "gecko": % if product == "gecko":
T::inline_grid => T::grid, Display::InlineGrid => Display::Grid,
T::_webkit_inline_box => T::_webkit_box, Display::WebkitInlineBox => Display::WebkitBox,
% endif % endif
// Special handling for contents and list-item on the root // Special handling for contents and list-item on the root
// element for Gecko. // element for Gecko.
% if product == "gecko": % if product == "gecko":
T::contents | T::list_item if _is_root_element => T::block, Display::Contents | Display::ListItem if _is_root_element => Display::Block,
% endif % endif
// These are not changed by blockification. // These are not changed by blockification.
T::none | T::block | T::flex | T::list_item | T::table => *self, Display::None |
Display::Block |
Display::Flex |
Display::ListItem |
Display::Table => *self,
% if product == "gecko": % if product == "gecko":
T::contents | T::flow_root | T::grid | T::_webkit_box => *self, Display::Contents |
Display::FlowRoot |
Display::Grid |
Display::WebkitBox => *self,
% endif % endif
// Everything else becomes block. // Everything else becomes block.
_ => T::block, _ => Display::Block,
} }
} }
@ -148,35 +163,38 @@
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn inlinify(&self) -> Self { pub fn inlinify(&self) -> Self {
match *self { match *self {
T::block | T::flow_root => T::inline_block, Display::Block |
T::table => T::inline_table, Display::FlowRoot => Display::InlineBlock,
T::flex => T::inline_flex, Display::Table => Display::InlineTable,
T::grid => T::inline_grid, Display::Flex => Display::InlineFlex,
T::_moz_box => T::_moz_inline_box, Display::Grid => Display::InlineGrid,
T::_moz_stack => T::_moz_inline_stack, Display::MozBox => Display::MozInlineBox,
T::_webkit_box => T::_webkit_inline_box, Display::MozStack => Display::MozInlineStack,
Display::WebkitBox => Display::WebkitInlineBox,
other => other, other => other,
} }
} }
} }
} }
// FIXME(emilio): Why does this reinvent the wheel, again?
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)] #[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, PartialEq, ToComputedValue)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
pub enum SpecifiedValue { pub enum SpecifiedValue {
% for value in values: % for value in values:
${to_rust_ident(value)}, ${to_camel_case(value)},
% endfor % endfor
} }
// TODO(emilio): derive.
impl ToCss for SpecifiedValue { impl ToCss for SpecifiedValue {
fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result
where W: ::std::fmt::Write, where W: ::std::fmt::Write,
{ {
match *self { match *self {
% for value in values: % for value in values:
SpecifiedValue::${to_rust_ident(value)} => dest.write_str("${value}"), SpecifiedValue::${to_camel_case(value)} => dest.write_str("${value}"),
% endfor % endfor
} }
} }
@ -185,7 +203,7 @@
/// The initial display value. /// The initial display value.
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
computed_value::T::${to_rust_ident(values[0])} computed_value::T::${to_camel_case(values[0])}
} }
/// Parse a display value. /// Parse a display value.
@ -194,12 +212,12 @@
try_match_ident_ignore_ascii_case! { input, try_match_ident_ignore_ascii_case! { input,
% for value in values: % for value in values:
"${value}" => { "${value}" => {
Ok(computed_value::T::${to_rust_ident(value)}) Ok(computed_value::T::${to_camel_case(value)})
}, },
% endfor % endfor
% for value in webkit_prefixed_values: % for value in webkit_prefixed_values:
"-webkit-${value}" => { "-webkit-${value}" => {
Ok(computed_value::T::${to_rust_ident(value)}) Ok(computed_value::T::${to_camel_case(value)})
}, },
% endfor % endfor
} }
@ -250,25 +268,25 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
let ltr = context.style().writing_mode.is_bidi_ltr(); let ltr = context.style().writing_mode.is_bidi_ltr();
// https://drafts.csswg.org/css-logical-props/#float-clear // https://drafts.csswg.org/css-logical-props/#float-clear
match *self { match *self {
SpecifiedValue::inline_start => { SpecifiedValue::InlineStart => {
context.rule_cache_conditions.borrow_mut() context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode); .set_writing_mode_dependency(context.builder.writing_mode);
if ltr { if ltr {
computed_value::T::left computed_value::T::Left
} else { } else {
computed_value::T::right computed_value::T::Right
} }
} }
SpecifiedValue::inline_end => { SpecifiedValue::InlineEnd => {
context.rule_cache_conditions.borrow_mut() context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode); .set_writing_mode_dependency(context.builder.writing_mode);
if ltr { if ltr {
computed_value::T::right computed_value::T::Right
} else { } else {
computed_value::T::left computed_value::T::Left
} }
} }
% for value in "none left right".split(): % for value in "None Left Right".split():
SpecifiedValue::${value} => computed_value::T::${value}, SpecifiedValue::${value} => computed_value::T::${value},
% endfor % endfor
} }
@ -276,7 +294,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
#[inline] #[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue { fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed { match *computed {
% for value in "none left right".split(): % for value in "None Left Right".split():
computed_value::T::${value} => SpecifiedValue::${value}, computed_value::T::${value} => SpecifiedValue::${value},
% endfor % endfor
} }
@ -302,25 +320,25 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
let ltr = context.style().writing_mode.is_bidi_ltr(); let ltr = context.style().writing_mode.is_bidi_ltr();
// https://drafts.csswg.org/css-logical-props/#float-clear // https://drafts.csswg.org/css-logical-props/#float-clear
match *self { match *self {
SpecifiedValue::inline_start => { SpecifiedValue::InlineStart => {
context.rule_cache_conditions.borrow_mut() context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode); .set_writing_mode_dependency(context.builder.writing_mode);
if ltr { if ltr {
computed_value::T::left computed_value::T::Left
} else { } else {
computed_value::T::right computed_value::T::Right
} }
} }
SpecifiedValue::inline_end => { SpecifiedValue::InlineEnd => {
context.rule_cache_conditions.borrow_mut() context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode); .set_writing_mode_dependency(context.builder.writing_mode);
if ltr { if ltr {
computed_value::T::right computed_value::T::Right
} else { } else {
computed_value::T::left computed_value::T::Left
} }
} }
% for value in "none left right both".split(): % for value in "None Left Right Both".split():
SpecifiedValue::${value} => computed_value::T::${value}, SpecifiedValue::${value} => computed_value::T::${value},
% endfor % endfor
} }
@ -328,7 +346,7 @@ ${helpers.single_keyword("position", "static absolute relative fixed sticky",
#[inline] #[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue { fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed { match *computed {
% for value in "none left right both".split(): % for value in "None Left Right Both".split():
computed_value::T::${value} => SpecifiedValue::${value}, computed_value::T::${value} => SpecifiedValue::${value},
% endfor % endfor
} }
@ -377,7 +395,7 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
${helpers.predefined_type( ${helpers.predefined_type(
"overflow-clip-box-" + direction, "overflow-clip-box-" + direction,
"OverflowClipBox", "OverflowClipBox",
"computed::OverflowClipBox::padding_box", "computed::OverflowClipBox::PaddingBox",
products="gecko", products="gecko",
enabled_in="ua", enabled_in="ua",
needs_context=False, needs_context=False,

View file

@ -136,7 +136,7 @@
input.try(|input| { input.try(|input| {
input.expect_comma()?; input.expect_comma()?;
list_style_type::parse(context, input) list_style_type::parse(context, input)
}).unwrap_or(list_style_type::computed_value::T::decimal) }).unwrap_or(list_style_type::computed_value::T::Decimal)
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]

View file

@ -76,13 +76,13 @@ ${helpers.single_keyword("word-break",
#[inline] #[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T { fn to_computed_value(&self, _: &Context) -> computed_value::T {
match *self { match *self {
% for value in "auto none inter_word".split(): % for value in "Auto None InterWord".split():
SpecifiedValue::${value} => computed_value::T::${value}, SpecifiedValue::${value} => computed_value::T::${value},
% endfor % endfor
% if product == "gecko": % if product == "gecko":
SpecifiedValue::inter_character => computed_value::T::inter_character, SpecifiedValue::InterCharacter => computed_value::T::InterCharacter,
// https://drafts.csswg.org/css-text-3/#valdef-text-justify-distribute // https://drafts.csswg.org/css-text-3/#valdef-text-justify-distribute
SpecifiedValue::distribute => computed_value::T::inter_character, SpecifiedValue::Distribute => computed_value::T::InterCharacter,
% endif % endif
} }
} }
@ -90,11 +90,11 @@ ${helpers.single_keyword("word-break",
#[inline] #[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue { fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed { match *computed {
% for value in "auto none inter_word".split(): % for value in "Auto None InterWord".split():
computed_value::T::${value} => SpecifiedValue::${value}, computed_value::T::${value} => SpecifiedValue::${value},
% endfor % endfor
% if product == "gecko": % if product == "gecko":
computed_value::T::inter_character => SpecifiedValue::inter_character, computed_value::T::InterCharacter => SpecifiedValue::InterCharacter,
% endif % endif
} }
} }
@ -109,18 +109,25 @@ ${helpers.single_keyword("text-align-last",
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last")} spec="https://drafts.csswg.org/css-text/#propdef-text-align-last")}
// TODO make this a shorthand and implement text-align-last/text-align-all // TODO make this a shorthand and implement text-align-last/text-align-all
//
// FIXME(emilio): This can't really be that complicated.
<%helpers:longhand name="text-align" animation_value_type="discrete" <%helpers:longhand name="text-align" animation_value_type="discrete"
flags="APPLIES_TO_PLACEHOLDER" flags="APPLIES_TO_PLACEHOLDER"
spec="https://drafts.csswg.org/css-text/#propdef-text-align"> spec="https://drafts.csswg.org/css-text/#propdef-text-align">
pub use self::computed_value::TextAlign;
pub mod computed_value { pub mod computed_value {
pub use self::TextAlign as T;
macro_rules! define_text_align { macro_rules! define_text_align {
( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => { ( $( $name: ident ( $string: expr ) => $discriminant: expr, )+ ) => {
define_css_keyword_enum! { T: define_css_keyword_enum! { TextAlign:
$( $(
$string => $name, $string => $name,
)+ )+
} }
impl T {
impl TextAlign {
pub fn to_u32(self) -> u32 { pub fn to_u32(self) -> u32 {
match self { match self {
$( $(
@ -139,22 +146,23 @@ ${helpers.single_keyword("text-align-last",
} }
} }
} }
// FIXME(emilio): Why reinventing the world?
define_text_align! { define_text_align! {
start("start") => 0, Start("start") => 0,
end("end") => 1, End("end") => 1,
left("left") => 2, Left("left") => 2,
right("right") => 3, Right("right") => 3,
center("center") => 4, Center("center") => 4,
justify("justify") => 5, Justify("justify") => 5,
% if product == "servo": % if product == "servo":
servo_center("-servo-center") => 6, ServoCenter("-servo-center") => 6,
servo_left("-servo-left") => 7, ServoLeft("-servo-left") => 7,
servo_right("-servo-right") => 8, ServoRight("-servo-right") => 8,
% else: % else:
_moz_center("-moz-center") => 6, MozCenter("-moz-center") => 6,
_moz_left("-moz-left") => 7, MozLeft("-moz-left") => 7,
_moz_right("-moz-right") => 8, MozRight("-moz-right") => 8,
char("char") => 10, Char("char") => 10,
% endif % endif
} }
@ -164,8 +172,8 @@ ${helpers.single_keyword("text-align-last",
gecko_strip_moz_prefix=False), type="T")} gecko_strip_moz_prefix=False), type="T")}
} }
#[inline] pub fn get_initial_value() -> computed_value::T { #[inline] pub fn get_initial_value() -> TextAlign {
computed_value::T::start TextAlign::Start
} }
@ -176,14 +184,14 @@ ${helpers.single_keyword("text-align-last",
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))] #[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
pub enum SpecifiedValue { pub enum SpecifiedValue {
Keyword(computed_value::T), Keyword(TextAlign),
MatchParent, MatchParent,
MozCenterOrInherit, MozCenterOrInherit,
} }
pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>) pub fn parse<'i, 't>(_context: &ParserContext, input: &mut Parser<'i, 't>)
-> Result<SpecifiedValue, ParseError<'i>> { -> Result<SpecifiedValue, ParseError<'i>> {
// MozCenterOrInherit cannot be parsed, only set directly on th elements // MozCenterOrInherit cannot be parsed, only set directly on th elements
if let Ok(key) = input.try(computed_value::T::parse) { if let Ok(key) = input.try(TextAlign::parse) {
Ok(SpecifiedValue::Keyword(key)) Ok(SpecifiedValue::Keyword(key))
} else { } else {
input.expect_ident_matching("match-parent")?; input.expect_ident_matching("match-parent")?;
@ -211,10 +219,10 @@ ${helpers.single_keyword("text-align-last",
} }
} }
impl ToComputedValue for SpecifiedValue { impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T; type ComputedValue = TextAlign;
#[inline] #[inline]
fn to_computed_value(&self, context: &Context) -> computed_value::T { fn to_computed_value(&self, context: &Context) -> TextAlign {
match *self { match *self {
SpecifiedValue::Keyword(key) => key, SpecifiedValue::Keyword(key) => key,
SpecifiedValue::MatchParent => { SpecifiedValue::MatchParent => {
@ -230,17 +238,17 @@ ${helpers.single_keyword("text-align-last",
let parent = context.builder.get_parent_inheritedtext().clone_text_align(); let parent = context.builder.get_parent_inheritedtext().clone_text_align();
let ltr = context.builder.inherited_writing_mode().is_bidi_ltr(); let ltr = context.builder.inherited_writing_mode().is_bidi_ltr();
match (parent, ltr) { match (parent, ltr) {
(computed_value::T::start, true) => computed_value::T::left, (TextAlign::Start, true) => TextAlign::Left,
(computed_value::T::start, false) => computed_value::T::right, (TextAlign::Start, false) => TextAlign::Right,
(computed_value::T::end, true) => computed_value::T::right, (TextAlign::End, true) => TextAlign::Right,
(computed_value::T::end, false) => computed_value::T::left, (TextAlign::End, false) => TextAlign::Left,
_ => parent _ => parent
} }
} }
SpecifiedValue::MozCenterOrInherit => { SpecifiedValue::MozCenterOrInherit => {
let parent = context.builder.get_parent_inheritedtext().clone_text_align(); let parent = context.builder.get_parent_inheritedtext().clone_text_align();
if parent == computed_value::T::start { if parent == TextAlign::Start {
computed_value::T::center TextAlign::Center
} else { } else {
parent parent
} }
@ -314,8 +322,8 @@ ${helpers.predefined_type("word-spacing",
// Start with no declarations if this is an atomic inline-level box; otherwise, start with the // Start with no declarations if this is an atomic inline-level box; otherwise, start with the
// declarations in effect and add in the text decorations that this block specifies. // declarations in effect and add in the text decorations that this block specifies.
let mut result = match context.style().get_box().clone_display() { let mut result = match context.style().get_box().clone_display() {
super::display::computed_value::T::inline_block | super::display::computed_value::T::InlineBlock |
super::display::computed_value::T::inline_table => get_initial_value(), super::display::computed_value::T::InlineTable => get_initial_value(),
_ => context.builder.get_parent_inheritedtext().clone__servo_text_decorations_in_effect() _ => context.builder.get_parent_inheritedtext().clone__servo_text_decorations_in_effect()
}; };
@ -354,31 +362,31 @@ ${helpers.predefined_type("word-spacing",
impl SpecifiedValue { impl SpecifiedValue {
pub fn allow_wrap(&self) -> bool { pub fn allow_wrap(&self) -> bool {
match *self { match *self {
SpecifiedValue::nowrap | SpecifiedValue::Nowrap |
SpecifiedValue::pre => false, SpecifiedValue::Pre => false,
SpecifiedValue::normal | SpecifiedValue::Normal |
SpecifiedValue::pre_wrap | SpecifiedValue::PreWrap |
SpecifiedValue::pre_line => true, SpecifiedValue::PreLine => true,
} }
} }
pub fn preserve_newlines(&self) -> bool { pub fn preserve_newlines(&self) -> bool {
match *self { match *self {
SpecifiedValue::normal | SpecifiedValue::Normal |
SpecifiedValue::nowrap => false, SpecifiedValue::Nowrap => false,
SpecifiedValue::pre | SpecifiedValue::Pre |
SpecifiedValue::pre_wrap | SpecifiedValue::PreWrap |
SpecifiedValue::pre_line => true, SpecifiedValue::PreLine => true,
} }
} }
pub fn preserve_spaces(&self) -> bool { pub fn preserve_spaces(&self) -> bool {
match *self { match *self {
SpecifiedValue::normal | SpecifiedValue::Normal |
SpecifiedValue::nowrap | SpecifiedValue::Nowrap |
SpecifiedValue::pre_line => false, SpecifiedValue::PreLine => false,
SpecifiedValue::pre | SpecifiedValue::Pre |
SpecifiedValue::pre_wrap => true, SpecifiedValue::PreWrap => true,
} }
} }
} }
@ -399,7 +407,7 @@ ${helpers.predefined_type(
<%helpers:longhand name="text-emphasis-style" products="gecko" boxed="True" <%helpers:longhand name="text-emphasis-style" products="gecko" boxed="True"
animation_value_type="discrete" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style"> spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-style">
use computed_values::writing_mode::T as writing_mode; use computed_values::writing_mode::T as WritingMode;
use std::fmt; use std::fmt;
use style_traits::ToCss; use style_traits::ToCss;
use unicode_segmentation::UnicodeSegmentation; use unicode_segmentation::UnicodeSegmentation;
@ -519,7 +527,7 @@ ${helpers.predefined_type(
match *self { match *self {
SpecifiedValue::Keyword(ref keyword) => { SpecifiedValue::Keyword(ref keyword) => {
let default_shape = if context.style().get_inheritedbox() let default_shape = if context.style().get_inheritedbox()
.clone_writing_mode() == writing_mode::horizontal_tb { .clone_writing_mode() == WritingMode::HorizontalTb {
ShapeKeyword::Circle ShapeKeyword::Circle
} else { } else {
ShapeKeyword::Sesame ShapeKeyword::Sesame

View file

@ -38,12 +38,12 @@ ${helpers.predefined_type(
#[inline] #[inline]
pub fn get_initial_value() -> computed_value::T { pub fn get_initial_value() -> computed_value::T {
Either::Second(BorderStyle::none) Either::Second(BorderStyle::None)
} }
#[inline] #[inline]
pub fn get_initial_specified_value() -> SpecifiedValue { pub fn get_initial_specified_value() -> SpecifiedValue {
Either::Second(BorderStyle::none) Either::Second(BorderStyle::None)
} }
pub mod computed_value { pub mod computed_value {
@ -54,7 +54,7 @@ ${helpers.predefined_type(
-> Result<SpecifiedValue, ParseError<'i>> { -> Result<SpecifiedValue, ParseError<'i>> {
SpecifiedValue::parse(context, input) SpecifiedValue::parse(context, input)
.and_then(|result| { .and_then(|result| {
if let Either::Second(BorderStyle::hidden) = result { if let Either::Second(BorderStyle::Hidden) = result {
// The outline-style property accepts the same values as // The outline-style property accepts the same values as
// border-style, except that 'hidden' is not a legal outline // border-style, except that 'hidden' is not a legal outline
// style. // style.

View file

@ -2396,24 +2396,24 @@ impl ComputedValuesInner {
/// Return true if the effects force the transform style to be Flat /// Return true if the effects force the transform style to be Flat
pub fn overrides_transform_style(&self) -> bool { pub fn overrides_transform_style(&self) -> bool {
use computed_values::mix_blend_mode; use computed_values::mix_blend_mode::T as MixBlendMode;
let effects = self.get_effects(); let effects = self.get_effects();
// TODO(gw): Add clip-path, isolation, mask-image, mask-border-source when supported. // TODO(gw): Add clip-path, isolation, mask-image, mask-border-source when supported.
effects.opacity < 1.0 || effects.opacity < 1.0 ||
!effects.filter.0.is_empty() || !effects.filter.0.is_empty() ||
!effects.clip.is_auto() || !effects.clip.is_auto() ||
effects.mix_blend_mode != mix_blend_mode::T::normal effects.mix_blend_mode != MixBlendMode::Normal
} }
/// <https://drafts.csswg.org/css-transforms/#grouping-property-values> /// <https://drafts.csswg.org/css-transforms/#grouping-property-values>
pub fn get_used_transform_style(&self) -> computed_values::transform_style::T { pub fn get_used_transform_style(&self) -> computed_values::transform_style::T {
use computed_values::transform_style; use computed_values::transform_style::T as TransformStyle;
let box_ = self.get_box(); let box_ = self.get_box();
if self.overrides_transform_style() { if self.overrides_transform_style() {
transform_style::T::flat TransformStyle::Flat
} else { } else {
// Return the computed value if not overridden by the above exceptions // Return the computed value if not overridden by the above exceptions
box_.transform_style box_.transform_style
@ -2913,15 +2913,15 @@ impl<'a> StyleBuilder<'a> {
/// Returns whether this computed style represents a floated object. /// Returns whether this computed style represents a floated object.
pub fn floated(&self) -> bool { pub fn floated(&self) -> bool {
self.get_box().clone_float() != longhands::float::computed_value::T::none self.get_box().clone_float() != longhands::float::computed_value::T::None
} }
/// Returns whether this computed style represents an out of flow-positioned /// Returns whether this computed style represents an out of flow-positioned
/// object. /// object.
pub fn out_of_flow_positioned(&self) -> bool { pub fn out_of_flow_positioned(&self) -> bool {
use properties::longhands::position::computed_value::T as position; use properties::longhands::position::computed_value::T as Position;
matches!(self.get_box().clone_position(), matches!(self.get_box().clone_position(),
position::absolute | position::fixed) Position::Absolute | Position::Fixed)
} }
/// Whether this style has a top-layer style. That's implemented in Gecko /// Whether this style has a top-layer style. That's implemented in Gecko
@ -2934,7 +2934,7 @@ impl<'a> StyleBuilder<'a> {
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
pub fn in_top_layer(&self) -> bool { pub fn in_top_layer(&self) -> bool {
matches!(self.get_box().clone__moz_top_layer(), matches!(self.get_box().clone__moz_top_layer(),
longhands::_moz_top_layer::computed_value::T::top) longhands::_moz_top_layer::computed_value::T::Top)
} }
/// Clears the "have any reset structs been modified" flag. /// Clears the "have any reset structs been modified" flag.

View file

@ -18,16 +18,17 @@
use values::specified::{Color, Position, PositionComponent}; use values::specified::{Color, Position, PositionComponent};
use parser::Parse; use parser::Parse;
// FIXME(emilio): Should be the same type!
impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue { impl From<background_origin::single_value::SpecifiedValue> for background_clip::single_value::SpecifiedValue {
fn from(origin: background_origin::single_value::SpecifiedValue) -> fn from(origin: background_origin::single_value::SpecifiedValue) ->
background_clip::single_value::SpecifiedValue { background_clip::single_value::SpecifiedValue {
match origin { match origin {
background_origin::single_value::SpecifiedValue::content_box => background_origin::single_value::SpecifiedValue::ContentBox =>
background_clip::single_value::SpecifiedValue::content_box, background_clip::single_value::SpecifiedValue::ContentBox,
background_origin::single_value::SpecifiedValue::padding_box => background_origin::single_value::SpecifiedValue::PaddingBox =>
background_clip::single_value::SpecifiedValue::padding_box, background_clip::single_value::SpecifiedValue::PaddingBox,
background_origin::single_value::SpecifiedValue::border_box => background_origin::single_value::SpecifiedValue::BorderBox =>
background_clip::single_value::SpecifiedValue::border_box, background_clip::single_value::SpecifiedValue::BorderBox,
} }
} }
} }
@ -177,7 +178,7 @@
size.to_css(dest)?; size.to_css(dest)?;
} }
if *origin != Origin::padding_box || *clip != Clip::border_box { if *origin != Origin::PaddingBox || *clip != Clip::BorderBox {
dest.write_str(" ")?; dest.write_str(" ")?;
origin.to_css(dest)?; origin.to_css(dest)?;
if *clip != From::from(*origin) { if *clip != From::from(*origin) {

View file

@ -80,7 +80,7 @@ pub fn parse_border<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
} }
if any { if any {
Ok((color.unwrap_or_else(|| Color::currentcolor()), Ok((color.unwrap_or_else(|| Color::currentcolor()),
style.unwrap_or(BorderStyle::none), style.unwrap_or(BorderStyle::None),
width.unwrap_or(BorderSideWidth::Medium))) width.unwrap_or(BorderSideWidth::Medium)))
} else { } else {
Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError)) Err(input.new_custom_error(StyleParseErrorKind::UnspecifiedError))

View file

@ -18,20 +18,20 @@
try_match_ident_ignore_ascii_case! { input, try_match_ident_ignore_ascii_case! { input,
"-moz-scrollbars-horizontal" => { "-moz-scrollbars-horizontal" => {
Ok(expanded! { Ok(expanded! {
overflow_x: SpecifiedValue::scroll, overflow_x: SpecifiedValue::Scroll,
overflow_y: SpecifiedValue::hidden, overflow_y: SpecifiedValue::Hidden,
}) })
} }
"-moz-scrollbars-vertical" => { "-moz-scrollbars-vertical" => {
Ok(expanded! { Ok(expanded! {
overflow_x: SpecifiedValue::hidden, overflow_x: SpecifiedValue::Hidden,
overflow_y: SpecifiedValue::scroll, overflow_y: SpecifiedValue::Scroll,
}) })
} }
"-moz-scrollbars-none" => { "-moz-scrollbars-none" => {
Ok(expanded! { Ok(expanded! {
overflow_x: SpecifiedValue::hidden, overflow_x: SpecifiedValue::Hidden,
overflow_y: SpecifiedValue::hidden, overflow_y: SpecifiedValue::Hidden,
}) })
} }
} }

View file

@ -60,7 +60,7 @@
fn list_style_type_none() -> list_style_type::SpecifiedValue { fn list_style_type_none() -> list_style_type::SpecifiedValue {
% if product == "servo": % if product == "servo":
list_style_type::SpecifiedValue::none list_style_type::SpecifiedValue::None
% else: % else:
use values::generics::CounterStyleOrNone; use values::generics::CounterStyleOrNone;
list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None) list_style_type::SpecifiedValue::CounterStyle(CounterStyleOrNone::None)

View file

@ -14,22 +14,23 @@
use values::specified::{Position, PositionComponent}; use values::specified::{Position, PositionComponent};
use parser::Parse; use parser::Parse;
// FIXME(emilio): These two mask types should be the same!
impl From<mask_origin::single_value::SpecifiedValue> for mask_clip::single_value::SpecifiedValue { impl From<mask_origin::single_value::SpecifiedValue> for mask_clip::single_value::SpecifiedValue {
fn from(origin: mask_origin::single_value::SpecifiedValue) -> mask_clip::single_value::SpecifiedValue { fn from(origin: mask_origin::single_value::SpecifiedValue) -> mask_clip::single_value::SpecifiedValue {
match origin { match origin {
mask_origin::single_value::SpecifiedValue::content_box => mask_origin::single_value::SpecifiedValue::ContentBox =>
mask_clip::single_value::SpecifiedValue::content_box, mask_clip::single_value::SpecifiedValue::ContentBox,
mask_origin::single_value::SpecifiedValue::padding_box => mask_origin::single_value::SpecifiedValue::PaddingBox =>
mask_clip::single_value::SpecifiedValue::padding_box, mask_clip::single_value::SpecifiedValue::PaddingBox ,
mask_origin::single_value::SpecifiedValue::border_box => mask_origin::single_value::SpecifiedValue::BorderBox =>
mask_clip::single_value::SpecifiedValue::border_box, mask_clip::single_value::SpecifiedValue::BorderBox,
% if product == "gecko": % if product == "gecko":
mask_origin::single_value::SpecifiedValue::fill_box => mask_origin::single_value::SpecifiedValue::FillBox =>
mask_clip::single_value::SpecifiedValue::fill_box, mask_clip::single_value::SpecifiedValue::FillBox ,
mask_origin::single_value::SpecifiedValue::stroke_box => mask_origin::single_value::SpecifiedValue::StrokeBox =>
mask_clip::single_value::SpecifiedValue::stroke_box, mask_clip::single_value::SpecifiedValue::StrokeBox,
mask_origin::single_value::SpecifiedValue::view_box => mask_origin::single_value::SpecifiedValue::ViewBox=>
mask_clip::single_value::SpecifiedValue::view_box, mask_clip::single_value::SpecifiedValue::ViewBox,
% endif % endif
} }
} }
@ -160,7 +161,7 @@
dest.write_str(" ")?; dest.write_str(" ")?;
repeat.to_css(dest)?; repeat.to_css(dest)?;
if *origin != Origin::border_box || *clip != Clip::border_box { if *origin != Origin::BorderBox || *clip != Clip::BorderBox {
dest.write_str(" ")?; dest.write_str(" ")?;
origin.to_css(dest)?; origin.to_css(dest)?;
if *clip != From::from(*origin) { if *clip != From::from(*origin) {

View file

@ -66,7 +66,7 @@
self.text_decoration_line.to_css(dest)?; self.text_decoration_line.to_css(dest)?;
% if product == "gecko": % if product == "gecko":
if self.text_decoration_style != &text_decoration_style::SpecifiedValue::solid { if *self.text_decoration_style != text_decoration_style::SpecifiedValue::Solid {
dest.write_str(" ")?; dest.write_str(" ")?;
self.text_decoration_style.to_css(dest)?; self.text_decoration_style.to_css(dest)?;
} }

View file

@ -5,7 +5,7 @@
//! The restyle damage is a hint that tells layout which kind of operations may //! The restyle damage is a hint that tells layout which kind of operations may
//! be needed in presence of incremental style changes. //! be needed in presence of incremental style changes.
use computed_values::display; use computed_values::display::T as Display;
use matching::{StyleChange, StyleDifference}; use matching::{StyleChange, StyleDifference};
use properties::ComputedValues; use properties::ComputedValues;
use std::fmt; use std::fmt;
@ -219,7 +219,7 @@ fn compute_damage(old: &ComputedValues, new: &ComputedValues) -> ServoRestyleDam
get_text.text_decoration_line, get_text.unicode_bidi, get_text.text_decoration_line, get_text.unicode_bidi,
get_inheritedtable.empty_cells, get_inheritedtable.caption_side, get_inheritedtable.empty_cells, get_inheritedtable.caption_side,
get_column.column_width, get_column.column_count get_column.column_width, get_column.column_count
]) || (new.get_box().display == display::T::inline && ]) || (new.get_box().display == Display::Inline &&
add_if_not_equal!(old, new, damage, add_if_not_equal!(old, new, damage,
[ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION, [ServoRestyleDamage::REPAINT, ServoRestyleDamage::REPOSITION,
ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES, ServoRestyleDamage::STORE_OVERFLOW, ServoRestyleDamage::BUBBLE_ISIZES,

View file

@ -15,7 +15,7 @@ use fnv::FnvHashMap;
use invalidation::element::element_wrapper::ElementSnapshot; use invalidation::element::element_wrapper::ElementSnapshot;
use properties::ComputedValues; use properties::ComputedValues;
use properties::PropertyFlags; use properties::PropertyFlags;
use properties::longhands::display::computed_value as display; use properties::longhands::display::computed_value::T as Display;
use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser}; use selector_parser::{AttrValue as SelectorAttrValue, PseudoElementCascadeType, SelectorParser};
use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity}; use selectors::attr::{AttrSelectorOperation, NamespaceConstraint, CaseSensitivity};
use selectors::parser::{SelectorMethods, SelectorParseErrorKind}; use selectors::parser::{SelectorMethods, SelectorParseErrorKind};
@ -229,10 +229,9 @@ impl PseudoElement {
/// Whether this pseudo-element should actually exist if it has /// Whether this pseudo-element should actually exist if it has
/// the given styles. /// the given styles.
pub fn should_exist(&self, style: &ComputedValues) -> bool pub fn should_exist(&self, style: &ComputedValues) -> bool {
{
let display = style.get_box().clone_display(); let display = style.get_box().clone_display();
if display == display::T::none { if display == Display::None {
return false; return false;
} }
if self.is_before_or_after() && style.ineffective_content_property() { if self.is_before_or_after() && style.ineffective_content_property() {

View file

@ -7,10 +7,10 @@
use app_units::Au; use app_units::Au;
use properties::{self, CascadeFlags, ComputedValues, StyleBuilder}; use properties::{self, CascadeFlags, ComputedValues, StyleBuilder};
use properties::longhands::display::computed_value::T as display; use properties::longhands::display::computed_value::T as Display;
use properties::longhands::float::computed_value::T as float; use properties::longhands::float::computed_value::T as Float;
use properties::longhands::overflow_x::computed_value::T as overflow; use properties::longhands::overflow_x::computed_value::T as Overflow;
use properties::longhands::position::computed_value::T as position; use properties::longhands::position::computed_value::T as Position;
/// A struct that implements all the adjustment methods. /// A struct that implements all the adjustment methods.
/// ///
@ -23,10 +23,9 @@ pub struct StyleAdjuster<'a, 'b: 'a> {
impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> { impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// Trivially constructs a new StyleAdjuster. /// Trivially constructs a new StyleAdjuster.
#[inline]
pub fn new(style: &'a mut StyleBuilder<'b>) -> Self { pub fn new(style: &'a mut StyleBuilder<'b>) -> Self {
StyleAdjuster { StyleAdjuster { style }
style: style,
}
} }
/// <https://fullscreen.spec.whatwg.org/#new-stacking-layer> /// <https://fullscreen.spec.whatwg.org/#new-stacking-layer>
@ -36,7 +35,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// ///
fn adjust_for_top_layer(&mut self) { fn adjust_for_top_layer(&mut self) {
if !self.style.out_of_flow_positioned() && self.style.in_top_layer() { if !self.style.out_of_flow_positioned() && self.style.in_top_layer() {
self.style.mutate_box().set_position(position::absolute); self.style.mutate_box().set_position(Position::Absolute);
} }
} }
@ -47,7 +46,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// ///
fn adjust_for_position(&mut self) { fn adjust_for_position(&mut self) {
if self.style.out_of_flow_positioned() && self.style.floated() { if self.style.out_of_flow_positioned() && self.style.floated() {
self.style.mutate_box().set_float(float::none); self.style.mutate_box().set_float(Float::None);
} }
} }
@ -97,7 +96,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
use properties::computed_value_flags::ComputedValueFlags; use properties::computed_value_flags::ComputedValueFlags;
if self.style.inherited_flags().contains(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE) || if self.style.inherited_flags().contains(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE) ||
self.style.get_box().clone_display() == display::none { self.style.get_box().clone_display() == Display::None {
self.style.flags.insert(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE); self.style.flags.insert(ComputedValueFlags::IS_IN_DISPLAY_NONE_SUBTREE);
} }
@ -127,10 +126,13 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// ///
/// TODO(emilio): we should (Gecko too) revise these adjustments in presence /// TODO(emilio): we should (Gecko too) revise these adjustments in presence
/// of display: contents. /// of display: contents.
///
/// FIXME(emilio): How does this play with logical properties? Doesn't
/// mutating writing-mode change the potential physical sides chosen?
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn adjust_for_text_combine_upright(&mut self) { fn adjust_for_text_combine_upright(&mut self) {
use computed_values::text_combine_upright::T as text_combine_upright; use computed_values::text_combine_upright::T as TextCombineUpright;
use computed_values::writing_mode::T as writing_mode; use computed_values::writing_mode::T as WritingMode;
use properties::computed_value_flags::ComputedValueFlags; use properties::computed_value_flags::ComputedValueFlags;
let writing_mode = let writing_mode =
@ -138,10 +140,10 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
let text_combine_upright = let text_combine_upright =
self.style.get_inheritedtext().clone_text_combine_upright(); self.style.get_inheritedtext().clone_text_combine_upright();
if writing_mode != writing_mode::horizontal_tb && if writing_mode != WritingMode::HorizontalTb &&
text_combine_upright == text_combine_upright::all { text_combine_upright == TextCombineUpright::All {
self.style.flags.insert(ComputedValueFlags::IS_TEXT_COMBINED); self.style.flags.insert(ComputedValueFlags::IS_TEXT_COMBINED);
self.style.mutate_inheritedbox().set_writing_mode(writing_mode::horizontal_tb); self.style.mutate_inheritedbox().set_writing_mode(WritingMode::HorizontalTb);
} }
} }
@ -181,8 +183,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
layout_parent_style.get_inheritedbox().clone_writing_mode(); layout_parent_style.get_inheritedbox().clone_writing_mode();
if our_writing_mode != parent_writing_mode && if our_writing_mode != parent_writing_mode &&
self.style.get_box().clone_display() == display::inline { self.style.get_box().clone_display() == Display::Inline {
self.style.mutate_box().set_display(display::inline_block); self.style.mutate_box().set_display(Display::InlineBlock);
} }
} }
@ -199,18 +201,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
return; return;
} }
if self.style.get_box().clone_display() == display::inline { if self.style.get_box().clone_display() == Display::Inline {
self.style.mutate_box().set_adjusted_display(display::inline_block, self.style.mutate_box().set_adjusted_display(Display::InlineBlock,
false); false);
} }
// When 'contain: paint', update overflow from 'visible' to 'clip'. // When 'contain: paint', update overflow from 'visible' to 'clip'.
if self.style.get_box().clone_contain().contains(SpecifiedValue::PAINT) { if self.style.get_box().clone_contain().contains(SpecifiedValue::PAINT) {
if self.style.get_box().clone_overflow_x() == overflow::visible { if self.style.get_box().clone_overflow_x() == Overflow::Visible {
let box_style = self.style.mutate_box(); let box_style = self.style.mutate_box();
box_style.set_overflow_x(overflow::_moz_hidden_unscrollable); box_style.set_overflow_x(Overflow::MozHiddenUnscrollable);
box_style.set_overflow_y(overflow::_moz_hidden_unscrollable); box_style.set_overflow_y(Overflow::MozHiddenUnscrollable);
} }
} }
} }
@ -219,15 +221,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// both forced to "normal". /// both forced to "normal".
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn adjust_for_mathvariant(&mut self) { fn adjust_for_mathvariant(&mut self) {
use properties::longhands::_moz_math_variant::computed_value::T as moz_math_variant; use properties::longhands::_moz_math_variant::computed_value::T as MozMathVariant;
use properties::longhands::font_style::computed_value::T as font_style; use properties::longhands::font_style::computed_value::T as FontStyle;
use properties::longhands::font_weight::computed_value::T as font_weight; use properties::longhands::font_weight::computed_value::T as FontWeight;
if self.style.get_font().clone__moz_math_variant() != moz_math_variant::none { if self.style.get_font().clone__moz_math_variant() != MozMathVariant::None {
let font_style = self.style.mutate_font(); let font_style = self.style.mutate_font();
// Sadly we don't have a nice name for the computed value // Sadly we don't have a nice name for the computed value
// of "font-weight: normal". // of "font-weight: normal".
font_style.set_font_weight(font_weight::normal()); font_style.set_font_weight(FontWeight::normal());
font_style.set_font_style(font_style::normal); font_style.set_font_style(FontStyle::Normal);
} }
} }
@ -237,18 +239,18 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// See https://github.com/servo/servo/issues/15229 /// See https://github.com/servo/servo/issues/15229
#[cfg(feature = "servo")] #[cfg(feature = "servo")]
fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) { fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues) {
use computed_values::align_items::T as align_items; use computed_values::align_items::T as AlignItems;
use computed_values::align_self::T as align_self; use computed_values::align_self::T as AlignSelf;
if self.style.get_position().clone_align_self() == align_self::auto && if self.style.get_position().clone_align_self() == AlignSelf::Auto &&
!self.style.out_of_flow_positioned() { !self.style.out_of_flow_positioned() {
let self_align = let self_align =
match layout_parent_style.get_position().clone_align_items() { match layout_parent_style.get_position().clone_align_items() {
align_items::stretch => align_self::stretch, AlignItems::Stretch => AlignSelf::Stretch,
align_items::baseline => align_self::baseline, AlignItems::Baseline => AlignSelf::Baseline,
align_items::flex_start => align_self::flex_start, AlignItems::FlexStart => AlignSelf::FlexStart,
align_items::flex_end => align_self::flex_end, AlignItems::FlexEnd => AlignSelf::FlexEnd,
align_items::center => align_self::center, AlignItems::Center => AlignSelf::Center,
}; };
self.style.mutate_position().set_align_self(self_align); self.style.mutate_position().set_align_self(self_align);
} }
@ -288,23 +290,23 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
// If 'visible' is specified but doesn't match the other dimension, // If 'visible' is specified but doesn't match the other dimension,
// it turns into 'auto'. // it turns into 'auto'.
if overflow_x == overflow::visible { if overflow_x == Overflow::Visible {
overflow_x = overflow::auto; overflow_x = Overflow::Auto;
} }
if overflow_y == overflow::visible { if overflow_y == Overflow::Visible {
overflow_y = overflow::auto; overflow_y = Overflow::Auto;
} }
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
{ {
// overflow: clip is deprecated, so convert to hidden if it's // overflow: clip is deprecated, so convert to hidden if it's
// specified in only one dimension. // specified in only one dimension.
if overflow_x == overflow::_moz_hidden_unscrollable { if overflow_x == Overflow::MozHiddenUnscrollable {
overflow_x = overflow::hidden; overflow_x = Overflow::Hidden;
} }
if overflow_y == overflow::_moz_hidden_unscrollable { if overflow_y == Overflow::MozHiddenUnscrollable {
overflow_y = overflow::hidden; overflow_y = Overflow::Hidden;
} }
} }
@ -324,11 +326,11 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
// TODO: We should probably convert display:contents into display:none // TODO: We should probably convert display:contents into display:none
// in some cases too: https://drafts.csswg.org/css-display/#unbox // in some cases too: https://drafts.csswg.org/css-display/#unbox
if !flags.contains(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS) || if !flags.contains(CascadeFlags::PROHIBIT_DISPLAY_CONTENTS) ||
self.style.get_box().clone_display() != display::contents { self.style.get_box().clone_display() != Display::Contents {
return; return;
} }
self.style.mutate_box().set_display(display::inline); self.style.mutate_box().set_display(Display::Inline);
} }
/// If a <fieldset> has grid/flex display type, we need to inherit /// If a <fieldset> has grid/flex display type, we need to inherit
@ -347,16 +349,16 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
if !flags.contains(CascadeFlags::IS_FIELDSET_CONTENT) { if !flags.contains(CascadeFlags::IS_FIELDSET_CONTENT) {
return; return;
} }
debug_assert_eq!(self.style.get_box().clone_display(), display::block); debug_assert_eq!(self.style.get_box().clone_display(), Display::Block);
// TODO We actually want style from parent rather than layout // TODO We actually want style from parent rather than layout
// parent, so that this fixup doesn't happen incorrectly when // parent, so that this fixup doesn't happen incorrectly when
// when <fieldset> has "display: contents". // when <fieldset> has "display: contents".
let parent_display = layout_parent_style.get_box().clone_display(); let parent_display = layout_parent_style.get_box().clone_display();
let new_display = match parent_display { let new_display = match parent_display {
display::flex | Display::Flex |
display::inline_flex => Some(display::flex), Display::InlineFlex => Some(Display::Flex),
display::grid | Display::Grid |
display::inline_grid => Some(display::grid), Display::InlineGrid => Some(Display::Grid),
_ => None, _ => None,
}; };
if let Some(new_display) = new_display { if let Some(new_display) = new_display {
@ -372,19 +374,19 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// table. /// table.
#[cfg(feature = "gecko")] #[cfg(feature = "gecko")]
fn adjust_for_table_text_align(&mut self) { fn adjust_for_table_text_align(&mut self) {
use properties::longhands::text_align::computed_value::T as text_align; use properties::longhands::text_align::computed_value::T as TextAlign;
if self.style.get_box().clone_display() != display::table { if self.style.get_box().clone_display() != Display::Table {
return; return;
} }
match self.style.get_inheritedtext().clone_text_align() { match self.style.get_inheritedtext().clone_text_align() {
text_align::_moz_left | TextAlign::MozLeft |
text_align::_moz_center | TextAlign::MozCenter |
text_align::_moz_right => {}, TextAlign::MozRight => {},
_ => return, _ => return,
} }
self.style.mutate_inheritedtext().set_text_align(text_align::start) self.style.mutate_inheritedtext().set_text_align(TextAlign::Start)
} }
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style. /// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
@ -419,15 +421,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
} }
match self.style.get_box().clone_display() { match self.style.get_box().clone_display() {
// Ruby base and text are always non-breakable. // Ruby base and text are always non-breakable.
display::ruby_base | Display::RubyBase |
display::ruby_text => true, Display::RubyText => true,
// Ruby base container and text container are breakable. // Ruby base container and text container are breakable.
// Note that, when certain HTML tags, e.g. form controls, have ruby // Note that, when certain HTML tags, e.g. form controls, have ruby
// level container display type, they could also escape from the // level container display type, they could also escape from the
// line break suppression flag while they shouldn't. However, it is // line break suppression flag while they shouldn't. However, it is
// generally fine since they themselves are non-breakable. // generally fine since they themselves are non-breakable.
display::ruby_base_container | Display::RubyBaseContainer |
display::ruby_text_container => false, Display::RubyTextContainer => false,
// Anything else is non-breakable if and only if its layout parent // Anything else is non-breakable if and only if its layout parent
// has a ruby display type, because any of the ruby boxes can be // has a ruby display type, because any of the ruby boxes can be
// anonymous. // anonymous.
@ -448,7 +450,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
) { ) {
use properties::CascadeFlags; use properties::CascadeFlags;
use properties::computed_value_flags::ComputedValueFlags; use properties::computed_value_flags::ComputedValueFlags;
use properties::longhands::unicode_bidi::computed_value::T as unicode_bidi; use properties::longhands::unicode_bidi::computed_value::T as UnicodeBidi;
let self_display = self.style.get_box().clone_display(); let self_display = self.style.get_box().clone_display();
// Check whether line break should be suppressed for this element. // Check whether line break should be suppressed for this element.
@ -475,9 +477,9 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
// per spec https://drafts.csswg.org/css-ruby-1/#bidi // per spec https://drafts.csswg.org/css-ruby-1/#bidi
if self_display.is_ruby_type() { if self_display.is_ruby_type() {
let new_value = match self.style.get_text().clone_unicode_bidi() { let new_value = match self.style.get_text().clone_unicode_bidi() {
unicode_bidi::normal | UnicodeBidi::Normal |
unicode_bidi::embed => Some(unicode_bidi::isolate), UnicodeBidi::Embed => Some(UnicodeBidi::Isolate),
unicode_bidi::bidi_override => Some(unicode_bidi::isolate_override), UnicodeBidi::BidiOverride => Some(UnicodeBidi::IsolateOverride),
_ => None, _ => None,
}; };
if let Some(new_value) = new_value { if let Some(new_value) = new_value {

View file

@ -12,7 +12,7 @@ use log::LogLevel::Trace;
use matching::{CascadeVisitedMode, MatchMethods}; use matching::{CascadeVisitedMode, MatchMethods};
use properties::{AnimationRules, CascadeFlags, ComputedValues}; use properties::{AnimationRules, CascadeFlags, ComputedValues};
use properties::cascade; use properties::cascade;
use properties::longhands::display::computed_value::T as display; use properties::longhands::display::computed_value::T as Display;
use rule_tree::StrongRuleNode; use rule_tree::StrongRuleNode;
use selector_parser::{PseudoElement, SelectorImpl}; use selector_parser::{PseudoElement, SelectorImpl};
use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode}; use selectors::matching::{ElementSelectorFlags, MatchingContext, MatchingMode, VisitedHandlingMode};
@ -115,7 +115,7 @@ fn eager_pseudo_is_definitely_not_generated(
} }
if !style.flags.intersects(ComputedValueFlags::INHERITS_DISPLAY) && if !style.flags.intersects(ComputedValueFlags::INHERITS_DISPLAY) &&
style.get_box().clone_display() == display::none { style.get_box().clone_display() == Display::None {
return true; return true;
} }

View file

@ -803,7 +803,7 @@ impl ToComputedValue for specified::MozScriptLevel {
specified::MozScriptLevel::Auto => { specified::MozScriptLevel::Auto => {
let parent = cx.builder.get_parent_font().clone__moz_script_level() as i32; let parent = cx.builder.get_parent_font().clone__moz_script_level() as i32;
let display = cx.builder.get_parent_font().clone__moz_math_display(); let display = cx.builder.get_parent_font().clone__moz_math_display();
if display == DisplayValue::inline { if display == DisplayValue::Inline {
parent + 1 parent + 1
} else { } else {
parent parent

View file

@ -125,9 +125,8 @@ define_css_keyword_enum! { OverscrollBehavior:
} }
add_impls_for_keyword_enum!(OverscrollBehavior); add_impls_for_keyword_enum!(OverscrollBehavior);
// FIXME(emilio): Make all keywords CamelCase.
define_css_keyword_enum! { OverflowClipBox: define_css_keyword_enum! { OverflowClipBox:
"padding-box" => padding_box, "padding-box" => PaddingBox,
"content-box" => content_box, "content-box" => ContentBox,
} }
add_impls_for_keyword_enum!(OverflowClipBox); add_impls_for_keyword_enum!(OverflowClipBox);

View file

@ -141,24 +141,26 @@ fn parse_number_with_clamping_mode<'i, 't>(
// The integer values here correspond to the border conflict resolution rules in CSS 2.1 § // The integer values here correspond to the border conflict resolution rules in CSS 2.1 §
// 17.6.2.1. Higher values override lower values. // 17.6.2.1. Higher values override lower values.
//
// FIXME(emilio): Should move to border.rs
define_numbered_css_keyword_enum! { BorderStyle: define_numbered_css_keyword_enum! { BorderStyle:
"none" => none = -1, "none" => None = -1,
"solid" => solid = 6, "solid" => Solid = 6,
"double" => double = 7, "double" => Double = 7,
"dotted" => dotted = 4, "dotted" => Dotted = 4,
"dashed" => dashed = 5, "dashed" => Dashed = 5,
"hidden" => hidden = -2, "hidden" => Hidden = -2,
"groove" => groove = 1, "groove" => Groove = 1,
"ridge" => ridge = 3, "ridge" => Ridge = 3,
"inset" => inset = 0, "inset" => Inset = 0,
"outset" => outset = 2, "outset" => Outset = 2,
} }
impl BorderStyle { impl BorderStyle {
/// Whether this border style is either none or hidden. /// Whether this border style is either none or hidden.
pub fn none_or_hidden(&self) -> bool { pub fn none_or_hidden(&self) -> bool {
matches!(*self, BorderStyle::none | BorderStyle::hidden) matches!(*self, BorderStyle::None | BorderStyle::Hidden)
} }
} }

View file

@ -11,7 +11,7 @@ use metrics::{PaintTimeMetrics, ProfilerMetadataFactory, ProgressiveWebMetric};
use msg::constellation_msg::TEST_PIPELINE_ID; 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 style::computed_values::image_rendering; use style::computed_values::image_rendering::T as ImageRendering;
use time; use time;
struct DummyProfilerMetadataFactory {} struct DummyProfilerMetadataFactory {}
@ -127,7 +127,7 @@ fn test_first_contentful_paint_setter() {
image_data: None, image_data: None,
stretch_size: Size2D::zero(), stretch_size: Size2D::zero(),
tile_spacing: Size2D::zero(), tile_spacing: Size2D::zero(),
image_rendering: image_rendering::T::auto, image_rendering: ImageRendering::Auto,
})); }));
let display_list = DisplayList { let display_list = DisplayList {
list: vec![image], list: vec![image],

View file

@ -3,7 +3,7 @@
* 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 properties::{parse, parse_input}; use properties::{parse, parse_input};
use style::computed_values::display::T::inline_block; use style::computed_values::display::T as Display;
use style::properties::{PropertyDeclaration, Importance}; use style::properties::{PropertyDeclaration, Importance};
use style::properties::parse_property_declaration_list; use style::properties::parse_property_declaration_list;
use style::values::{CustomIdent, RGBA, Auto}; use style::values::{CustomIdent, RGBA, Auto};
@ -32,16 +32,15 @@ fn property_declaration_block_should_serialize_correctly() {
LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))), LengthOrPercentageOrAuto::Length(NoCalcLength::from_px(20f32))),
Importance::Important), Importance::Important),
(PropertyDeclaration::Display( (PropertyDeclaration::Display(Display::InlineBlock),
inline_block),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::OverflowX( (PropertyDeclaration::OverflowX(
OverflowValue::auto), OverflowValue::Auto),
Importance::Normal), Importance::Normal),
(PropertyDeclaration::OverflowY( (PropertyDeclaration::OverflowY(
OverflowValue::auto), OverflowValue::Auto),
Importance::Normal), Importance::Normal),
]; ];
@ -74,7 +73,7 @@ mod shorthand_serialization {
fn equal_overflow_properties_should_serialize_to_single_value() { fn equal_overflow_properties_should_serialize_to_single_value() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let overflow = OverflowValue::auto; let overflow = OverflowValue::Auto;
properties.push(PropertyDeclaration::OverflowX(overflow)); properties.push(PropertyDeclaration::OverflowX(overflow));
properties.push(PropertyDeclaration::OverflowY(overflow)); properties.push(PropertyDeclaration::OverflowY(overflow));
@ -86,10 +85,10 @@ mod shorthand_serialization {
fn different_overflow_properties_should_serialize_to_two_values() { fn different_overflow_properties_should_serialize_to_two_values() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let overflow_x = OverflowValue::scroll; let overflow_x = OverflowValue::Scroll;
properties.push(PropertyDeclaration::OverflowX(overflow_x)); properties.push(PropertyDeclaration::OverflowX(overflow_x));
let overflow_y = OverflowValue::auto; let overflow_y = OverflowValue::Auto;
properties.push(PropertyDeclaration::OverflowY(overflow_y)); properties.push(PropertyDeclaration::OverflowY(overflow_y));
let serialization = shorthand_properties_to_string(properties); let serialization = shorthand_properties_to_string(properties);
@ -171,7 +170,7 @@ mod shorthand_serialization {
fn different_longhands_should_serialize_to_long_form() { fn different_longhands_should_serialize_to_long_form() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = BorderStyle::solid; let solid = BorderStyle::Solid;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone()));
@ -202,7 +201,7 @@ mod shorthand_serialization {
fn same_longhands_should_serialize_correctly() { fn same_longhands_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = BorderStyle::solid; let solid = BorderStyle::Solid;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(solid.clone())); properties.push(PropertyDeclaration::BorderRightStyle(solid.clone()));
@ -303,8 +302,8 @@ mod shorthand_serialization {
fn border_style_should_serialize_correctly() { fn border_style_should_serialize_correctly() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let solid = BorderStyle::solid; let solid = BorderStyle::Solid;
let dotted = BorderStyle::dotted; let dotted = BorderStyle::Dotted;
properties.push(PropertyDeclaration::BorderTopStyle(solid.clone())); properties.push(PropertyDeclaration::BorderTopStyle(solid.clone()));
properties.push(PropertyDeclaration::BorderRightStyle(dotted.clone())); properties.push(PropertyDeclaration::BorderRightStyle(dotted.clone()));
properties.push(PropertyDeclaration::BorderBottomStyle(solid)); properties.push(PropertyDeclaration::BorderBottomStyle(solid));
@ -345,7 +344,7 @@ mod shorthand_serialization {
fn border_top_and_color() { fn border_top_and_color() {
let mut properties = Vec::new(); let mut properties = Vec::new();
properties.push(PropertyDeclaration::BorderTopWidth(BorderSideWidth::Length(Length::from_px(1.)))); properties.push(PropertyDeclaration::BorderTopWidth(BorderSideWidth::Length(Length::from_px(1.))));
properties.push(PropertyDeclaration::BorderTopStyle(BorderStyle::solid)); properties.push(PropertyDeclaration::BorderTopStyle(BorderStyle::Solid));
let c = Color::Numeric { let c = Color::Numeric {
parsed: RGBA::new(255, 0, 0, 255), parsed: RGBA::new(255, 0, 0, 255),
authored: Some("green".to_string().into_boxed_str()) authored: Some("green".to_string().into_boxed_str())
@ -377,7 +376,7 @@ mod shorthand_serialization {
properties.push(PropertyDeclaration::BorderRightColor(c.clone())); properties.push(PropertyDeclaration::BorderRightColor(c.clone()));
properties.push(PropertyDeclaration::BorderTopWidth(BorderSideWidth::Length(Length::from_px(1.)))); properties.push(PropertyDeclaration::BorderTopWidth(BorderSideWidth::Length(Length::from_px(1.))));
properties.push(PropertyDeclaration::BorderTopStyle(BorderStyle::solid)); properties.push(PropertyDeclaration::BorderTopStyle(BorderStyle::Solid));
let c = Color::Numeric { let c = Color::Numeric {
parsed: RGBA::new(255, 0, 0, 255), parsed: RGBA::new(255, 0, 0, 255),
authored: Some("green".to_string().into_boxed_str()) authored: Some("green".to_string().into_boxed_str())
@ -396,7 +395,7 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = BorderSideWidth::Length(Length::from_px(4f32)); let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = BorderStyle::solid; let style = BorderStyle::Solid;
let color = RGBA::new(255, 0, 0, 255).into(); let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::BorderTopWidth(width)); properties.push(PropertyDeclaration::BorderTopWidth(width));
@ -409,7 +408,7 @@ mod shorthand_serialization {
fn get_border_property_values() -> (BorderSideWidth, BorderStyle, Color) { fn get_border_property_values() -> (BorderSideWidth, BorderStyle, Color) {
(BorderSideWidth::Length(Length::from_px(4f32)), (BorderSideWidth::Length(Length::from_px(4f32)),
BorderStyle::solid, BorderStyle::Solid,
Color::currentcolor()) Color::currentcolor())
} }
@ -492,10 +491,10 @@ mod shorthand_serialization {
fn list_style_should_show_all_properties_when_values_are_set() { fn list_style_should_show_all_properties_when_values_are_set() {
let mut properties = Vec::new(); let mut properties = Vec::new();
let position = ListStylePosition::inside; let position = ListStylePosition::Inside;
let image = let image =
ListStyleImage(Either::First(SpecifiedUrl::new_for_testing("http://servo/test.png"))); ListStyleImage(Either::First(SpecifiedUrl::new_for_testing("http://servo/test.png")));
let style_type = ListStyleType::disc; let style_type = ListStyleType::Disc;
properties.push(PropertyDeclaration::ListStylePosition(position)); properties.push(PropertyDeclaration::ListStylePosition(position));
@ -520,7 +519,7 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let width = BorderSideWidth::Length(Length::from_px(4f32)); let width = BorderSideWidth::Length(Length::from_px(4f32));
let style = Either::Second(BorderStyle::solid); let style = Either::Second(BorderStyle::Solid);
let color = RGBA::new(255, 0, 0, 255).into(); let color = RGBA::new(255, 0, 0, 255).into();
properties.push(PropertyDeclaration::OutlineWidth(width)); properties.push(PropertyDeclaration::OutlineWidth(width));
@ -589,8 +588,8 @@ mod shorthand_serialization {
let mut properties = Vec::new(); let mut properties = Vec::new();
let direction = FlexDirection::row; let direction = FlexDirection::Row;
let wrap = FlexWrap::wrap; let wrap = FlexWrap::Wrap;
properties.push(PropertyDeclaration::FlexDirection(direction)); properties.push(PropertyDeclaration::FlexDirection(direction));
properties.push(PropertyDeclaration::FlexWrap(wrap)); properties.push(PropertyDeclaration::FlexWrap(wrap));

View file

@ -80,7 +80,7 @@ fn test_insertion_style_attribute(rule_tree: &RuleTree, rules: &[(StyleSource, C
let mut rules = rules.to_vec(); let mut rules = rules.to_vec();
rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one( rules.push((StyleSource::Declarations(Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Display( PropertyDeclaration::Display(
longhands::display::SpecifiedValue::block), longhands::display::SpecifiedValue::Block),
Importance::Normal Importance::Normal
)))), CascadeLevel::UserNormal)); )))), CascadeLevel::UserNormal));
test_insertion(rule_tree, rules) test_insertion(rule_tree, rules)

View file

@ -108,7 +108,7 @@ fn test_parse_stylesheet() {
), (0 << 20) + (1 << 10) + (1 << 0)) ), (0 << 20) + (1 << 10) + (1 << 0))
)), )),
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![ block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
(PropertyDeclaration::Display(longhands::display::SpecifiedValue::none), (PropertyDeclaration::Display(longhands::display::SpecifiedValue::None),
Importance::Important), Importance::Important),
(PropertyDeclaration::Custom(Atom::from("a"), (PropertyDeclaration::Custom(Atom::from("a"),
DeclaredValueOwned::CSSWideKeyword(CSSWideKeyword::Inherit)), DeclaredValueOwned::CSSWideKeyword(CSSWideKeyword::Inherit)),
@ -138,7 +138,7 @@ fn test_parse_stylesheet() {
), ),
)), )),
block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![ block: Arc::new(stylesheet.shared_lock.wrap(block_from(vec![
(PropertyDeclaration::Display(longhands::display::SpecifiedValue::block), (PropertyDeclaration::Display(longhands::display::SpecifiedValue::Block),
Importance::Normal), Importance::Normal),
]))), ]))),
source_location: SourceLocation { source_location: SourceLocation {

View file

@ -31,7 +31,7 @@ fn get_mock_rules(css_selectors: &[&str]) -> (Vec<Vec<Rule>>, SharedRwLock) {
selectors: selectors, selectors: selectors,
block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one( block: Arc::new(shared_lock.wrap(PropertyDeclarationBlock::with_one(
PropertyDeclaration::Display( PropertyDeclaration::Display(
longhands::display::SpecifiedValue::block), longhands::display::SpecifiedValue::Block),
Importance::Normal Importance::Normal
))), ))),
source_location: SourceLocation { source_location: SourceLocation {