mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Move HAS_TEXT_DECORATION_LINES setting into StyleAdjuster.
This commit is contained in:
parent
86799d4d6e
commit
fcf37b19fd
4 changed files with 17 additions and 37 deletions
|
@ -4,8 +4,6 @@
|
|||
|
||||
//! Misc information about a given computed style.
|
||||
|
||||
use properties::{ComputedValues, StyleBuilder};
|
||||
|
||||
bitflags! {
|
||||
/// Misc information about a given computed style.
|
||||
///
|
||||
|
@ -22,29 +20,3 @@ bitflags! {
|
|||
const HAS_TEXT_DECORATION_LINES = 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_LINES) ||
|
||||
!this_style.get_text().clone_text_decoration_line().is_empty() {
|
||||
ret.insert(HAS_TEXT_DECORATION_LINES);
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ impl ComputedValues {
|
|||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(), // FIXME(bz): This seems dubious
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
flags: ComputedValueFlags::initial(),
|
||||
flags: ComputedValueFlags::empty(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
% for style_struct in data.style_structs:
|
||||
|
|
|
@ -2384,8 +2384,6 @@ impl<'a, T: 'a> Deref for StyleStructRef<'a, T> {
|
|||
/// actually cloning them, until we either build the style, or mutate the
|
||||
/// inherited value.
|
||||
pub struct StyleBuilder<'a> {
|
||||
/// The style we're inheriting from.
|
||||
inherited_style: &'a ComputedValues,
|
||||
/// The rule node representing the ordered list of rules matched for this
|
||||
/// node.
|
||||
rules: Option<StrongRuleNode>,
|
||||
|
@ -2396,6 +2394,8 @@ pub struct StyleBuilder<'a> {
|
|||
pub writing_mode: WritingMode,
|
||||
/// The keyword behind the current font-size property, if any.
|
||||
pub font_size_keyword: Option<(longhands::font_size::KeywordSize, f32)>,
|
||||
/// Flags for the computed value.
|
||||
pub flags: ComputedValueFlags,
|
||||
/// The element's style if visited, only computed if there's a relevant link
|
||||
/// for this element. A element's "relevant link" is the element being
|
||||
/// matched if it is a link or the nearest ancestor link.
|
||||
|
@ -2418,7 +2418,6 @@ impl<'a> StyleBuilder<'a> {
|
|||
visited_style: Option<Arc<ComputedValues>>,
|
||||
) -> Self {
|
||||
StyleBuilder {
|
||||
inherited_style,
|
||||
rules,
|
||||
custom_properties,
|
||||
writing_mode,
|
||||
|
@ -2518,11 +2517,10 @@ impl<'a> StyleBuilder<'a> {
|
|||
|
||||
/// Turns this `StyleBuilder` into a proper `ComputedValues` instance.
|
||||
pub fn build(self) -> ComputedValues {
|
||||
let flags = ComputedValueFlags::compute(&self, &self.inherited_style);
|
||||
ComputedValues::new(self.custom_properties,
|
||||
self.writing_mode,
|
||||
self.font_size_keyword,
|
||||
flags,
|
||||
self.flags,
|
||||
self.rules,
|
||||
self.visited_style,
|
||||
% for style_struct in data.active_style_structs():
|
||||
|
@ -2567,7 +2565,7 @@ mod lazy_static_module {
|
|||
% endfor
|
||||
custom_properties: None,
|
||||
writing_mode: WritingMode::empty(),
|
||||
flags: ComputedValueFlags::initial(),
|
||||
flags: ComputedValueFlags::empty(),
|
||||
font_computation_data: FontComputationData::default_values(),
|
||||
rules: None,
|
||||
visited_style: None,
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* 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/. */
|
||||
|
||||
//! A struct to encapsulate all the style fixups a computed style needs in order
|
||||
//! for it to adhere to the CSS spec.
|
||||
//! A struct to encapsulate all the style fixups and flags propagations
|
||||
//! a computed style needs in order for it to adhere to the CSS spec.
|
||||
|
||||
use app_units::Au;
|
||||
use properties::{self, CascadeFlags, ComputedValues};
|
||||
|
@ -312,6 +312,15 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
self.style.mutate_inheritedtext().set_text_align(text_align::start);
|
||||
}
|
||||
|
||||
/// Set the HAS_TEXT_DECORATION_LINES flag based on parent style.
|
||||
fn adjust_for_text_decoration_lines(&mut self, layout_parent_style: &ComputedValues) {
|
||||
use properties::computed_value_flags::HAS_TEXT_DECORATION_LINES;
|
||||
if layout_parent_style.flags.contains(HAS_TEXT_DECORATION_LINES) ||
|
||||
!self.style.get_text().clone_text_decoration_line().is_empty() {
|
||||
self.style.flags.insert(HAS_TEXT_DECORATION_LINES);
|
||||
}
|
||||
}
|
||||
|
||||
/// Adjusts the style to account for various fixups that don't fit naturally
|
||||
/// into the cascade.
|
||||
///
|
||||
|
@ -341,5 +350,6 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
|
|||
self.adjust_for_border_width();
|
||||
self.adjust_for_outline();
|
||||
self.adjust_for_writing_mode(layout_parent_style);
|
||||
self.adjust_for_text_decoration_lines(layout_parent_style);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue