LayoutTests/ChangeLog

 12010-01-30 Simon Fraser <simon.fraser@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Do color animations on premultiplied colors
 6 https://bugs.webkit.org/show_bug.cgi?id=34383
 7
 8 Testcase for animating from transparent colors.
 9
 10 * transitions/color-transition-premultiplied-expected.txt: Added.
 11 * transitions/color-transition-premultiplied.html: Added.
 12
1132010-01-29 Victor Wang <victorw@chromium.org>
214
315 Reviewed by darin@apple.com.

LayoutTests/transitions/color-transition-premultiplied-expected.txt

 1PASS - "background-color" property for "one" element at 0.5s saw something close to: 0,127,0
 2PASS - "background-color" property for "two" element at 0.5s saw something close to: 0,0,255
 3

LayoutTests/transitions/color-transition-premultiplied.html

 1<!DOCTYPE html>
 2
 3<html>
 4<head>
 5 <style type="text/css" media="screen">
 6
 7 .box {
 8 width: 100px;
 9 height: 100px;
 10 margin: 10px;
 11 border: 1px solid black;
 12 -webkit-transition: background-color 1s linear;
 13 -moz-transition: background-color 1s linear;
 14 }
 15
 16 #one {
 17 background-color: transparent;
 18 }
 19
 20 #one.changed {
 21 background-color: green;
 22 }
 23
 24 #two {
 25 background-color: rgba(0, 255, 0, 0);
 26 }
 27
 28 #two.changed {
 29 background-color: rgba(0, 0, 255, 1);
 30 }
 31 </style>
 32 <script src="transition-test-helpers.js" type="text/javascript" charset="utf-8"></script>
 33 <script type="text/javascript" charset="utf-8">
 34 const expectedValues = [
 35 // [time, element-id, property, expected-value, tolerance]
 36 [0.5, 'one', 'background-color', [0, 127, 0], 2],
 37 [0.5, 'two', 'background-color', [0, 0, 255], 2]
 38 ];
 39
 40 function setupTest()
 41 {
 42 document.getElementById('one').className = 'box changed';
 43 document.getElementById('two').className = 'box changed';
 44 }
 45
 46 runTransitionTest(expectedValues, setupTest, true);
 47 </script>
 48</head>
 49<body>
 50
 51 <div class="box" id="one">
 52 </div>
 53
 54 <div class="box" id="two">
 55 </div>
 56
 57 <div id="result">
 58 </div>
 59
 60</body>
 61</html>

WebCore/ChangeLog

 12010-01-30 Simon Fraser <simon.fraser@apple.com>
 2
 3 Reviewed by NOBODY (OOPS!).
 4
 5 Do color animations on premultiplied colors
 6 https://bugs.webkit.org/show_bug.cgi?id=34383
 7
 8 Convert colors to premultiplied alpha before interpolating them,
 9 then convert the result back to non-premultiplied. This gives better
 10 results when animating from transparent colors.
 11
 12 Test: transitions/color-transition-premultiplied.html
 13
 14 * page/animation/AnimationBase.cpp:
 15 (WebCore::blendFunc):
 16
1172010-01-29 Steve Falkenburg <sfalken@apple.com>
218
319 Reviewed by Darin Adler.

WebCore/page/animation/AnimationBase.cpp

@@static inline Color blendFunc(const AnimationBase* anim, const Color& from, cons
9292 if (progress == 1 && !to.isValid())
9393 return Color();
9494
95  return Color(blendFunc(anim, from.red(), to.red(), progress),
96  blendFunc(anim, from.green(), to.green(), progress),
97  blendFunc(anim, from.blue(), to.blue(), progress),
98  blendFunc(anim, from.alpha(), to.alpha(), progress));
 95 // Contrary to the name, RGBA32 actually stores ARGB, so we can initialize Color directly from premultipliedARGBFromColor().
 96 // Also, premultipliedARGBFromColor() bails on zero alpha, so special-case that.
 97 Color premultFrom = from.alpha() ? premultipliedARGBFromColor(from) : 0;
 98 Color premultTo = to.alpha() ? premultipliedARGBFromColor(to) : 0;
 99
 100 Color premultBlended(blendFunc(anim, premultFrom.red(), premultTo.red(), progress),
 101 blendFunc(anim, premultFrom.green(), premultTo.green(), progress),
 102 blendFunc(anim, premultFrom.blue(), premultTo.blue(), progress),
 103 blendFunc(anim, premultFrom.alpha(), premultTo.alpha(), progress));
 104
 105 return Color(colorFromPremultipliedARGB(premultBlended.rgb()));
99106}
100107
101108static inline Length blendFunc(const AnimationBase*, const Length& from, const Length& to, double progress)