Bug 50974 - getComputedStyle() returns wrong values for zoomed elements when display is none
Summary: getComputedStyle() returns wrong values for zoomed elements when display is none
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Beth Dakin
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2010-12-13 14:13 PST by Beth Dakin
Modified: 2010-12-14 11:36 PST (History)
1 user (show)

See Also:


Attachments
Test case (1.41 KB, text/html)
2010-12-13 14:14 PST, Beth Dakin
no flags Details
Patch (7.96 KB, patch)
2010-12-13 14:22 PST, Beth Dakin
darin: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Beth Dakin 2010-12-13 14:13:37 PST
This is a follow-on from https://bugs.webkit.org/show_bug.cgi?id=32230 getComputedStyle() returns different values for different zoom levels.

If an element (or one of the element's ancestors) has display:none, this bug still occurs - the value returned by getComputedStyle() is multiplied by the zoom factor. 

A brief summary of the issue (see the original issue for more detail):
The values returned by getComputedStyle() are scaled according to the CSS zoom property, which is different from all other DOM APIs (e.g. offsetHeight/Width) and other browsers (Gecko returns unscaled values).

The return values should be unscaled.

<rdar://problem/8522731>

Patch forthcoming!
Comment 1 Beth Dakin 2010-12-13 14:14:36 PST
Created attachment 76437 [details]
Test case
Comment 2 Beth Dakin 2010-12-13 14:22:04 PST
Created attachment 76438 [details]
Patch
Comment 3 David Levin 2010-12-13 19:49:40 PST
Comment on attachment 76438 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=76438&action=review

> WebCore/css/CSSComputedStyleDeclaration.cpp:1550
> +

I don't know this area but I do see a pattern here.

Why not create a function like this:

PassRefPtr<CSSValue> get{FillInNameHere}(const Length& length, const RenderStyle* style)
{
    if (length.isFixed())
        return zoomAdjustedPixelValue(width.value(), style);
    return CSSPrimitiveValue::create(width);
}

and use this in all of these places
?
Comment 4 Darin Adler 2010-12-13 22:26:28 PST
Comment on attachment 76438 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=76438&action=review

r=me, but please consider factoring out the repetitive code into a function

>> WebCore/css/CSSComputedStyleDeclaration.cpp:1550
>> +
> 
> I don't know this area but I do see a pattern here.
> 
> Why not create a function like this:
> 
> PassRefPtr<CSSValue> get{FillInNameHere}(const Length& length, const RenderStyle* style)
> {
>     if (length.isFixed())
>         return zoomAdjustedPixelValue(width.value(), style);
>     return CSSPrimitiveValue::create(width);
> }
> 
> and use this in all of these places
> ?

I was going to make the same suggestion. No need to use the word “get”, though!
Comment 5 Beth Dakin 2010-12-14 11:36:43 PST
Thanks all Fixed with r74045.