Skip to main content

StyleAdjuster

Struct StyleAdjuster 

Source
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>) -> bool
where 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_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_table_text_align(&mut self)

-moz-center, -moz-left and -moz-right are used for HTML’s alignment.

This is covering the

case.

In this case, we don’t want to inherit the text alignment into the table.

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

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

If ‘-webkit-appearance’ is ‘menulist’ on a