highlighters.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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 { FrontClassWithSpec, custom } = require("devtools/shared/protocol");
  6. const {
  7. customHighlighterSpec,
  8. highlighterSpec
  9. } = require("devtools/shared/specs/highlighters");
  10. const HighlighterFront = FrontClassWithSpec(highlighterSpec, {
  11. // Update the object given a form representation off the wire.
  12. form: function (json) {
  13. this.actorID = json.actor;
  14. // FF42+ HighlighterActors starts exposing custom form, with traits object
  15. this.traits = json.traits || {};
  16. },
  17. pick: custom(function (doFocus) {
  18. if (doFocus && this.pickAndFocus) {
  19. return this.pickAndFocus();
  20. }
  21. return this._pick();
  22. }, {
  23. impl: "_pick"
  24. })
  25. });
  26. exports.HighlighterFront = HighlighterFront;
  27. const CustomHighlighterFront = FrontClassWithSpec(customHighlighterSpec, {});
  28. exports.CustomHighlighterFront = CustomHighlighterFront;