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:
Emilio Cobos Álvarez 2017-06-26 22:50:43 +02:00
parent 3f2d747689
commit 5c7632f4c4
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
4 changed files with 135 additions and 81 deletions

View 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
}
}