Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Issue 13871003: Fixing getComputedStyle to return pixel values for left / right / top / bottom (Closed)

Created:
7 years, 8 months ago by mithro-old
Modified:
7 years, 1 month ago
Reviewers:
eseidel
CC:
blink-reviews, Alexis Menard
Base URL:
https://chromium.googlesource.com/chromium/blink.git@master
Visibility:
Public.

Description

Fixing getComputedStyle to return pixel values for left / right / top / bottom The returned object in CSS 2.1 "used values" (while CSS 2.0 used the "computed values"). http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-CSSview-getComputedStyle The "used value" of any CSS property is the final value of that property after all calculations have been performed. Dimensions are all in pixels. http://www.w3.org/TR/CSS2/cascade.html#used-value This is now consistent with both release Firefox and IE9. BUG=229280 R=eseidel

Patch Set 1 #

Patch Set 2 : Small refactor and adding of comments. #

Patch Set 3 : Merging with latest HEAD. #

Total comments: 2

Patch Set 4 : Fixing style nits and merge latest blink. #

Patch Set 5 : Fixing a const issue. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+963 lines, -50 lines) Patch
A LayoutTests/dom/svg/svg-className-lookup-crash.htm View 1 chunk +24 lines, -0 lines 0 comments Download
A LayoutTests/dom/svg/svg-className-lookup-crash-expected.txt View 1 chunk +4 lines, -0 lines 0 comments Download
M LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt View 1 2 4 chunks +4 lines, -4 lines 0 comments Download
M LayoutTests/fast/css/getComputedStyle/computed-style-negative-top.html View 1 chunk +50 lines, -4 lines 0 comments Download
M LayoutTests/fast/css/getComputedStyle/computed-style-negative-top-expected.txt View 1 chunk +22 lines, -1 line 0 comments Download
A LayoutTests/fast/css/getComputedStyle/getComputedStyle-offsets.html View 1 chunk +419 lines, -0 lines 0 comments Download
A LayoutTests/fast/css/getComputedStyle/getComputedStyle-offsets-expected.txt View 1 chunk +333 lines, -0 lines 0 comments Download
M LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size.html View 2 chunks +4 lines, -3 lines 0 comments Download
M LayoutTests/fast/css/getComputedStyle/getComputedStyle-zoom-and-background-size-expected.txt View 2 chunks +0 lines, -4 lines 0 comments Download
M LayoutTests/fast/css/hover-affects-child.html View 1 chunk +4 lines, -3 lines 0 comments Download
M Source/core/css/CSSComputedStyleDeclaration.cpp View 1 2 3 4 2 chunks +99 lines, -31 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
mithro-old
Hi Eric, I updated the change to have the refactoring you requested plus added a ...
7 years, 8 months ago (2013-04-12 04:33:13 UTC) #1
eseidel
other than the style nit, lgtm. https://codereview.chromium.org/13871003/diff/4001/Source/WebCore/css/CSSComputedStyleDeclaration.cpp File Source/WebCore/css/CSSComputedStyleDeclaration.cpp (right): https://codereview.chromium.org/13871003/diff/4001/Source/WebCore/css/CSSComputedStyleDeclaration.cpp#newcode638 Source/WebCore/css/CSSComputedStyleDeclaration.cpp:638: static Length getOffsetComputedStyle(RenderStyle* ...
7 years, 8 months ago (2013-04-12 07:33:50 UTC) #2
mithro-old
Fixed. Can you PTAL? If it's good can you commit? https://codereview.chromium.org/13871003/diff/4001/Source/WebCore/css/CSSComputedStyleDeclaration.cpp File Source/WebCore/css/CSSComputedStyleDeclaration.cpp (right): https://codereview.chromium.org/13871003/diff/4001/Source/WebCore/css/CSSComputedStyleDeclaration.cpp#newcode638 ...
7 years, 8 months ago (2013-04-26 05:30:38 UTC) #3
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mithro@mithis.com/13871003/11001
7 years, 8 months ago (2013-04-26 05:34:39 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mithro@mithis.com/13871003/11001
7 years, 8 months ago (2013-04-26 05:36:54 UTC) #5
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 8 months ago (2013-04-26 05:40:08 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mithro@mithis.com/13871003/11001
7 years, 8 months ago (2013-04-26 05:42:01 UTC) #7
commit-bot: I haz the power
Sorry for I got bad news for ya. Compile failed with a clobber build on ...
7 years, 8 months ago (2013-04-26 05:44:52 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/mithro@mithis.com/13871003/16003
7 years, 8 months ago (2013-04-26 09:19:18 UTC) #9
commit-bot: I haz the power
Retried try job too often on linux_layout_rel for step(s) webkit_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_layout_rel&number=5647
7 years, 8 months ago (2013-04-26 09:43:55 UTC) #10
mithro-old
On 2013/04/26 09:43:55, I haz the power (commit-bot) wrote: > Retried try job too often ...
7 years, 5 months ago (2013-07-23 12:52:20 UTC) #11
mithro-old
7 years, 5 months ago (2013-07-23 12:55:19 UTC) #12
From: Timothy Robert Ansell <tansell@google.com>
Date: 29 April 2013 12:46
To: Tab Atkins <tabatkins@google.com>

Hi Tab,

Mike suggested you would be a good person to talk to about this.

I'm trying to get the fast/css/computed-offset-with-zoom.html test to work with
my fixes to getComputedStyle (see change
https://chromiumcodereview.appspot.com/13871003/ ). Our implementation has been
lagging the spec and there has been a bug open since 2009.

The test sets a relative box with the following;
            #test-fixed  {
                position: relative;
                left: 100px;
                right: 20px;
                top: 100px;
                bottom: 100px;
            }

Which according to the layout spec is overconstrained; and should ignore the
right value;
See http://www.w3.org/TR/CSS2/visuren.html#relative-positioning
>
> For relatively positioned elements, 'left' and 'right' move the box(es)
horizontally, without changing their size. 'Left' moves the boxes to the right,
and 'right' moves them to the left. Since boxes are not split or stretched as a
result of 'left' or 'right', the used values are always: left = -right. 

<snip> 
>
> If neither 'left' nor 'right' is 'auto', the position is over-constrained, and
one of them has to be ignored. If the 'direction' property of the containing
block is 'ltr', the value of 'left' wins and 'right' becomes -'left'. If
'direction' of the containing block is 'rtl', 'right' wins and 'left' is
ignored.

The spec also says that getComputedStyle should returned the "used value"
http://www.w3.org/TR/CSS2/cascade.html#used-value
>
> 6.1.3 Used values
> Computed values are processed as far as possible without formatting the
document. Some values, however, can only be determined when the document is
being laid out. For example, if the width of an element is set to be a certain
percentage of its containing block, the width cannot be determined until the
width of the containing block has been determined. The used value is the result
of taking the computed value and resolving any remaining dependencies into an
absolute value.


My reading of the spec is that the getComputedValue value for the right property
in the above should be -100px (as we ignore the right: 20px).

The problem is that Chrome, FireFox and IE all return 20px, IE the value which
was set.

I'm not sure how to resolve this problem, Mike suggested you might know better
what I should be doing.

Tim

----------
From: Tab Atkins <tabatkins@google.com>
Date: 30 April 2013 03:56
To: Timothy Robert Ansell <tansell@google.com>


Note - that paragraph only applies if the width is non-auto as well.
If 'width' is "auto", then non-auto 'left' and 'right' aren't
overconstrained, they're exactly constrained enough. ^_^

> The spec also says that getComputedStyle should returned the "used value"
> http://www.w3.org/TR/CSS2/cascade.html#used-value
>>
>> 6.1.3 Used values
>> Computed values are processed as far as possible without formatting the
>> document. Some values, however, can only be determined when the document is
>> being laid out. For example, if the width of an element is set to be a
>> certain percentage of its containing block, the width cannot be determined
>> until the width of the containing block has been determined. The used value
>> is the result of taking the computed value and resolving any remaining
>> dependencies into an absolute value.
>
> My reading of the spec is that the getComputedValue value for the right
> property in the above should be -100px (as we ignore the right: 20px).
>
> The problem is that Chrome, FireFox and IE all return 20px, IE the value
> which was set.
>
> I'm not sure how to resolve this problem, Mike suggested you might know
> better what I should be doing.

Oh jeez, the spec is *hilariously* underdefined here.  It never
actually mentions "used values" there; it just says "ignore the value
for 'left' and solve for it using the other values instead".  Good
job, past 2.1 editors.

I'll need to ask the WG for input.  I'll get back to you.

~TJ

----------
From: Tab Atkins <tabatkins@google.com>
Date: 30 April 2013 04:01
To: Timothy Robert Ansell <tansell@google.com>


On Mon, Apr 29, 2013 at 10:56 AM, Tab Atkins <tabatkins@google.com> wrote:
> Note - that paragraph only applies if the width is non-auto as well.
> If 'width' is "auto", then non-auto 'left' and 'right' aren't
> overconstrained, they're exactly constrained enough. ^_^

Hurp durp, I didn't read your email well enough.  You're talking about
relpos, not abspos.  Better response incoming.

~TJ

----------
From: Tab Atkins <tabatkins@google.com>
Date: 30 April 2013 04:05
To: Timothy Robert Ansell <tansell@google.com>


Okay, same level of undefinedness and weasel-wordiness.  Joy.  Back to
waiting for a WG response.

~TJ

----------
From: Timothy Robert Ansell <tansell@google.com>
Date: 30 April 2013 11:22
To: Tab Atkins <tabatkins@google.com>


So what should I do?

I believe my way is correct as specified, but maybe we should just do what
everyone else does?

Tim

----------
From: Tab Atkins <tabatkins@google.com>
Date: 3 May 2013 09:49
To: Timothy Robert Ansell <tansell@google.com>


On Mon, Apr 29, 2013 at 6:22 PM, Timothy Robert Ansell
<tansell@google.com> wrote:
> So what should I do?
>
> I believe my way is correct as specified, but maybe we should just do what
> everyone else does?

Sorry, I was discussing the issue in the mailing list.

It looks like, for bugwards compat, the way forward is:

If the *computed* value was "auto" and the computed value of the
opposite property was non-"auto", return the negation of the opposite
property's used value.  Otherwise, return the used value.

~TJ

----------
From: Timothy Robert Ansell <tansell@google.com>
Date: 31 May 2013 14:36
To: Tab Atkins <tabatkins@google.com>


Hi Tab,

I've been away for 3 weeks on holidays and want to get this committed. Is this
the final say on this?

If the *computed* value was "auto" and the computed value of the
opposite property was non-"auto", return the negation of the opposite
property's used value.  Otherwise, return the used value.

It sounds really confusing :(

Tim



----------
From: Tab Atkins <tabatkins@google.com>
Date: 1 June 2013 04:16
To: Timothy Robert Ansell <tansell@google.com>


On Thu, May 30, 2013 at 9:36 PM, Timothy Robert Ansell
<tansell@google.com> wrote:
> Hi Tab,
>
> I've been away for 3 weeks on holidays and want to get this committed. Is
> this the final say on this?
>
> If the *computed* value was "auto" and the computed value of the
> opposite property was non-"auto", return the negation of the opposite
> property's used value.  Otherwise, return the used value.
>
> It sounds really confusing :(

Unless we want to play chicken with compat bugs, yes, that's the final say.

~TJ

Powered by Google App Engine
This is Rietveld 408576698