mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Recascade the document when rem units are used and the root font-size changes.
This commit is contained in:
parent
7b61d55421
commit
19b61dfc08
6 changed files with 76 additions and 21 deletions
|
@ -14,7 +14,7 @@ use parser::ParserContext;
|
|||
use properties::{ComputedValues, StyleBuilder};
|
||||
use properties::longhands::font_size;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicIsize, Ordering};
|
||||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||
use style_traits::{CSSPixel, ToCss};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use values::computed::{self, ToComputedValue};
|
||||
|
@ -41,6 +41,10 @@ pub struct Device {
|
|||
/// a relaxed atomic here.
|
||||
#[ignore_heap_size_of = "Pure stack type"]
|
||||
root_font_size: AtomicIsize,
|
||||
/// Whether any styles computed in the document relied on the root font-size
|
||||
/// by using rem units.
|
||||
#[ignore_heap_size_of = "Pure stack type"]
|
||||
used_root_font_size: AtomicBool,
|
||||
}
|
||||
|
||||
impl Device {
|
||||
|
@ -52,6 +56,7 @@ impl Device {
|
|||
media_type: media_type,
|
||||
viewport_size: viewport_size,
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
||||
used_root_font_size: AtomicBool::new(false),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +70,7 @@ impl Device {
|
|||
|
||||
/// Get the font size of the root element (for rem)
|
||||
pub fn root_font_size(&self) -> Au {
|
||||
self.used_root_font_size.store(true, Ordering::Relaxed);
|
||||
Au::new(self.root_font_size.load(Ordering::Relaxed) as i32)
|
||||
}
|
||||
|
||||
|
@ -73,6 +79,11 @@ impl Device {
|
|||
self.root_font_size.store(size.0 as isize, Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// Returns whether we ever looked up the root font size of the Device.
|
||||
pub fn used_root_font_size(&self) -> bool {
|
||||
self.used_root_font_size.load(Ordering::Relaxed)
|
||||
}
|
||||
|
||||
/// Returns the viewport size of the current device in app units, needed,
|
||||
/// among other things, to resolve viewport units.
|
||||
#[inline]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue