Skip to content

Commit 7d96426

Browse files
committed
Fix DFL-3365: Update initial and suggested CSS properties with new unprefixed properties.
1 parent 0200411 commit 7d96426

File tree

3 files changed

+154
-2
lines changed

3 files changed

+154
-2
lines changed

src/style/css_shorthand_resolver.js

Lines changed: 119 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,84 @@ CssShorthandResolver.shorthands = (function() {
279279
var get_initial_value = cls.Stylesheets.get_initial_value;
280280

281281
return {
282+
"animation": {
283+
properties: [
284+
// Note that animation-play-state is not part of the shorthand
285+
"animation-name",
286+
"animation-duration",
287+
"animation-timing-function",
288+
"animation-delay",
289+
"animation-iteration-count",
290+
"animation-direction",
291+
"animation-fill-mode"
292+
],
293+
format: function(decls) {
294+
// Workaround for CORE-45497: -o-animation-duration computed style
295+
// missing comma when having multiple values
296+
// Fixed in ci-322
297+
var duration = decls["animation-duration"];
298+
if (duration.value.indexOf(" ") !== -1 && duration.value.indexOf(",") === -1)
299+
duration.value = duration.value.replace(/\s+/g, ", ");
300+
301+
var declarations = split_values(decls);
302+
var template = [];
303+
var len = declarations["animation-name"].length;
304+
resolve_multiple_values(declarations, len);
305+
for (var i = 0; i < len; i++)
306+
{
307+
var sub_template = [];
308+
var is_final_layer = (i == len-1);
309+
// The spec says that the first value that can be parsed as time is
310+
// assigned to the animation-duration. There are two time values in
311+
// the shorthand, 'duration' and 'delay'. If delay has a non-default
312+
// value, we must therefore include duration.
313+
var is_default_delay = declarations["animation-delay"][i].value ==
314+
get_initial_value("animation-delay");
315+
316+
if (declarations["animation-name"][i].value !=
317+
get_initial_value("animation-name"))
318+
sub_template.push(" ", declarations["animation-name"][i]);
319+
320+
if (!is_default_delay || declarations["animation-duration"][i].value !=
321+
get_initial_value("animation-duration"))
322+
sub_template.push(" ", declarations["animation-duration"][i]);
323+
324+
if (declarations["animation-timing-function"][i].value !=
325+
get_initial_value("animation-timing-function"))
326+
sub_template.push(" ", declarations["animation-timing-function"][i]);
327+
328+
if (!is_default_delay)
329+
sub_template.push(" ", declarations["animation-delay"][i]);
330+
331+
if (declarations["animation-iteration-count"][i].value !=
332+
get_initial_value("animation-iteration-count"))
333+
sub_template.push(" ", declarations["animation-iteration-count"][i]);
334+
335+
if (declarations["animation-direction"][i].value !=
336+
get_initial_value("animation-direction"))
337+
sub_template.push(" ", declarations["animation-direction"][i]);
338+
339+
if (declarations["animation-fill-mode"][i].value !=
340+
get_initial_value("animation-fill-mode"))
341+
sub_template.push(" ", declarations["animation-fill-mode"][i]);
342+
343+
// There's always an extra space at the beginning, remove it here
344+
sub_template.splice(0, 1);
345+
346+
// If all properties have default values, at least append the default name
347+
if (!sub_template.length)
348+
template.push("none");
349+
350+
if (!is_final_layer)
351+
sub_template.push(", ");
352+
353+
template.push.apply(template, sub_template);
354+
}
355+
356+
return template;
357+
}
358+
},
359+
282360
"-o-animation": {
283361
properties: [
284362
// Note that -o-animation-play-state is not part of the shorthand
@@ -769,6 +847,33 @@ CssShorthandResolver.shorthands = (function() {
769847
}
770848
},
771849

850+
"transition": {
851+
properties: [
852+
"transition-property",
853+
"transition-duration",
854+
"transition-timing-function",
855+
"transition-delay",
856+
],
857+
format: function(decls) {
858+
var declarations = split_values(decls);
859+
var template = [];
860+
var len = declarations["transition-property"].length;
861+
resolve_multiple_values(declarations, len);
862+
for (var i = 0; i < len; i++)
863+
{
864+
template.push(
865+
get_tokens(declarations["transition-property"][i]), " ",
866+
get_tokens(declarations["transition-duration"][i]), " ",
867+
get_tokens(declarations["transition-timing-function"][i]), " ",
868+
get_tokens(declarations["transition-delay"][i]), ", "
869+
);
870+
}
871+
template.splice(-1, 1); // Remove the last ','
872+
873+
return template;
874+
}
875+
},
876+
772877
"-o-transition": {
773878
properties: [
774879
"-o-transition-property",
@@ -799,7 +904,15 @@ CssShorthandResolver.shorthands = (function() {
799904
})();
800905

801906
CssShorthandResolver.property_to_shorthand = {
802-
// Note that -o-animation-play-state is not part of the shorthand
907+
// Note that animation-play-state is not part of the shorthand
908+
"animation-delay": "animation",
909+
"animation-direction": "animation",
910+
"animation-duration": "animation",
911+
"animation-fill-mode": "animation",
912+
"animation-iteration-count": "animation",
913+
"animation-name": "animation",
914+
"animation-timing-function": "animation",
915+
803916
"-o-animation-delay": "-o-animation",
804917
"-o-animation-direction": "-o-animation",
805918
"-o-animation-duration": "-o-animation",
@@ -878,6 +991,11 @@ CssShorthandResolver.property_to_shorthand = {
878991

879992
// pause not supported
880993

994+
"transition-property": "transition",
995+
"transition-duration": "transition",
996+
"transition-timing-function": "transition",
997+
"transition-delay": "transition",
998+
881999
"-o-transition-property": "-o-transition",
8821000
"-o-transition-duration": "-o-transition",
8831001
"-o-transition-timing-function": "-o-transition",

src/style/css_suggest_values.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,27 +204,32 @@ suggest_values['-o-border-image'] =
204204
[
205205
];
206206

207+
suggest_values['animation'] =
207208
suggest_values['-o-animation'] =
208209
[
209210
];
210211

212+
suggest_values['animation-delay'] =
211213
suggest_values['-o-animation-delay'] =
212214
[
213215
// <time>
214216
'0'
215217
];
216218

219+
suggest_values['animation-direction'] =
217220
suggest_values['-o-animation-direction'] =
218221
[
219222
'normal',
220223
'alternate'
221224
];
222225

226+
suggest_values['animation-duration'] =
223227
suggest_values['-o-animation-duration'] =
224228
[
225229
'0'
226230
];
227231

232+
suggest_values['animation-fill-mode'] =
228233
suggest_values['-o-animation-fill-mode'] =
229234
[
230235
'none',
@@ -233,23 +238,27 @@ suggest_values['-o-animation-fill-mode'] =
233238
'both'
234239
];
235240

241+
suggest_values['animation-iteration-count'] =
236242
suggest_values['-o-animation-iteration-count'] =
237243
[
238244
// <number>
239245
'infinite'
240246
];
241247

248+
suggest_values['animation-name'] =
242249
suggest_values['-o-animation-name'] =
243250
[
244251
'none'
245252
];
246253

254+
suggest_values['animation-play-state'] =
247255
suggest_values['-o-animation-play-state'] =
248256
[
249257
'running',
250258
'paused'
251259
];
252260

261+
suggest_values['animation-timing-function'] =
253262
suggest_values['-o-animation-timing-function'] =
254263
[
255264
'ease',
@@ -283,11 +292,13 @@ suggest_values['-o-text-overflow'] =
283292
'ellipsis'
284293
];
285294

295+
suggest_values['transform'] =
286296
suggest_values['-o-transform'] =
287297
[
288298
'none'
289299
];
290300

301+
suggest_values['transform-origin'] =
291302
suggest_values['-o-transform-origin'] =
292303
[
293304
'left',
@@ -297,24 +308,29 @@ suggest_values['-o-transform-origin'] =
297308
'bottom'
298309
];
299310

311+
suggest_values['transition'] =
300312
suggest_values['-o-transition'] =
301313
[
302314
];
303315

316+
suggest_values['transition-delay'] =
304317
suggest_values['-o-transition-delay'] =
305318
[
306319
];
307320

321+
suggest_values['transition-duration'] =
308322
suggest_values['-o-transition-duration'] =
309323
[
310324
];
311325

326+
suggest_values['transition-property'] =
312327
suggest_values['-o-transition-property'] =
313328
[
314329
'none',
315330
'all'
316331
];
317332

333+
suggest_values['transition-timing-function'] =
318334
suggest_values['-o-transition-timing-function'] =
319335
[
320336
'ease',

src/style/stylesheets.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,30 +355,39 @@ cls.Stylesheets.get_initial_value = function(prop, data, index_map)
355355
case "-apple-dashboard-region":
356356
return "";
357357

358+
case "animation":
358359
case "-o-animation":
359360
return "none 0s 0s cubic-bezier(0.25, 0.1, 0.25, 1) normal none 1";
360361

362+
case "animation-delay":
361363
case "-o-animation-delay":
362364
return "0s";
363365

366+
case "animation-direction":
364367
case "-o-animation-direction":
365368
return "normal";
366369

370+
case "animation-duration":
367371
case "-o-animation-duration":
368372
return "0s";
369373

374+
case "animation-fill-mode":
370375
case "-o-animation-fill-mode":
371376
return "none";
372377

378+
case "animation-iteration-count":
373379
case "-o-animation-iteration-count":
374380
return "1";
375381

382+
case "animation-name":
376383
case "-o-animation-name":
377384
return "none";
378385

386+
case "animation-play-state":
379387
case "-o-animation-play-state":
380388
return "running";
381389

390+
case "animation-timing-function":
382391
case "-o-animation-timing-function":
383392
return "cubic-bezier(0.25, 0.1, 0.25, 1)";
384393

@@ -412,10 +421,12 @@ cls.Stylesheets.get_initial_value = function(prop, data, index_map)
412421
case "-o-text-overflow":
413422
return "";
414423

424+
case "transform":
415425
case "-o-transform":
416426
case "-webkit-transform":
417427
return "none";
418428

429+
case "transform-origin":
419430
case "-o-transform-origin":
420431
case "-webkit-transform-origin":
421432
var w = parseInt(data[index_map.indexOf("width")]) || 0;
@@ -429,22 +440,27 @@ cls.Stylesheets.get_initial_value = function(prop, data, index_map)
429440
}
430441
return (w / 2) + "px " + (h / 2) + "px";
431442

443+
case "transition":
432444
case "-o-transition":
433445
case "-webkit-transition":
434446
return "all 0s 0s cubic-bezier(0.25, 0.1, 0.25, 1)";
435447

448+
case "transition-delay":
436449
case "-o-transition-delay":
437450
case "-webkit-transition-delay":
438451
return "0s";
439452

453+
case "transition-duration":
440454
case "-o-transition-duration":
441455
case "-webkit-transition-duration":
442456
return "0s";
443457

458+
case "transition-property":
444459
case "-o-transition-property":
445460
case "-webkit-transition-property":
446461
return "all";
447462

463+
case "transition-timing-function":
448464
case "-o-transition-timing-function":
449465
case "-webkit-transition-timing-function":
450466
return "cubic-bezier(0.25, 0.1, 0.25, 1)";
@@ -528,6 +544,7 @@ cls.Stylesheets.get_initial_value = function(prop, data, index_map)
528544
return "repeat";
529545

530546
case "background-size":
547+
case "-webkit-background-size":
531548
return "auto";
532549

533550
case "baseline-shift":
@@ -600,7 +617,8 @@ cls.Stylesheets.get_initial_value = function(prop, data, index_map)
600617
return "0px";
601618

602619
case "border-radius":
603-
return "";
620+
case "-webkit-border-radius":
621+
return "0px";
604622

605623
case "border-bottom-left-radius":
606624
case "-webkit-border-bottom-left-radius":

0 commit comments

Comments
 (0)