Skip to content

Commit dcfdb44

Browse files
xidachenbfgeek
authored andcommitted
[CSS Paint API] Pass snapped concrete size to paint function (w3c#518)
Fixes w3c#508
1 parent 4e21469 commit dcfdb44

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

css-paint-api/Overview.bs

+14-10
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,12 @@ Note: The user agent can optionally defer drawing images which are <a>paint-inva
451451
</div>
452452

453453
The <a>draw a paint image</a> function is invoked by the user agent during the <a>object size
454-
negotiation</a> algorithm which is responsible for rendering an <<image>>, with |concreteObjectSize|
455-
set to the <a>concrete object size</a> of the <a>box</a>.
454+
negotiation</a> algorithm which is responsible for rendering an <<image>>, with |snappedConcreteObjectSize|
455+
defined as follows. Let |concreteObjectSize| be the <a>concrete object size</a> of the <a>box</a>.
456+
The |snappedConcreteObjectSize| is usually the same as the |concreteObjectSize|. However, the
457+
user agent may adjust the size such that it paints to pixel boundaries. If it does, the user agent
458+
should adjust the |snappedConcreteObjectSize| by the proportional change from its original size
459+
such that the <<paint()>> function can adjust the drawing accordingly.
456460

457461
For the purposes of the <a>object size negotiation</a> algorithm, the paint image has no
458462
<a>intrinsic dimensions</a>.
@@ -463,15 +467,15 @@ Note: In a future version of the spec, the author could have the ability to spec
463467
dimensions</a> based on computed style and size changes.
464468

465469
The {{PaintSize}} object represents the size of the image that the author should draw. This is
466-
the <a>concrete object size</a> given by the user agent.
470+
the |snappedConcreteObjectSize| given by the user agent.
467471

468472
Note: See [[css-images-3#object-sizing-examples]] for examples on how the <a>concrete object
469473
size</a> is calculated.
470474

471475
The <a>draw a paint image</a> function may be speculatively invoked by the user agent at any point,
472-
with any |concreteObjectSize|. The resulting image is not displayed.
476+
with any |snappedConcreteObjectSize|. The resulting image is not displayed.
473477

474-
Note: User agents may use any heuristic to speculate a possible future value for |concretObjectSize|,
478+
Note: User agents may use any heuristic to speculate a possible future value for |snappedConcretObjectSize|,
475479
for example speculating that the size remains unchanged.
476480

477481
Note: Although the image is not displayed, it may still be cached, and subsequent invocations of
@@ -488,12 +492,12 @@ interface PaintSize {
488492
<div algorithm>
489493
When the user agent wants to <dfn>draw a paint image</dfn> of a <<paint()>> function for a |box|
490494
into its appropriate stacking level (as defined by the property the CSS property its associated
491-
with), given |concreteObjectSize| it <em>must</em> run the following steps:
495+
with), given |snappedConcreteObjectSize| it <em>must</em> run the following steps:
492496
1. Let |paintFunction| be the <<paint()>> function on the |box| which the user agent wants to
493497
draw.
494498

495499
2. If the <a>paint valid flag</a> for the |paintFunction| is <a>paint-valid</a>, and the
496-
previous invocation had the same |concreteObjectSize|, the user agent <em>may</em> use the
500+
previous invocation had the same |snappedConcreteObjectSize|, the user agent <em>may</em> use the
497501
drawn image from the previous invocation. If so it <em>may</em> abort all these steps and
498502
use the previously drawn image.
499503

@@ -572,7 +576,7 @@ with), given |concreteObjectSize| it <em>must</em> run the following steps:
572576
The user agent <em>may</em> also <a>create a WorkletGlobalScope</a> at this time, given the
573577
paint {{Worklet}}.
574578

575-
13. Run <a>invoke a paint callback</a> given |name|, |inputArguments|, |concreteObjectSize|,
579+
13. Run <a>invoke a paint callback</a> given |name|, |inputArguments|, |snappedConcreteObjectSize|,
576580
|workletGlobalScope| optionally <a>in parallel</a>.
577581

578582
Note: If the user agent runs <a>invoke a paint callback</a> on a thread <a>in parallel</a>,
@@ -581,7 +585,7 @@ with), given |concreteObjectSize| it <em>must</em> run the following steps:
581585

582586
<div algorithm>
583587
When the user agent wants to <dfn>invoke a paint callback</dfn> given |name|, |inputArguments|,
584-
|concreteObjectSize|, and |workletGlobalScope|, it <em>must</em> run the following steps:
588+
|snappedConcreteObjectSize|, and |workletGlobalScope|, it <em>must</em> run the following steps:
585589

586590
1. Let |paintDefinitionMap| be |workletGlobalScope|'s <a>paint definitions</a> map.
587591

@@ -646,7 +650,7 @@ When the user agent wants to <dfn>invoke a paint callback</dfn> given |name|, |i
646650
images.
647651

648652
9. Let |paintSize| be a new {{PaintSize}} initialized to the width and height defined by
649-
|concreteObjectSize|.
653+
|snappedConcreteObjectSize|.
650654

651655
10. At this stage the user agent may re-use an image from a previous invocation if |paintSize|,
652656
|styleMap|, |inputArguments| are equivalent to that previous invocation. If so let the image

0 commit comments

Comments
 (0)