Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bi-directional layout support #736

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[unstable]
codegen-backend = true

[profile.dev]
codegen-backend = "cranelift"

[alias]
gentest = "run --release --package gentest --"
import-yoga-tests = "run --package import-yoga-tests --"
Expand Down
13 changes: 12 additions & 1 deletion src/compute/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use crate::util::sys::f32_max;
use crate::util::sys::Vec;
use crate::util::MaybeMath;
use crate::util::{MaybeResolve, ResolveOrZero};
use crate::{BlockContainerStyle, BlockItemStyle, BoxGenerationMode, BoxSizing, LayoutBlockContainer, TextAlign};
use crate::{
BlockContainerStyle, BlockItemStyle, BoxGenerationMode, BoxSizing, Direction, LayoutBlockContainer, TextAlign,
};

#[cfg(feature = "content_size")]
use super::common::content_size::compute_content_size_contribution;
Expand All @@ -26,6 +28,9 @@ struct BlockItem {
/// Items that are tables don't have stretch sizing applied to them
is_table: bool,

/// Direction (LTR or RTL)
direction: Direction,

/// The base size of this item
size: Size<Option<f32>>,
/// The minimum allowable size of this item
Expand Down Expand Up @@ -194,6 +199,7 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs:
|| matches!(min_size.height, Some(h) if h > 0.0);

let text_align = style.text_align();
let direction = style.direction();

drop(style);

Expand Down Expand Up @@ -257,6 +263,7 @@ fn compute_inner(tree: &mut impl LayoutBlockContainer, node_id: NodeId, inputs:
Size::NONE,
Size::MAX_CONTENT,
SizingMode::InherentSize,
direction,
Line::FALSE,
);
}
Expand Down Expand Up @@ -314,6 +321,7 @@ fn generate_item_list(
node_id: child_node_id,
order: order as u32,
is_table: child_style.is_table(),
direction: child_style.direction(),
size: child_style
.size()
.maybe_resolve(node_inner_size)
Expand Down Expand Up @@ -369,6 +377,7 @@ fn determine_content_based_container_width(
Size::NONE,
available_space.map_width(|w| w.maybe_sub(item_x_margin_sum)),
SizingMode::InherentSize,
item.direction,
Line::TRUE,
);

Expand Down Expand Up @@ -434,6 +443,7 @@ fn perform_final_layout_on_in_flow_children(
parent_size,
available_space.map_width(|w| w.maybe_sub(item_non_auto_x_margin_sum)),
SizingMode::InherentSize,
item.direction,
Line::TRUE,
);
let final_size = item_layout.size;
Expand Down Expand Up @@ -649,6 +659,7 @@ fn perform_absolute_layout_on_absolute_children(
height: AvailableSpace::Definite(area_height.maybe_clamp(min_size.height, max_size.height)),
},
SizingMode::ContentSize,
item.direction,
Line::FALSE,
);
let measured_size = layout_output.size;
Expand Down
Loading
Loading