mirror of
https://github.com/servo/servo.git
synced 2025-08-04 05:00:08 +01:00
Expand the block size of the root flow's margin box to the viewport size
instead of expanding the block size of its border box. Closes #9308.
This commit is contained in:
parent
55d4773311
commit
777c46fd3f
24 changed files with 83 additions and 76 deletions
|
@ -696,7 +696,8 @@ impl BlockFlow {
|
||||||
///
|
///
|
||||||
/// TODO(#2017, pcwalton): This is somewhat inefficient (traverses kids twice); can we do
|
/// TODO(#2017, pcwalton): This is somewhat inefficient (traverses kids twice); can we do
|
||||||
/// better?
|
/// better?
|
||||||
fn adjust_fragments_for_collapsed_margins_if_root(&mut self) {
|
fn adjust_fragments_for_collapsed_margins_if_root<'a>(&mut self,
|
||||||
|
layout_context: &'a LayoutContext<'a>) {
|
||||||
if !self.is_root() {
|
if !self.is_root() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -720,10 +721,19 @@ impl BlockFlow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.base.position.size.block = self.base.position.size.block + block_start_margin_value +
|
// FIXME(#2003, pcwalton): The max is taken here so that you can scroll the page, but this
|
||||||
block_end_margin_value;
|
// is not correct behavior according to CSS 2.1 § 10.5. Instead I think we should treat the
|
||||||
self.fragment.border_box.size.block = self.fragment.border_box.size.block + block_start_margin_value +
|
// root element as having `overflow: scroll` and use the layers-based scrolling
|
||||||
block_end_margin_value;
|
// infrastructure to make it scrollable.
|
||||||
|
let viewport_size =
|
||||||
|
LogicalSize::from_physical(self.fragment.style.writing_mode,
|
||||||
|
layout_context.shared_context().viewport_size);
|
||||||
|
let block_size = max(viewport_size.block,
|
||||||
|
self.fragment.border_box.size.block + block_start_margin_value +
|
||||||
|
block_end_margin_value);
|
||||||
|
|
||||||
|
self.base.position.size.block = block_size;
|
||||||
|
self.fragment.border_box.size.block = block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Assign block-size for current flow.
|
/// Assign block-size for current flow.
|
||||||
|
@ -882,18 +892,8 @@ impl BlockFlow {
|
||||||
self.base.collapsible_margins = collapsible_margins;
|
self.base.collapsible_margins = collapsible_margins;
|
||||||
translate_including_floats(&mut cur_b, delta, &mut floats);
|
translate_including_floats(&mut cur_b, delta, &mut floats);
|
||||||
|
|
||||||
// FIXME(#2003, pcwalton): The max is taken here so that you can scroll the page, but
|
|
||||||
// this is not correct behavior according to CSS 2.1 § 10.5. Instead I think we should
|
|
||||||
// treat the root element as having `overflow: scroll` and use the layers-based
|
|
||||||
// scrolling infrastructure to make it scrollable.
|
|
||||||
let mut block_size = cur_b - block_start_offset;
|
let mut block_size = cur_b - block_start_offset;
|
||||||
let is_root = self.is_root();
|
let is_root = self.is_root();
|
||||||
if is_root {
|
|
||||||
let viewport_size =
|
|
||||||
LogicalSize::from_physical(self.fragment.style.writing_mode,
|
|
||||||
layout_context.shared_context().viewport_size);
|
|
||||||
block_size = max(viewport_size.block, block_size)
|
|
||||||
}
|
|
||||||
|
|
||||||
if is_root || self.formatting_context_type() != FormattingContextType::None ||
|
if is_root || self.formatting_context_type() != FormattingContextType::None ||
|
||||||
self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||||
|
@ -903,6 +903,17 @@ impl BlockFlow {
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
if self.base.flags.contains(IS_ABSOLUTELY_POSITIONED) {
|
||||||
|
// FIXME(#2003, pcwalton): The max is taken here so that you can scroll the page,
|
||||||
|
// but this is not correct behavior according to CSS 2.1 § 10.5. Instead I think we
|
||||||
|
// should treat the root element as having `overflow: scroll` and use the layers-
|
||||||
|
// based scrolling infrastructure to make it scrollable.
|
||||||
|
if is_root {
|
||||||
|
let viewport_size =
|
||||||
|
LogicalSize::from_physical(self.fragment.style.writing_mode,
|
||||||
|
layout_context.shared_context().viewport_size);
|
||||||
|
block_size = max(viewport_size.block, block_size)
|
||||||
|
}
|
||||||
|
|
||||||
// Store the content block-size for use in calculating the absolute flow's
|
// Store the content block-size for use in calculating the absolute flow's
|
||||||
// dimensions later.
|
// dimensions later.
|
||||||
//
|
//
|
||||||
|
@ -957,7 +968,7 @@ impl BlockFlow {
|
||||||
// Store the current set of floats in the flow so that flows that come later in the
|
// Store the current set of floats in the flow so that flows that come later in the
|
||||||
// document can access them.
|
// document can access them.
|
||||||
self.base.floats = floats.clone();
|
self.base.floats = floats.clone();
|
||||||
self.adjust_fragments_for_collapsed_margins_if_root();
|
self.adjust_fragments_for_collapsed_margins_if_root(layout_context);
|
||||||
} else {
|
} else {
|
||||||
// We don't need to reflow, but we still need to perform in-order traversals if
|
// We don't need to reflow, but we still need to perform in-order traversals if
|
||||||
// necessary.
|
// necessary.
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
[background-bg-pos-206.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-001.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-005.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-006.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-007.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-009.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-012.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-013.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-014.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[bottom-applies-to-015.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[containing-block-023.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-001.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-005.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-006.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-007.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-009.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-012.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-013.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-014.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -1,3 +0,0 @@
|
||||||
[position-applies-to-015.htm]
|
|
||||||
type: reftest
|
|
||||||
expected: FAIL
|
|
|
@ -4044,6 +4044,18 @@
|
||||||
"url": "/_mozilla/css/root_margin_collapse_a.html"
|
"url": "/_mozilla/css/root_margin_collapse_a.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"css/root_margins_a.html": [
|
||||||
|
{
|
||||||
|
"path": "css/root_margins_a.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/css/root_margins_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/css/root_margins_a.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"css/root_pseudo_a.html": [
|
"css/root_pseudo_a.html": [
|
||||||
{
|
{
|
||||||
"path": "css/root_pseudo_a.html",
|
"path": "css/root_pseudo_a.html",
|
||||||
|
@ -10136,6 +10148,18 @@
|
||||||
"url": "/_mozilla/css/root_margin_collapse_a.html"
|
"url": "/_mozilla/css/root_margin_collapse_a.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"css/root_margins_a.html": [
|
||||||
|
{
|
||||||
|
"path": "css/root_margins_a.html",
|
||||||
|
"references": [
|
||||||
|
[
|
||||||
|
"/_mozilla/css/root_margins_ref.html",
|
||||||
|
"=="
|
||||||
|
]
|
||||||
|
],
|
||||||
|
"url": "/_mozilla/css/root_margins_a.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"css/root_pseudo_a.html": [
|
"css/root_pseudo_a.html": [
|
||||||
{
|
{
|
||||||
"path": "css/root_pseudo_a.html",
|
"path": "css/root_pseudo_a.html",
|
||||||
|
|
15
tests/wpt/mozilla/tests/css/root_margins_a.html
Normal file
15
tests/wpt/mozilla/tests/css/root_margins_a.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<link rel="match" href="root_margins_ref.html">
|
||||||
|
<style>
|
||||||
|
div {
|
||||||
|
position: absolute;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background: steelblue;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
|
17
tests/wpt/mozilla/tests/css/root_margins_ref.html
Normal file
17
tests/wpt/mozilla/tests/css/root_margins_ref.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
position: absolute;
|
||||||
|
width: 100px;
|
||||||
|
height: 100px;
|
||||||
|
background: steelblue;
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue