stylesheets.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const {
  6. Arg,
  7. RetVal,
  8. generateActorSpec,
  9. types
  10. } = require("devtools/shared/protocol");
  11. const originalSourceSpec = generateActorSpec({
  12. typeName: "originalsource",
  13. methods: {
  14. getText: {
  15. response: {
  16. text: RetVal("longstring")
  17. }
  18. }
  19. }
  20. });
  21. exports.originalSourceSpec = originalSourceSpec;
  22. const mediaRuleSpec = generateActorSpec({
  23. typeName: "mediarule",
  24. events: {
  25. "matches-change": {
  26. type: "matchesChange",
  27. matches: Arg(0, "boolean"),
  28. }
  29. }
  30. });
  31. exports.mediaRuleSpec = mediaRuleSpec;
  32. types.addActorType("stylesheet");
  33. const styleSheetSpec = generateActorSpec({
  34. typeName: "stylesheet",
  35. events: {
  36. "property-change": {
  37. type: "propertyChange",
  38. property: Arg(0, "string"),
  39. value: Arg(1, "json")
  40. },
  41. "style-applied": {
  42. type: "styleApplied",
  43. kind: Arg(0, "number"),
  44. styleSheet: Arg(1, "stylesheet")
  45. },
  46. "media-rules-changed": {
  47. type: "mediaRulesChanged",
  48. rules: Arg(0, "array:mediarule")
  49. }
  50. },
  51. methods: {
  52. toggleDisabled: {
  53. response: { disabled: RetVal("boolean")}
  54. },
  55. getText: {
  56. response: {
  57. text: RetVal("longstring")
  58. }
  59. },
  60. getOriginalSources: {
  61. request: {},
  62. response: {
  63. originalSources: RetVal("nullable:array:originalsource")
  64. }
  65. },
  66. getOriginalLocation: {
  67. request: {
  68. line: Arg(0, "number"),
  69. column: Arg(1, "number")
  70. },
  71. response: RetVal(types.addDictType("originallocationresponse", {
  72. source: "string",
  73. line: "number",
  74. column: "number"
  75. }))
  76. },
  77. getMediaRules: {
  78. request: {},
  79. response: {
  80. mediaRules: RetVal("nullable:array:mediarule")
  81. }
  82. },
  83. update: {
  84. request: {
  85. text: Arg(0, "string"),
  86. transition: Arg(1, "boolean")
  87. }
  88. }
  89. }
  90. });
  91. exports.styleSheetSpec = styleSheetSpec;
  92. const styleSheetsSpec = generateActorSpec({
  93. typeName: "stylesheets",
  94. events: {
  95. "stylesheet-added": {
  96. type: "stylesheetAdded",
  97. sheet: Arg(0, "stylesheet"),
  98. isNew: Arg(1, "boolean")
  99. },
  100. },
  101. methods: {
  102. getStyleSheets: {
  103. request: {},
  104. response: { styleSheets: RetVal("array:stylesheet") }
  105. },
  106. addStyleSheet: {
  107. request: { text: Arg(0, "string") },
  108. response: { styleSheet: RetVal("stylesheet") }
  109. }
  110. }
  111. });
  112. exports.styleSheetsSpec = styleSheetsSpec;