mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #19757 - emilio:bye-custom-cascade, r=nox
style: Remove -servo-text-decorations-in-effect It is bogus, because it depends on the display property as it's cascaded, but the display property can change afterwards, for example, if we get blockified because we're the root element or a flex item. Replace it with a normal field instead. Also, it carries some weight, because it's the last property that uses this concept of "derived" property, and "custom cascade". So we can remove some code after this. Compute it after the cascade process in StyleAdjuster. <!-- 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/19757) <!-- Reviewable:end -->
This commit is contained in:
commit
f2036e7661
12 changed files with 176 additions and 226 deletions
|
@ -4,6 +4,8 @@
|
|||
|
||||
//! Computed types for text properties.
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
use properties::StyleBuilder;
|
||||
use std::fmt;
|
||||
use style_traits::ToCss;
|
||||
use values::{CSSInteger, CSSFloat};
|
||||
|
@ -103,3 +105,45 @@ impl ToCss for TextDecorationLine {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// A struct that represents the _used_ value of the text-decoration property.
|
||||
///
|
||||
/// FIXME(emilio): This is done at style resolution time, though probably should
|
||||
/// be done at layout time, otherwise we need to account for display: contents
|
||||
/// and similar stuff when we implement it.
|
||||
///
|
||||
/// FIXME(emilio): Also, should be just a bitfield instead of three bytes.
|
||||
#[derive(Clone, Copy, Debug, Default, MallocSizeOf, PartialEq)]
|
||||
pub struct TextDecorationsInEffect {
|
||||
/// Whether an underline is in effect.
|
||||
pub underline: bool,
|
||||
/// Whether an overline decoration is in effect.
|
||||
pub overline: bool,
|
||||
/// Whether a line-through style is in effect.
|
||||
pub line_through: bool,
|
||||
}
|
||||
|
||||
impl TextDecorationsInEffect {
|
||||
/// Computes the text-decorations in effect for a given style.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn from_style(style: &StyleBuilder) -> Self {
|
||||
use values::computed::Display;
|
||||
|
||||
// Start with no declarations if this is an atomic inline-level box;
|
||||
// otherwise, start with the declarations in effect and add in the text
|
||||
// decorations that this block specifies.
|
||||
let mut result = match style.get_box().clone_display() {
|
||||
Display::InlineBlock |
|
||||
Display::InlineTable => Self::default(),
|
||||
_ => style.get_parent_inheritedtext().text_decorations_in_effect.clone(),
|
||||
};
|
||||
|
||||
let text_style = style.get_text();
|
||||
|
||||
result.underline |= text_style.has_underline();
|
||||
result.overline |= text_style.has_overline();
|
||||
result.line_through |= text_style.has_line_through();
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,15 +7,11 @@
|
|||
use Atom;
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
#[cfg(feature = "servo")]
|
||||
use properties::{longhands, PropertyDeclaration};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use std::fmt;
|
||||
use style_traits::{ParseError, ToCss, StyleParseErrorKind};
|
||||
use values::CustomIdent;
|
||||
use values::KeyframesName;
|
||||
#[cfg(feature = "servo")]
|
||||
use values::computed::Context;
|
||||
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
|
||||
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
|
||||
use values::specified::{AllowQuirks, Number};
|
||||
|
@ -220,16 +216,6 @@ impl Display {
|
|||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
/// Custom cascade for the `display` property in servo
|
||||
pub fn cascade_property_custom(
|
||||
_declaration: &PropertyDeclaration,
|
||||
context: &mut Context
|
||||
) {
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_display(context);
|
||||
}
|
||||
}
|
||||
|
||||
/// A specified value for the `vertical-align` property.
|
||||
|
|
|
@ -6,8 +6,6 @@
|
|||
|
||||
use cssparser::{Parser, Token};
|
||||
use parser::{Parse, ParserContext};
|
||||
#[cfg(feature = "servo")]
|
||||
use properties::{longhands, PropertyDeclaration};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
use std::fmt;
|
||||
|
@ -281,13 +279,6 @@ impl TextDecorationLine {
|
|||
pub fn none() -> Self {
|
||||
TextDecorationLine::NONE
|
||||
}
|
||||
|
||||
#[cfg(feature = "servo")]
|
||||
#[inline]
|
||||
/// Custom cascade for the text-decoration-line property in servo
|
||||
pub fn cascade_property_custom(_declaration: &PropertyDeclaration, context: &mut Context) {
|
||||
longhands::_servo_text_decorations_in_effect::derive_from_text_decoration(context);
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for TextDecorationLine {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue