mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: simplify -servo-text-decorations-in-effect.
It's stupid. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
2c88248b87
commit
15a76b01c1
2 changed files with 34 additions and 51 deletions
|
@ -2230,13 +2230,10 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
|
||||
// Create display items for text decorations.
|
||||
let mut text_decorations = self.style()
|
||||
let text_decorations =
|
||||
self.style()
|
||||
.get_inheritedtext()
|
||||
._servo_text_decorations_in_effect;
|
||||
// Note that the text decoration colors are always the same as the text color.
|
||||
text_decorations.underline = text_decorations.underline.map(|_| text_color);
|
||||
text_decorations.overline = text_decorations.overline.map(|_| text_color);
|
||||
text_decorations.line_through = text_decorations.line_through.map(|_| text_color);
|
||||
|
||||
let stacking_relative_content_box =
|
||||
LogicalRect::from_physical(self.style.writing_mode,
|
||||
|
@ -2244,25 +2241,29 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
container_size);
|
||||
|
||||
// Underline
|
||||
if let Some(ref underline_color) = text_decorations.underline {
|
||||
if text_decorations.underline {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.start.b = stacking_relative_content_box.start.b +
|
||||
metrics.ascent - metrics.underline_offset;
|
||||
stacking_relative_box.size.block = metrics.underline_size;
|
||||
self.build_display_list_for_text_decoration(state,
|
||||
underline_color,
|
||||
self.build_display_list_for_text_decoration(
|
||||
state,
|
||||
&text_color,
|
||||
&stacking_relative_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
}
|
||||
|
||||
// Overline
|
||||
if let Some(ref overline_color) = text_decorations.overline {
|
||||
if text_decorations.overline {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.size.block = metrics.underline_size;
|
||||
self.build_display_list_for_text_decoration(state,
|
||||
overline_color,
|
||||
self.build_display_list_for_text_decoration(
|
||||
state,
|
||||
&text_color,
|
||||
&stacking_relative_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
}
|
||||
|
||||
// Text
|
||||
|
@ -2281,15 +2282,17 @@ impl FragmentDisplayListBuilding for Fragment {
|
|||
|
||||
|
||||
// Line-Through
|
||||
if let Some(ref line_through_color) = text_decorations.line_through {
|
||||
if text_decorations.line_through {
|
||||
let mut stacking_relative_box = stacking_relative_content_box;
|
||||
stacking_relative_box.start.b = stacking_relative_box.start.b + metrics.ascent -
|
||||
metrics.strikeout_offset;
|
||||
stacking_relative_box.size.block = metrics.strikeout_size;
|
||||
self.build_display_list_for_text_decoration(state,
|
||||
line_through_color,
|
||||
self.build_display_list_for_text_decoration(
|
||||
state,
|
||||
&text_color,
|
||||
&stacking_relative_box,
|
||||
clip);
|
||||
clip,
|
||||
);
|
||||
}
|
||||
|
||||
// Pair all the PushTextShadows
|
||||
|
|
|
@ -282,17 +282,16 @@ ${helpers.predefined_type("word-spacing",
|
|||
need_clone="True" products="servo"
|
||||
animation_value_type="none"
|
||||
spec="Nonstandard (Internal property used by Servo)">
|
||||
use cssparser::RGBA;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[cfg_attr(feature = "gecko", derive(MallocSizeOf))]
|
||||
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
|
||||
pub struct SpecifiedValue {
|
||||
pub underline: Option<RGBA>,
|
||||
pub overline: Option<RGBA>,
|
||||
pub line_through: Option<RGBA>,
|
||||
pub underline: bool,
|
||||
pub overline: bool,
|
||||
pub line_through: bool,
|
||||
}
|
||||
|
||||
trivial_to_computed_value!(SpecifiedValue);
|
||||
|
@ -310,19 +309,7 @@ ${helpers.predefined_type("word-spacing",
|
|||
|
||||
#[inline]
|
||||
pub fn get_initial_value() -> computed_value::T {
|
||||
SpecifiedValue {
|
||||
underline: None,
|
||||
overline: None,
|
||||
line_through: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn maybe(flag: bool, context: &Context) -> Option<RGBA> {
|
||||
if flag {
|
||||
Some(context.style().get_color().clone_color())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
SpecifiedValue::default()
|
||||
}
|
||||
|
||||
fn derive(context: &Context) -> computed_value::T {
|
||||
|
@ -330,20 +317,13 @@ ${helpers.predefined_type("word-spacing",
|
|||
// declarations in effect and add in the text decorations that this block specifies.
|
||||
let mut result = match context.style().get_box().clone_display() {
|
||||
super::display::computed_value::T::inline_block |
|
||||
super::display::computed_value::T::inline_table => SpecifiedValue {
|
||||
underline: None,
|
||||
overline: None,
|
||||
line_through: None,
|
||||
},
|
||||
super::display::computed_value::T::inline_table => get_initial_value(),
|
||||
_ => context.builder.get_parent_inheritedtext().clone__servo_text_decorations_in_effect()
|
||||
};
|
||||
|
||||
result.underline = maybe(context.style().get_text().has_underline()
|
||||
|| result.underline.is_some(), context);
|
||||
result.overline = maybe(context.style().get_text().has_overline()
|
||||
|| result.overline.is_some(), context);
|
||||
result.line_through = maybe(context.style().get_text().has_line_through()
|
||||
|| result.line_through.is_some(), context);
|
||||
result.underline |= context.style().get_text().has_underline();
|
||||
result.overline |= context.style().get_text().has_overline();
|
||||
result.line_through |= context.style().get_text().has_line_through();
|
||||
|
||||
result
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue