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 new file mode 100644 index 00000000000..586ef3d69d6 Binary files /dev/null and b/tests/wpt/mozilla/tests/css/250x250_green.png differ 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 @@ + + +