Bug 106535 (computedstyle-pseudo)

Summary: getComputedStyle() doesn't report intermediate values during a transition of a pseudo element
Product: WebKit Reporter: Rodney Rehm <mail>
Component: CSSAssignee: Elliott Sprehn <esprehn>
Status: RESOLVED FIXED    
Severity: Normal CC: buildbot, cmarcelo, dglazkov, eric, esprehn, macpherson, menard, ojan.autocc, ojan, peter+ews, philn, rniwa, roger_fong, webkit-ews, webkit.review.bot, xan.lopez
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac (Intel)   
OS: OS X 10.7   
URL: http://rodneyrehm.de/t/generated-content-computedStyle.html
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch for landing none

Rodney Rehm
Reported 2013-01-10 00:25:13 PST
The computedStyle() of a property is supposed to change according to the transition. While computedStyle() of a regular element behaves as expected (returning intermediate values), it fails on pseudo elements. Steps to Reproduce: 1. define a CSS transition of any property of :before 2. bind a requestAnimationFrame loop to extract the computedStyle of that property on :before and log to console 3. start the transition Actual Result: Output looks like "1px, 100px" Expected Result: Output looks like "1px, 3px, 10px, …, 100px"
Attachments
Patch (18.26 KB, patch)
2013-01-11 15:01 PST, Elliott Sprehn
no flags
Patch (26.93 KB, patch)
2013-01-15 16:42 PST, Elliott Sprehn
no flags
Patch (16.58 KB, patch)
2013-02-06 15:27 PST, Elliott Sprehn
no flags
Patch for landing (16.82 KB, patch)
2013-02-07 16:41 PST, Elliott Sprehn
no flags
Elliott Sprehn
Comment 1 2013-01-10 02:29:30 PST
This is a really old FIXME: RenderStyle* Element::computedStyle(PseudoId pseudoElementSpecifier) { // FIXME: Find and use the renderer from the pseudo element instead of the actual element so that the 'length' // properties, which are only known by the renderer because it did the layout, will be correct and so that the // values returned for the ":selection" pseudo-element will be correct. We need to get the pseudoElement(BEFORE or AFTER) and use their renderStyle() instead. We also need to fix CSSComputedStyleDeclaration::getPropertyCSSValue as it seems the logic for pseudo element styles is wrong since we consult the cached pseudo style from the parent element in the composited case.
Elliott Sprehn
Comment 2 2013-01-11 15:01:52 PST
Created attachment 182424 [details] Patch Still needs a non-manual test.
Early Warning System Bot
Comment 3 2013-01-11 15:18:14 PST
Early Warning System Bot
Comment 4 2013-01-11 15:19:02 PST
Build Bot
Comment 5 2013-01-11 15:34:37 PST
Elliott Sprehn
Comment 6 2013-01-11 16:15:01 PST
Woops, botched a variable rename right before uploading.
WebKit Review Bot
Comment 7 2013-01-11 16:22:34 PST
Comment on attachment 182424 [details] Patch Attachment 182424 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/15813351
Build Bot
Comment 8 2013-01-11 16:26:49 PST
Peter Beverloo (cr-android ews)
Comment 9 2013-01-11 16:28:09 PST
Comment on attachment 182424 [details] Patch Attachment 182424 [details] did not pass cr-android-ews (chromium-android): Output: http://queues.webkit.org/results/15820098
EFL EWS Bot
Comment 10 2013-01-13 20:58:01 PST
Elliott Sprehn
Comment 11 2013-01-15 16:42:28 PST
Ojan Vafai
Comment 12 2013-01-17 17:09:40 PST
Comment on attachment 182873 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=182873&action=review Fine at a high-level. Just a few nits. Mainly R- because I'm hoping we can tighten up the tests. > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1509 > + Node* styledNode = this->styledNode(); Nit: Can we make this styledElement? You can't get computed style on a non-Element anymore with Antti's recent refactorings. > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1513 > + Document* document = styledNode->document(); Do you need to move this? pseudo elements are necessarily in the same document as their node, no? > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1550 > + style = m_node->computedStyle(m_pseudoElementSpecifier); May as well use styledNode and avoid the need for the comment? > LayoutTests/fast/css-generated-content/pseudo-animation.html:86 > + shouldBeCloseTo('div.offsetWidth', 20, 1); Why shouldBeCloseTo instead of shouldBe? Seems like we should be able to modify the test so that we can get a hard value.
Elliott Sprehn
Comment 13 2013-01-17 18:54:10 PST
(In reply to comment #12) > (From update of attachment 182873 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=182873&action=review > > Fine at a high-level. Just a few nits. > > Mainly R- because I'm hoping we can tighten up the tests. > > > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1509 > > + Node* styledNode = this->styledNode(); > > Nit: Can we make this styledElement? You can't get computed style on a non-Element anymore with Antti's recent refactorings. Unfortunately EditingStyle creates these for text nodes :( I tried that at first and found out we can't do that without a bunch of refactoring. I think we may still want to do that, but I'd like to do it in a separate step. > > > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1513 > > + Document* document = styledNode->document(); > > Do you need to move this? pseudo elements are necessarily in the same document as their node, no? Yeah, I was just trying to clean up the code. > > > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1550 > > + style = m_node->computedStyle(m_pseudoElementSpecifier); > > May as well use styledNode and avoid the need for the comment? The problem is that you end up doing essentially beforePseudo->computedStyle(":before"), which I think works because Element::computedStyle falls back to the element's own style if there's no pseudo style available, but seemed a bit weird. I'll change it to be consistent. > > > LayoutTests/fast/css-generated-content/pseudo-animation.html:86 > > + shouldBeCloseTo('div.offsetWidth', 20, 1); > > Why shouldBeCloseTo instead of shouldBe? Seems like we should be able to modify the test so that we can get a hard value. I had trouble with subpixel layout where my test fails in ports that don't have it turned on yet in Bug 92591, I can see about trying to pick values that snap but I'm not sure how to do that. Do you have suggestions?
Elliott Sprehn
Comment 14 2013-02-06 15:27:46 PST
Elliott Sprehn
Comment 15 2013-02-06 15:29:32 PST
(In reply to comment #13) > (In reply to comment #12) > > (From update of attachment 182873 [details] [details]) > > View in context: https://bugs.webkit.org/attachment.cgi?id=182873&action=review > > > ... > > I had trouble with subpixel layout where my test fails in ports that don't have it turned on yet in Bug 92591, I can see about trying to pick values that snap but I'm not sure how to do that. Do you have suggestions? I fixed the other comments, but I left the test the way it is for now. I'll fix that in a follow up patch, for now I just added a FIXME.
Ojan Vafai
Comment 16 2013-02-06 16:21:28 PST
Comment on attachment 186933 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=186933&action=review > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1513 > +Node* CSSComputedStyleDeclaration::styledNode() const Can you add a FIXME to make this styledElement with a brief explanation that we create EditingStyles for TextNodes?
Elliott Sprehn
Comment 17 2013-02-07 16:41:20 PST
(In reply to comment #16) > (From update of attachment 186933 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=186933&action=review > > > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1513 > > +Node* CSSComputedStyleDeclaration::styledNode() const > > Can you add a FIXME to make this styledElement with a brief explanation that we create EditingStyles for TextNodes? Done.
Elliott Sprehn
Comment 18 2013-02-07 16:41:24 PST
Created attachment 187197 [details] Patch for landing
WebKit Review Bot
Comment 19 2013-02-07 17:42:06 PST
Comment on attachment 187197 [details] Patch for landing Clearing flags on attachment: 187197 Committed r142215: <http://trac.webkit.org/changeset/142215>
WebKit Review Bot
Comment 20 2013-02-07 17:42:12 PST
All reviewed patches have been landed. Closing bug.
Roger Fong
Comment 21 2013-02-07 18:48:30 PST
This broke about 100 tests on Windows port. http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r142215%20(32210)/results.html Please fix or roll out
Elliott Sprehn
Comment 22 2013-02-07 19:00:32 PST
(In reply to comment #21) > This broke about 100 tests on Windows port. > http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r142215%20(32210)/results.html > > Please fix or roll out It seems very unlikely it was this patch. All those failures have to do with compositing and not getComputedStyle. It also doesn't make any sense that all the pills would be green and then it would fail. :)
Elliott Sprehn
Comment 23 2013-02-07 19:16:02 PST
(In reply to comment #22) > (In reply to comment #21) > > This broke about 100 tests on Windows port. > > http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r142215%20(32210)/results.html > > > > Please fix or roll out > > It seems very unlikely it was this patch. All those failures have to do with compositing and not getComputedStyle. It also doesn't make any sense that all the pills would be green and then it would fail. :) Also note that the failures go away in the next run: http://build.webkit.org/results/Apple%20Win%207%20Release%20(Tests)/r142217%20%2832211%29/results.html http://build.webkit.org/builders/Apple%20Win%207%20Release%20%28Tests%29?numbuilds=100 This looks like a problem with the Windows bot, there's several other runs in the history that seem to fail hundreds where no patch makes sense and the next run is fine.
Roger Fong
Comment 24 2013-02-08 00:35:37 PST
Ah yes, my b, didn't really look at the commit, just which revision the tests went crazy on. I'll have to look into that bot hiccup at some point.
Note You need to log in before you can comment on or make changes to this bug.