mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #14188 - AgostonSzepessy:text-emphasis-position, r=SimonSapin
Added parsing/serialization for text-emphasis-position Implemented parsing/serialization for text-emphasis-position - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #13850 - [X] There are tests for these changes <!-- 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/14188) <!-- Reviewable:end -->
This commit is contained in:
commit
00f229d615
2 changed files with 80 additions and 0 deletions
|
@ -936,6 +936,55 @@ ${helpers.single_keyword("text-align-last",
|
|||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
<%helpers:longhand name="text-emphasis-position" animatable="False" products="none">
|
||||
use std::fmt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
use values::NoViewportPercentage;
|
||||
use style_traits::ToCss;
|
||||
|
||||
define_css_keyword_enum!(HorizontalWritingModeValue:
|
||||
"over" => Over,
|
||||
"under" => Under);
|
||||
define_css_keyword_enum!(VerticalWritingModeValue:
|
||||
"right" => Right,
|
||||
"left" => Left);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue(pub HorizontalWritingModeValue, pub VerticalWritingModeValue);
|
||||
|
||||
pub mod computed_value {
|
||||
pub type T = super::SpecifiedValue;
|
||||
}
|
||||
|
||||
impl ComputedValueAsSpecified for SpecifiedValue {}
|
||||
impl NoViewportPercentage for SpecifiedValue {}
|
||||
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
SpecifiedValue(HorizontalWritingModeValue::Over, VerticalWritingModeValue::Right)
|
||||
}
|
||||
|
||||
pub fn parse(_context: &ParserContext, input: &mut Parser) -> Result<SpecifiedValue, ()> {
|
||||
if let Ok(horizontal) = input.try(|input| HorizontalWritingModeValue::parse(input)) {
|
||||
let vertical = try!(VerticalWritingModeValue::parse(input));
|
||||
Ok(SpecifiedValue(horizontal, vertical))
|
||||
} else {
|
||||
let vertical = try!(VerticalWritingModeValue::parse(input));
|
||||
let horizontal = try!(HorizontalWritingModeValue::parse(input));
|
||||
Ok(SpecifiedValue(horizontal, vertical))
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for SpecifiedValue {
|
||||
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
|
||||
let SpecifiedValue(horizontal, vertical) = *self;
|
||||
try!(horizontal.to_css(dest));
|
||||
try!(dest.write_char(' '));
|
||||
vertical.to_css(dest)
|
||||
}
|
||||
}
|
||||
</%helpers:longhand>
|
||||
|
||||
// TODO(pcwalton): `full-width`
|
||||
${helpers.single_keyword("text-transform",
|
||||
"none capitalize uppercase lowercase",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue