style: Add a StyleBuilder struct to avoid refcount and atomic CAS during the cascade.

This should fix most of the complaints that caused
https://bugzilla.mozilla.org/show_bug.cgi?id=1360889 to be open, and also fix a
bunch of other FIXMEs across the style system.
This commit is contained in:
Emilio Cobos Álvarez 2017-04-30 13:59:10 +02:00
parent caa66a880a
commit 3b857f1c4e
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
11 changed files with 279 additions and 120 deletions

View file

@ -6,7 +6,7 @@
//! for it to adhere to the CSS spec.
use app_units::Au;
use properties::{self, ComputedValues};
use properties::{self, ComputedValues, StyleBuilder};
use properties::longhands::display::computed_value::T as display;
use properties::longhands::float::computed_value::T as float;
use properties::longhands::overflow_x::computed_value::T as overflow;
@ -14,14 +14,14 @@ use properties::longhands::position::computed_value::T as position;
/// An unsized struct that implements all the adjustment methods.
pub struct StyleAdjuster<'a> {
style: &'a mut ComputedValues,
pub struct StyleAdjuster<'a, 'b: 'a> {
style: &'a mut StyleBuilder<'b>,
is_root_element: bool,
}
impl<'a> StyleAdjuster<'a> {
impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// Trivially constructs a new StyleAdjuster.
pub fn new(style: &'a mut ComputedValues, is_root_element: bool) -> Self {
pub fn new(style: &'a mut StyleBuilder<'b>, is_root_element: bool) -> Self {
StyleAdjuster {
style: style,
is_root_element: is_root_element,
@ -264,7 +264,7 @@ impl<'a> StyleAdjuster<'a> {
///
/// When comparing to Gecko, this is similar to the work done by
/// `nsStyleContext::ApplyStyleFixups`.
pub fn adjust(mut self,
pub fn adjust(&mut self,
layout_parent_style: &ComputedValues,
skip_root_and_element_display_fixup: bool) {
self.adjust_for_top_layer();