Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify what 'contentful' means #66

Merged
merged 22 commits into from
Mar 20, 2020
Merged
Changes from 18 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
78 changes: 76 additions & 2 deletions painttiming.bs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,39 @@ urlPrefix: https://www.w3.org/TR/hr-time-2/#idl-def-domhighrestimestamp; spec: H
type: typedef; text: DOMHighResTimeStamp
urlPrefix: https://www.w3.org/TR/CSS2/visuren.html; spec: CSS-2;
type: dfn; url: #viewport; text: viewport
urlPrefix: https://www.w3.org/TR/CSS22/visufx.html; spec: CSS-2;
noamr marked this conversation as resolved.
Show resolved Hide resolved
type: dfn; url: #propdef-visibility; text: visibility;
urlPrefix: https://www.w3.org/TR/css-color-3; spec: CSS-COLOR-3;
type: dfn; url: #opacity; text: opacity;
urlPrefix: https://html.spec.whatwg.org/multipage/images.html
type: dfn; text: fully decodable image; url: #img-good
urlPrefix: https://www.w3.org/TR/SVG2/render.html; spec: CR-SVG2
type: dfn; url: #Rendered-vs-NonRendered; text: svg element with rendered descendants;
urlPrefix: https://www.w3.org/TR/css-backgrounds-3/; spec: CSS-BACKGROUNDS-3;
type: dfn; text: background-image; url: #propdef-background-image;
type: dfn; text: background-size; url: #background-size;
urlPrefix: https://html.spec.whatwg.org/multipage/canvas.html
type: dfn; text: canvas;
type: dfn; text: context mode; url: #concept-canvas-context-mode;
urlPrefix: https://html.spec.whatwg.org/multipage/rendering.html
type: dfn; text: replaced element; url: #replaced-elements;
urlPrefix: https://w3c.github.io/IntersectionObserver/
type: dfn; text: Intersection rect algorithm; url: #calculate-intersection-rect-algo
urlPrefix: https://drafts.csswg.org/css-cascade-4/
type: dfn; text: used; url: #used;
urlPrefix: https://html.spec.whatwg.org/multipage/dom.html
type: dfn; text: element; url: #element;
urlPrefix: https://drafts.csswg.org/css-pseudo-4
type: dfn; text: generated content pseudo-element; url: #generated-content;
urlPrefix: https://www.w3.org/TR/cssom-view
type: dfn; text: getBoundingClientRect; url: #dom-element-getboundingclientrect;
type: dfn; text: scrolling area; url: #scrolling-area;
urlPrefix: https://www.w3.org/TR/css3-values/
type: dfn; text: url valued; url: #url-value;
urlPrefix: https://drafts.fxtf.org/css-masking-1/
type: dfn; text: clip-path; url: #the-clip-path;
urlPrefix: https://www.w3.org/TR/css-images-3/
type: dfn; text: image; url: #typedef-image;
</pre>

