Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions components/layout/display_list_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1154,10 +1154,14 @@ impl FragmentDisplayListBuilding for Fragment {
paint_worklet: &PaintWorklet,
index: usize)
{
// TODO: check that this is the servo equivalent of "concrete object size".
// This should be the "concrete object size" of the fragment.
// https://drafts.css-houdini.org/css-paint-api/#draw-a-paint-image
// https://drafts.csswg.org/css-images-3/#concrete-object-size
let size = self.content_box().size.to_physical(style.writing_mode);
// Experimentally, chrome is using the size in px of the box,
// including padding, but not border or margin, so we follow suit.
// https://github.com/w3c/css-houdini-drafts/issues/417
let unbordered_box = self.border_box - style.logical_border_width();
let size = unbordered_box.size.to_physical(style.writing_mode);
let name = paint_worklet.name.clone();

// If the script thread has not added any paint worklet modules, there is nothing to do!
Expand Down
34 changes: 34 additions & 0 deletions tests/wpt/mozilla/meta/MANIFEST.json
Original file line number Diff line number Diff line change
Expand Up @@ -6772,6 +6772,18 @@
],
{}
]
],
"mozilla/worklets/test_paint_worklet_size.html": [
[
"/_mozilla/mozilla/worklets/test_paint_worklet_size.html",
[
[
"/_mozilla/mozilla/worklets/test_paint_worklet_ref.html",
"=="
]
],
{}
]
]
},
"reftest_node": {
Expand Down Expand Up @@ -11264,6 +11276,16 @@
{}
]
],
"mozilla/worklets/test_paint_worklet_size.js": [
[
{}
]
],
"mozilla/worklets/test_paint_worklet_size_ref.html": [
[
{}
]
],
"mozilla/worklets/test_worklet.js": [
[
{}
Expand Down Expand Up @@ -31889,6 +31911,18 @@
"e9cfa945824a8ecf07c41a269f82a2c2ca002406",
"support"
],
"mozilla/worklets/test_paint_worklet_size.html": [
"6ddcf8ad81eaf4a5112de39a87cbd3d290fd9ab4",
"reftest"
],
"mozilla/worklets/test_paint_worklet_size.js": [
"07bbe5099c4e721da1ca9cc8cbf5196e7e6e9510",
"support"
],
"mozilla/worklets/test_paint_worklet_size_ref.html": [
"7c92e508e08d7d146354a5be7fa256ccbd465dde",
"support"
],
"mozilla/worklets/test_worklet.html": [
"fe9c93a5307c616f878b6623155e1b04c86dd994",
"testharness"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[test_paint_worklet_size.html]
type: reftest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh? Why expected fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Paint rendering contexts haven't landed yet, that's #17326.

expected: FAIL
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!doctype html>
<html class="reftest-wait">
<head>
<meta charset=utf-8>
<title>Test the size parameter of paint worklets</title>
<link rel=match href=/_mozilla/mozilla/worklets/test_paint_worklet_ref.html>
</head>
<body>
<div style="height: 100px; width: 200px; background: paint(test);
margin: 10px; border: 3px solid blue; padding: 5px;"></div>
</body>
<script>
window.paintWorklet
.addModule("test_paint_worklet_size.js")
.then(function() { document.documentElement.classList.remove("reftest-wait"); });
</script>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
registerPaint("test", class {
paint(ctx, size) {
if ((size.width === 210) && (size.height === 110)) {
ctx.fillStyle = "green";
ctx.fillRect(0, 0, size.width, size.height);
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<!doctype html>
<html>
<body>
<div style="height: 100px; width: 200px; background: green;
margin: 10px; border: 3px solid blue; padding: 5px;"></div>
</body>
</html>