mirror of
https://github.com/servo/servo.git
synced 2025-07-03 21:43:41 +01:00
Use BorderSideWidth for outline-width
This commit is contained in:
parent
2c7fbb4b4c
commit
7da94d0880
13 changed files with 137 additions and 186 deletions
|
@ -167,7 +167,7 @@ impl TextRunScanner {
|
||||||
};
|
};
|
||||||
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;
|
||||||
word_spacing = inherited_text_style.word_spacing.value().cloned()
|
word_spacing = inherited_text_style.word_spacing.value()
|
||||||
.map(|lop| lop.to_hash_key())
|
.map(|lop| lop.to_hash_key())
|
||||||
.unwrap_or((Au(0), NotNaN::new(0.0).unwrap()));
|
.unwrap_or((Au(0), NotNaN::new(0.0).unwrap()));
|
||||||
text_rendering = inherited_text_style.text_rendering;
|
text_rendering = inherited_text_style.text_rendering;
|
||||||
|
|
|
@ -646,7 +646,7 @@ impl LayoutElementHelpers for LayoutJS<Element> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(border) = border {
|
if let Some(border) = border {
|
||||||
let width_value = specified::BorderWidth::from_length(specified::Length::from_px(border as f32));
|
let width_value = specified::BorderSideWidth::Length(specified::Length::from_px(border as f32));
|
||||||
hints.push(from_declaration(
|
hints.push(from_declaration(
|
||||||
shared_lock,
|
shared_lock,
|
||||||
PropertyDeclaration::BorderTopWidth(width_value.clone())));
|
PropertyDeclaration::BorderTopWidth(width_value.clone())));
|
||||||
|
|
|
@ -32,7 +32,9 @@
|
||||||
spec=maybe_logical_spec(side, "style"),
|
spec=maybe_logical_spec(side, "style"),
|
||||||
animation_value_type="none", logical=side[1])}
|
animation_value_type="none", logical=side[1])}
|
||||||
|
|
||||||
${helpers.predefined_type("border-%s-width" % side[0], "BorderWidth", "Au::from_px(3)",
|
${helpers.predefined_type("border-%s-width" % side[0],
|
||||||
|
"BorderSideWidth",
|
||||||
|
"Au::from_px(3)",
|
||||||
computed_type="::app_units::Au",
|
computed_type="::app_units::Au",
|
||||||
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"),
|
alias=maybe_moz_logical_alias(product, side, "-moz-border-%s-width"),
|
||||||
spec=maybe_logical_spec(side, "width"),
|
spec=maybe_logical_spec(side, "width"),
|
||||||
|
|
|
@ -40,11 +40,15 @@ ${helpers.single_keyword("column-fill", "balance auto", extra_prefixes="moz",
|
||||||
products="gecko", animation_value_type="discrete",
|
products="gecko", animation_value_type="discrete",
|
||||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")}
|
spec="https://drafts.csswg.org/css-multicol/#propdef-column-fill")}
|
||||||
|
|
||||||
${helpers.predefined_type("column-rule-width", "BorderWidth", "Au::from_px(3)",
|
${helpers.predefined_type("column-rule-width",
|
||||||
initial_specified_value="specified::BorderWidth::Medium",
|
"BorderSideWidth",
|
||||||
products="gecko", computed_type="::app_units::Au",
|
"Au::from_px(3)",
|
||||||
|
initial_specified_value="specified::BorderSideWidth::Medium",
|
||||||
|
computed_type="::app_units::Au",
|
||||||
|
products="gecko",
|
||||||
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width",
|
spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-width",
|
||||||
animation_value_type="ComputedValue", extra_prefixes="moz")}
|
animation_value_type="ComputedValue",
|
||||||
|
extra_prefixes="moz")}
|
||||||
|
|
||||||
// https://drafts.csswg.org/css-multicol-1/#crc
|
// https://drafts.csswg.org/css-multicol-1/#crc
|
||||||
${helpers.predefined_type("column-rule-color", "CSSColor",
|
${helpers.predefined_type("column-rule-color", "CSSColor",
|
||||||
|
|
|
@ -872,13 +872,15 @@ ${helpers.predefined_type(
|
||||||
ignored_when_colors_disabled=True,
|
ignored_when_colors_disabled=True,
|
||||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
|
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-color")}
|
||||||
|
|
||||||
${helpers.predefined_type("-webkit-text-stroke-width", "BorderWidth", "Au::from_px(0)",
|
${helpers.predefined_type("-webkit-text-stroke-width",
|
||||||
initial_specified_value="specified::BorderWidth::from_length(specified::Length::zero())",
|
"BorderSideWidth",
|
||||||
computed_type="::app_units::Au", products="gecko",
|
"Au::from_px(0)",
|
||||||
|
initial_specified_value="specified::BorderSideWidth::Length(specified::Length::zero())",
|
||||||
|
computed_type="::app_units::Au",
|
||||||
|
products="gecko",
|
||||||
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
|
spec="https://compat.spec.whatwg.org/#the-webkit-text-stroke-width",
|
||||||
animation_value_type="none")}
|
animation_value_type="none")}
|
||||||
|
|
||||||
|
|
||||||
// CSS Ruby Layout Module Level 1
|
// CSS Ruby Layout Module Level 1
|
||||||
// https://drafts.csswg.org/css-ruby/
|
// https://drafts.csswg.org/css-ruby/
|
||||||
${helpers.single_keyword("ruby-align", "space-around start center space-between",
|
${helpers.single_keyword("ruby-align", "space-around start center space-between",
|
||||||
|
|
|
@ -61,50 +61,13 @@ ${helpers.predefined_type("outline-color", "CSSColor", "computed::CSSColor::Curr
|
||||||
}
|
}
|
||||||
</%helpers:longhand>
|
</%helpers:longhand>
|
||||||
|
|
||||||
<%helpers:longhand name="outline-width" animation_value_type="ComputedValue"
|
${helpers.predefined_type("outline-width",
|
||||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-width">
|
"BorderSideWidth",
|
||||||
use std::fmt;
|
"Au::from_px(3)",
|
||||||
use style_traits::ToCss;
|
initial_specified_value="specified::BorderSideWidth::Medium",
|
||||||
|
computed_type="::app_units::Au",
|
||||||
impl ToCss for SpecifiedValue {
|
animation_value_type="ComputedValue",
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
spec="https://drafts.csswg.org/css-ui/#propdef-outline-width")}
|
||||||
self.0.to_css(dest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
|
||||||
specified::parse_border_width(context, input).map(SpecifiedValue)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
|
||||||
pub struct SpecifiedValue(pub specified::Length);
|
|
||||||
|
|
||||||
pub mod computed_value {
|
|
||||||
use app_units::Au;
|
|
||||||
pub type T = Au;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub use super::border_top_width::get_initial_value;
|
|
||||||
#[inline]
|
|
||||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
|
||||||
SpecifiedValue(specified::Length::NoCalc(specified::NoCalcLength::medium()))
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToComputedValue for SpecifiedValue {
|
|
||||||
type ComputedValue = computed_value::T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_computed_value(&self, context: &Context) -> computed_value::T {
|
|
||||||
self.0.to_computed_value(context)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn from_computed_value(computed: &computed_value::T) -> Self {
|
|
||||||
SpecifiedValue(ToComputedValue::from_computed_value(computed))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</%helpers:longhand>
|
|
||||||
|
|
||||||
// The -moz-outline-radius-* properties are non-standard and not on a standards track.
|
// The -moz-outline-radius-* properties are non-standard and not on a standards track.
|
||||||
// TODO: Should they animate?
|
// TODO: Should they animate?
|
||||||
|
|
|
@ -18,11 +18,11 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style",
|
||||||
for side in PHYSICAL_SIDES)}"
|
for side in PHYSICAL_SIDES)}"
|
||||||
spec="https://drafts.csswg.org/css-backgrounds/#border-width">
|
spec="https://drafts.csswg.org/css-backgrounds/#border-width">
|
||||||
use values::generics::rect::Rect;
|
use values::generics::rect::Rect;
|
||||||
use values::specified::{AllowQuirks, BorderWidth};
|
use values::specified::{AllowQuirks, BorderSideWidth};
|
||||||
|
|
||||||
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
|
||||||
let rect = Rect::parse_with(context, input, |_, i| {
|
let rect = Rect::parse_with(context, input, |_, i| {
|
||||||
BorderWidth::parse_quirky(context, i, AllowQuirks::Yes)
|
BorderSideWidth::parse_quirky(context, i, AllowQuirks::Yes)
|
||||||
})?;
|
})?;
|
||||||
Ok(expanded! {
|
Ok(expanded! {
|
||||||
border_top_width: rect.0,
|
border_top_width: rect.0,
|
||||||
|
@ -46,8 +46,8 @@ ${helpers.four_sides_shorthand("border-style", "border-%s-style",
|
||||||
pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
-> Result<(specified::CSSColor,
|
-> Result<(specified::CSSColor,
|
||||||
specified::BorderStyle,
|
specified::BorderStyle,
|
||||||
specified::BorderWidth), ()> {
|
specified::BorderSideWidth), ()> {
|
||||||
use values::specified::{CSSColor, BorderStyle, BorderWidth};
|
use values::specified::{CSSColor, BorderStyle, BorderSideWidth};
|
||||||
let _unused = context;
|
let _unused = context;
|
||||||
let mut color = None;
|
let mut color = None;
|
||||||
let mut style = None;
|
let mut style = None;
|
||||||
|
@ -69,7 +69,7 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if width.is_none() {
|
if width.is_none() {
|
||||||
if let Ok(value) = input.try(|i| BorderWidth::parse(context, i)) {
|
if let Ok(value) = input.try(|i| BorderSideWidth::parse(context, i)) {
|
||||||
width = Some(value);
|
width = Some(value);
|
||||||
any = true;
|
any = true;
|
||||||
continue
|
continue
|
||||||
|
@ -80,7 +80,7 @@ pub fn parse_border(context: &ParserContext, input: &mut Parser)
|
||||||
if any {
|
if any {
|
||||||
Ok((color.unwrap_or_else(|| CSSColor::currentcolor()),
|
Ok((color.unwrap_or_else(|| CSSColor::currentcolor()),
|
||||||
style.unwrap_or(BorderStyle::none),
|
style.unwrap_or(BorderStyle::none),
|
||||||
width.unwrap_or(BorderWidth::Medium)))
|
width.unwrap_or(BorderSideWidth::Medium)))
|
||||||
} else {
|
} else {
|
||||||
Err(())
|
Err(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,33 @@
|
||||||
|
|
||||||
//! Specified types for CSS values related to borders.
|
//! Specified types for CSS values related to borders.
|
||||||
|
|
||||||
|
use app_units::Au;
|
||||||
use cssparser::Parser;
|
use cssparser::Parser;
|
||||||
use parser::{Parse, ParserContext};
|
use parser::{Parse, ParserContext};
|
||||||
|
use std::fmt;
|
||||||
|
use style_traits::ToCss;
|
||||||
|
use values::computed::{Context, ToComputedValue};
|
||||||
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
use values::generics::border::BorderCornerRadius as GenericBorderCornerRadius;
|
||||||
use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
|
use values::generics::border::BorderImageSlice as GenericBorderImageSlice;
|
||||||
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
|
use values::generics::border::BorderImageWidthSide as GenericBorderImageWidthSide;
|
||||||
use values::generics::border::BorderRadius as GenericBorderRadius;
|
use values::generics::border::BorderRadius as GenericBorderRadius;
|
||||||
use values::generics::rect::Rect;
|
use values::generics::rect::Rect;
|
||||||
use values::specified::{Number, NumberOrPercentage};
|
use values::specified::{AllowQuirks, Number, NumberOrPercentage};
|
||||||
use values::specified::length::LengthOrPercentage;
|
use values::specified::length::{Length, LengthOrPercentage};
|
||||||
|
|
||||||
|
/// A specified value for a single side of the `border-width` property.
|
||||||
|
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||||
|
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
||||||
|
pub enum BorderSideWidth {
|
||||||
|
/// `thin`
|
||||||
|
Thin,
|
||||||
|
/// `medium`
|
||||||
|
Medium,
|
||||||
|
/// `thick`
|
||||||
|
Thick,
|
||||||
|
/// `<length>`
|
||||||
|
Length(Length),
|
||||||
|
}
|
||||||
|
|
||||||
/// A specified value for the `border-image-width` property.
|
/// A specified value for the `border-image-width` property.
|
||||||
pub type BorderImageWidth = Rect<BorderImageWidthSide>;
|
pub type BorderImageWidth = Rect<BorderImageWidthSide>;
|
||||||
|
@ -29,6 +47,65 @@ pub type BorderRadius = GenericBorderRadius<LengthOrPercentage>;
|
||||||
/// A specified value for the `border-*-radius` longhand properties.
|
/// A specified value for the `border-*-radius` longhand properties.
|
||||||
pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
|
pub type BorderCornerRadius = GenericBorderCornerRadius<LengthOrPercentage>;
|
||||||
|
|
||||||
|
impl BorderSideWidth {
|
||||||
|
/// Parses, with quirks.
|
||||||
|
pub fn parse_quirky(
|
||||||
|
context: &ParserContext,
|
||||||
|
input: &mut Parser,
|
||||||
|
allow_quirks: AllowQuirks)
|
||||||
|
-> Result<Self, ()>
|
||||||
|
{
|
||||||
|
if let Ok(length) = input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) {
|
||||||
|
return Ok(BorderSideWidth::Length(length));
|
||||||
|
}
|
||||||
|
match_ignore_ascii_case! { &input.expect_ident()?,
|
||||||
|
"thin" => Ok(BorderSideWidth::Thin),
|
||||||
|
"medium" => Ok(BorderSideWidth::Medium),
|
||||||
|
"thick" => Ok(BorderSideWidth::Thick),
|
||||||
|
_ => Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Parse for BorderSideWidth {
|
||||||
|
fn parse(context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
|
||||||
|
Self::parse_quirky(context, input, AllowQuirks::No)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToCss for BorderSideWidth {
|
||||||
|
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||||
|
match *self {
|
||||||
|
BorderSideWidth::Thin => dest.write_str("thin"),
|
||||||
|
BorderSideWidth::Medium => dest.write_str("medium"),
|
||||||
|
BorderSideWidth::Thick => dest.write_str("thick"),
|
||||||
|
BorderSideWidth::Length(ref length) => length.to_css(dest)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToComputedValue for BorderSideWidth {
|
||||||
|
type ComputedValue = Au;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
||||||
|
// We choose the pixel length of the keyword values the same as both spec and gecko.
|
||||||
|
// Spec: https://drafts.csswg.org/css-backgrounds-3/#line-width
|
||||||
|
// Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=1312155#c0
|
||||||
|
match *self {
|
||||||
|
BorderSideWidth::Thin => Length::from_px(1.).to_computed_value(context),
|
||||||
|
BorderSideWidth::Medium => Length::from_px(3.).to_computed_value(context),
|
||||||
|
BorderSideWidth::Thick => Length::from_px(5.).to_computed_value(context),
|
||||||
|
BorderSideWidth::Length(ref length) => length.to_computed_value(context)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
||||||
|
BorderSideWidth::Length(ToComputedValue::from_computed_value(computed))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl BorderImageWidthSide {
|
impl BorderImageWidthSide {
|
||||||
/// Returns `1`.
|
/// Returns `1`.
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
//! TODO(emilio): Enhance docs.
|
//! TODO(emilio): Enhance docs.
|
||||||
|
|
||||||
use Namespace;
|
use Namespace;
|
||||||
use app_units::Au;
|
|
||||||
use context::QuirksMode;
|
use context::QuirksMode;
|
||||||
use cssparser::{self, Parser, Token, serialize_identifier};
|
use cssparser::{self, Parser, Token, serialize_identifier};
|
||||||
use itoa;
|
use itoa;
|
||||||
|
@ -32,7 +31,7 @@ use values::specified::calc::CalcNode;
|
||||||
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
pub use self::align::{AlignItems, AlignJustifyContent, AlignJustifySelf, JustifyItems};
|
||||||
pub use self::background::BackgroundSize;
|
pub use self::background::BackgroundSize;
|
||||||
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
|
||||||
pub use self::border::{BorderImageWidthSide, BorderRadius};
|
pub use self::border::{BorderImageWidthSide, BorderRadius, BorderSideWidth};
|
||||||
pub use self::color::Color;
|
pub use self::color::Color;
|
||||||
pub use self::rect::LengthOrNumberRect;
|
pub use self::rect::LengthOrNumberRect;
|
||||||
pub use super::generics::grid::GridLine;
|
pub use super::generics::grid::GridLine;
|
||||||
|
@ -434,92 +433,6 @@ impl Angle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub fn parse_border_width(context: &ParserContext, input: &mut Parser) -> Result<Length, ()> {
|
|
||||||
input.try(|i| Length::parse_non_negative(context, i)).or_else(|()| {
|
|
||||||
match_ignore_ascii_case! { &try!(input.expect_ident()),
|
|
||||||
"thin" => Ok(Length::from_px(1.)),
|
|
||||||
"medium" => Ok(Length::from_px(3.)),
|
|
||||||
"thick" => Ok(Length::from_px(5.)),
|
|
||||||
_ => Err(())
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, HasViewportPercentage, PartialEq)]
|
|
||||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub enum BorderWidth {
|
|
||||||
Thin,
|
|
||||||
Medium,
|
|
||||||
Thick,
|
|
||||||
Width(Length),
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Parse for BorderWidth {
|
|
||||||
fn parse(context: &ParserContext, input: &mut Parser) -> Result<BorderWidth, ()> {
|
|
||||||
Self::parse_quirky(context, input, AllowQuirks::No)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BorderWidth {
|
|
||||||
/// Parses a border width, allowing quirks.
|
|
||||||
pub fn parse_quirky(context: &ParserContext,
|
|
||||||
input: &mut Parser,
|
|
||||||
allow_quirks: AllowQuirks)
|
|
||||||
-> Result<BorderWidth, ()> {
|
|
||||||
match input.try(|i| Length::parse_non_negative_quirky(context, i, allow_quirks)) {
|
|
||||||
Ok(length) => Ok(BorderWidth::Width(length)),
|
|
||||||
Err(_) => match_ignore_ascii_case! { &try!(input.expect_ident()),
|
|
||||||
"thin" => Ok(BorderWidth::Thin),
|
|
||||||
"medium" => Ok(BorderWidth::Medium),
|
|
||||||
"thick" => Ok(BorderWidth::Thick),
|
|
||||||
_ => Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl BorderWidth {
|
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub fn from_length(length: Length) -> Self {
|
|
||||||
BorderWidth::Width(length)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToCss for BorderWidth {
|
|
||||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
|
||||||
match *self {
|
|
||||||
BorderWidth::Thin => dest.write_str("thin"),
|
|
||||||
BorderWidth::Medium => dest.write_str("medium"),
|
|
||||||
BorderWidth::Thick => dest.write_str("thick"),
|
|
||||||
BorderWidth::Width(ref length) => length.to_css(dest)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ToComputedValue for BorderWidth {
|
|
||||||
type ComputedValue = Au;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn to_computed_value(&self, context: &Context) -> Self::ComputedValue {
|
|
||||||
// We choose the pixel length of the keyword values the same as both spec and gecko.
|
|
||||||
// Spec: https://drafts.csswg.org/css-backgrounds-3/#line-width
|
|
||||||
// Gecko: https://bugzilla.mozilla.org/show_bug.cgi?id=1312155#c0
|
|
||||||
match *self {
|
|
||||||
BorderWidth::Thin => Length::from_px(1.).to_computed_value(context),
|
|
||||||
BorderWidth::Medium => Length::from_px(3.).to_computed_value(context),
|
|
||||||
BorderWidth::Thick => Length::from_px(5.).to_computed_value(context),
|
|
||||||
BorderWidth::Width(ref length) => length.to_computed_value(context)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn from_computed_value(computed: &Self::ComputedValue) -> Self {
|
|
||||||
BorderWidth::Width(ToComputedValue::from_computed_value(computed))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
||||||
define_numbered_css_keyword_enum! { BorderStyle:
|
define_numbered_css_keyword_enum! { BorderStyle:
|
||||||
|
|
|
@ -1946,7 +1946,7 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
|
||||||
use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing;
|
use style::properties::longhands::border_spacing::SpecifiedValue as BorderSpacing;
|
||||||
use style::properties::longhands::height::SpecifiedValue as Height;
|
use style::properties::longhands::height::SpecifiedValue as Height;
|
||||||
use style::properties::longhands::width::SpecifiedValue as Width;
|
use style::properties::longhands::width::SpecifiedValue as Width;
|
||||||
use style::values::specified::BorderWidth;
|
use style::values::specified::BorderSideWidth;
|
||||||
use style::values::specified::MozLength;
|
use style::values::specified::MozLength;
|
||||||
use style::values::specified::length::{NoCalcLength, LengthOrPercentage};
|
use style::values::specified::length::{NoCalcLength, LengthOrPercentage};
|
||||||
|
|
||||||
|
@ -1956,10 +1956,10 @@ pub extern "C" fn Servo_DeclarationBlock_SetPixelValue(declarations:
|
||||||
let prop = match_wrap_declared! { long,
|
let prop = match_wrap_declared! { long,
|
||||||
Height => Height(MozLength::LengthOrPercentageOrAuto(nocalc.into())),
|
Height => Height(MozLength::LengthOrPercentageOrAuto(nocalc.into())),
|
||||||
Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())),
|
Width => Width(MozLength::LengthOrPercentageOrAuto(nocalc.into())),
|
||||||
BorderTopWidth => BorderWidth::Width(nocalc.into()),
|
BorderTopWidth => BorderSideWidth::Length(nocalc.into()),
|
||||||
BorderRightWidth => BorderWidth::Width(nocalc.into()),
|
BorderRightWidth => BorderSideWidth::Length(nocalc.into()),
|
||||||
BorderBottomWidth => BorderWidth::Width(nocalc.into()),
|
BorderBottomWidth => BorderSideWidth::Length(nocalc.into()),
|
||||||
BorderLeftWidth => BorderWidth::Width(nocalc.into()),
|
BorderLeftWidth => BorderSideWidth::Length(nocalc.into()),
|
||||||
MarginTop => nocalc.into(),
|
MarginTop => nocalc.into(),
|
||||||
MarginRight => nocalc.into(),
|
MarginRight => nocalc.into(),
|
||||||
MarginBottom => nocalc.into(),
|
MarginBottom => nocalc.into(),
|
||||||
|
|
|
@ -9,7 +9,7 @@ use style::properties::longhands::outline_color::computed_value::T as ComputedCo
|
||||||
use style::properties::parse_property_declaration_list;
|
use style::properties::parse_property_declaration_list;
|
||||||
use style::values::{RGBA, Auto};
|
use style::values::{RGBA, Auto};
|
||||||
use style::values::CustomIdent;
|
use style::values::CustomIdent;
|
||||||
use style::values::specified::{BorderStyle, BorderWidth, CSSColor, Length, LengthOrPercentage};
|
use style::values::specified::{BorderStyle, BorderSideWidth, CSSColor, Length, LengthOrPercentage};
|
||||||
use style::values::specified::{LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
|
use style::values::specified::{LengthOrPercentageOrAuto, LengthOrPercentageOrAutoOrContent};
|
||||||
use style::values::specified::{NoCalcLength, PositionComponent};
|
use style::values::specified::{NoCalcLength, PositionComponent};
|
||||||
use style::values::specified::position::Y;
|
use style::values::specified::position::Y;
|
||||||
|
@ -221,8 +221,8 @@ mod shorthand_serialization {
|
||||||
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
|
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
|
||||||
properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone()));
|
properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone()));
|
||||||
|
|
||||||
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
|
let px_30 = BorderSideWidth::Length(Length::from_px(30f32));
|
||||||
let px_10 = BorderWidth::from_length(Length::from_px(10f32));
|
let px_10 = BorderSideWidth::Length(Length::from_px(10f32));
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
|
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
|
||||||
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
|
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
|
||||||
|
@ -255,7 +255,7 @@ mod shorthand_serialization {
|
||||||
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
|
properties.push(PropertyDeclaration::BorderBottomStyle(solid.clone()));
|
||||||
properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone()));
|
properties.push(PropertyDeclaration::BorderLeftStyle(solid.clone()));
|
||||||
|
|
||||||
let px_30 = BorderWidth::from_length(Length::from_px(30f32));
|
let px_30 = BorderSideWidth::Length(Length::from_px(30f32));
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
|
properties.push(PropertyDeclaration::BorderTopWidth(px_30.clone()));
|
||||||
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
|
properties.push(PropertyDeclaration::BorderRightWidth(px_30.clone()));
|
||||||
|
@ -295,11 +295,11 @@ mod shorthand_serialization {
|
||||||
fn border_width_should_serialize_correctly() {
|
fn border_width_should_serialize_correctly() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let top_px = BorderWidth::from_length(Length::from_px(10f32));
|
let top_px = BorderSideWidth::Length(Length::from_px(10f32));
|
||||||
let bottom_px = BorderWidth::from_length(Length::from_px(10f32));
|
let bottom_px = BorderSideWidth::Length(Length::from_px(10f32));
|
||||||
|
|
||||||
let right_px = BorderWidth::from_length(Length::from_px(15f32));
|
let right_px = BorderSideWidth::Length(Length::from_px(15f32));
|
||||||
let left_px = BorderWidth::from_length(Length::from_px(15f32));
|
let left_px = BorderSideWidth::Length(Length::from_px(15f32));
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
|
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
|
||||||
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
|
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
|
||||||
|
@ -314,10 +314,10 @@ mod shorthand_serialization {
|
||||||
fn border_width_with_keywords_should_serialize_correctly() {
|
fn border_width_with_keywords_should_serialize_correctly() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let top_px = BorderWidth::Thin;
|
let top_px = BorderSideWidth::Thin;
|
||||||
let right_px = BorderWidth::Medium;
|
let right_px = BorderSideWidth::Medium;
|
||||||
let bottom_px = BorderWidth::Thick;
|
let bottom_px = BorderSideWidth::Thick;
|
||||||
let left_px = BorderWidth::from_length(Length::from_px(15f32));
|
let left_px = BorderSideWidth::Length(Length::from_px(15f32));
|
||||||
|
|
||||||
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
|
properties.push(PropertyDeclaration::BorderTopWidth(top_px));
|
||||||
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
|
properties.push(PropertyDeclaration::BorderRightWidth(right_px));
|
||||||
|
@ -403,7 +403,7 @@ mod shorthand_serialization {
|
||||||
fn directional_border_should_show_all_properties_when_values_are_set() {
|
fn directional_border_should_show_all_properties_when_values_are_set() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let width = BorderWidth::from_length(Length::from_px(4f32));
|
let width = BorderSideWidth::Length(Length::from_px(4f32));
|
||||||
let style = BorderStyle::solid;
|
let style = BorderStyle::solid;
|
||||||
let color = CSSColor {
|
let color = CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
|
@ -418,8 +418,8 @@ mod shorthand_serialization {
|
||||||
assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);");
|
assert_eq!(serialization, "border-top: 4px solid rgb(255, 0, 0);");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_border_property_values() -> (BorderWidth, BorderStyle, CSSColor) {
|
fn get_border_property_values() -> (BorderSideWidth, BorderStyle, CSSColor) {
|
||||||
(BorderWidth::from_length(Length::from_px(4f32)),
|
(BorderSideWidth::Length(Length::from_px(4f32)),
|
||||||
BorderStyle::solid,
|
BorderStyle::solid,
|
||||||
CSSColor::currentcolor())
|
CSSColor::currentcolor())
|
||||||
}
|
}
|
||||||
|
@ -523,7 +523,6 @@ mod shorthand_serialization {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod outline {
|
mod outline {
|
||||||
use style::properties::longhands::outline_width::SpecifiedValue as WidthContainer;
|
|
||||||
use style::values::Either;
|
use style::values::Either;
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
@ -531,7 +530,7 @@ mod shorthand_serialization {
|
||||||
fn outline_should_show_all_properties_when_set() {
|
fn outline_should_show_all_properties_when_set() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let width = WidthContainer(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 = CSSColor {
|
let color = CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
|
@ -550,7 +549,7 @@ mod shorthand_serialization {
|
||||||
fn outline_should_serialize_correctly_when_style_is_auto() {
|
fn outline_should_serialize_correctly_when_style_is_auto() {
|
||||||
let mut properties = Vec::new();
|
let mut properties = Vec::new();
|
||||||
|
|
||||||
let width = WidthContainer(Length::from_px(4f32));
|
let width = BorderSideWidth::Length(Length::from_px(4f32));
|
||||||
let style = Either::First(Auto);
|
let style = Either::First(Auto);
|
||||||
let color = CSSColor {
|
let color = CSSColor {
|
||||||
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
parsed: ComputedColor::RGBA(RGBA::new(255, 0, 0, 255)),
|
||||||
|
|
|
@ -4,22 +4,22 @@
|
||||||
|
|
||||||
use app_units::Au;
|
use app_units::Au;
|
||||||
use style::properties::PropertyDeclaration;
|
use style::properties::PropertyDeclaration;
|
||||||
use style::properties::longhands::border_top_width;
|
|
||||||
use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPercentageLength};
|
use style::values::specified::{AbsoluteLength, Length, NoCalcLength, ViewportPercentageLength};
|
||||||
|
use style::values::specified::border::BorderSideWidth;
|
||||||
use style_traits::HasViewportPercentage;
|
use style_traits::HasViewportPercentage;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn has_viewport_percentage_for_specified_value() {
|
fn has_viewport_percentage_for_specified_value() {
|
||||||
//TODO: test all specified value with a HasViewportPercentage impl
|
//TODO: test all specified value with a HasViewportPercentage impl
|
||||||
let pvw = PropertyDeclaration::BorderTopWidth(
|
let pvw = PropertyDeclaration::BorderTopWidth(
|
||||||
border_top_width::SpecifiedValue::from_length(
|
BorderSideWidth::Length(
|
||||||
Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
|
Length::NoCalc(NoCalcLength::ViewportPercentage(ViewportPercentageLength::Vw(100.)))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
assert!(pvw.has_viewport_percentage());
|
assert!(pvw.has_viewport_percentage());
|
||||||
|
|
||||||
let pabs = PropertyDeclaration::BorderTopWidth(
|
let pabs = PropertyDeclaration::BorderTopWidth(
|
||||||
border_top_width::SpecifiedValue::from_length(
|
BorderSideWidth::Length(
|
||||||
Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px())))
|
Length::NoCalc(NoCalcLength::Absolute(AbsoluteLength::Px(Au(100).to_f32_px())))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -45,15 +45,6 @@
|
||||||
[outline-color: invert]
|
[outline-color: invert]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[outline-width: thin]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[outline-width: medium]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[outline-width: thick]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[page-break-after: auto]
|
[page-break-after: auto]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue