pub struct StyleAdjuster<'a, 'b: 'a> {
    style: &'a mut StyleBuilder<'b>,
}
Expand description

A struct that implements all the adjustment methods.

NOTE(emilio): If new adjustments are introduced that depend on reset properties of the parent, you may need tweaking the ChildCascadeRequirement code in matching.rs.

NOTE(emilio): Also, if new adjustments are introduced that break the following invariant:

Given same tag name, namespace, rules and parent style, two elements would end up with exactly the same style.

Then you need to adjust the lookup_by_rules conditions in the sharing cache.

Fields§

§style: &'a mut StyleBuilder<'b>

Implementations§

source§

impl<'a, 'b: 'a> StyleAdjuster<'a, 'b>

source

pub fn new(style: &'a mut StyleBuilder<'b>) -> Self

Trivially constructs a new StyleAdjuster.

source

fn adjust_for_top_layer(&mut self)

https://fullscreen.spec.whatwg.org/#new-stacking-layer

Any position value other than ‘absolute’ and ‘fixed’ are computed to ‘absolute’ if the element is in a top layer.

source

fn adjust_for_position(&mut self)

CSS 2.1 section 9.7:

If ‘position’ has the value ‘absolute’ or ‘fixed’, […] the computed value of ‘float’ is ‘none’.

source

fn skip_item_display_fixup<E>(&self, element: Option<E>) -> boolwhere E: TElement,

Whether we should skip any item-based display property blockification on this element.

source

fn blockify_if_necessary<E>( &mut self, layout_parent_style: &ComputedValues, element: Option<E> )where E: TElement,

Apply the blockification rules based on the table in CSS 2.2 section 9.7. https://drafts.csswg.org/css2/visuren.html#dis-pos-flo A ::marker pseudo-element with ‘list-style-position:outside’ needs to have its ‘display’ blockified, unless the ::marker is for an inline list-item (for which ‘list-style-position:outside’ behaves as ‘inside’). https://drafts.csswg.org/css-lists-3/#list-style-position-property

source

fn set_bits(&mut self)

Compute a few common flags for both text and element’s style.

source

fn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues)

https://drafts.csswg.org/css-writing-modes-3/#block-flow:

If a box has a different writing-mode value than its containing block:

   - If the box has a specified display of inline, its display
     computes to inline-block. [CSS21]

This matches the adjustment that Gecko does, not exactly following the spec. See also:

https://lists.w3.org/Archives/Public/www-style/2017Mar/0045.html https://github.com/servo/servo/issues/15754

source

fn adjust_for_alignment(&mut self, layout_parent_style: &ComputedValues)

This implements an out-of-date spec. The new spec moves the handling of this to layout, which Gecko implements but Servo doesn’t.

See https://github.com/servo/servo/issues/15229

source

fn adjust_for_border_width(&mut self)

The initial value of border-*-width may be changed at computed value time.

This is moved to properties.rs for convenience.

source

fn adjust_for_outline_width(&mut self)

outline-style: none causes a computed outline-width of zero at computed value time.

source

fn adjust_for_overflow(&mut self)

CSS overflow-x and overflow-y require some fixup as well in some cases. https://drafts.csswg.org/css-overflow-3/#overflow-properties “Computed value: as specified, except with visible/clip computing to auto/hidden (respectively) if one of overflow-x or overflow-y is neither visible nor clip.”

source

fn adjust_for_text_decorations_in_effect(&mut self)

Computes the used text decoration for Servo.

FIXME(emilio): This is a layout tree concept, should move away from style, since otherwise we’re going to have the same subtle bugs WebKit and Blink have with this very same thing.

source

fn adjust_for_visited<E>(&mut self, element: Option<E>)where E: TElement,

Computes the RELEVANT_LINK_VISITED flag based on the parent style and on whether we’re a relevant link.

NOTE(emilio): We don’t do this for text styles, which is… dubious, but Gecko doesn’t seem to do it either. It’s extremely easy to do if needed though.

FIXME(emilio): This isn’t technically a style adjustment thingie, could it move somewhere else?

source

pub fn adjust<E>( &mut self, layout_parent_style: &ComputedValues, element: Option<E> )where E: TElement,

Adjusts the style to account for various fixups that don’t fit naturally into the cascade.

When comparing to Gecko, this is similar to the work done by ComputedStyle::ApplyStyleFixups, plus some parts of nsStyleSet::GetContext.

Auto Trait Implementations§

§

impl<'a, 'b> !RefUnwindSafe for StyleAdjuster<'a, 'b>

§

impl<'a, 'b> Send for StyleAdjuster<'a, 'b>

§

impl<'a, 'b> !Sync for StyleAdjuster<'a, 'b>

§

impl<'a, 'b> Unpin for StyleAdjuster<'a, 'b>

§

impl<'a, 'b> !UnwindSafe for StyleAdjuster<'a, 'b>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T, Global>> for T

source§

fn maybe_boxed(self) -> Box<T, Global>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Erased for T

source§

impl<T> ErasedDestructor for Twhere T: 'static,

source§

impl<T> MaybeSendSync for T