stylo: Implement tab-size

MozReview-Commit-ID: DNmtu1hm8u1
This commit is contained in:
Manish Goregaokar 2017-02-06 16:03:13 -08:00 committed by Manish Goregaokar
parent 30deaab48a
commit 7e4f788172
4 changed files with 29 additions and 4 deletions

View file

@ -2204,7 +2204,7 @@ fn static_assert() {
<%self:impl_trait style_struct_name="InheritedText" <%self:impl_trait style_struct_name="InheritedText"
skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing skip_longhands="text-align text-emphasis-style text-shadow line-height letter-spacing word-spacing
-webkit-text-stroke-width text-emphasis-position"> -webkit-text-stroke-width text-emphasis-position -moz-tab-size">
<% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " + <% text_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " +
"-moz-right match-parent") %> "-moz-right match-parent") %>
@ -2373,6 +2373,22 @@ fn static_assert() {
<%call expr="impl_app_units('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth', need_clone=False)"></%call> <%call expr="impl_app_units('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth', need_clone=False)"></%call>
#[allow(non_snake_case)]
pub fn set__moz_tab_size(&mut self, v: longhands::_moz_tab_size::computed_value::T) {
use values::Either;
match v {
Either::Second(number) => {
self.gecko.mTabSize.set_value(CoordDataValue::Factor(number));
}
Either::First(au) => {
self.gecko.mTabSize.set(au);
}
}
}
<%call expr="impl_coord_copy('_moz_tab_size', 'mTabSize')"></%call>
</%self:impl_trait> </%self:impl_trait>
<%self:impl_trait style_struct_name="Text" <%self:impl_trait style_struct_name="Text"

View file

@ -257,10 +257,10 @@ ${helpers.single_keyword("-moz-float-edge", "content-box margin-box",
} }
} }
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> { pub fn parse(context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
let mut values = vec![]; let mut values = vec![];
for _ in 0..4 { for _ in 0..4 {
let value = input.try(|input| LengthOrNumber::parse_non_negative(input)); let value = input.try(|input| LengthOrNumber::parse_non_negative(context, input));
match value { match value {
Ok(val) => values.push(val), Ok(val) => values.push(val),
Err(_) => break, Err(_) => break,

View file

@ -1030,6 +1030,15 @@ ${helpers.predefined_type("text-emphasis-color", "CSSColor",
boxed=True, boxed=True,
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color")} spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-color")}
${helpers.predefined_type(
"-moz-tab-size", "LengthOrNumber",
"::values::Either::Second(8.0)",
"parse_non_negative",
products="gecko", animatable=False,
spec="https://drafts.csswg.org/css-text-3/#tab-size-property")}
// CSS Compatibility // CSS Compatibility
// https://compat.spec.whatwg.org // https://compat.spec.whatwg.org
${helpers.predefined_type( ${helpers.predefined_type(

View file

@ -1215,7 +1215,7 @@ pub type LengthOrNumber = Either<Length, Number>;
impl LengthOrNumber { impl LengthOrNumber {
/// Parse a non-negative LengthOrNumber. /// Parse a non-negative LengthOrNumber.
pub fn parse_non_negative(input: &mut Parser) -> Result<Self, ()> { pub fn parse_non_negative(_context: &ParserContext, input: &mut Parser) -> Result<Self, ()> {
// We try to parse as a Number first because, for cases like LengthOrNumber, // We try to parse as a Number first because, for cases like LengthOrNumber,
// we want "0" to be parsed as a plain Number rather than a Length (0px); this // we want "0" to be parsed as a plain Number rather than a Length (0px); this
// matches the behaviour of all major browsers // matches the behaviour of all major browsers