Summary: | getComputedStyle() should return zoom-adjusted offset values | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Adam Craven <adammcraven> | ||||||||||
Component: | CSS | Assignee: | Nobody <webkit-unassigned> | ||||||||||
Status: | RESOLVED DUPLICATE | ||||||||||||
Severity: | Major | CC: | abarth, bdakin, cbiesinger, cerimorgan, darin, eae, eric, esprehn+autocc, macpherson, menard, m.goleb+bugzilla, mike.sherov, mithro, ojan.autocc, simon.fraser, webkit-bug-importer, webkit, webkit.review.bot | ||||||||||
Priority: | P2 | Keywords: | InRadar, WebExposed | ||||||||||
Version: | WebKit Nightly Build | ||||||||||||
Hardware: | Mac | ||||||||||||
OS: | OS X 10.11 | ||||||||||||
Bug Depends on: | |||||||||||||
Bug Blocks: | 110007 | ||||||||||||
Attachments: |
|
Description
Adam Craven
2013-01-02 17:45:20 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%... Please correct the title to getComputedStyle please. There's a typo. Sorry, typo fixed... Seems wrong. Thanks for the report and the test case. Created attachment 188671 [details]
Patch
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. Good point, I'll make sure to add tests for percentage values. Created attachment 189181 [details]
Patch
Darin, when you get a chance could you please take another look? Ping? 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. 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. Oh, of course. That makes more sense. Thank you! Will this patch also fix the values for offsetWidth and offsetHeight? offsetWidth and offsetHeight are manifesting themselves as http://bugs.jquery.com/ticket/13543 in jQuery Core. (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. Created attachment 192295 [details]
Patch
(In reply to comment #11) Found a better way to do it, thanks. Please take another look. I thought christian had recently posted a patch for this? I must be confused. I didn't post a patch for this... I was mostly working on flexbox stuff lately. Sorry, I'm thinking of Mithro. 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 ;-) 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? 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 (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. |