Skip to content

Instantly share code, notes, and snippets.

@daviddahl
Last active May 18, 2016 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daviddahl/3b4dae8ba67bc111dd296a4773425c2e to your computer and use it in GitHub Desktop.
Save daviddahl/3b4dae8ba67bc111dd296a4773425c2e to your computer and use it in GitHub Desktop.
CSS transform research

CSS transform research

Find, in the relevant standard(s), why the following works in Gecko:

  • elem.style.WebKitTransform

A:

It is difficult to tell from reading the spec why the browser implementations behave the way the do. Outside of the standards process, human decisions around not supporting unstandardized browser functionality and behavior drove the usage of -webkit-* and -moz-*. digging through the mailing lists will no doubt turn up the exact reasons.

For now, the techical reasons are found in code.

In Gecko there is a CSS property alias for WebkitTransform here: http://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSPropAliasList.h#234

But the following doesn't:

  • elem.style[-webkit-transform]

A:

A reference to -moz-transform is in a list of CSS properties (-webkit-transform is not included), here: http://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSPropList.h#4207 but alas, not corresponding -webkit-transform.

I would love to know exactly why - not the "techical why" but I fear this will take too much of my day away.

And relatedly, why both work in Chrome.

A:

Naturally, the original implementation was probably completed before the spec was adopted by vendors. The latest W3C spec appears to still be A working draft. Whuck?

Finding relevant bugs (Bugzilla, crbug, spec bugs, etc.) and links to source code would be helpful

A:

It looks like Mozilla did some research into prefixes to help determine which -webkit prefixixes might warrant support. transform is talked about a lot here: https://bugzilla.mozilla.org/show_bug.cgi?id=708406#c6 It would seem that getting it unprefixed was the goal, however, I am unsure what the final result was - at that time. A few questions for dbaron or jet might help me understand better.

@miketaylr
Copy link

A reference to -moz-transform is in a list of CSS properties (-webkit-transform is not included), here: http://mxr.mozilla.org/mozilla-central/source/layout/style/nsCSSPropList.h#4207 but alas, not corresponding -webkit-transform.

But elem.style[-moz-transform] doesn't work either. So it's not really a question of aliases, but more about why a CSSStyleDeclaration setter works for one form and not the other.

The "technical" why this doesn't work is found here: http://mxr.mozilla.org/mozilla-central/source/dom/bindings/GenerateCSS2PropertiesWebIDL.py#36

The "spec" why is https://www.w3.org/Bugs/Public/show_bug.cgi?id=29440, in that it's not actually (unabiguously) defined in the CSSOM spec yet. But Chrome and Edge support that... just because?

https://bugzilla.mozilla.org/show_bug.cgi?id=1246796 has some more context and webcompat/web-bugs#1039 (comment) is the original bug that inspired this exercise. ^_^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment