mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Support text-decoration-line and the text-decoration shorthand in geckolib.
This commit is contained in:
parent
53a9defa9f
commit
0580e1854e
4 changed files with 74 additions and 9 deletions
|
@ -16,7 +16,8 @@ ${helpers.single_keyword("text-overflow", "clip ellipsis")}
|
|||
|
||||
${helpers.single_keyword("unicode-bidi", "normal embed isolate bidi-override isolate-override plaintext")}
|
||||
|
||||
<%helpers:longhand name="text-decoration" custom_cascade="${product == 'servo'}">
|
||||
<%helpers:longhand name="${'text-decoration' if product == 'servo' else 'text-decoration-line'}"
|
||||
custom_cascade="${product == 'servo'}">
|
||||
use cssparser::ToCss;
|
||||
use std::fmt;
|
||||
use values::computed::ComputedValueAsSpecified;
|
||||
|
|
|
@ -130,6 +130,7 @@ pub mod shorthands {
|
|||
<%include file="/shorthand/margin.mako.rs" />
|
||||
<%include file="/shorthand/outline.mako.rs" />
|
||||
<%include file="/shorthand/padding.mako.rs" />
|
||||
<%include file="/shorthand/text.mako.rs" />
|
||||
}
|
||||
|
||||
|
||||
|
@ -815,14 +816,15 @@ pub mod style_structs {
|
|||
self.outline_width != ::app_units::Au(0)
|
||||
}
|
||||
% elif style_struct.trait_name == "Text":
|
||||
<% text_decoration_field = 'text_decoration' if product == 'servo' else 'text_decoration_line' %>
|
||||
fn has_underline(&self) -> bool {
|
||||
self.text_decoration.underline
|
||||
self.${text_decoration_field}.underline
|
||||
}
|
||||
fn has_overline(&self) -> bool {
|
||||
self.text_decoration.overline
|
||||
self.${text_decoration_field}.overline
|
||||
}
|
||||
fn has_line_through(&self) -> bool {
|
||||
self.text_decoration.line_through
|
||||
self.${text_decoration_field}.line_through
|
||||
}
|
||||
% endif
|
||||
}
|
||||
|
@ -1463,7 +1465,7 @@ pub fn cascade<C: ComputedValues>(
|
|||
PropertyDeclaration::Color(_) |
|
||||
PropertyDeclaration::Position(_) |
|
||||
PropertyDeclaration::Float(_) |
|
||||
PropertyDeclaration::TextDecoration(_)
|
||||
PropertyDeclaration::TextDecoration${'' if product == 'servo' else 'Line'}(_)
|
||||
);
|
||||
if
|
||||
% if category_to_cascade_now == "early":
|
||||
|
|
46
components/style/properties/shorthand/text.mako.rs
Normal file
46
components/style/properties/shorthand/text.mako.rs
Normal file
|
@ -0,0 +1,46 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
<%namespace name="helpers" file="/helpers.mako.rs" />
|
||||
|
||||
<%helpers:shorthand name="text-decoration"
|
||||
sub_properties="text-decoration-color
|
||||
text-decoration-line
|
||||
text-decoration-style"
|
||||
products="gecko">
|
||||
use cssparser::Color as CSSParserColor;
|
||||
use properties::longhands::{text_decoration_color, text_decoration_line, text_decoration_style};
|
||||
use values::specified::CSSColor;
|
||||
|
||||
let (mut color, mut line, mut style, mut any) = (None, None, None, false);
|
||||
loop {
|
||||
macro_rules! parse_component {
|
||||
($value:ident, $module:ident) => (
|
||||
if $value.is_none() {
|
||||
if let Ok(value) = input.try(|input| $module::parse(context, input)) {
|
||||
$value = Some(value);
|
||||
any = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
parse_component!(color, text_decoration_color);
|
||||
parse_component!(line, text_decoration_line);
|
||||
parse_component!(style, text_decoration_style);
|
||||
break;
|
||||
}
|
||||
|
||||
if !any {
|
||||
return Err(());
|
||||
}
|
||||
|
||||
Ok(Longhands {
|
||||
text_decoration_color: color.or(Some(CSSColor { parsed: CSSParserColor::CurrentColor,
|
||||
authored: None })),
|
||||
text_decoration_line: line.or(Some(text_decoration_line::computed_value::none)),
|
||||
text_decoration_style: style.or(Some(text_decoration_style::computed_value::T::solid)),
|
||||
})
|
||||
</%helpers:shorthand>
|
|
@ -727,20 +727,36 @@ fn static_assert() {
|
|||
</%self:impl_trait>
|
||||
|
||||
<%self:impl_trait style_struct_name="Text"
|
||||
skip_longhands="text-decoration-color"
|
||||
skip_longhands="text-decoration-color text-decoration-line"
|
||||
skip_additionals="*">
|
||||
|
||||
<% impl_color("text_decoration_color", "mTextDecorationColor",
|
||||
color_flags_ffi_name="mTextDecorationStyle") %>
|
||||
|
||||
fn set_text_decoration_line(&mut self, v: longhands::text_decoration_line::computed_value::T) {
|
||||
let mut bits: u8 = 0;
|
||||
if v.underline {
|
||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8;
|
||||
}
|
||||
if v.overline {
|
||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8;
|
||||
}
|
||||
if v.line_through {
|
||||
bits |= structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8;
|
||||
}
|
||||
self.gecko.mTextDecorationLine = bits;
|
||||
}
|
||||
|
||||
<%call expr="impl_simple_copy('text_decoration_line', 'mTextDecorationLine')"></%call>
|
||||
|
||||
fn has_underline(&self) -> bool {
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0
|
||||
(self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_UNDERLINE as u8)) != 0
|
||||
}
|
||||
fn has_overline(&self) -> bool {
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0
|
||||
(self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_OVERLINE as u8)) != 0
|
||||
}
|
||||
fn has_line_through(&self) -> bool {
|
||||
(self.gecko.mTextDecorationStyle & (structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0
|
||||
(self.gecko.mTextDecorationLine & (structs::NS_STYLE_TEXT_DECORATION_LINE_LINE_THROUGH as u8)) != 0
|
||||
}
|
||||
</%self:impl_trait>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue