TableWrapper: fix content inline size calculation

The preferred size of all columns was always being used before, but this
caused problems when it does not fit along with margins.
This commit is contained in:
Gabriel Poesia 2016-10-10 16:12:17 -03:00
parent f6163c77b9
commit d7a9c3f8e5
4 changed files with 91 additions and 1 deletions

View file

@ -778,7 +778,13 @@ fn initial_computed_inline_size(block: &mut BlockFlow,
containing_block_inline_size); containing_block_inline_size);
match inline_size_from_style { match inline_size_from_style {
MaybeAuto::Auto => { MaybeAuto::Auto => {
MaybeAuto::Specified(min(containing_block_inline_size, preferred_width_of_all_columns)) if preferred_width_of_all_columns + table_border_padding <= containing_block_inline_size {
MaybeAuto::Specified(preferred_width_of_all_columns + table_border_padding)
} else if minimum_width_of_all_columns > containing_block_inline_size {
MaybeAuto::Specified(minimum_width_of_all_columns)
} else {
MaybeAuto::Auto
}
} }
MaybeAuto::Specified(inline_size_from_style) => { MaybeAuto::Specified(inline_size_from_style) => {
MaybeAuto::Specified(max(inline_size_from_style - table_border_padding, MaybeAuto::Specified(max(inline_size_from_style - table_border_padding,

View file

@ -5220,6 +5220,18 @@
"url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html"
} }
], ],
"css/table_margin_a.html": [
{
"path": "css/table_margin_a.html",
"references": [
[
"/_mozilla/css/table_margin_ref.html",
"=="
]
],
"url": "/_mozilla/css/table_margin_a.html"
}
],
"css/table_margin_auto_a.html": [ "css/table_margin_auto_a.html": [
{ {
"path": "css/table_margin_auto_a.html", "path": "css/table_margin_auto_a.html",
@ -20286,6 +20298,18 @@
"url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html" "url": "/_mozilla/css/table_intrinsic_style_specified_width_a.html"
} }
], ],
"css/table_margin_a.html": [
{
"path": "css/table_margin_a.html",
"references": [
[
"/_mozilla/css/table_margin_ref.html",
"=="
]
],
"url": "/_mozilla/css/table_margin_a.html"
}
],
"css/table_margin_auto_a.html": [ "css/table_margin_auto_a.html": [
{ {
"path": "css/table_margin_auto_a.html", "path": "css/table_margin_auto_a.html",

View file

@ -0,0 +1,36 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="match" href="table_margin_ref.html" />
<style type="text/css">
table.ombox {
margin: 0 0 0 50%;
background: #f9f9f9;
}
td, tr, table {
padding: 0;
margin: 0;
}
.template-documentation {
width: 100%;
background-color: #ecfcf4;
padding: 0;
}
</style>
</head>
<body>
<div class="template-documentation">
<table class="ombox">
<tr>
<td>
This is a test. This line is large, large enough so that it will wrap.
Issue #12748, for which this test was created, is about the table margin not behaving correctly.
</td>
</tr>
</table>
</div>
</body>
</html>

View file

@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
.ombox {
margin-left: 50%;
background: #f9f9f9;
padding: 2px;
}
.template-documentation {
background-color: #ecfcf4;
width: 100%;
}
</style>
</head>
<body>
<div class="template-documentation">
<div class="ombox">
This is a test. This line is large, large enough so that it will wrap.
Issue #12748, for which this test was created, is about the table margin not behaving correctly.
</div>
</div>
</body>
</html>