getPropertyValue on computed style (getComputedStyle) does not do shorthand properties
Categories
(Core :: DOM: CSS Object Model, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox96 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: emilio)
References
(Blocks 4 open bugs, )
Details
(Whiteboard: [wpt-triaged])
Attachments
(2 files)
| Reporter | ||
Updated•23 years ago
|
| Reporter | ||
Comment 1•22 years ago
|
||
| Reporter | ||
Updated•22 years ago
|
Updated•16 years ago
|
Comment 5•12 years ago
|
||
Comment 6•12 years ago
|
||
| Reporter | ||
Comment 7•12 years ago
|
||
Comment 8•12 years ago
|
||
| Reporter | ||
Comment 9•12 years ago
|
||
| Reporter | ||
Comment 10•12 years ago
|
||
| Assignee | ||
Comment 19•8 years ago
|
||
| Assignee | ||
Updated•8 years ago
|
Updated•7 years ago
|
Comment 21•7 years ago
|
||
Comment 23•7 years ago
•
|
||
For the record, this bug is the reason that we (alone) fail these WPT tests:
https://wpt.fyi/results/css/css-align/gaps/gap-animation-001.html
https://wpt.fyi/results/css/css-align/gaps/gap-animation-002.html
https://wpt.fyi/results/css/css-align/gaps/gap-animation-003.html
https://wpt.fyi/results/css/css-align/gaps/gap-animation-004.html
Comment 25•6 years ago
|
||
I may take a look at this once I finish Bug 1574222.
Updated•6 years ago
|
Comment 26•6 years ago
|
||
[tweaking title to mention "getComputedStyle", for bugzilla-search-discoverability purposes]
Updated•6 years ago
|
Updated•6 years ago
|
Comment 27•6 years ago
•
|
||
I'm thinking about what should we do for this bug. Perhaps we should drop SHORTHAND_IN_GETCS from ServoCSSPropList.mako.py, which makes "shorthand in gCS" be a default behavior.
| Assignee | ||
Comment 28•6 years ago
|
||
There are various different cases. The current shorthand-in-getcs code doesn't work for all properties. In particular, this code won't do the right thing for:
- Properties that depend on layout (like padding and margin).
- Properties that are logical / non-animatable.
I haven't thought all this through, but for the first, I think ideally we'd fix ToResolvedValue for the relevant bits so that we can also remove all the C++-side implementations and CSSValue and so on. That may be a bit of work though, and depending on how many shorthands of the layout-affecting properties are there, we may want to punt on it and just implement them on C++. However it seems like there's a fair amount of them.
For the second we just need more generated code to go from resolved to specified value. Right now that code is reusing AnimatedValue::from_computed_value() and then AnimatedValue::uncompute. This makes assumptions that don't hold for all properties:
- That resolved and computed values are the same.
- That all properties are animatable.
All those assumptions don't hold for all shorthands. They hold for the shorthands we support right now though.
Comment 29•5 years ago
|
||
This bug is also problematic for WebDriver tests where "Get Element CSS Value" is being called with a shorthand css property resulting in different results for Chrome and Firefox (see e.g.: https://github.com/webdriverio/webdriverio/issues/6161).
Comment 31•5 years ago
|
||
FWIW, this bug seems to be the root cause of some of the test-failures in tests on the compat2021 list:
https://wpt.fyi/results/css/css-flexbox/parsing/flex-computed.html?label=master&label=experimental&aligned
https://wpt.fyi/results/css/css-flexbox/parsing/flex-flow-computed.html?label=master&label=experimental&aligned
https://wpt.fyi/results/css/css-grid/parsing/grid-area-computed.html?label=master&label=experimental&aligned
Updated•4 years ago
|
Updated•4 years ago
|
Updated•4 years ago
|
Comment 34•4 years ago
|
||
The Webcompat team is not sure about it. There's only one restaurant site breaking, but there seems to be duplicate from devs reporting the issue.
Comment 35•4 years ago
|
||
As Daniel noted above, we do fail a large number of WPTs (unnecessarily) because of this bug, which makes us look bad in "Web Standards Compliance" scores. So maybe it doesn't impact our users that much directly, it's still bad for our reputation to have low scores on "number of WPTs passed" IMO.
Is the spec clear nowadays how this should be implemented?
(I seem to recall it was discussed/resolved somewhat recently in a csswg issue?)
Comment 36•4 years ago
|
||
maybe
https://github.com/w3c/csswg-drafts/issues/2529
https://github.com/webdriverio/webdriverio/issues/6161
https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue
The spec seems clear that it should return the full list of values.
- If property is a shorthand property, then follow these substeps:
- Let list be a new empty array.
- For each longhand property longhand that property maps to, in canonical order, follow these substeps:
- If longhand is a case-sensitive match for a property name of a CSS declaration in the declarations, let declaration be that CSS declaration, or null otherwise.
- If declaration is null, then return the empty string.
- Append the declaration to list.
Just tested.
data:text/html,<!doctype html> <p id="log" style="border: 1px solid red">border</p> <script> var log = document.getElementById('log'); log.textContent = window.getComputedStyle(log).getPropertyValue('border'); </script>
- FAIL Gecko Firefox Nightly 95.0a1 (2021-10-31)
- PASS WebKit Safari Tech Preview Release 133 (Safari 15.4, WebKit 17613.1.2.2)
- PASS Blink Edge Canary 97.0.1060.0
| Assignee | ||
Updated•4 years ago
|
| Assignee | ||
Comment 37•4 years ago
|
||
There's still some potential work to do for layout-dependent shorthands, but I
believe given there's only progressions here this is worth doing.
Comment 38•4 years ago
|
||
Comment 39•4 years ago
|
||
Comment 40•4 years ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/8786e120af24
https://hg.mozilla.org/mozilla-central/rev/57f8c783bb2b
Description
•