Truly independent web browser
LibWeb: Honor object-fit and object-position on canvases
sideshowbarker3714c4569a1a
diff --git a/Libraries/LibWeb/Painting/PaintFacts.cpp b/Libraries/LibWeb/Painting/PaintFacts.cppindex b4895be55f9..e463bca0a65 100644--- a/Libraries/LibWeb/Painting/PaintFacts.cpp+++ b/Libraries/LibWeb/Painting/PaintFacts.cpp@@ -66,6 +66,8 @@ static void queue_canvas_paint_facts(HTML::HTMLCanvasElement const& canvas)// NB: The output bitmap of an ImageBitmapRenderingContext is painted as the image of the canvas.if (auto const* bitmap_renderer = canvas.canvas_bitmap_renderer_context()) {Layout::RustFFI::FfiReplacedImagePaintFacts image_facts {};+ image_facts.natural.width = CSSPixels(canvas.width());+ image_facts.natural.height = CSSPixels(canvas.height());if (auto const* frame = bitmap_renderer->frame()) {image_facts.content.kind = Layout::RustFFI::FfiImageContentKind::Raster;image_facts.content.frame = frame;diff --git a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rsindex bbd76c71890..58559d5b095 100644--- a/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs+++ b/Libraries/LibWeb/Rust/src/painting/record/paint/replaced.rs@@ -20,7 +20,7 @@ use crate::painting::force_dark::ForceDarkRole;use crate::painting::paintable_geometry::absolute_rect;use crate::painting::record::PaintRecorder;use crate::painting::record::paint::background::{paint_image_content, to_gfx_scaling_mode};-use crate::painting::replaced_paint_facts::VideoPaintFacts;+use crate::painting::replaced_paint_facts::{ReplacedPaintFacts, VideoPaintFacts};use crate::painting::visual_context::node_values::padding_edge_border_radii;use libgfx_rust::{Color, CornerRadii, FloatRect, IntRect, ScalingMode};@@ -257,53 +257,76 @@ fn paint_custom_highlight_washes<O: Observer>(}pub(crate) fn paint_canvas_foreground<O: Observer>(recorder: &mut PaintRecorder<'_, O>, paintable: NodeSlotId) {- let replaced_facts = recorder.source.replaced_paint_facts(paintable);- let (_, image_rendering) = replaced_style(recorder, paintable);+ let Some(facts) = recorder.source.replaced_paint_facts(paintable) else {+ return;+ };+ let natural_size = match &facts {+ ReplacedPaintFacts::Image(image) if image.content != crate::painting::image_content::ImageContent::None => {+ CssPixelSize::new(+ image.natural.width.unwrap_or_default(),+ image.natural.height.unwrap_or_default(),+ )+ }+ ReplacedPaintFacts::Canvas(canvas) if canvas.has_content => CssPixelSize::new(+ CssPixels::from_integer(i64::from(canvas.content_width)),+ CssPixels::from_integer(i64::from(canvas.content_height)),+ ),+ _ => return,+ };+ let (object_fit, image_rendering) = replaced_style(recorder, paintable);let canvas_rect = recorder.converter.rounded_device_rect(absolute_rect(recorder.source, paintable));-- // NB: A canvas whose context is an ImageBitmapRenderingContext paints the output bitmap of the context as its image.- // AD-HOC: The spec has the canvas take the natural dimensions of its output bitmap. Instead, the canvas keeps the- // natural dimensions its width and height attributes give it, and the output bitmap is stretched to fill- // its content box — so a transfer never changes the layout of the page.- // https://html.spec.whatwg.org/multipage/canvas.html#the-canvas-element- // FIXME: Composite the output bitmap onto opaque black when the alpha flag of the context is false.- if let Some(image_facts) = replaced_facts.clone().and_then(|facts| facts.image()) {- if image_facts.content == crate::painting::image_content::ImageContent::None {- return;- }- let (content_rect, corner_radii) = replaced_content_clip_geometry(recorder, paintable);- let corner_clip =- corner_radii.map(|corner_radii| PendingInlineClip::intersecting_rounded_rect(content_rect, corner_radii));- recorder.record_with_inline_clips(corner_clip.as_slice(), |recorder| {+ let zoom = recorder+ .source+ .node_style_if_live(paintable)+ .map_or(1.0, |style| style.effective_zoom());+ let natural_size = CssPixelSize::new(+ CssPixels::nearest_value_for(natural_size.width.to_double() * f64::from(zoom)),+ CssPixels::nearest_value_for(natural_size.height.to_double() * f64::from(zoom)),+ );+ let draw_rect = if natural_size.is_empty() {+ canvas_rect+ } else {+ get_replaced_box_painting_area(recorder, paintable, object_fit, natural_size)+ };+ if draw_rect.is_empty() {+ return;+ }+ let (content_rect, corner_radii) = replaced_content_clip_geometry(recorder, paintable);+ let mut inline_clips = Vec::new();+ if let Some(corner_radii) = corner_radii {+ inline_clips.push(PendingInlineClip::intersecting_rounded_rect(content_rect, corner_radii));+ }+ if !canvas_rect.contains_rect(draw_rect) {+ inline_clips.push(PendingInlineClip::intersecting_float_rect(content_rect));+ }+ recorder.record_with_inline_clips(&inline_clips, |recorder| match &facts {+ // AD-HOC: The spec has the canvas take the natural dimensions of its output bitmap. Instead, the canvas keeps+ // the dimensions its width and height attributes give it, and fits the bitmap using those dimensions.+ // So, transferring a bitmap never changes the layout of the page.+ // https://html.spec.whatwg.org/multipage/canvas.html#the-canvas-element+ // FIXME: Composite the output bitmap onto opaque black when the alpha flag of the context is false.+ ReplacedPaintFacts::Image(image) => {paint_replaced_image_content(recorder,paintable,- &image_facts.content,- canvas_rect.to_float(),+ &image.content,+ draw_rect.to_float(),image_rendering,);- });- return;- }-- let facts = replaced_facts.and_then(|facts| facts.canvas()).unwrap_or_default();- if !facts.has_content {- return;- }- let (content_rect, corner_radii) = replaced_content_clip_geometry(recorder, paintable);- let corner_clip =- corner_radii.map(|corner_radii| PendingInlineClip::intersecting_rounded_rect(content_rect, corner_radii));- recorder.record_with_inline_clips(corner_clip.as_slice(), |recorder| {- let scaling_mode = to_gfx_scaling_mode(- image_rendering,- (facts.content_width, facts.content_height),- (canvas_rect.width, canvas_rect.height),- );- recorder- .recorder- .draw_canvas(canvas_rect, CanvasId(facts.canvas_id), scaling_mode);+ }+ ReplacedPaintFacts::Canvas(canvas) => {+ let scaling_mode = to_gfx_scaling_mode(+ image_rendering,+ (canvas.content_width, canvas.content_height),+ (draw_rect.width, draw_rect.height),+ );+ recorder+ .recorder+ .draw_canvas(draw_rect, CanvasId(canvas.canvas_id), scaling_mode);+ }+ _ => unreachable!(),});}diff --git a/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs b/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rsindex 074aeb91066..0871569b0c9 100644--- a/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs+++ b/Libraries/LibWeb/Rust/src/painting/replaced_paint_facts.rs@@ -143,13 +143,6 @@ impl ReplacedPaintFacts {}}- pub(crate) fn canvas(self) -> Option<FfiCanvasPaintFacts> {- match self {- Self::Canvas(facts) => Some(facts),- _ => None,- }- }-pub(crate) fn navigable_container(self) -> Option<FfiNavigableContainerPaintFacts> {match self {Self::NavigableContainer(facts) => Some(facts),diff --git a/Tests/LibWeb/Ref/expected/canvas-object-fit-contexts-ref.html b/Tests/LibWeb/Ref/expected/canvas-object-fit-contexts-ref.htmlnew file mode 100644index 00000000000..c03404a4c3d--- /dev/null+++ b/Tests/LibWeb/Ref/expected/canvas-object-fit-contexts-ref.html@@ -0,0 +1,36 @@+<!doctype html>+<html class="reftest-wait">+<meta charset="utf-8">+<style>+body { margin: 0; }+.case { display: inline-block; position: relative; width: 80px; height: 80px; margin: 4px; background: gray; overflow: hidden; }+canvas { display: block; image-rendering: pixelated; }+.zoom { zoom: 2; }+</style>+<div class="case"><canvas width="16" height="8" data-context="2d" style="position:absolute;width:80px;height:40px;left:0;top:40px;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="bitmap" style="position:absolute;width:80px;height:40px;left:0;top:40px;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="offscreen" style="position:absolute;width:80px;height:40px;left:0;top:40px;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="bitmap" style="position:absolute;width:160px;height:80px;left:-40px;top:0;"></canvas></div>+<div class="case zoom"><canvas width="16" height="8" data-context="bitmap" style="position:absolute;width:16px;height:8px;left:61px;top:67px;"></canvas></div>+<div class="case"><canvas width="0" height="8" data-context="bitmap" style="width:80px;height:80px;"></canvas></div>+<script>+ function draw(context) {+ context.fillStyle = "red";+ context.fillRect(0, 0, context.canvas.width, context.canvas.height);+ context.fillStyle = "lime";+ context.fillRect(0, 0, context.canvas.width / 2, context.canvas.height / 2);+ }+ Promise.all([...document.querySelectorAll("canvas")].map(async canvas => {+ if (canvas.dataset.context === "bitmap") {+ const source = new OffscreenCanvas(8, 16);+ draw(source.getContext("2d"));+ canvas.getContext("bitmaprenderer").transferFromImageBitmap(source.transferToImageBitmap());+ } else if (canvas.dataset.context === "offscreen") {+ draw(canvas.transferControlToOffscreen().getContext("2d"));+ } else {+ draw(canvas.getContext("2d"));+ }+ })).then(() => requestAnimationFrame(() => requestAnimationFrame(() => {+ document.documentElement.classList.remove("reftest-wait");+ })));+</script>diff --git a/Tests/LibWeb/Ref/expected/canvas-object-fit-small-zoom-ref.html b/Tests/LibWeb/Ref/expected/canvas-object-fit-small-zoom-ref.htmlnew file mode 100644index 00000000000..a78df1a8db5--- /dev/null+++ b/Tests/LibWeb/Ref/expected/canvas-object-fit-small-zoom-ref.html@@ -0,0 +1,6 @@+<!doctype html>+<style>+body { margin: 0; }+div { width: 100px; height: 100px; background: red; }+</style>+<div></div>diff --git a/Tests/LibWeb/Ref/input/canvas-object-fit-contexts.html b/Tests/LibWeb/Ref/input/canvas-object-fit-contexts.htmlnew file mode 100644index 00000000000..1977790c4e8--- /dev/null+++ b/Tests/LibWeb/Ref/input/canvas-object-fit-contexts.html@@ -0,0 +1,37 @@+<!doctype html>+<html class="reftest-wait">+<meta charset="utf-8">+<link rel="match" href="../expected/canvas-object-fit-contexts-ref.html">+<style>+body { margin: 0; }+.case { display: inline-block; position: relative; width: 80px; height: 80px; margin: 4px; background: gray; }+canvas { display: block; image-rendering: pixelated; }+.zoom { zoom: 2; }+</style>+<div class="case"><canvas width="16" height="8" data-context="2d" style="width:80px;height:80px;object-fit:contain;object-position:right bottom;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="bitmap" style="width:80px;height:80px;object-fit:contain;object-position:right bottom;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="offscreen" style="width:80px;height:80px;object-fit:contain;object-position:right bottom;"></canvas></div>+<div class="case"><canvas width="16" height="8" data-context="bitmap" style="width:80px;height:80px;object-fit:cover;object-position:center;"></canvas></div>+<div class="case zoom"><canvas width="16" height="8" data-context="bitmap" style="width:80px;height:80px;object-fit:none;object-position:right 3px bottom 5px;"></canvas></div>+<div class="case"><canvas width="0" height="8" data-context="bitmap" style="width:80px;height:80px;object-fit:contain;"></canvas></div>+<script>+ function draw(context) {+ context.fillStyle = "red";+ context.fillRect(0, 0, context.canvas.width, context.canvas.height);+ context.fillStyle = "lime";+ context.fillRect(0, 0, context.canvas.width / 2, context.canvas.height / 2);+ }+ Promise.all([...document.querySelectorAll("canvas")].map(async canvas => {+ if (canvas.dataset.context === "bitmap") {+ const source = new OffscreenCanvas(8, 16);+ draw(source.getContext("2d"));+ canvas.getContext("bitmaprenderer").transferFromImageBitmap(source.transferToImageBitmap());+ } else if (canvas.dataset.context === "offscreen") {+ draw(canvas.transferControlToOffscreen().getContext("2d"));+ } else {+ draw(canvas.getContext("2d"));+ }+ })).then(() => requestAnimationFrame(() => requestAnimationFrame(() => {+ document.documentElement.classList.remove("reftest-wait");+ })));+</script>diff --git a/Tests/LibWeb/Ref/input/canvas-object-fit-small-zoom.html b/Tests/LibWeb/Ref/input/canvas-object-fit-small-zoom.htmlnew file mode 100644index 00000000000..5704d17a268--- /dev/null+++ b/Tests/LibWeb/Ref/input/canvas-object-fit-small-zoom.html@@ -0,0 +1,16 @@+<!doctype html>+<html class="reftest-wait">+<link rel="match" href="../expected/canvas-object-fit-small-zoom-ref.html">+<style>+body { margin: 0; }+canvas { display: block; zoom: 0.005; width: 20000px; height: 20000px; }+</style>+<canvas width="1" height="1"></canvas>+<script>+ const context = document.querySelector("canvas").getContext("2d");+ context.fillStyle = "red";+ context.fillRect(0, 0, 1, 1);+ requestAnimationFrame(() => requestAnimationFrame(() => {+ document.documentElement.classList.remove("reftest-wait");+ }));+</script>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-001c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-001c.htmlnew file mode 100644index 00000000000..3dbba1b8184--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-001c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: contain' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-contain-png-001-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: contain;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-16x8.png')">+ <!-- big/wide: -->+ <canvas width="16" height="8" class="bigWide tr"></canvas>+ <canvas width="16" height="8" class="bigWide bl"></canvas>+ <canvas width="16" height="8" class="bigWide tl"></canvas>+ <canvas width="16" height="8" class="bigWide br"></canvas>+ <canvas width="16" height="8" class="bigWide tc"></canvas>+ <canvas width="16" height="8" class="bigWide cr"></canvas>+ <canvas width="16" height="8" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="16" height="8" class="bigTall tr"></canvas>+ <canvas width="16" height="8" class="bigTall bl"></canvas>+ <canvas width="16" height="8" class="bigTall tl"></canvas>+ <canvas width="16" height="8" class="bigTall br"></canvas>+ <canvas width="16" height="8" class="bigTall tc"></canvas>+ <canvas width="16" height="8" class="bigTall cr"></canvas>+ <canvas width="16" height="8" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="16" height="8" class="small tr"></canvas>+ <canvas width="16" height="8" class="small bl"></canvas>+ <canvas width="16" height="8" class="small tl"></canvas>+ <canvas width="16" height="8" class="small br"></canvas>+ <canvas width="16" height="8" class="small tc"></canvas>+ <canvas width="16" height="8" class="small cr"></canvas>+ <canvas width="16" height="8" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-002c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-002c.htmlnew file mode 100644index 00000000000..76f58006a12--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-contain-png-002c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: contain' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-contain-png-002-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: contain;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-8x16.png')">+ <!-- big/wide: -->+ <canvas width="8" height="16" class="bigWide tr"></canvas>+ <canvas width="8" height="16" class="bigWide bl"></canvas>+ <canvas width="8" height="16" class="bigWide tl"></canvas>+ <canvas width="8" height="16" class="bigWide br"></canvas>+ <canvas width="8" height="16" class="bigWide tc"></canvas>+ <canvas width="8" height="16" class="bigWide cr"></canvas>+ <canvas width="8" height="16" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="8" height="16" class="bigTall tr"></canvas>+ <canvas width="8" height="16" class="bigTall bl"></canvas>+ <canvas width="8" height="16" class="bigTall tl"></canvas>+ <canvas width="8" height="16" class="bigTall br"></canvas>+ <canvas width="8" height="16" class="bigTall tc"></canvas>+ <canvas width="8" height="16" class="bigTall cr"></canvas>+ <canvas width="8" height="16" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="8" height="16" class="small tr"></canvas>+ <canvas width="8" height="16" class="small bl"></canvas>+ <canvas width="8" height="16" class="small tl"></canvas>+ <canvas width="8" height="16" class="small br"></canvas>+ <canvas width="8" height="16" class="small tc"></canvas>+ <canvas width="8" height="16" class="small cr"></canvas>+ <canvas width="8" height="16" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-001c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-001c.htmlnew file mode 100644index 00000000000..606e4e5ce03--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-001c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: cover' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-cover-png-001-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: cover;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-16x8.png')">+ <!-- big/wide: -->+ <canvas width="16" height="8" class="bigWide tr"></canvas>+ <canvas width="16" height="8" class="bigWide bl"></canvas>+ <canvas width="16" height="8" class="bigWide tl"></canvas>+ <canvas width="16" height="8" class="bigWide br"></canvas>+ <canvas width="16" height="8" class="bigWide tc"></canvas>+ <canvas width="16" height="8" class="bigWide cr"></canvas>+ <canvas width="16" height="8" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="16" height="8" class="bigTall tr"></canvas>+ <canvas width="16" height="8" class="bigTall bl"></canvas>+ <canvas width="16" height="8" class="bigTall tl"></canvas>+ <canvas width="16" height="8" class="bigTall br"></canvas>+ <canvas width="16" height="8" class="bigTall tc"></canvas>+ <canvas width="16" height="8" class="bigTall cr"></canvas>+ <canvas width="16" height="8" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="16" height="8" class="small tr"></canvas>+ <canvas width="16" height="8" class="small bl"></canvas>+ <canvas width="16" height="8" class="small tl"></canvas>+ <canvas width="16" height="8" class="small br"></canvas>+ <canvas width="16" height="8" class="small tc"></canvas>+ <canvas width="16" height="8" class="small cr"></canvas>+ <canvas width="16" height="8" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-002c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-002c.htmlnew file mode 100644index 00000000000..bd5b2fb05a8--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-cover-png-002c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: cover' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-cover-png-002-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: cover;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-8x16.png')">+ <!-- big/wide: -->+ <canvas width="8" height="16" class="bigWide tr"></canvas>+ <canvas width="8" height="16" class="bigWide bl"></canvas>+ <canvas width="8" height="16" class="bigWide tl"></canvas>+ <canvas width="8" height="16" class="bigWide br"></canvas>+ <canvas width="8" height="16" class="bigWide tc"></canvas>+ <canvas width="8" height="16" class="bigWide cr"></canvas>+ <canvas width="8" height="16" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="8" height="16" class="bigTall tr"></canvas>+ <canvas width="8" height="16" class="bigTall bl"></canvas>+ <canvas width="8" height="16" class="bigTall tl"></canvas>+ <canvas width="8" height="16" class="bigTall br"></canvas>+ <canvas width="8" height="16" class="bigTall tc"></canvas>+ <canvas width="8" height="16" class="bigTall cr"></canvas>+ <canvas width="8" height="16" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="8" height="16" class="small tr"></canvas>+ <canvas width="8" height="16" class="small bl"></canvas>+ <canvas width="8" height="16" class="small tl"></canvas>+ <canvas width="8" height="16" class="small br"></canvas>+ <canvas width="8" height="16" class="small tc"></canvas>+ <canvas width="8" height="16" class="small cr"></canvas>+ <canvas width="8" height="16" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-001c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-001c.htmlnew file mode 100644index 00000000000..641f6ab2e5e--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-001c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: fill' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-fill-png-001-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: fill;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-16x8.png')">+ <!-- big/wide: -->+ <canvas width="16" height="8" class="bigWide tr"></canvas>+ <canvas width="16" height="8" class="bigWide bl"></canvas>+ <canvas width="16" height="8" class="bigWide tl"></canvas>+ <canvas width="16" height="8" class="bigWide br"></canvas>+ <canvas width="16" height="8" class="bigWide tc"></canvas>+ <canvas width="16" height="8" class="bigWide cr"></canvas>+ <canvas width="16" height="8" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="16" height="8" class="bigTall tr"></canvas>+ <canvas width="16" height="8" class="bigTall bl"></canvas>+ <canvas width="16" height="8" class="bigTall tl"></canvas>+ <canvas width="16" height="8" class="bigTall br"></canvas>+ <canvas width="16" height="8" class="bigTall tc"></canvas>+ <canvas width="16" height="8" class="bigTall cr"></canvas>+ <canvas width="16" height="8" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="16" height="8" class="small tr"></canvas>+ <canvas width="16" height="8" class="small bl"></canvas>+ <canvas width="16" height="8" class="small tl"></canvas>+ <canvas width="16" height="8" class="small br"></canvas>+ <canvas width="16" height="8" class="small tc"></canvas>+ <canvas width="16" height="8" class="small cr"></canvas>+ <canvas width="16" height="8" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-002c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-002c.htmlnew file mode 100644index 00000000000..c81cdc0fb13--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-fill-png-002c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: fill' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-fill-png-002-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: fill;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-8x16.png')">+ <!-- big/wide: -->+ <canvas width="8" height="16" class="bigWide tr"></canvas>+ <canvas width="8" height="16" class="bigWide bl"></canvas>+ <canvas width="8" height="16" class="bigWide tl"></canvas>+ <canvas width="8" height="16" class="bigWide br"></canvas>+ <canvas width="8" height="16" class="bigWide tc"></canvas>+ <canvas width="8" height="16" class="bigWide cr"></canvas>+ <canvas width="8" height="16" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="8" height="16" class="bigTall tr"></canvas>+ <canvas width="8" height="16" class="bigTall bl"></canvas>+ <canvas width="8" height="16" class="bigTall tl"></canvas>+ <canvas width="8" height="16" class="bigTall br"></canvas>+ <canvas width="8" height="16" class="bigTall tc"></canvas>+ <canvas width="8" height="16" class="bigTall cr"></canvas>+ <canvas width="8" height="16" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="8" height="16" class="small tr"></canvas>+ <canvas width="8" height="16" class="small bl"></canvas>+ <canvas width="8" height="16" class="small tl"></canvas>+ <canvas width="8" height="16" class="small br"></canvas>+ <canvas width="8" height="16" class="small tc"></canvas>+ <canvas width="8" height="16" class="small cr"></canvas>+ <canvas width="8" height="16" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-001c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-001c.htmlnew file mode 100644index 00000000000..eed132163bb--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-001c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: none' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-none-png-001-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: none;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-16x8.png')">+ <!-- big/wide: -->+ <canvas width="16" height="8" class="bigWide tr"></canvas>+ <canvas width="16" height="8" class="bigWide bl"></canvas>+ <canvas width="16" height="8" class="bigWide tl"></canvas>+ <canvas width="16" height="8" class="bigWide br"></canvas>+ <canvas width="16" height="8" class="bigWide tc"></canvas>+ <canvas width="16" height="8" class="bigWide cr"></canvas>+ <canvas width="16" height="8" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="16" height="8" class="bigTall tr"></canvas>+ <canvas width="16" height="8" class="bigTall bl"></canvas>+ <canvas width="16" height="8" class="bigTall tl"></canvas>+ <canvas width="16" height="8" class="bigTall br"></canvas>+ <canvas width="16" height="8" class="bigTall tc"></canvas>+ <canvas width="16" height="8" class="bigTall cr"></canvas>+ <canvas width="16" height="8" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="16" height="8" class="small tr"></canvas>+ <canvas width="16" height="8" class="small bl"></canvas>+ <canvas width="16" height="8" class="small tl"></canvas>+ <canvas width="16" height="8" class="small br"></canvas>+ <canvas width="16" height="8" class="small tc"></canvas>+ <canvas width="16" height="8" class="small cr"></canvas>+ <canvas width="16" height="8" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-002c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-002c.htmlnew file mode 100644index 00000000000..f0b6832be3c--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-none-png-002c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: none' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-none-png-002-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: none;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-8x16.png')">+ <!-- big/wide: -->+ <canvas width="8" height="16" class="bigWide tr"></canvas>+ <canvas width="8" height="16" class="bigWide bl"></canvas>+ <canvas width="8" height="16" class="bigWide tl"></canvas>+ <canvas width="8" height="16" class="bigWide br"></canvas>+ <canvas width="8" height="16" class="bigWide tc"></canvas>+ <canvas width="8" height="16" class="bigWide cr"></canvas>+ <canvas width="8" height="16" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="8" height="16" class="bigTall tr"></canvas>+ <canvas width="8" height="16" class="bigTall bl"></canvas>+ <canvas width="8" height="16" class="bigTall tl"></canvas>+ <canvas width="8" height="16" class="bigTall br"></canvas>+ <canvas width="8" height="16" class="bigTall tc"></canvas>+ <canvas width="8" height="16" class="bigTall cr"></canvas>+ <canvas width="8" height="16" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="8" height="16" class="small tr"></canvas>+ <canvas width="8" height="16" class="small bl"></canvas>+ <canvas width="8" height="16" class="small tl"></canvas>+ <canvas width="8" height="16" class="small br"></canvas>+ <canvas width="8" height="16" class="small tc"></canvas>+ <canvas width="8" height="16" class="small cr"></canvas>+ <canvas width="8" height="16" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-001c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-001c.htmlnew file mode 100644index 00000000000..5254fd496cf--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-001c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: scale-down' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-scale-down-png-001-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: scale-down;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-16x8.png')">+ <!-- big/wide: -->+ <canvas width="16" height="8" class="bigWide tr"></canvas>+ <canvas width="16" height="8" class="bigWide bl"></canvas>+ <canvas width="16" height="8" class="bigWide tl"></canvas>+ <canvas width="16" height="8" class="bigWide br"></canvas>+ <canvas width="16" height="8" class="bigWide tc"></canvas>+ <canvas width="16" height="8" class="bigWide cr"></canvas>+ <canvas width="16" height="8" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="16" height="8" class="bigTall tr"></canvas>+ <canvas width="16" height="8" class="bigTall bl"></canvas>+ <canvas width="16" height="8" class="bigTall tl"></canvas>+ <canvas width="16" height="8" class="bigTall br"></canvas>+ <canvas width="16" height="8" class="bigTall tc"></canvas>+ <canvas width="16" height="8" class="bigTall cr"></canvas>+ <canvas width="16" height="8" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="16" height="8" class="small tr"></canvas>+ <canvas width="16" height="8" class="small bl"></canvas>+ <canvas width="16" height="8" class="small tl"></canvas>+ <canvas width="16" height="8" class="small br"></canvas>+ <canvas width="16" height="8" class="small tc"></canvas>+ <canvas width="16" height="8" class="small cr"></canvas>+ <canvas width="16" height="8" class="small"></canvas>+ <br>+ </body>+</html>diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-002c.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-002c.htmlnew file mode 100644index 00000000000..5afe702cc89--- /dev/null+++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-images/object-fit-scale-down-png-002c.html@@ -0,0 +1,92 @@+<!DOCTYPE html>+<!--+ Any copyright is dedicated to the Public Domain.+ http://creativecommons.org/publicdomain/zero/1.0/+-->+<html class="reftest-wait">+ <head>+ <meta charset="utf-8">+ <title>CSS Test: 'object-fit: scale-down' on canvas element, with a PNG image and with various 'object-position' values</title>+ <link rel="author" title="Daniel Holbert" href="mailto:[email protected]">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#sizing">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-fit">+ <link rel="help" href="http://www.w3.org/TR/css3-images/#the-object-position">+ <link rel="match" href="../../../../expected/wpt-import/css/css-images/object-fit-scale-down-png-002-ref.html">+ <style type="text/css">+ canvas {+ border: 1px dashed gray;+ padding: 1px;+ object-fit: scale-down;+ image-rendering: pixelated; /* for UAs that don't support crisp-edges */+ image-rendering: crisp-edges;+ float: left;+ }++ .bigWide {+ width: 48px;+ height: 32px;+ }+ .bigTall {+ width: 32px;+ height: 48px;+ }+ .small {+ width: 8px;+ height: 8px;+ }++ br { clear: both; }++ .tr { object-position: top right }+ .bl { object-position: bottom left }+ .tl { object-position: top 25% left 25% }+ .br { object-position: bottom 1px right 2px }++ .tc { object-position: top 3px left 50% }+ .cr { object-position: top 50% right 25% }+ </style>+ <script>+ function drawImageToCanvases(imageURI) {+ var image = new Image();+ image.onload = function() {+ var canvasElems = document.getElementsByTagName("canvas");+ for (var i = 0; i < canvasElems.length; i++) {+ var ctx = canvasElems[i].getContext("2d");+ ctx.drawImage(image, 0, 0);+ }+ document.documentElement.removeAttribute("class");+ }+ image.src = imageURI;+ }+ </script>+ </head>+ <body onload="drawImageToCanvases('support/colors-8x16.png')">+ <!-- big/wide: -->+ <canvas width="8" height="16" class="bigWide tr"></canvas>+ <canvas width="8" height="16" class="bigWide bl"></canvas>+ <canvas width="8" height="16" class="bigWide tl"></canvas>+ <canvas width="8" height="16" class="bigWide br"></canvas>+ <canvas width="8" height="16" class="bigWide tc"></canvas>+ <canvas width="8" height="16" class="bigWide cr"></canvas>+ <canvas width="8" height="16" class="bigWide"></canvas>+ <br>+ <!-- big/tall: -->+ <canvas width="8" height="16" class="bigTall tr"></canvas>+ <canvas width="8" height="16" class="bigTall bl"></canvas>+ <canvas width="8" height="16" class="bigTall tl"></canvas>+ <canvas width="8" height="16" class="bigTall br"></canvas>+ <canvas width="8" height="16" class="bigTall tc"></canvas>+ <canvas width="8" height="16" class="bigTall cr"></canvas>+ <canvas width="8" height="16" class="bigTall"></canvas>+ <br>+ <!-- small: -->+ <canvas width="8" height="16" class="small tr"></canvas>+ <canvas width="8" height="16" class="small bl"></canvas>+ <canvas width="8" height="16" class="small tl"></canvas>+ <canvas width="8" height="16" class="small br"></canvas>+ <canvas width="8" height="16" class="small tc"></canvas>+ <canvas width="8" height="16" class="small cr"></canvas>+ <canvas width="8" height="16" class="small"></canvas>+ <br>+ </body>+</html>