CSSKeyframeRule.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //.CommonJS
  2. var CSSOM = {
  3. CSSRule: require("./CSSRule").CSSRule,
  4. CSSStyleDeclaration: require('./CSSStyleDeclaration').CSSStyleDeclaration
  5. };
  6. // Use cssstyle if available
  7. try {
  8. CSSOM.CSSStyleDeclaration = require("cssstyle").CSSStyleDeclaration;
  9. } catch (e) {
  10. // ignore
  11. }
  12. ///CommonJS
  13. /**
  14. * @constructor
  15. * @see http://www.w3.org/TR/css3-animations/#DOM-CSSKeyframeRule
  16. */
  17. CSSOM.CSSKeyframeRule = function CSSKeyframeRule() {
  18. CSSOM.CSSRule.call(this);
  19. this.keyText = '';
  20. this.__style = new CSSOM.CSSStyleDeclaration();
  21. this.__style.parentRule = this;
  22. };
  23. CSSOM.CSSKeyframeRule.prototype = Object.create(CSSOM.CSSRule.prototype);
  24. CSSOM.CSSKeyframeRule.prototype.constructor = CSSOM.CSSKeyframeRule;
  25. Object.setPrototypeOf(CSSOM.CSSKeyframeRule, CSSOM.CSSRule);
  26. Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "type", {
  27. value: 8,
  28. writable: false
  29. });
  30. //FIXME
  31. //CSSOM.CSSKeyframeRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
  32. //CSSOM.CSSKeyframeRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
  33. Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "style", {
  34. get: function() {
  35. return this.__style;
  36. },
  37. set: function(value) {
  38. if (typeof value === "string") {
  39. this.__style.cssText = value;
  40. } else {
  41. this.__style = value;
  42. }
  43. }
  44. });
  45. // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSKeyframeRule.cpp
  46. Object.defineProperty(CSSOM.CSSKeyframeRule.prototype, "cssText", {
  47. get: function() {
  48. return this.keyText + " {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
  49. }
  50. });
  51. //.CommonJS
  52. exports.CSSKeyframeRule = CSSOM.CSSKeyframeRule;
  53. ///CommonJS