New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 671490 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner: ----
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 3
Type: Bug

Blocking:
issue 641877



Sign in to add a comment

getComputedStyle for registered custom CSS properties is not very consistent

Project Member Reported by timloh@chromium.org, Dec 6 2016

Issue description

1) Registered properties don't have the initial value go through computation for getComputedStyle.

CSS.registerProperty({name: '--foo', syntax: '<length>', initialValue: 'calc(10px)'});

getComputedStyle(e).getPropertyValue('--foo') will return calc(10px) when --foo is not set, but will return 10px when it is set to calc(10px) or to initial.

2) Computation only does things for <length> types. For regular properties, we always compute colors like pink into rgb values, but a custom property registered as <color> will be returned by getComputedStyle as pink.
 
I think I'm seeing something related:

width: calc(360px * 2); // getPropertyValue returns 720px
--customWidth: calc(360px * 2); // getPropertyValue returns " calc(360px * 2)"

This is Chrome for OSX, Version 54.0.2840.98.
This bug is for registered custom properties. Unregistered custom properties will always just return the value you specify if there are no var() references.
Project Member

Comment 3 by bugdroid1@chromium.org, Jan 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/8a637421ef6b1bbfe05708f814a914e57c17a8b6

commit 8a637421ef6b1bbfe05708f814a914e57c17a8b6
Author: timloh <timloh@chromium.org>
Date: Mon Jan 16 05:14:07 2017

Compute initial values for registered custom properties.

This patch makes initial values for registered custom properties go
through computation, so initial values like calc(10px) end up as 10px
when accessed through getComputedStyle. As per css-cascade logic they
would normally go through regular computation anyway, but since we
skip this for registered properties for efficiency we need to handle
this case specially.

BUG= 671490 

Review-Url: https://codereview.chromium.org/2622403006
Cr-Commit-Position: refs/heads/master@{#443847}

[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/LayoutTests/custom-properties/registered-property-initial.html
[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/Source/core/css/CSSToLengthConversionData.cpp
[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/Source/core/css/CSSToLengthConversionData.h
[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/Source/core/css/PropertyRegistration.cpp
[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.cpp
[modify] https://crrev.com/8a637421ef6b1bbfe05708f814a914e57c17a8b6/third_party/WebKit/Source/core/css/resolver/StyleBuilderConverter.h

Comment 4 by timloh@chromium.org, Jan 17 2017

Owner: meade@chromium.org
The first part is fixed by the patch in comment 3, the remaining bit is mostly just a consistency thing and probably not too important. It's unclear whether the specs are supposed to make it work but if so I think it'll be implied by the cssom specs.

Comment 5 by nainar@chromium.org, Feb 13 2017

Labels: Hotlist-Interop Update-Quarterly

Comment 6 by meade@chromium.org, Mar 8 2017

Cc: meade@chromium.org
Owner: ----
Status: Available (was: Assigned)
Project Member

Comment 7 by bugdroid1@chromium.org, Jun 29 2017

Labels: Code-ComputedStyle

Comment 9 by meade@chromium.org, Oct 31 2017

Status: Fixed (was: Available)
This seems to be fixed, see http://jsfiddle.net/4h54z3v6/1
Labels: -Hotlist-Interop Blink-Only

Sign in to add a comment