Skip to content
Open
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ taffy = { version = "0.14.0", default-features = false, features = [
"calc",
"detailed_layout_info",
] }
parley = { git = "https://github.com/DioxusLabs/parley", rev = "a0752c7bdc3ad88dac19fc194d2b8e57e59bea2e", default-features = false, features = ["std"] }
parley = { git = "https://github.com/DioxusLabs/parley", rev = "5335bd6bc7cfde320e7c9a5c5725b1586588724d", default-features = false, features = ["std"] }
skrifa = { version = "0.44", default-features = false, features = [
"std",
] } # Should match parley and vello versions
Expand Down
22 changes: 20 additions & 2 deletions packages/blitz-dom/src/layout/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ use std::sync::Arc;

use markup5ever::{QualName, local_name, ns};
use parley::{
FontContext, InlineBox, InlineBoxKind, LayoutContext, StyleProperty, TreeBuilder,
WhiteSpaceCollapse,
FontContext, InlineBox, InlineBoxKind, InlineBoxVerticalAlign, LayoutContext, StyleProperty,
TreeBuilder, WhiteSpaceCollapse,
};
use style::{
computed_values::position::T as PositionProperty,
data::ElementData as StyloElementData,
shared_lock::StylesheetGuards,
values::{
computed::{Content, ContentItem, Display, Float, TextTransform},
generics::box_::{BaselineShiftKeyword, GenericBaselineShift},
specified::box_::{DisplayInside, DisplayOutside},
},
};
Expand Down Expand Up @@ -1041,6 +1042,10 @@ pub(crate) fn build_inline_layout_into(
// Create a parley tree builder
let mut builder = layout_ctx.tree_builder(font_ctx, scale, true, &parley_style);

// Size every line box as if it started with a zero-width glyph in the root style
// (the CSS "strut", https://www.w3.org/TR/CSS22/visudet.html#strut)
builder.set_compute_strut(true);

// Set whitespace collapsing mode
let collapse_mode = root_node_style
.as_ref()
Expand Down Expand Up @@ -1164,6 +1169,17 @@ pub(crate) fn build_inline_layout_into(
} else {
InlineBoxKind::InFlow
};
let vertical_align = style
.map(|s| match s.clone_baseline_shift() {
GenericBaselineShift::Keyword(BaselineShiftKeyword::Top) => {
InlineBoxVerticalAlign::Top
}
GenericBaselineShift::Keyword(BaselineShiftKeyword::Bottom) => {
InlineBoxVerticalAlign::Bottom
}
_ => InlineBoxVerticalAlign::Baseline,
})
.unwrap_or_default();

match (display.outside(), display.inside()) {
(DisplayOutside::None, DisplayInside::None) => {
Expand Down Expand Up @@ -1200,6 +1216,7 @@ pub(crate) fn build_inline_layout_into(
width: 0.0,
height: 0.0,
baseline: None,
vertical_align,
});
} else if *tag_name == local_name!("br") {
// node.remove_damage(CONSTRUCT_DESCENDENT | CONSTRUCT_FC | CONSTRUCT_BOX);
Expand Down Expand Up @@ -1281,6 +1298,7 @@ pub(crate) fn build_inline_layout_into(
width: 0.0,
height: 0.0,
baseline: None,
vertical_align,
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion packages/blitz-dom/src/layout/inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ impl BaseDocument {
// dbg!(&layout.size);
// dbg!(&layout.location);

state.append_inline_box_to_line(box_break_data.advance, 0.0, 0.0, false);
state.append_inline_box_to_line(box_break_data.advance, None, false);

// if float.is_floated() {
// println!("INLINE FLOATED BOX ({}) {:?}", ibox.id, float);
Expand Down
Loading