Introduction {#intro}
Expand Down Expand Up @@ -69,9 +102,50 @@ Formally, we consider the user agent to have "rendered" a document when it has p

NOTE: The rendering pipeline is very complex, and the timestamp should be the latest timestamp the user agent is able to note in this pipeline (best effort). Typically the time at which the frame is submitted to the OS for display is recommended for this API.

A [=generated content pseudo-element=] is a <dfn>paintable pseudo-element</dfn> when all of the following apply:
* The pseudo-element's [=used=] [=visibility=] is <code>visible</code>.
* The pseudo-element's [=used=] [=opacity=] is greater than zero.
noamr marked this conversation as resolved.
Show resolved Hide resolved
* The pseudo-element generates a non-empty [=box=].

A CSS [=image=] |img| is a <dfn>contentful image</dfn> when all of the following apply:
* |img| is [=url valued=]
* |img| represents a [=fully decodable image=]

noamr marked this conversation as resolved.
Show resolved Hide resolved
An [=element=] |target| is <dfn export>contentful</dfn> when one or more of the following apply:
* |target| has a [=text node=] child, with at least one character, excluding [=document white space characters=].
* |target| is a [=replaced element=] representing a [=fully decodable image=].
* |target| has a [=background-image=] which is a [=contentful image=], and its [=used=] [=background-size=] has non-zero width and height values.
* |target| is a [=canvas=] with its [=context mode=] set to any value other than <code>none</code>.
* |target| is an [=svg element with rendered descendants=].
* |target| is an [=originating element=] for a [=paintable pseudo-element=] that represents a [=contentful image=] or text with at least one character excluding [=document white space characters=].

To compute the <dfn>paintable bounding rect</dfn> of [=element=] |target|, run the following steps:
1. Let |boundingRect| be the result of running the [=getBoundingClientRect=] on |target|.
1. Let |container| be the [=containing block=] of |target|.
1. While |container| is not the [=document=]
1. If container has <code>overflow: clip</code>, or its [=used=] style a css [=clip-path=] property, update |boundingRect| by applying |container|’s clip.
noamr marked this conversation as resolved.
Show resolved Hide resolved
noamr marked this conversation as resolved.
Show resolved Hide resolved
1. Update |container| to be the [=containing block=] of |container|.
1. Clip |boundingRect| with the [=document=]'s [=scrolling area=].
noamr marked this conversation as resolved.
Show resolved Hide resolved
1. Return |boundingRect|.

NOTE: elements contained by boxes with <code>overflow: scroll</code> or <code>overflow: hidden</code> don't have their [=paintable bounding rect=] clipped, as in both cases the [=element=] can become visible by scrolling.

An [=element=] |el| is <dfn>paintable</dfn> when all of the following apply:
* |el|'s [=used=] [=visibility=] is <code>visible</code>.
* |el| and all of its ancestors' [=used=] [=opacity=] is greater than zero.

NOTE: there could be cases where a <code>paintable</code> [=element=] would not be visible to the user, for example in the case of text that has the same color as its background.
Those elements would still considered as paintable for the purpose of computing [=first contentful paint=].

* |el|'s [=paintable bounding rect=] intersects with the [=scrolling area=] of the [=document=].

NOTE: This covers the cases where the element is scaled to zero size, has <code>display: none</code>, or <code>display: contents</code> where the contents resolve to an empty rect.

NOTE: As a general rule, an [=element=] is paintable if it is within the viewport, or can potentially be in the viewport as a result of scrolling or zooming.

<dfn export>First paint</dfn> entry contains a {{DOMHighResTimeStamp}} reporting the time when the user agent first rendered after navigation. This excludes the default background paint, but includes non-default background paint and the enclosing box of an iframe. This is the first key moment developers care about in page load – when the user agent has started to render the page.

<dfn export>First contentful paint</dfn> entry contains a {{DOMHighResTimeStamp}} reporting the time when the user agent first rendered any text, image (including background images), non-white canvas or SVG. This excludes any content of iframes, but includes text with pending webfonts. This is the first time users could start consuming page content.
<dfn export>First contentful paint</dfn> entry contains a {{DOMHighResTimeStamp}} reporting the time when the user agent first rendered a [=document=] which includes at least one [=element=] that is both [=contentful=] and [=paintable=].

Whenever a user agent preemptively paints content outside of the [=viewport=], those paints must be considered for [=first paint=] and [=first contentful paint=].

Expand Down Expand Up @@ -115,7 +189,7 @@ Reporting paint timing {#sec-reporting-paint-timing}

1. If this instance of [=update the rendering=] is the [=first contentful paint=] of |document|, then invoke the [[#report-paint-timing]] algorithm with |document|, <code>"first-contentful-paint"</code>, and |paintTimestamp| as arguments.

NOTE: This paint must include text, image (including background images), non-white canvas or SVG.
NOTE: This paint must include elements that are both [=contentful=] and [=paintable=].
noamr marked this conversation as resolved.
Show resolved Hide resolved

NOTE: A parent frame should not be aware of the paint events from its child iframes, and vice versa. This means that a frame that contains just iframes will have [=first paint=] (due to the enclosing boxes of the iframes) but no [=first contentful paint=].
</div>
Expand Down