Auto merge of #17253 - dadaa:bug1368610, r=hiikezoe,nox,emilio

Bug1368610 - stylo: implement primitive (bit, uXX) type of discrete animatable properties

<!-- Please describe your changes on the following line: -->
This PR is to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1368610

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors

<!-- Either: -->
- [X] There are tests for these changes. The tests will land in dom/animation/test of m-c. Test code is patch 6 of https://bugzilla.mozilla.org/show_bug.cgi?id=1368610

<!-- 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/17253)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-09 10:01:35 -07:00 committed by GitHub
commit 88b47b0154
12 changed files with 326 additions and 211 deletions

View file

@ -18,18 +18,20 @@ ${helpers.predefined_type("line-height",
${helpers.single_keyword("text-transform",
"none capitalize uppercase lowercase",
extra_gecko_values="full-width",
animation_value_type="none",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-text-transform")}
${helpers.single_keyword("hyphens", "manual none auto",
gecko_enum_prefix="StyleHyphens",
products="gecko", animation_value_type="none", extra_prefixes="moz",
gecko_inexhaustive=True,
products="gecko", animation_value_type="discrete", extra_prefixes="moz",
spec="https://drafts.csswg.org/css-text/#propdef-hyphens")}
// TODO: Support <percentage>
${helpers.single_keyword("-moz-text-size-adjust", "auto none",
gecko_constant_prefix="NS_STYLE_TEXT_SIZE_ADJUST",
products="gecko", animation_value_type="none",
gecko_ffi_name="mTextSizeAdjust",
products="gecko", animation_value_type="discrete",
spec="https://drafts.csswg.org/css-size-adjust/#adjustment-control",
alias="-webkit-text-size-adjust")}
@ -45,7 +47,7 @@ ${helpers.predefined_type("text-indent",
${helpers.single_keyword("overflow-wrap",
"normal break-word",
gecko_constant_prefix="NS_STYLE_OVERFLOWWRAP",
animation_value_type="none",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-overflow-wrap",
alias="word-wrap")}
@ -53,7 +55,7 @@ ${helpers.single_keyword("overflow-wrap",
${helpers.single_keyword("word-break",
"normal break-all keep-all",
gecko_constant_prefix="NS_STYLE_WORDBREAK",
animation_value_type="none",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-word-break")}
// TODO(pcwalton): Support `text-justify: distribute`.
@ -62,7 +64,8 @@ ${helpers.single_keyword("word-break",
extra_gecko_values="inter-character"
extra_specified="${'distribute' if product == 'gecko' else ''}"
gecko_enum_prefix="StyleTextJustify"
animation_value_type="none"
gecko_inexhaustive="True"
animation_value_type="discrete"
spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
no_viewport_percentage!(SpecifiedValue);
@ -101,11 +104,11 @@ ${helpers.single_keyword("text-align-last",
"auto start end left right center justify",
products="gecko",
gecko_constant_prefix="NS_STYLE_TEXT_ALIGN",
animation_value_type="none",
animation_value_type="discrete",
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last")}
// TODO make this a shorthand and implement text-align-last/text-align-all
<%helpers:longhand name="text-align" animation_value_type="none" need_clone="True"
<%helpers:longhand name="text-align" animation_value_type="discrete"
spec="https://drafts.csswg.org/css-text/#propdef-text-align">
no_viewport_percentage!(SpecifiedValue);
pub mod computed_value {
@ -360,7 +363,8 @@ ${helpers.predefined_type("word-spacing",
extra_gecko_values="-moz-pre-space"
gecko_enum_prefix="StyleWhiteSpace"
needs_conversion="True"
animation_value_type="none"
gecko_inexhaustive="True"
animation_value_type="discrete"
spec="https://drafts.csswg.org/css-text/#propdef-white-space">
use values::computed::ComputedValueAsSpecified;
impl ComputedValueAsSpecified for SpecifiedValue {}
@ -605,7 +609,7 @@ ${helpers.predefined_type("word-spacing",
}
</%helpers:longhand>
<%helpers:longhand name="text-emphasis-position" animation_value_type="none" products="gecko"
<%helpers:longhand name="text-emphasis-position" animation_value_type="discrete" products="gecko"
spec="https://drafts.csswg.org/css-text-decor/#propdef-text-emphasis-position">
use values::computed::ComputedValueAsSpecified;
use style_traits::ToCss;
@ -663,6 +667,32 @@ ${helpers.predefined_type("word-spacing",
SpecifiedValue(horiz, vert)
}
}
impl From<u8> for SpecifiedValue {
fn from(bits: u8) -> SpecifiedValue {
SpecifiedValue::from_gecko_keyword(bits as u32)
}
}
impl From<SpecifiedValue> for u8 {
fn from(v: SpecifiedValue) -> u8 {
use gecko_bindings::structs;
let mut result = match v.0 {
HorizontalWritingModeValue::Over => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_OVER,
HorizontalWritingModeValue::Under => structs::NS_STYLE_TEXT_EMPHASIS_POSITION_UNDER,
};
match v.1 {
VerticalWritingModeValue::Right => {
result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_RIGHT;
}
VerticalWritingModeValue::Left => {
result |= structs::NS_STYLE_TEXT_EMPHASIS_POSITION_LEFT;
}
};
result as u8
}
}
% endif
</%helpers:longhand>