Skip to content

[scroll-animations-1] Use CSSTypedOM instead of strings (#5213)#5300

Merged
majido merged 3 commits into
w3c:masterfrom
majido:use-typed-om
Jul 9, 2020
Merged

[scroll-animations-1] Use CSSTypedOM instead of strings (#5213)#5300
majido merged 3 commits into
w3c:masterfrom
majido:use-typed-om

Conversation

@majido
Copy link
Copy Markdown
Contributor

@majido majido commented Jul 8, 2020

Use appropriate CSSTypedOM instead of DOMStrings in the API. Fixes #5213.

Changes:

  • For offsets use CSSNumericValue or CSSKeywordish instead of DOMString
  • When setting the offset, the grammars for these values is check to ensure only the valid subset can be set.
  • When computing effective scroll offset check the offset actual type and interpret it accordingly
  • Update examples to showcase the API and add noted to clarify the usage.

@majido majido requested a review from andruud July 8, 2020 19:14
Comment thread scroll-animations-1/Overview.bs Outdated

: <var>offset</var> is a <<length-percentage>>
: If <var>offset</var> is a {{CSSNumberish}} and matches <<number>>:
:: The distance indicated by the value in <a value>pixel unit</a> along
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was under the impression that treating plain numbers as px was a pattern we didn't want? Maybe get someone else's opinion on this. (@tabatkins ?)

Copy link
Copy Markdown
Contributor Author

@majido majido Jul 9, 2020

Choose a reason for hiding this comment

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

I personally felt allowing numbers to be interpreted as px would make the API easier to use in Javascript. Specially as it matches all existing scroll related APIs where numbers are treated as pixels

But I can also see at least two possible concerns:

  • Automatic type conversion can be a footgun but perhaps this is limited enough to be safe
  • Having every downstream spec convert <numbers> differently would be bad. So perhaps have a common way to do this i.e., <number> -> <length> with pixel for all JS API's that accept length but want to accept number too.

BTW, does TypedOM have a special handling for 0 length for which in CSS the unit is optional?

In any case, this is a trade-off and @tabatkins expert's opinion is appreciated. :)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We really don't want to interpret bare numbers as px. The definition of CSSNumberish interprets numeric values as a CSS "number" not a length. offset should simply be a CSSNumericValue or a CSSStyleValue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. I removed CSSNumberish and just use CSSNumericValue which I think is the right type.

Also added a procedure to validate the incoming values when they are being set.

Comment thread scroll-animations-1/Overview.bs Outdated
{{source}}'s scroll range in {{orientation}}.


: If <var>offset</var> is a {{CSSNumberish}} and matches
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread scroll-animations-1/Overview.bs Outdated
<pre class="idl">
enum ScrollTimelineAutoKeyword { "auto" };

typedef (CSSNumberish or ScrollTimelineAutoKeyword) ContainerBasedOffset;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should IMO also accept CSSKeywordValue matching auto.

Would you want to use CSSKeywordish here (if it existed)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

My bad, CSSKeywordish already exists: https://drafts.css-houdini.org/css-typed-om-1/#typedefdef-csskeywordish

Do we want to use that somehow, then?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. As part of this I now have a procedure that rectifies strings into CSSKeyword and rejects invalid values at the time of setting the value.

Copy link
Copy Markdown
Member

@andruud andruud left a comment

Choose a reason for hiding this comment

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

👍

@majido majido merged commit 44bca0a into w3c:master Jul 9, 2020
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 2, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 9, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 10, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 11, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 11, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}
chromium-wpt-export-bot pushed a commit to web-platform-tests/wpt that referenced this pull request Sep 11, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}
pull Bot pushed a commit to Yannic/chromium that referenced this pull request Sep 12, 2020
The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Sep 23, 2020
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366
sidvishnoi pushed a commit to sidvishnoi/gecko-webmonetization that referenced this pull request Sep 24, 2020
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Sep 28, 2020
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Reviewed-by: Kevin Ellis <keverschromium.org>
Cr-Commit-Position: refs/heads/master{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366

UltraBlame original commit: ae84065cb5cf0390e0c328afcc132056e3943776
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Sep 28, 2020
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Reviewed-by: Kevin Ellis <keverschromium.org>
Cr-Commit-Position: refs/heads/master{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366

UltraBlame original commit: ae84065cb5cf0390e0c328afcc132056e3943776
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Sep 28, 2020
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruudchromium.org>
Reviewed-by: Yuki Shiino <yukishiinochromium.org>
Reviewed-by: Kevin Ellis <keverschromium.org>
Cr-Commit-Position: refs/heads/master{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366

UltraBlame original commit: ae84065cb5cf0390e0c328afcc132056e3943776
bhearsum pushed a commit to mozilla-releng/staging-firefox that referenced this pull request May 1, 2025
…o specify offsets, a=testonly

Automatic update from web-platform-tests
[scroll-animations] Use CSSStyleValues to specify offsets

The spec changed a while ago to use CSSNumericValue/CSSKeywordish for
specifying container-based offsets [1]. This CL makes that switch.

[1] w3c/csswg-drafts#5300

Bug: 1109769

Change-Id: I1d14d68008098e39035aecba940c0e02645f9d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2390740
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kevin Ellis <kevers@chromium.org>
Cr-Commit-Position: refs/heads/master@{#806346}

--

wpt-commits: c6ac22678d95c1a8414656822ff46d05ff0d1fed
wpt-pr: 25366
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scroll-animations-1] Use of DOMString in API surface

3 participants