Auto merge of #15839 - chenpighead:stylo-text-justify, r=upsuper

Stylo - gecko glue code for text-justify

<!-- Please describe your changes on the following line: -->

Implement gecko glue for text-justify property.

Gecko has supported text-justify in [Bug 276079](https://bugzilla.mozilla.org/show_bug.cgi?id=276079), and going to pref-on on Nightly very soon in [Bug 1343512](https://bugzilla.mozilla.org/show_bug.cgi?id=1343512). Let's make it work for stylo.

---
<!-- 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
- [ ] These changes fix #__ (github issue number if applicable).

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- 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/15839)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-09 17:57:15 -08:00 committed by GitHub
commit d124297456

View file

@ -192,18 +192,46 @@ ${helpers.single_keyword("word-break",
spec="https://drafts.csswg.org/css-text/#propdef-word-break")}
// TODO(pcwalton): Support `text-justify: distribute`.
${helpers.single_keyword("text-justify",
"auto none inter-word",
products="servo",
animatable=False,
spec="https://drafts.csswg.org/css-text/#propdef-text-justify")}
<%helpers:single_keyword_computed name="text-justify"
values="auto none inter-word"
extra_gecko_values="inter-character"
extra_specified="${'distribute' if product == 'gecko' else ''}"
gecko_enum_prefix="StyleTextJustify"
animatable="False"
spec="https://drafts.csswg.org/css-text/#propdef-text-justify">
use values::HasViewportPercentage;
no_viewport_percentage!(SpecifiedValue);
${helpers.single_keyword("text-align-last",
"auto start end left right center justify",
products="gecko",
gecko_constant_prefix="NS_STYLE_TEXT_ALIGN",
animatable=False,
spec="https://drafts.csswg.org/css-text/#propdef-text-align-last")}
impl ToComputedValue for SpecifiedValue {
type ComputedValue = computed_value::T;
#[inline]
fn to_computed_value(&self, _: &Context) -> computed_value::T {
match *self {
% for value in "auto none inter_word".split():
SpecifiedValue::${value} => computed_value::T::${value},
% endfor
% if product == "gecko":
SpecifiedValue::inter_character => computed_value::T::inter_character,
// https://drafts.csswg.org/css-text-3/#valdef-text-justify-distribute
SpecifiedValue::distribute => computed_value::T::inter_character,
% endif
}
}
#[inline]
fn from_computed_value(computed: &computed_value::T) -> SpecifiedValue {
match *computed {
% for value in "auto none inter_word".split():
computed_value::T::${value} => SpecifiedValue::${value},
% endfor
% if product == "gecko":
computed_value::T::inter_character => SpecifiedValue::inter_character,
% endif
}
}
}
</%helpers:single_keyword_computed>
// TODO make this a shorthand and implement text-align-last/text-align-all
<%helpers:longhand name="text-align" animatable="False" spec="https://drafts.csswg.org/css-text/#propdef-text-align">