Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Layout 2020 box tree support for Flexbox, behind a pref #26755
Conversation
highfive
commented
Jun 2, 2020
|
Heads up! This PR modifies the following files:
|
|
@bors-servo r+ |
|
|
|
|
|
Failures are legit, I messed up the I’ve also pushed other commits for sprinkling some rayon on. |
|
@bors-servo r=nox |
|
|
|
|
|
This PR adds a The fix is straightforward: fixup! Flex items in the box tree
diff --git components/layout_2020/flow/root.rs components/layout_2020/flow/root.rs
index 61f6ca888b..79285767d3 100644
--- components/layout_2020/flow/root.rs
+++ components/layout_2020/flow/root.rs
@@ -10,6 +10,7 @@ use crate::display_list::stacking_context::{
};
use crate::dom_traversal::{iter_child_nodes, Contents, NodeExt};
use crate::element_data::LayoutBox;
+use crate::flexbox::FlexLevelBox;
use crate::flow::construct::ContainsFloats;
use crate::flow::float::FloatBox;
use crate::flow::inline::InlineLevelBox;
@@ -119,6 +120,7 @@ impl BoxTree {
enum UpdatePoint {
AbsolutelyPositionedBlockLevelBox(ArcRefCell<BlockLevelBox>),
AbsolutelyPositionedInlineLevelBox(ArcRefCell<InlineLevelBox>),
+ AbsolutelyPositionedFlexLevelBox(ArcRefCell<FlexLevelBox>),
}
fn update_point<'dom, Node>(
@@ -188,6 +190,16 @@ impl BoxTree {
},
_ => return None,
},
+ LayoutBox::FlexLevel(flex_level_box) => match &*flex_level_box.borrow() {
+ FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(_)
+ if box_style.position.is_absolutely_positioned() =>
+ {
+ UpdatePoint::AbsolutelyPositionedFlexLevelBox(
+ flex_level_box.clone(),
+ )
+ },
+ _ => return None,
+ },
};
Some((primary_style.clone(), display_inside, update_point))
}
@@ -217,6 +229,12 @@ impl BoxTree {
out_of_flow_absolutely_positioned_box,
);
},
+ UpdatePoint::AbsolutelyPositionedFlexLevelBox(flex_level_box) => {
+ *flex_level_box.borrow_mut() =
+ FlexLevelBox::OutOfFlowAbsolutelyPositionedBox(
+ out_of_flow_absolutely_positioned_box,
+ );
+ },
}
return true;
} |
|
@bors-servo r=nox |
|
|
|
|
| } | ||
|
|
||
| /// https://drafts.csswg.org/css-text/#white-space | ||
| fn is_only_document_white_space(string: &str) -> bool { |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
SimonSapin
Jul 13, 2020
Author
Member
It could be, but I’m not sure that would be a win. I’d guess that white-space only text nodes are typically small (at most a couple newlines plus indentation in non-minified HTML) so this should run quickly, and in other cases we’ll typically find a non-white-space character not far from the start where Iterator::all will short-circuit and we’ll also return quickly.
SimonSapin commentedJun 2, 2020
CC #26639
Layout support will come in future PRs. This one generates a zero-size fragment with no content.