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

Use the is_absolute_containing_block method everywhere #18112

Merged
merged 1 commit into from Aug 17, 2017
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use the is_absolute_containing_block method everywhere

This is a better approach than relying on
contains_positioned_fragments, because in the future other properties
will create absolute containing blocks.
  • Loading branch information
mrobinson committed Aug 16, 2017
commit 0a24c2f03cc8c90798c790b3d8633c17165d63e1
@@ -1989,12 +1989,12 @@ impl Flow for BlockFlow {

// For relatively-positioned descendants, the containing block formed by a block is just
// the content box. The containing block for absolutely-positioned descendants, on the
// other hand, is only established if we are positioned.
// other hand, is established in other circumstances (see `is_absolute_containing_block').
let relative_offset =
self.fragment.relative_position(&self.base
.early_absolute_position_info
.relative_containing_block_size);
if self.contains_positioned_fragments() {
if self.is_absolute_containing_block() {
let border_box_origin = (self.fragment.border_box -
self.fragment.style.logical_border_width()).start;
self.base
@@ -2013,14 +2013,15 @@ impl Flow for BlockFlow {
logical_border_width.inline_start,
logical_border_width.block_start);
let position = position.to_physical(self.base.writing_mode, container_size);
if self.contains_positioned_fragments() {

// Some blocks establish a stacking context, but not a containing block for
// absolutely positioned elements. An example of this might be a block that has
// `position: static` and `opacity` set. In these cases, absolutely-positioned
// children will not be positioned relative to us but will instead be positioned
// relative to our containing block.
if self.is_absolute_containing_block() {
position
} else {
// We establish a stacking context but are not positioned. (This will happen
// if, for example, the element has `position: static` but has `opacity` or
// `transform` set.) In this case, absolutely-positioned children will not be
// positioned relative to us but will instead be positioned relative to our
// containing block.
position - self.base.stacking_relative_position
}
} else {
@@ -2105,10 +2106,6 @@ impl Flow for BlockFlow {
(self.fragment.border_box - self.fragment.style().logical_border_width()).size
}

fn is_absolute_containing_block(&self) -> bool {
self.contains_positioned_fragments()
}

fn update_late_computed_inline_position_if_necessary(&mut self, inline_position: Au) {
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) &&
self.fragment.style().logical_position().inline_start ==
@@ -616,14 +616,12 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
flow.finish();

// Set up the absolute descendants.
let contains_positioned_fragments = flow.contains_positioned_fragments();
let is_absolutely_positioned = flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED);
if contains_positioned_fragments {
if flow.is_absolute_containing_block() {
// This is the containing block for all the absolute descendants.
flow.set_absolute_descendants(abs_descendants);

abs_descendants = AbsoluteDescendants::new();
if is_absolutely_positioned {
if flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED) {
// This is now the only absolute flow in the subtree which hasn't yet
// reached its CB.
abs_descendants.push(flow.clone());
@@ -1060,16 +1058,13 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>

// The flow is done.
flow.finish();
let contains_positioned_fragments = flow.contains_positioned_fragments();
if contains_positioned_fragments {
if flow.is_absolute_containing_block() {
// This is the containing block for all the absolute descendants.
flow.set_absolute_descendants(abs_descendants);

abs_descendants = AbsoluteDescendants::new();

let is_absolutely_positioned =
flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED);
if is_absolutely_positioned {
if flow::base(&*flow).flags.contains(IS_ABSOLUTELY_POSITIONED) {
// This is now the only absolute flow in the subtree which hasn't yet
// reached its containing block.
abs_descendants.push(flow.clone());
@@ -1134,16 +1129,13 @@ impl<'a, ConcreteThreadSafeLayoutNode: ThreadSafeLayoutNode>
legalizer.finish(&mut wrapper_flow);
wrapper_flow.finish();

let contains_positioned_fragments = wrapper_flow.contains_positioned_fragments();
if contains_positioned_fragments {
if wrapper_flow.is_absolute_containing_block() {
// This is the containing block for all the absolute descendants.
wrapper_flow.set_absolute_descendants(abs_descendants);

abs_descendants = AbsoluteDescendants::new();

let is_absolutely_positioned =
flow::base(&*wrapper_flow).flags.contains(IS_ABSOLUTELY_POSITIONED);
if is_absolutely_positioned {
if flow::base(&*wrapper_flow).flags.contains(IS_ABSOLUTELY_POSITIONED) {
// This is now the only absolute flow in the subtree which hasn't yet
// reached its containing block.
abs_descendants.push(wrapper_flow.clone());
@@ -404,7 +404,7 @@ pub trait Flow: fmt::Debug + Sync + Send + 'static {

/// Returns true if this is an absolute containing block.
fn is_absolute_containing_block(&self) -> bool {
false
self.contains_positioned_fragments()
}

/// Updates the inline position of a child flow during the assign-height traversal. At present,
@@ -1486,7 +1486,7 @@ impl Flow for InlineFlow {
indentation = Au(0)
}

if self.contains_positioned_fragments() {
if self.is_absolute_containing_block() {
// Assign block-sizes for all flows in this absolute flow tree.
// This is preorder because the block-size of an absolute flow may depend on
// the block-size of its containing block, which may also be an absolute flow.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.