WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED DUPLICATE of
bug 29084
Bug 105979
getComputedStyle() should return zoom-adjusted offset values
https://bugs.webkit.org/show_bug.cgi?id=105979
Summary
getComputedStyle() should return zoom-adjusted offset values
Adam Craven
Reported
2013-01-02 17:45:20 PST
Created
attachment 181121
[details]
Test Case In WebKit, getComputedStyle() returns scaled values (seems to be +10%) for properties such as left, right, top and bottom (when the 'position' of an element is 'relative'). This makes it impossible to rely on these values. Firefox reports the values accurately. Please see the attached test case. The jQuery community has stumbled upon the issue a few times over the years... This issue prevents jQuery.animate() from functioning correctly in WebKit.
http://bugs.jquery.com/ticket/4993#comment:9
An example of that issue can be seen here:
http://jsfiddle.net/sFYjc/2/
Related to
https://bugs.webkit.org/show_bug.cgi?id=32230
Attachments
Test Case
(2.00 KB, text/html)
2013-01-02 17:45 PST
,
Adam Craven
no flags
Details
Patch
(5.39 KB, patch)
2013-02-15 17:15 PST
,
Emil A Eklund
no flags
Details
Formatted Diff
Diff
Patch
(12.82 KB, patch)
2013-02-19 15:22 PST
,
Emil A Eklund
darin
: review-
Details
Formatted Diff
Diff
Patch
(13.94 KB, patch)
2013-03-08 15:39 PST
,
Emil A Eklund
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Adam Craven
Comment 1
2013-01-02 17:59:38 PST
To be more accurate, forget about "(seems to be +10%)"... it is scaled according to the zoom level... The 10% is for when the zoom is 110%...
Mike Sherov
Comment 2
2013-01-02 18:03:37 PST
Please correct the title to getComputedStyle please. There's a typo.
Adam Craven
Comment 3
2013-01-02 18:18:39 PST
Sorry, typo fixed...
Emil A Eklund
Comment 4
2013-02-15 16:11:10 PST
Seems wrong. Thanks for the report and the test case.
Emil A Eklund
Comment 5
2013-02-15 17:15:43 PST
Created
attachment 188671
[details]
Patch
Darin Adler
Comment 6
2013-02-16 12:43:11 PST
Comment on
attachment 188671
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=188671&action=review
> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:670 > + return zoomAdjustedPixelValue(l.value(), style);
Does this work correctly when "l" is a percentage? The test case does not cover that.
Emil A Eklund
Comment 7
2013-02-19 10:43:23 PST
Good point, I'll make sure to add tests for percentage values.
Emil A Eklund
Comment 8
2013-02-19 15:22:30 PST
Created
attachment 189181
[details]
Patch
Emil A Eklund
Comment 9
2013-02-21 14:40:36 PST
Darin, when you get a chance could you please take another look?
Emil A Eklund
Comment 10
2013-02-22 10:30:23 PST
Ping?
Darin Adler
Comment 11
2013-02-26 09:21:49 PST
Comment on
attachment 189181
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=189181&action=review
> Source/WebCore/css/CSSComputedStyleDeclaration.cpp:662 > + renderer->document()->updateLayoutIgnorePendingStylesheets(); > + LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || propertyID == CSSPropertyRight) ? > + toRenderBox(renderer)->containingBlockLogicalWidthForContent() : > + toRenderBox(renderer)->containingBlockLogicalHeightForContent(ExcludeMarginBorderPadding);
This code sequence is incorrect. Calling updateLayout can result in the renderer being destroyed, so itβs not safe to use renderer after that. The renderer may no longer exist, or may not be a box. Generally speaking, when we update layout, all renderers are invalid and must be refetched. I believe that includes renderView.
Darin Adler
Comment 12
2013-02-26 09:22:51 PST
Typically this means that calls to updateLayout need to be made at a higher level, not inside functions that take render tree arguments, but before even fetching the renderers.
Emil A Eklund
Comment 13
2013-02-26 13:27:00 PST
Oh, of course. That makes more sense. Thank you!
Mike Sherov
Comment 14
2013-03-08 10:19:29 PST
Will this patch also fix the values for offsetWidth and offsetHeight?
Mike Sherov
Comment 15
2013-03-08 10:20:57 PST
offsetWidth and offsetHeight are manifesting themselves as
http://bugs.jquery.com/ticket/13543
in jQuery Core.
Emil A Eklund
Comment 16
2013-03-08 10:25:13 PST
(In reply to
comment #15
)
> offsetWidth and offsetHeight are manifesting themselves as
http://bugs.jquery.com/ticket/13543
in jQuery Core.
No, that has to do with our pixel-snapping logic (see
http://trac.webkit.org/wiki/LayoutUnit
). For precise box metrics we recommend using getBoundingClientRect which returns values with decimal precision.
Emil A Eklund
Comment 17
2013-03-08 15:39:19 PST
Created
attachment 192295
[details]
Patch
Emil A Eklund
Comment 18
2013-03-11 13:53:37 PDT
(In reply to
comment #11
) Found a better way to do it, thanks. Please take another look.
Eric Seidel (no email)
Comment 19
2013-03-15 12:17:38 PDT
I thought christian had recently posted a patch for this? I must be confused.
Christian Biesinger
Comment 20
2013-03-15 13:25:42 PDT
I didn't post a patch for this... I was mostly working on flexbox stuff lately.
Eric Seidel (no email)
Comment 21
2013-03-15 13:50:47 PDT
Sorry, I'm thinking of Mithro.
Mike Sherov
Comment 22
2013-03-15 13:53:48 PDT
Just chiming in here: Mithro is working on
https://bugs.webkit.org/show_bug.cgi?id=29084
, which hits similar code paths. jQuery is eagerly awaiting both of these fixes ;-)
Emil A Eklund
Comment 23
2013-03-27 03:32:03 PDT
29084 hasn't been updated in weeks. What do you want me to do with this bug? Mark it as a duplicate or land it in preparation for the other change?
Tim 'mithro' Ansell
Comment 24
2013-03-27 20:48:42 PDT
Hi eae, Sorry about blocking you, I've been away on holidays for the last two weeks (attending PyCon in the US). I'll be back onto this as my first priority after the Easter break (I may get to some of it today too). In my bug I have feedback from Eric that I need to respond too and I'd like to merge your test into my patch to make sure it covers all your issues. Looking at your code, your test seems to only cover a small section of these usage for these values. Does your patch break any of the other layout tests? Sorry once again. - Tim 'mithro' Ansell
Emil A Eklund
Comment 25
2013-03-28 03:03:14 PDT
(In reply to
comment #24
)
> Looking at your code, your test seems to only cover a small section of these usage for these values. Does your patch break any of the other layout tests?
No worries. The new tests covers how zoomed values are handled, it doesn't try to test any of the existing behavior as we already have other tests for that. The cr-linux and mac ews bots runs the tests and as you can see they are both green indicating that all tests pass.
Radar WebKit Bug Importer
Comment 26
2016-04-04 10:43:31 PDT
<
rdar://problem/25531120
>
Simon Fraser (smfr)
Comment 27
2017-05-26 22:00:47 PDT
This will be fixed by the patch in
bug 29084
. *** This bug has been marked as a duplicate of
bug 29084
***
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug