style: Add a style flag for the root element style.

This is needed to make the root element not a containing block in presence of
filters or what not.

Differential Revision: https://phabricator.services.mozilla.com/D61167
This commit is contained in:
Emilio Cobos Álvarez 2020-01-31 14:51:06 +00:00
parent f426b644ca
commit 16fd7cad0c
No known key found for this signature in database
GPG key ID: E1152D0994E4BF8A
13 changed files with 37 additions and 46 deletions

View file

@ -126,9 +126,6 @@ pub mod url;
/// A `Context` is all the data a specified value could ever need to compute
/// itself and be transformed to a computed value.
pub struct Context<'a> {
/// Whether the current element is the root element.
pub is_root_element: bool,
/// Values accessed through this need to be in the properties "computed
/// early": color, text-decoration, font-size, display, position, float,
/// border-*-style, outline-style, font-family, writing-mode...
@ -187,7 +184,6 @@ impl<'a> Context<'a> {
let provider = get_metrics_provider_for_product();
let context = Context {
is_root_element: false,
builder: StyleBuilder::for_inheritance(device, None, None),
font_metrics_provider: &provider,
cached_system_font: None,
@ -201,11 +197,6 @@ impl<'a> Context<'a> {
f(&context)
}
/// Whether the current element is the root element.
pub fn is_root_element(&self) -> bool {
self.is_root_element
}
/// The current device.
pub fn device(&self) -> &Device {
self.builder.device

View file

@ -7,9 +7,9 @@
//! [length]: https://drafts.csswg.org/css-values/#lengths
use super::{AllowQuirks, Number, Percentage, ToComputedValue};
use crate::computed_value_flags::ComputedValueFlags;
use crate::font_metrics::{FontMetrics, FontMetricsOrientation};
use crate::parser::{Parse, ParserContext};
use crate::properties::computed_value_flags::ComputedValueFlags;
use crate::values::computed::{self, CSSPixelLength, Context};
use crate::values::generics::length as generics;
use crate::values::generics::length::{
@ -206,7 +206,7 @@ impl FontRelativeLength {
// element, the rem units refer to the property's initial
// value.
//
let reference_size = if context.is_root_element || context.in_media_query {
let reference_size = if context.builder.is_root_element || context.in_media_query {
reference_font_size
} else {
computed::Length::new(context.device().root_font_size().to_f32_px())

View file

@ -596,7 +596,7 @@ impl ToComputedValue for TextAlign {
// In that case, the default behavior here will set it to left,
// but we want to set it to right -- instead set it to the default (`start`),
// which will do the right thing in this case (but not the general case)
if _context.is_root_element {
if _context.builder.is_root_element {
return TextAlignKeyword::Start;
}
let parent = _context