servo: Merge #14358 - stylo - implement -webkit-text-fill-color and -webkit-text-stroke (from chenpighead:webkit-text-stroke); r=canaltinova

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

Implement -webkit-text-fill-color property.
Implement -webkit-text-stroke property, along with -webkit-text-stroke-width and -webkit-text-stroke-color longhand properties.

---
<!-- 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
- [x] These changes fix #13849 (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. -->

Source-Repo: https://github.com/servo/servo
Source-Revision: c4f87f451faf8eeac3e046c38ebf8b9b3dd0051e
This commit is contained in:
Jeremy Chen 2016-11-26 07:17:34 -08:00
Родитель 5eae07c4ed
Коммит ab2cea122f
3 изменённых файлов: 106 добавлений и 1 удалений

Просмотреть файл

@ -1819,7 +1819,8 @@ fn static_assert() {
<%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_align_keyword = Keyword("text-align", "start end left right center justify -moz-center -moz-left " +
"-moz-right match-parent") %>
@ -1966,6 +1967,13 @@ fn static_assert() {
self.gecko.mTextEmphasisStyle = other.gecko.mTextEmphasisStyle;
}
#[allow(non_snake_case)]
pub fn set__webkit_text_stroke_width(&mut self, v: longhands::_webkit_text_stroke_width::computed_value::T) {
self.gecko.mWebkitTextStrokeWidth.set_value(CoordDataValue::Coord(v.0));
}
<%call expr="impl_coord_copy('_webkit_text_stroke_width', 'mWebkitTextStrokeWidth')"></%call>
</%self:impl_trait>
<%self:impl_trait style_struct_name="Text"

Просмотреть файл

@ -996,6 +996,48 @@ ${helpers.predefined_type("text-emphasis-color", "CSSColor",
products="gecko",animatable=True,
complex_color=True, need_clone=True)}
// CSS Compatibility
// https://compat.spec.whatwg.org/#the-webkit-text-fill-color
${helpers.predefined_type(
"-webkit-text-fill-color", "CSSColor",
"CSSParserColor::CurrentColor",
products="gecko", animatable=True,
complex_color=True, need_clone=True)}
// CSS Compatibility
// https://compat.spec.whatwg.org/#the-webkit-text-stroke-color
${helpers.predefined_type(
"-webkit-text-stroke-color", "CSSColor",
"CSSParserColor::CurrentColor",
products="gecko", animatable=True,
complex_color=True, need_clone=True)}
// CSS Compatibility
// https://compat.spec.whatwg.org/#the-webkit-text-stroke-width
<%helpers:longhand products="gecko" name="-webkit-text-stroke-width" animatable="False">
use app_units::Au;
use std::fmt;
use style_traits::ToCss;
use values::HasViewportPercentage;
use values::specified::BorderWidth;
pub type SpecifiedValue = BorderWidth;
#[inline]
pub fn parse(_context: &ParserContext, input: &mut Parser)
-> Result<SpecifiedValue, ()> {
BorderWidth::parse(input)
}
pub mod computed_value {
use app_units::Au;
pub type T = Au;
}
#[inline] pub fn get_initial_value() -> computed_value::T {
Au::from_px(0)
}
</%helpers:longhand>
// TODO(pcwalton): `full-width`
${helpers.single_keyword("text-transform",
"none capitalize uppercase lowercase",

Просмотреть файл

@ -78,3 +78,58 @@
}
}
</%helpers:shorthand>
// CSS Compatibility
// https://compat.spec.whatwg.org/#the-webkit-text-stroke
<%helpers:shorthand name="-webkit-text-stroke"
sub_properties="-webkit-text-stroke-color
-webkit-text-stroke-width"
products="gecko">
use cssparser::Color as CSSParserColor;
use properties::longhands::{_webkit_text_stroke_color, _webkit_text_stroke_width};
use values::specified::CSSColor;
pub fn parse_value(context: &ParserContext, input: &mut Parser) -> Result<Longhands, ()> {
use values::specified::{BorderWidth, Length};
use app_units::Au;
let (mut color, mut width, mut any) = (None, None, false);
% for value in "color width".split():
if ${value}.is_none() {
if let Ok(value) = input.try(|input| _webkit_text_stroke_${value}::parse(context, input)) {
${value} = Some(value);
any = true;
}
}
% endfor
if !any {
return Err(());
}
Ok(Longhands {
_webkit_text_stroke_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
authored: None })),
_webkit_text_stroke_width: width.or(Some(BorderWidth::from_length(Length::Absolute(Au::from_px(0))))),
})
}
impl<'a> LonghandsToSerialize<'a> {
fn to_css_declared<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
let mut style_present = false;
if let DeclaredValue::Value(ref width) = *self._webkit_text_stroke_width {
style_present = true;
try!(width.to_css(dest));
}
if let DeclaredValue::Value(ref color) = *self._webkit_text_stroke_color {
if style_present {
try!(write!(dest, " "));
}
try!(color.to_css(dest));
}
Ok(())
}
}
</%helpers:shorthand>