Aucune description

image-rendering.js 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. (function() {
  2. var Declaration, ImageRendering,
  3. extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
  4. hasProp = {}.hasOwnProperty;
  5. Declaration = require('../declaration');
  6. ImageRendering = (function(superClass) {
  7. extend(ImageRendering, superClass);
  8. function ImageRendering() {
  9. return ImageRendering.__super__.constructor.apply(this, arguments);
  10. }
  11. ImageRendering.names = ['image-rendering', 'interpolation-mode'];
  12. ImageRendering.prototype.check = function(decl) {
  13. return decl.value === 'pixelated';
  14. };
  15. ImageRendering.prototype.prefixed = function(prop, prefix) {
  16. if (prefix === '-ms-') {
  17. return '-ms-interpolation-mode';
  18. } else {
  19. return ImageRendering.__super__.prefixed.apply(this, arguments);
  20. }
  21. };
  22. ImageRendering.prototype.set = function(decl, prefix) {
  23. if (prefix === '-ms-') {
  24. decl.prop = '-ms-interpolation-mode';
  25. decl.value = 'nearest-neighbor';
  26. return decl;
  27. } else {
  28. return ImageRendering.__super__.set.apply(this, arguments);
  29. }
  30. };
  31. ImageRendering.prototype.normalize = function(prop) {
  32. return 'image-rendering';
  33. };
  34. ImageRendering.prototype.process = function(node, result) {
  35. if (this.name === 'image-rendering' && node.value === 'crisp-edges') {
  36. result.warn('There is no browsers with crisp-edges rendering support.' + 'Maybe you mean pixelated?', {
  37. node: node
  38. });
  39. }
  40. return ImageRendering.__super__.process.apply(this, arguments);
  41. };
  42. return ImageRendering;
  43. })(Declaration);
  44. module.exports = ImageRendering;
  45. }).call(this);