Skip to content

Commit

Permalink
Adding some missing conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
kokoISnoTarget committed Jul 1, 2024
1 parent 0f963a8 commit cb09159
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/style/dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@

use core::fmt::{Debug, Formatter};
use core::ops::Neg;
use std::ptr::NonNull;
use core::ptr::NonNull;

use num_traits::{Signed, Zero};

use crate::geometry::{Rect, Size};
use crate::style_helpers::{FromLength, FromPercent, TaffyAuto, TaffyMaxContent, TaffyMinContent, TaffyZero};
use crate::sys::{Box, Vec};
#[cfg(feature = "calc")]
use crate::sys::Box;
use crate::sys::Vec;
use crate::util::sys::abs;

macro_rules! impl_debug {
($ty:ident, $name:literal) => {
impl Debug for $ty {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
#[cfg(feature = "calc")]
unsafe {
f.debug_tuple($name)
.field(match self.is_calc() {
Expand All @@ -23,6 +26,10 @@ macro_rules! impl_debug {
})
.finish()
}
#[cfg(not(feature = "calc"))]
f.debug_tuple($name)
.field(unsafe { &self.inner })
.finish()
}
}
};
Expand Down Expand Up @@ -287,6 +294,7 @@ impl LengthPercentageAuto {
match self.get_inner() {
LengthPercentageAutoInner::Length(length) => Some(length),
LengthPercentageAutoInner::Percent(percent) => Some(context * percent),
#[cfg(feature = "calc")]
LengthPercentageAutoInner::Calc => self.get_calc().map(|calc| calc.resolve(context)),
LengthPercentageAutoInner::Auto => None,
}
Expand Down
7 changes: 6 additions & 1 deletion src/style/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,12 @@ impl MinTrackSizingFunction {
pub fn uses_percentage(self) -> bool {
use MinTrackSizingFunction::*;
match self {
Fixed(length) => length.is_percent() || length.is_calc(),
Fixed(length) => {
#[cfg(feature = "calc")]
return length.is_percent() || length.is_calc();
#[cfg(not(feature = "calc"))]
return length.is_percent();
},
_ => false,
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/style/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ mod flex;

pub use self::alignment::{AlignContent, AlignItems, AlignSelf, JustifyContent, JustifyItems, JustifySelf};
pub use self::dimension::{
AvailableSpace, CalcNode, Dimension, DimensionInner, LengthPercentage, LengthPercentageAuto,
LengthPercentageAutoInner, LengthPercentageInner, RoundingStrategy,
AvailableSpace, Dimension, DimensionInner, LengthPercentage, LengthPercentageAuto,
LengthPercentageAutoInner, LengthPercentageInner,
};
#[cfg(feature = "calc")]
pub use self::dimension::{ CalcNode, RoundingStrategy };

#[cfg(feature = "flexbox")]
pub use self::flex::{FlexDirection, FlexWrap};
Expand Down

0 comments on commit cb09159

Please sign in to comment.