mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Add some flags to the computed values.
This will allow us to fix propagation of text-decoration, and also to implement inlinization of ruby kids. Signed-off-by: Emilio Cobos Álvarez <emilio@crisal.io>
This commit is contained in:
parent
3f2d747689
commit
5c7632f4c4
4 changed files with 135 additions and 81 deletions
45
components/style/properties/computed_value_flags.rs
Normal file
45
components/style/properties/computed_value_flags.rs
Normal file
|
@ -0,0 +1,45 @@
|
|||
/* 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/. */
|
||||
|
||||
//! Misc information about a given computed style.
|
||||
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
|
||||
bitflags! {
|
||||
/// Misc information about a given computed style.
|
||||
pub flags ComputedValueFlags: u8 {
|
||||
/// Whether the style or any of the ancestors has a text-decoration
|
||||
/// property that should get propagated to descendants.
|
||||
///
|
||||
/// text-decoration is a reset property, but gets propagated in the
|
||||
/// frame/box tree.
|
||||
const HAS_TEXT_DECORATION_LINE = 1 << 0,
|
||||
}
|
||||
}
|
||||
|
||||
impl ComputedValueFlags {
|
||||
/// Get the computed value flags for the initial style.
|
||||
pub fn initial() -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
||||
/// Compute the flags for this style, given the parent style.
|
||||
pub fn compute(
|
||||
this_style: &StyleBuilder,
|
||||
parent_style: &ComputedValues,
|
||||
) -> Self {
|
||||
let mut ret = Self::empty();
|
||||
|
||||
// FIXME(emilio): This feels like it wants to look at the
|
||||
// layout_parent_style, but the way it works in Gecko means it's not
|
||||
// needed (we'd recascade a bit more when it changes, but that's fine),
|
||||
// and this way it simplifies the code for text styles and similar.
|
||||
if parent_style.flags.contains(HAS_TEXT_DECORATION_LINE) ||
|
||||
!this_style.get_text().clone_text_decoration_line().is_empty() {
|
||||
ret.insert(HAS_TEXT_DECORATION_LINE);
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue