CSSFontFaceRule.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //.CommonJS
  2. var CSSOM = {
  3. CSSStyleDeclaration: require("./CSSStyleDeclaration").CSSStyleDeclaration,
  4. CSSRule: require("./CSSRule").CSSRule
  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://dev.w3.org/csswg/cssom/#css-font-face-rule
  16. */
  17. CSSOM.CSSFontFaceRule = function CSSFontFaceRule() {
  18. CSSOM.CSSRule.call(this);
  19. this.__style = new CSSOM.CSSStyleDeclaration();
  20. this.__style.parentRule = this;
  21. };
  22. CSSOM.CSSFontFaceRule.prototype = Object.create(CSSOM.CSSRule.prototype);
  23. CSSOM.CSSFontFaceRule.prototype.constructor = CSSOM.CSSFontFaceRule;
  24. Object.setPrototypeOf(CSSOM.CSSFontFaceRule, CSSOM.CSSRule);
  25. Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "type", {
  26. value: 5,
  27. writable: false
  28. });
  29. //FIXME
  30. //CSSOM.CSSFontFaceRule.prototype.insertRule = CSSStyleSheet.prototype.insertRule;
  31. //CSSOM.CSSFontFaceRule.prototype.deleteRule = CSSStyleSheet.prototype.deleteRule;
  32. Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "style", {
  33. get: function() {
  34. return this.__style;
  35. },
  36. set: function(value) {
  37. if (typeof value === "string") {
  38. this.__style.cssText = value;
  39. } else {
  40. this.__style = value;
  41. }
  42. }
  43. });
  44. // http://www.opensource.apple.com/source/WebCore/WebCore-955.66.1/css/WebKitCSSFontFaceRule.cpp
  45. Object.defineProperty(CSSOM.CSSFontFaceRule.prototype, "cssText", {
  46. get: function() {
  47. return "@font-face {" + (this.style.cssText ? " " + this.style.cssText : "") + " }";
  48. }
  49. });
  50. //.CommonJS
  51. exports.CSSFontFaceRule = CSSOM.CSSFontFaceRule;
  52. ///CommonJS