зеркало из https://github.com/mozilla/gecko-dev.git
servo: Merge #19548 - style: Move outline-style outside of mako (from CYBAI:move-outline-style-out-of-mako); r=emilio
This is a sub-PR of #19015 r? emilio --- - [x] `./mach build -d` does not report any errors - [x] `./mach test-tidy` does not report any errors - [x] These changes fix #19546 - [x] These changes do not require tests Source-Repo: https://github.com/servo/servo Source-Revision: 714c1b2455bc6f651e982b5efec85e3bf711f708 --HG-- extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear extra : subtree_revision : c435362b7e4d8abcae2548a7bfd07e7e77328e8a
This commit is contained in:
Родитель
3257faa639
Коммит
1fe45bc205
|
@ -1700,7 +1700,7 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
style: &ComputedValues,
|
||||
bounds: &Rect<Au>,
|
||||
clip: &Rect<Au>) {
|
||||
use style::values::Either;
|
||||
use style::values::specified::outline::OutlineStyle;
|
||||
|
||||
let width = Au::from(style.get_outline().outline_width);
|
||||
if width == Au(0) {
|
||||
|
@ -1708,9 +1708,9 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
}
|
||||
|
||||
let outline_style = match style.get_outline().outline_style {
|
||||
Either::First(_auto) => BorderStyle::Solid,
|
||||
Either::Second(BorderStyle::None) => return,
|
||||
Either::Second(border_style) => border_style
|
||||
OutlineStyle::Auto => BorderStyle::Solid,
|
||||
OutlineStyle::Other(BorderStyle::None) => return,
|
||||
OutlineStyle::Other(border_style) => border_style
|
||||
};
|
||||
|
||||
// Outlines are not accounted for in the dimensions of the border box, so adjust the
|
||||
|
|
|
@ -61,6 +61,7 @@ use values::{self, Auto, CustomIdent, Either, KeyframesName, None_};
|
|||
use values::computed::{NonNegativeLength, ToComputedValue, Percentage};
|
||||
use values::computed::font::{FontSize, SingleFontFamily};
|
||||
use values::computed::effects::{BoxShadow, Filter, SimpleShadow};
|
||||
use values::computed::outline::OutlineStyle;
|
||||
use computed_values::border_style;
|
||||
|
||||
pub mod style_structs {
|
||||
|
@ -2348,10 +2349,10 @@ fn static_assert() {
|
|||
// cast + static_asserts
|
||||
let result = match v {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
Either::Second(border_style::T::${to_camel_case(value)}) =>
|
||||
OutlineStyle::Other(border_style::T::${to_camel_case(value)}) =>
|
||||
structs::${border_style_keyword.gecko_constant(value)} ${border_style_keyword.maybe_cast("u8")},
|
||||
% endfor
|
||||
Either::First(Auto) =>
|
||||
OutlineStyle::Auto =>
|
||||
structs::${border_style_keyword.gecko_constant('auto')} ${border_style_keyword.maybe_cast("u8")},
|
||||
};
|
||||
${set_gecko_property("mOutlineStyle", "result")}
|
||||
|
@ -2378,10 +2379,10 @@ fn static_assert() {
|
|||
match ${get_gecko_property("mOutlineStyle")} ${border_style_keyword.maybe_cast("u32")} {
|
||||
% for value in border_style_keyword.values_for('gecko'):
|
||||
structs::${border_style_keyword.gecko_constant(value)} => {
|
||||
Either::Second(border_style::T::${to_camel_case(value)})
|
||||
OutlineStyle::Other(border_style::T::${to_camel_case(value)})
|
||||
},
|
||||
% endfor
|
||||
structs::${border_style_keyword.gecko_constant('auto')} => Either::First(Auto),
|
||||
structs::${border_style_keyword.gecko_constant('auto')} => OutlineStyle::Auto,
|
||||
% if border_style_keyword.gecko_inexhaustive:
|
||||
x => panic!("Found unexpected value in style struct for outline_style property: {:?}", x),
|
||||
% endif
|
||||
|
|
|
@ -20,51 +20,14 @@ ${helpers.predefined_type(
|
|||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-color",
|
||||
)}
|
||||
|
||||
<%helpers:longhand name="outline-style" animation_value_type="discrete"
|
||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style">
|
||||
use values::specified::BorderStyle;
|
||||
|
||||
pub type SpecifiedValue = Either<Auto, BorderStyle>;
|
||||
|
||||
impl SpecifiedValue {
|
||||
#[inline]
|
||||
pub fn none_or_hidden(&self) -> bool {
|
||||
match *self {
|
||||
Either::First(ref _auto) => false,
|
||||
Either::Second(ref border_style) => border_style.none_or_hidden()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
Either::Second(BorderStyle::None)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_initial_specified_value() -> SpecifiedValue {
|
||||
Either::Second(BorderStyle::None)
|
||||
}
|
||||
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
}
|
||||
|
||||
pub fn parse<'i, 't>(context: &ParserContext, input: &mut Parser<'i, 't>)
|
||||
-> Result<SpecifiedValue, ParseError<'i>> {
|
||||
SpecifiedValue::parse(context, input)
|
||||
.and_then(|result| {
|
||||
if let Either::Second(BorderStyle::Hidden) = result {
|
||||
// The outline-style property accepts the same values as
|
||||
// border-style, except that 'hidden' is not a legal outline
|
||||
// style.
|
||||
Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())))
|
||||
} else {
|
||||
Ok(result)
|
||||
}
|
||||
})
|
||||
}
|
||||
</%helpers:longhand>
|
||||
${helpers.predefined_type(
|
||||
"outline-style",
|
||||
"OutlineStyle",
|
||||
"computed::OutlineStyle::none()",
|
||||
initial_specified_value="specified::OutlineStyle::none()",
|
||||
animation_value_type="discrete",
|
||||
spec="https://drafts.csswg.org/css-ui/#propdef-outline-style",
|
||||
)}
|
||||
|
||||
${helpers.predefined_type("outline-width",
|
||||
"BorderSideWidth",
|
||||
|
|
|
@ -54,6 +54,7 @@ pub use super::specified::{BorderStyle, TextDecorationLine};
|
|||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNumber, LengthOrPercentage};
|
||||
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
|
||||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDashArray, SVGWidth};
|
||||
|
@ -79,6 +80,7 @@ pub mod image;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub mod gecko;
|
||||
pub mod length;
|
||||
pub mod outline;
|
||||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Computed values for outline properties
|
||||
|
||||
pub use values::specified::OutlineStyle;
|
|
@ -49,6 +49,7 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
|||
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{NoCalcLength, ViewportPercentageLength};
|
||||
pub use self::length::NonNegativeLengthOrPercentage;
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::rect::LengthOrNumberRect;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::{Position, PositionComponent, GridAutoFlow, GridTemplateAreas};
|
||||
|
@ -78,6 +79,7 @@ pub mod gecko;
|
|||
pub mod grid;
|
||||
pub mod image;
|
||||
pub mod length;
|
||||
pub mod outline;
|
||||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Specified values for outline properties
|
||||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use style_traits::ParseError;
|
||||
use values::specified::BorderStyle;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord)]
|
||||
#[derive(PartialEq, PartialOrd, ToComputedValue, ToCss)]
|
||||
/// <https://drafts.csswg.org/css-ui/#propdef-outline-style>
|
||||
pub enum OutlineStyle {
|
||||
/// auto
|
||||
Auto,
|
||||
/// <border-style>
|
||||
Other(BorderStyle),
|
||||
}
|
||||
|
||||
impl OutlineStyle {
|
||||
#[inline]
|
||||
/// Get default value as None
|
||||
pub fn none() -> OutlineStyle {
|
||||
OutlineStyle::Other(BorderStyle::None)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Get value for None or Hidden
|
||||
pub fn none_or_hidden(&self) -> bool {
|
||||
match *self {
|
||||
OutlineStyle::Auto => false,
|
||||
OutlineStyle::Other(ref border_style) => border_style.none_or_hidden()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for OutlineStyle {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<OutlineStyle, ParseError<'i>> {
|
||||
if let Ok(border_style) = input.try(|i| BorderStyle::parse(context, i)) {
|
||||
if let BorderStyle::Hidden = border_style {
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())));
|
||||
}
|
||||
|
||||
return Ok(OutlineStyle::Other(border_style));
|
||||
}
|
||||
|
||||
input.expect_ident_matching("auto")?;
|
||||
Ok(OutlineStyle::Auto)
|
||||
}
|
||||
}
|
|
@ -511,7 +511,7 @@ mod shorthand_serialization {
|
|||
}
|
||||
|
||||
mod outline {
|
||||
use style::values::Either;
|
||||
use style::values::specified::outline::OutlineStyle;
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
|
@ -519,7 +519,7 @@ mod shorthand_serialization {
|
|||
let mut properties = Vec::new();
|
||||
|
||||
let width = BorderSideWidth::Length(Length::from_px(4f32));
|
||||
let style = Either::Second(BorderStyle::Solid);
|
||||
let style = OutlineStyle::Other(BorderStyle::Solid);
|
||||
let color = RGBA::new(255, 0, 0, 255).into();
|
||||
|
||||
properties.push(PropertyDeclaration::OutlineWidth(width));
|
||||
|
@ -535,7 +535,7 @@ mod shorthand_serialization {
|
|||
let mut properties = Vec::new();
|
||||
|
||||
let width = BorderSideWidth::Length(Length::from_px(4f32));
|
||||
let style = Either::First(Auto);
|
||||
let style = OutlineStyle::Auto;
|
||||
let color = RGBA::new(255, 0, 0, 255).into();
|
||||
properties.push(PropertyDeclaration::OutlineWidth(width));
|
||||
properties.push(PropertyDeclaration::OutlineStyle(style));
|
||||
|
|
Загрузка…
Ссылка в новой задаче