tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1061HTML 997Markdown 12TOML 83120 Definitions

Fix build when block_layout is enabled bu float_layout isn't

Signed-off-by: Nico Burns <nico@nicoburns.com>

9e6b0bd4179f932451cf51d7d8e53cc09b3c4a3f · by Nico Burns · (8 months ago) · parent 99a5944d4 · browse the tree at this commit

Semantic delta · 10

src/compute/float.rs

src/compute/mod.rs

3 files · +45 −46

diff --git a/src/compute/block.rs b/src/compute/block.rs
index ae9c9d2ad..a2380a441 100644
--- a/src/compute/block.rs
+++ b/src/compute/block.rs
@@ -10,14 +10,12 @@ use crate::util::sys::Vec;
 use crate::util::MaybeMath;
 use crate::util::{MaybeResolve, ResolveOrZero};
 use crate::{
-    BlockContainerStyle, BlockItemStyle, BoxGenerationMode, BoxSizing, Direction, LayoutBlockContainer, RequestedAxis,
-    TextAlign,
+    BlockContainerStyle, BlockItemStyle, BoxGenerationMode, BoxSizing, ContentSlot, Direction, LayoutBlockContainer,
+    RequestedAxis, TextAlign,
 };
 
 #[cfg(feature = "float_layout")]
-use super::float::FloatIntrinsicWidthCalculator;
-#[cfg(feature = "float_layout")]
-use super::{ContentSlot, FloatContext};
+use super::float::{FloatContext, FloatIntrinsicWidthCalculator};
 #[cfg(feature = "float_layout")]
 use crate::{Clear, Float, FloatDirection};
 
diff --git a/src/compute/float.rs b/src/compute/float.rs
index 85a2b8cfa..ec2934168 100644
--- a/src/compute/float.rs
+++ b/src/compute/float.rs
@@ -28,46 +28,7 @@
 
 use core::ops::Range;
 
-use crate::{AvailableSpace, Clear, FloatDirection, Point, Size};
-
-/// An empty "slot" that avoids floats that is suitable for non-floated content
-/// to be laid out into
-#[derive(Debug, Clone, Copy, Default)]
-pub struct ContentSlot {
-    /// The id of the segment that the slot starts in
-    pub segment_id: Option<usize>,
-    /// The x position of the start of the slot
-    pub x: f32,
-    /// The y position of the start of the slot
-    pub y: f32,
-    /// The width of the slot
-    pub width: f32,
-    /// The height of the slot
-    pub height: f32,
-}
-
-impl ContentSlot {
-    /// The distance of the left edge of the slot from the left side of it's container
-    #[inline(always)]
-    pub fn left_edge(&self) -> f32 {
-        self.x
-    }
-    /// The distance of the right edge of the slot from the left side of it's container
-    #[inline(always)]
-    pub fn right_edge(&self) -> f32 {
-        self.x + self.width
-    }
-    /// The distance of the top edge of the slot from the top side of it's container
-    #[inline(always)]
-    pub fn top_edge(&self) -> f32 {
-        self.y + self.height
-    }
-    /// The distance of the bottom edge of the slot from the top side of it's container
-    #[inline(always)]
-    pub fn bottom_edge(&self) -> f32 {
-        self.y + self.height
-    }
-}
+use crate::{AvailableSpace, Clear, ContentSlot, FloatDirection, Point, Size};
 
 /// A floated box
 #[derive(Debug, Clone, Default)]
diff --git a/src/compute/mod.rs b/src/compute/mod.rs
index 7a3e630fe..522cc0ee5 100644
--- a/src/compute/mod.rs
+++ b/src/compute/mod.rs
@@ -48,7 +48,7 @@ pub use self::flexbox::compute_flexbox_layout;
 pub use self::grid::compute_grid_layout;
 
 #[cfg(feature = "float_layout")]
-pub use self::float::{ContentSlot, FloatContext, FloatIntrinsicWidthCalculator};
+pub use self::float::{FloatContext, FloatIntrinsicWidthCalculator};
 
 use crate::geometry::{Line, Point, Size};
 use crate::style::{AvailableSpace, CoreStyle, Overflow};
@@ -60,6 +60,46 @@ use crate::util::sys::round;
 use crate::util::ResolveOrZero;
 use crate::{CacheTree, MaybeMath, MaybeResolve};
 
+/// An empty "slot" that avoids floats that is suitable for non-floated content
+/// to be laid out into
+#[derive(Debug, Clone, Copy, Default)]
+#[cfg(any(feature = "float_layout", feature = "block_layout"))]
+pub struct ContentSlot {
+    /// The id of the segment that the slot starts in
+    pub segment_id: Option<usize>,
+    /// The x position of the start of the slot
+    pub x: f32,
+    /// The y position of the start of the slot
+    pub y: f32,
+    /// The width of the slot
+    pub width: f32,
+    /// The height of the slot
+    pub height: f32,
+}
+
+impl ContentSlot {
+    /// The distance of the left edge of the slot from the left side of it's container
+    #[inline(always)]
+    pub fn left_edge(&self) -> f32 {
+        self.x
+    }
+    /// The distance of the right edge of the slot from the left side of it's container
+    #[inline(always)]
+    pub fn right_edge(&self) -> f32 {
+        self.x + self.width
+    }
+    /// The distance of the top edge of the slot from the top side of it's container
+    #[inline(always)]
+    pub fn top_edge(&self) -> f32 {
+        self.y + self.height
+    }
+    /// The distance of the bottom edge of the slot from the top side of it's container
+    #[inline(always)]
+    pub fn bottom_edge(&self) -> f32 {
+        self.y + self.height
+    }
+}
+
 /// Compute layout for the root node in the tree
 pub fn compute_root_layout(tree: &mut impl LayoutPartialTree, root: NodeId, available_space: Size<AvailableSpace>) {
     let mut known_dimensions = Size::NONE;