aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout/fragment.rs
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2015-08-11 17:39:43 -0700
committerPatrick Walton <pcwalton@mimiga.net>2015-08-17 12:43:12 -0700
commita30379975a50e52dd8ad7b7b0f95447efe231c5a (patch)
tree1a8340f927374a207294abae9bf915800d7427f9 /components/layout/fragment.rs
parent55e755e35ac8622a80cbebe3395aae44a0239b4f (diff)
downloadservo-a30379975a50e52dd8ad7b7b0f95447efe231c5a.tar.gz
servo-a30379975a50e52dd8ad7b7b0f95447efe231c5a.zip
layout: Improve our handling of inline absolute containing blocks.
Several issues are addressed in this commit: * Inline flows now bubble up their absolute descendants instead of making the inline flow the containing block for them. (In the future, we will need to make the inline flow *sometimes* be the containing block for them, but for now it improves sites to unconditionally bubble up.) * Fragments now look at their inline fragment context to determine whether they are positioned. * Inline flows now push the stacking-relative position of the absolute containing block down to their inline-block fragments. * Inline absolute hypothetical fragments can be containing blocks. * Fixes the logic in `containing_block_range_for_flow_surrounding_fragment_at_index`. The condition to determine whether fragments are positioned was inverted! * `Descendants`/`AbsDescendants` has been refactored in order to become more friendly to inline absolute containing blocks in the future. Improves the inline position of the green drop-down arrow in the Google SERPs. (The block position is still wrong.)
Diffstat (limited to 'components/layout/fragment.rs')
-rw-r--r--components/layout/fragment.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index a512db3670c..87f8f935589 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -2234,6 +2234,22 @@ impl Fragment {
pub fn margin_box_inline_size(&self) -> Au {
self.border_box.size.inline + self.margin.inline_start_end()
}
+
+ /// Returns true if this node *or any of the nodes within its inline fragment context* have
+ /// non-`static` `position`.
+ pub fn is_positioned(&self) -> bool {
+ if self.style.get_box().position != position::T::static_ {
+ return true
+ }
+ if let Some(ref inline_context) = self.inline_context {
+ for node in inline_context.nodes.iter() {
+ if node.style.get_box().position != position::T::static_ {
+ return true
+ }
+ }
+ }
+ false
+ }
}
impl fmt::Debug for Fragment {