aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2019-10-07 15:45:43 +0200
committerEmilio Cobos Álvarez <emilio@crisal.io>2019-10-07 16:57:18 +0200
commit6b674a670b97c4f01f7fd04871c6d489e1bf9f42 (patch)
tree9a38627d74c5ad9e9e1571a83b744ff469d84441
parent0b5aaeff5d85f286640ff7a0b723b253e3a8dc05 (diff)
downloadservo-6b674a670b97c4f01f7fd04871c6d489e1bf9f42.tar.gz
servo-6b674a670b97c4f01f7fd04871c6d489e1bf9f42.zip
style: Use consistent naming and shared code for out-of-flow stuff.
Use the functions introduced in ee17eedf3a857f27ce2b6b775574a3a455df8aa3.
-rw-r--r--components/style/properties/longhands/box.mako.rs5
-rw-r--r--components/style/properties/properties.mako.rs12
-rw-r--r--components/style/style_adjuster.rs12
3 files changed, 12 insertions, 17 deletions
diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index 2fd69229878..a75504be193 100644
--- a/components/style/properties/longhands/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -53,10 +53,7 @@ ${helpers.single_keyword(
>
impl computed_value::T {
pub fn is_absolutely_positioned(self) -> bool {
- match self {
- Self::Absolute | Self::Fixed => true,
- _ => false,
- }
+ matches!(self, Self::Absolute | Self::Fixed)
}
}
</%helpers:single_keyword>
diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs
index a1b4cedcfed..d926e28c5c4 100644
--- a/components/style/properties/properties.mako.rs
+++ b/components/style/properties/properties.mako.rs
@@ -3694,16 +3694,14 @@ impl<'a> StyleBuilder<'a> {
<% del style_struct %>
/// Returns whether this computed style represents a floated object.
- pub fn floated(&self) -> bool {
- self.get_box().clone_float() != longhands::float::computed_value::T::None
+ pub fn is_floating(&self) -> bool {
+ self.get_box().clone_float().is_floating()
}
- /// Returns whether this computed style represents an out of flow-positioned
+ /// Returns whether this computed style represents an absolutely-positioned
/// object.
- pub fn out_of_flow_positioned(&self) -> bool {
- use crate::properties::longhands::position::computed_value::T as Position;
- matches!(self.get_box().clone_position(),
- Position::Absolute | Position::Fixed)
+ pub fn is_absolutely_positioned(&self) -> bool {
+ self.get_box().clone_position().is_absolutely_positioned()
}
/// Whether this style has a top-layer style.
diff --git a/components/style/style_adjuster.rs b/components/style/style_adjuster.rs
index 9f274917b08..ac528f4fb37 100644
--- a/components/style/style_adjuster.rs
+++ b/components/style/style_adjuster.rs
@@ -145,7 +145,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// computed to 'absolute' if the element is in a top layer.
///
fn adjust_for_top_layer(&mut self) {
- if !self.style.out_of_flow_positioned() && self.style.in_top_layer() {
+ if !self.style.is_absolutely_positioned() && self.style.in_top_layer() {
self.style.mutate_box().set_position(Position::Absolute);
}
}
@@ -156,7 +156,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
/// value of 'float' is 'none'.
///
fn adjust_for_position(&mut self) {
- if self.style.out_of_flow_positioned() && self.style.floated() {
+ if self.style.is_absolutely_positioned() && self.style.is_floating() {
self.style.mutate_box().set_float(Float::None);
}
}
@@ -205,8 +205,8 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
let is_item_or_root = blockify;
- blockify_if!(self.style.floated());
- blockify_if!(self.style.out_of_flow_positioned());
+ blockify_if!(self.style.is_floating());
+ blockify_if!(self.style.is_absolutely_positioned());
#[cfg(any(feature = "servo-layout-2013", feature = "gecko"))]
blockify_if!(
self.style.pseudo.map_or(false, |p| p.is_marker()) &&
@@ -375,7 +375,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
use crate::computed_values::align_self::T as AlignSelf;
if self.style.get_position().clone_align_self() == AlignSelf::Auto &&
- !self.style.out_of_flow_positioned()
+ !self.style.is_absolutely_positioned()
{
let self_align = match layout_parent_style.get_position().clone_align_items() {
AlignItems::Stretch => AlignSelf::Stretch,
@@ -556,7 +556,7 @@ impl<'a, 'b: 'a> StyleAdjuster<'a, 'b> {
#[cfg(feature = "gecko")]
fn should_suppress_linebreak(&self, layout_parent_style: &ComputedValues) -> bool {
// Line break suppression should only be propagated to in-flow children.
- if self.style.floated() || self.style.out_of_flow_positioned() {
+ if self.style.is_floating() || self.style.is_absolutely_positioned() {
return false;
}
let parent_display = layout_parent_style.get_box().clone_display();