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>
impl<'a, 'b: 'a> StyleAdjuster<'a, 'b>
Sourcepub fn new(style: &'a mut StyleBuilder<'b>) -> Self
pub fn new(style: &'a mut StyleBuilder<'b>) -> Self
Trivially constructs a new StyleAdjuster.
Sourcefn adjust_for_top_layer(&mut self)
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.
Sourcefn adjust_for_position(&mut self)
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’.
Sourcefn skip_item_display_fixup<E>(&self, element: Option<E>) -> boolwhere
E: TElement,
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.
Sourcefn blockify_if_necessary<E>(
&mut self,
layout_parent_style: &ComputedValues,
element: Option<E>,
)where
E: TElement,
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
Sourcefn adjust_for_writing_mode(&mut self, layout_parent_style: &ComputedValues)
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
Sourcefn adjust_for_border_width(&mut self)
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.
Sourcefn adjust_for_outline_width(&mut self)
fn adjust_for_outline_width(&mut self)
outline-style: none causes a computed outline-width of zero at computed value time.
Sourcefn adjust_for_overflow(&mut self)
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
.”
Sourcefn adjust_for_table_text_align(&mut self)
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
In this case, we don’t want to inherit the text alignment into the table.
Sourcefn adjust_for_text_decorations_in_effect(&mut self)
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.
Sourcefn adjust_for_visited<E>(&mut self, element: Option<E>)where
E: TElement,
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?
Sourcepub fn adjust<E>(
&mut self,
layout_parent_style: &ComputedValues,
element: Option<E>,
)where
E: TElement,
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> Freeze for StyleAdjuster<'a, 'b>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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