Bug 105442

Summary: Querying transition-timing-function value on the computed style does not return keywords when it should.
Product: WebKit Reporter: Alexis Menard (darktears) <menard>
Component: CSSAssignee: Alexis Menard (darktears) <menard>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, cmarcelo, dglazkov, dino, macpherson, noam, ojan.autocc, simon.fraser, tabatkins, tmpsantos, webkit-ews, webkit.review.bot, zeno
Priority: P2 Keywords: WebExposed
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 106083    
Bug Blocks: 93136    
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Attempt to fix WK2 builds with CoordinatedGraphics
none
Another attempt to fix WK2 builds with CoordinatedGraphics
none
Patch
none
Patch
none
Patch for landing none

Alexis Menard (darktears)
Reported 2012-12-19 08:56:51 PST
Consider : style.transitionTimingFunction = "ease"; computedStyle.transitionTimingFunction will return cubic-bezier(0.25, 0.1, 0.25, 1) as Opera or FF for example. It is valid for ease-out, ease-in, ease-in-out, ease where the return value will be similar (e.g. cubic-bezier(x1, y1 , x2 , y2)). For some reason linear does not return cubic-bezier(0, 0, 1, 1) but "linear" making it inconsistent with other possible values and also inconsistent with other UA.
Attachments
Patch (4.92 KB, patch)
2012-12-20 03:48 PST, Alexis Menard (darktears)
no flags
Patch (18.66 KB, patch)
2012-12-20 04:25 PST, Alexis Menard (darktears)
no flags
Patch (43.59 KB, patch)
2012-12-28 11:53 PST, Alexis Menard (darktears)
no flags
Patch (43.63 KB, patch)
2012-12-28 12:06 PST, Alexis Menard (darktears)
no flags
Attempt to fix WK2 builds with CoordinatedGraphics (48.97 KB, patch)
2012-12-28 13:18 PST, Alexis Menard (darktears)
no flags
Another attempt to fix WK2 builds with CoordinatedGraphics (49.00 KB, patch)
2012-12-28 13:29 PST, Alexis Menard (darktears)
no flags
Patch (49.41 KB, patch)
2013-01-02 05:52 PST, Alexis Menard (darktears)
no flags
Patch (49.04 KB, patch)
2013-01-03 06:22 PST, Alexis Menard (darktears)
no flags
Patch for landing (48.86 KB, patch)
2013-01-03 11:42 PST, Alexis Menard (darktears)
no flags
Alexis Menard (darktears)
Comment 1 2012-12-20 03:48:27 PST
Alexis Menard (darktears)
Comment 2 2012-12-20 04:25:11 PST
Alexis Menard (darktears)
Comment 3 2012-12-20 12:31:09 PST
[16:17] <smfr> darktears: at some point css-wg talked about returning the "shorthand" functions [16:17] <smfr> darktears: does the spec say anything about this? [16:17] <darktears> smfr: not a word [16:17] <darktears> smfr: the serialization is not really documented, at least I made them consistent [16:18] <darktears> /s/made/make [16:18] <smfr> TabAtkins: any opinion on ^^ [16:20] <TabAtkins> smfr: Serialization is undefined, obviously. I'm fine with always returning a cubic-bezier().
Dean Jackson
Comment 4 2012-12-20 13:15:27 PST
I disagree here. I think we should return 'linear' when we know it is a linear timing function. The fact that we implement it under the hood as a cubic bezier doesn't need to be exposed. We originally returned cubic-bezier in all cases, but once we added the steps timing function it meant that developers had to do more than just look for a regular expression if they were going to interpret computed timing functions. So I figured it was better to be clear (and closer to what the developer specified) and return 'linear' where possible. I probably intended to do the same to the 'ease' forms, but they are a little trickier. You could also imagine a future where we have more timing function forms - like "bounce" or trig functions.
Tab Atkins
Comment 5 2012-12-20 14:41:16 PST
(In reply to comment #4) > I disagree here. I think we should return 'linear' when we know it is a linear timing function. The fact that we implement it under the hood as a cubic bezier doesn't need to be exposed. > > We originally returned cubic-bezier in all cases, but once we added the steps timing function it meant that developers had to do more than just look for a regular expression if they were going to interpret computed timing functions. So I figured it was better to be clear (and closer to what the developer specified) and return 'linear' where possible. I probably intended to do the same to the 'ease' forms, but they are a little trickier. > > You could also imagine a future where we have more timing function forms - like "bounce" or trig functions. If we do that, then we should go ahead and do it for all of them. We can either guess based on float equality, or just plumb a flag through so that the parser can tell you when it read a keyword.
Dean Jackson
Comment 6 2012-12-20 17:53:05 PST
(In reply to comment #5) > If we do that, then we should go ahead and do it for all of them. We can either guess based on float equality, or just plumb a flag through so that the parser can tell you when it read a keyword. Yes, I agree. Plumbing it through is a bit annoying, but otherwise we might return linear if someone specified cubic-bezier(0, 0, 1, 1)
Alexis Menard (darktears)
Comment 7 2012-12-21 04:57:53 PST
(In reply to comment #6) > (In reply to comment #5) > > > If we do that, then we should go ahead and do it for all of them. We can either guess based on float equality, or just plumb a flag through so that the parser can tell you when it read a keyword. > > Yes, I agree. Plumbing it through is a bit annoying, but otherwise we might return linear if someone specified cubic-bezier(0, 0, 1, 1) Ok I'll give a shot and rename the bug later if needed.
Alexis Menard (darktears)
Comment 8 2012-12-28 11:53:43 PST
Early Warning System Bot
Comment 9 2012-12-28 12:00:55 PST
Early Warning System Bot
Comment 10 2012-12-28 12:01:07 PST
EFL EWS Bot
Comment 11 2012-12-28 12:02:45 PST
Alexis Menard (darktears)
Comment 12 2012-12-28 12:06:59 PST
Early Warning System Bot
Comment 13 2012-12-28 12:15:29 PST
EFL EWS Bot
Comment 14 2012-12-28 12:23:20 PST
Build Bot
Comment 15 2012-12-28 13:03:43 PST
Comment on attachment 180891 [details] Patch Attachment 180891 [details] did not pass mac-ews (mac): Output: http://queues.webkit.org/results/15557836 New failing tests: svg/css/getComputedStyle-basic.xhtml fast/sub-pixel/sub-pixel-iframe-copy-on-scroll.html fast/sub-pixel/sub-pixel-accumulates-to-layers.html fast/sub-pixel/transformed-iframe-copy-on-scroll.html
Alexis Menard (darktears)
Comment 16 2012-12-28 13:18:58 PST
Created attachment 180895 [details] Attempt to fix WK2 builds with CoordinatedGraphics
Alexis Menard (darktears)
Comment 17 2012-12-28 13:29:13 PST
Created attachment 180898 [details] Another attempt to fix WK2 builds with CoordinatedGraphics
Kenneth Rohde Christiansen
Comment 18 2012-12-29 01:35:39 PST
Comment on attachment 180898 [details] Another attempt to fix WK2 builds with CoordinatedGraphics View in context: https://bugs.webkit.org/attachment.cgi?id=180898&action=review LGTM > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1108 > + } > + if (tf->isStepsTimingFunction()) { > + const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf); > + return CSSStepsTimingFunctionValue::create(stf->numberOfSteps(), stf->stepAtStart()); > + } > + return CSSLinearTimingFunctionValue::create(); I would suggest a newline around this if > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1122 > const TimingFunction* tf = animList->animation(i)->timingFunction().get(); > - if (tf->isCubicBezierTimingFunction()) { > - const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf); > - list->append(CSSCubicBezierTimingFunctionValue::create(ctf->x1(), ctf->y1(), ctf->x2(), ctf->y2())); > - } else if (tf->isStepsTimingFunction()) { > - const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf); > - list->append(CSSStepsTimingFunctionValue::create(stf->numberOfSteps(), stf->stepAtStart())); > - } else { > - list->append(CSSLinearTimingFunctionValue::create()); > - } > + list->append(createAnimationValue(tf)); > } > } else { > // Note that initialAnimationTimingFunction() is used for both transitions and animations > RefPtr<TimingFunction> tf = Animation::initialAnimationTimingFunction(); > - if (tf->isCubicBezierTimingFunction()) { > - const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf.get()); > - list->append(CSSCubicBezierTimingFunctionValue::create(ctf->x1(), ctf->y1(), ctf->x2(), ctf->y2())); > - } else if (tf->isStepsTimingFunction()) { > - const StepsTimingFunction* stf = static_cast<const StepsTimingFunction*>(tf.get()); > - list->append(CSSStepsTimingFunctionValue::create(stf->numberOfSteps(), stf->stepAtStart())); > - } else { > - list->append(CSSLinearTimingFunctionValue::create()); > - } > + list->append(createAnimationValue(tf.get())); why not use tf.get() both places. like change const TimingFunction* tf = animList->animation(i)->timingFunction().get(); to not include the .get() part? > Source/WebCore/platform/animation/TimingFunction.h:83 > + enum CubicBezierTimingFunctionType { > + Ease, EaseIn, EaseOut, EaseInOut, Custom > + }; I believe we should have those on separate lines > Source/WebCore/platform/animation/TimingFunction.h:88 > + > + static PassRefPtr<CubicBezierTimingFunction> create(CubicBezierTimingFunctionType type, double x1, double y1, double x2, double y2) > { > - return adoptRef(new CubicBezierTimingFunction(x1, y1, x2, y2)); > + return adoptRef(new CubicBezierTimingFunction(type, x1, y1, x2, y2)); > } In a way I don't like you call it type, when I can reuse a type with different values (which would then be considered an error). What about calling it ...FunctionDescription?
Alexis Menard (darktears)
Comment 19 2013-01-02 05:52:19 PST
Simon Fraser (smfr)
Comment 20 2013-01-02 20:59:56 PST
Comment on attachment 181027 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=181027&action=review > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1079 > +static PassRefPtr<CSSValue> createAnimationValue(const TimingFunction* tf) > +{ > + if (tf->isCubicBezierTimingFunction()) { You should expand 'tf' to timingFunction. > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1080 > + const CubicBezierTimingFunction* ctf = static_cast<const CubicBezierTimingFunction*>(tf); Avoid abbreviations like ctf. > Source/WebCore/css/CSSComputedStyleDeclaration.cpp:1082 > + CSSValueID id = CSSValueInvalid; Don't use 'id' (it's a reserved word in Objective-C). > Source/WebCore/css/CSSToStyleMap.cpp:460 > - animation->setTimingFunction(CubicBezierTimingFunction::create(0.42, 0.0, 1.0, 1.0)); > + animation->setTimingFunction(CubicBezierTimingFunction::create(CubicBezierTimingFunction::EaseIn, 0.42, 0.0, 1.0, 1.0)); Seems redundant to pass in both the enum, and the values that it corresponds to. Would be better to have an overloaded CubicBezierTimingFunction::create() and ctor that takes the enum only. > Source/WebCore/platform/animation/TimingFunction.h:105 > + return m_x1 == ctf->m_x1 && m_y1 == ctf->m_y1 && m_x2 == ctf->m_x2 && m_y2 == ctf->m_y2 && m_cubicBezierTimingFunctionDescription == ctf->m_cubicBezierTimingFunctionDescription; Can't you test the type first; you only need to test the values for custom functions.
Alexis Menard (darktears)
Comment 21 2013-01-03 06:22:32 PST
WebKit Review Bot
Comment 22 2013-01-03 07:46:21 PST
Comment on attachment 181170 [details] Patch Attachment 181170 [details] did not pass chromium-ews (chromium-xvfb): Output: http://queues.webkit.org/results/15635832 New failing tests: inspector-protocol/debugger-terminate-dedicated-worker-while-paused.html
Alexis Menard (darktears)
Comment 23 2013-01-03 07:49:52 PST
Comment on attachment 181170 [details] Patch Putting cq? again as the test failing is completely unrelated to my change.
Simon Fraser (smfr)
Comment 24 2013-01-03 10:35:03 PST
Comment on attachment 181170 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=181170&action=review > Source/WebCore/platform/animation/TimingFunction.h:81 > + enum CubicBezierTimingFunctionType { CubicBezierTimingFunctionType is a bit long-winded, esp. since this is in class scope. I think this would be better as TimingFunctionPreset or something, 'Type' seems a bit too general. > Source/WebCore/platform/animation/TimingFunction.h:122 > + return (m_cubicBezierTimingFunctionType != Custom && m_cubicBezierTimingFunctionType == ctf->m_cubicBezierTimingFunctionType) || (m_x1 == ctf->m_x1 && m_y1 == ctf->m_y1 && m_x2 == ctf->m_x2 && m_y2 == ctf->m_y2); I think this would be clearer as two separate if tests.
Alexis Menard (darktears)
Comment 25 2013-01-03 11:42:33 PST
Created attachment 181197 [details] Patch for landing
WebKit Review Bot
Comment 26 2013-01-03 12:24:06 PST
Comment on attachment 181197 [details] Patch for landing Clearing flags on attachment: 181197 Committed r138728: <http://trac.webkit.org/changeset/138728>
WebKit Review Bot
Comment 27 2013-01-03 12:24:11 PST
All reviewed patches have been landed. Closing bug.
Thiago Marcos P. Santos
Comment 28 2013-01-04 01:43:46 PST
Chris Dumez
Comment 29 2013-01-04 04:12:15 PST
(In reply to comment #28) > We have many new crashes after this patch on debug bots: > > http://build.webkit.org/results/EFL%20Linux%2064-bit%20Debug%20WK2/r138728%20(7648)/results.html I filed Bug 106083 to track the regression and uploaded a bugfix patch there.
Note You need to log in before you can comment on or make changes to this bug.