diff options
-rw-r--r-- | components/layout/fragment.rs | 31 | ||||
-rw-r--r-- | tests/wpt/metadata-css/css21_dev/html4/max-width-110.htm.ini | 3 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 96 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/250x250_green.png | bin | 0 -> 628 bytes | |||
-rw-r--r-- | tests/wpt/mozilla/tests/css/max_inline_block_size.html | 21 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/max_inline_block_size_canvas.html | 24 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/max_inline_block_size_image.html | 18 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/css/max_inline_block_size_ref.html | 20 |
8 files changed, 202 insertions, 11 deletions
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs index 439e8a79f60..03638be5fab 100644 --- a/components/layout/fragment.rs +++ b/components/layout/fragment.rs @@ -1029,12 +1029,15 @@ impl Fragment { fn style_specified_intrinsic_inline_size(&self) -> IntrinsicISizesContribution { let flags = self.quantities_included_in_intrinsic_inline_size(); let style = self.style(); - let specified = if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) { - max(model::specified(style.min_inline_size(), Au(0)), - MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero()) - } else { - Au(0) - }; + let mut specified = Au(0); + + if flags.contains(INTRINSIC_INLINE_SIZE_INCLUDES_SPECIFIED) { + specified = MaybeAuto::from_style(style.content_inline_size(), Au(0)).specified_or_zero(); + specified = max(model::specified(style.min_inline_size(), Au(0)), specified); + if let Some(max) = model::specified_or_none(style.max_inline_size(), Au(0)) { + specified = min(specified, max) + } + } // FIXME(#2261, pcwalton): This won't work well for inlines: is this OK? let surrounding_inline_size = self.surrounding_intrinsic_inline_size(); @@ -1375,7 +1378,7 @@ impl Fragment { result.union_block(&block_flow.base.intrinsic_inline_sizes) } SpecificFragmentInfo::Image(ref mut image_fragment_info) => { - let image_inline_size = match self.style.content_inline_size() { + let mut image_inline_size = match self.style.content_inline_size() { LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Percentage(_) => { image_fragment_info.image_inline_size() @@ -1383,13 +1386,19 @@ impl Fragment { LengthOrPercentageOrAuto::Length(length) => length, LengthOrPercentageOrAuto::Calc(calc) => calc.length(), }; + + image_inline_size = max(model::specified(self.style.min_inline_size(), Au(0)), image_inline_size); + if let Some(max) = model::specified_or_none(self.style.max_inline_size(), Au(0)) { + image_inline_size = min(image_inline_size, max) + } + result.union_block(&IntrinsicISizes { minimum_inline_size: image_inline_size, preferred_inline_size: image_inline_size, }); } SpecificFragmentInfo::Canvas(ref mut canvas_fragment_info) => { - let canvas_inline_size = match self.style.content_inline_size() { + let mut canvas_inline_size = match self.style.content_inline_size() { LengthOrPercentageOrAuto::Auto | LengthOrPercentageOrAuto::Percentage(_) => { canvas_fragment_info.canvas_inline_size() @@ -1397,6 +1406,12 @@ impl Fragment { LengthOrPercentageOrAuto::Length(length) => length, LengthOrPercentageOrAuto::Calc(calc) => calc.length(), }; + + canvas_inline_size = max(model::specified(self.style.min_inline_size(), Au(0)), canvas_inline_size); + if let Some(max) = model::specified_or_none(self.style.max_inline_size(), Au(0)) { + canvas_inline_size = min(canvas_inline_size, max) + } + result.union_block(&IntrinsicISizes { minimum_inline_size: canvas_inline_size, preferred_inline_size: canvas_inline_size, diff --git a/tests/wpt/metadata-css/css21_dev/html4/max-width-110.htm.ini b/tests/wpt/metadata-css/css21_dev/html4/max-width-110.htm.ini deleted file mode 100644 index bbc6b87885f..00000000000 --- a/tests/wpt/metadata-css/css21_dev/html4/max-width-110.htm.ini +++ /dev/null @@ -1,3 +0,0 @@ -[max-width-110.htm] - type: reftest - expected: FAIL diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index 25c5cd18688..df6a6e7ad41 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -3179,6 +3179,54 @@ "url": "/_mozilla/css/marker_block_direction_placement_a.html" } ], + "css/max_inline_block_size.html": [ + { + "path": "css/max_inline_block_size.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size.html" + } + ], + "css/max_inline_block_size_canvas.html": [ + { + "path": "css/max_inline_block_size_canvas.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_canvas.html" + } + ], + "css/max_inline_block_size_image.html": [ + { + "path": "css/max_inline_block_size_image.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_image.html" + } + ], + "css/max_inline_block_size_ref.html": [ + { + "path": "css/max_inline_block_size_ref.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_ref.html" + } + ], "css/max_width_float_simple_a.html": [ { "path": "css/max_width_float_simple_a.html", @@ -9709,6 +9757,54 @@ "url": "/_mozilla/css/marker_block_direction_placement_a.html" } ], + "css/max_inline_block_size.html": [ + { + "path": "css/max_inline_block_size.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size.html" + } + ], + "css/max_inline_block_size_canvas.html": [ + { + "path": "css/max_inline_block_size_canvas.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_canvas.html" + } + ], + "css/max_inline_block_size_image.html": [ + { + "path": "css/max_inline_block_size_image.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_image.html" + } + ], + "css/max_inline_block_size_ref.html": [ + { + "path": "css/max_inline_block_size_ref.html", + "references": [ + [ + "/_mozilla/css/max_inline_block_size_ref.html", + "==" + ] + ], + "url": "/_mozilla/css/max_inline_block_size_ref.html" + } + ], "css/max_width_float_simple_a.html": [ { "path": "css/max_width_float_simple_a.html", diff --git a/tests/wpt/mozilla/tests/css/250x250_green.png b/tests/wpt/mozilla/tests/css/250x250_green.png Binary files differnew file mode 100644 index 00000000000..586ef3d69d6 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/250x250_green.png diff --git a/tests/wpt/mozilla/tests/css/max_inline_block_size.html b/tests/wpt/mozilla/tests/css/max_inline_block_size.html new file mode 100644 index 00000000000..f0f23893143 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/max_inline_block_size.html @@ -0,0 +1,21 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Max inline-block size inside another inline-block element</title> +<link rel="match" href="max_inline_block_size_ref.html"> +<style> +html, body { margin: 0; padding: 0; } + +div { display: inline-block; } + +#a { + background: red; +} + +#b { + background: rgb(0, 255, 0); + width: 500px; + max-width: 250px; + height: 250px; +} +</style> +<div id="a"><div id="b"></div></div> diff --git a/tests/wpt/mozilla/tests/css/max_inline_block_size_canvas.html b/tests/wpt/mozilla/tests/css/max_inline_block_size_canvas.html new file mode 100644 index 00000000000..48cd896a2b7 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/max_inline_block_size_canvas.html @@ -0,0 +1,24 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Max inline-block size inside another inline-block element</title> +<link rel="match" href="max_inline_block_size_ref.html"> +<style> +html, body { margin: 0; padding: 0; } + +div, canvas { display: inline-block; } + +#a { + background: red; +} + +#c { + max-width: 250px; + height: 250px; +} +</style> +<div id="a"><canvas width="500" height="250" id="c"></canvas></div> +<script> + var c = document.getElementById("c").getContext("2d"); + c.fillStyle = "rgb(0, 255, 0)"; + c.fillRect(0, 0, c.canvas.width, c.canvas.height); +</script> diff --git a/tests/wpt/mozilla/tests/css/max_inline_block_size_image.html b/tests/wpt/mozilla/tests/css/max_inline_block_size_image.html new file mode 100644 index 00000000000..283bbd43256 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/max_inline_block_size_image.html @@ -0,0 +1,18 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Max inline-block size inside another inline-block element</title> +<link rel="match" href="max_inline_block_size_ref.html"> +<style> +html, body { margin: 0; padding: 0; } + +div, img { display: inline-block; } + +#a { + background: red; +} + +#b { + max-width: 250px; +} +</style> +<div id="a"><img id="b" width="500" height="250" src="250x250_green.png"></div> diff --git a/tests/wpt/mozilla/tests/css/max_inline_block_size_ref.html b/tests/wpt/mozilla/tests/css/max_inline_block_size_ref.html new file mode 100644 index 00000000000..7fa1370faf7 --- /dev/null +++ b/tests/wpt/mozilla/tests/css/max_inline_block_size_ref.html @@ -0,0 +1,20 @@ +<!doctype html> +<meta charset="utf-8"> +<title>Max inline-block size inside another inline-block element</title> +<link rel="match" href="max_inline_block_size_ref.html"> +<style> +html, body { margin: 0; padding: 0; } + +div { display: inline-block; } + +#a { + background: red; +} + +#b { + background: rgb(0, 255, 0); + width: 250px; + height: 250px; +} +</style> +<div id="a"><div id="b"></div></div> |