addon-sdk/source/lib/sdk/deprecated/events/assembler.js

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 2 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 4
michael@0 5 "use strict";
michael@0 6
michael@0 7 const { Trait } = require("../light-traits");
michael@0 8 const { removeListener, on } = require("../../dom/events");
michael@0 9
michael@0 10 /**
michael@0 11 * Trait may be used for building objects / composing traits that wish to handle
michael@0 12 * multiple dom events from multiple event targets in one place. Event targets
michael@0 13 * can be added / removed by calling `observe / ignore` methods. Composer should
michael@0 14 * provide array of event types it wishes to handle as property
michael@0 15 * `supportedEventsTypes` and function for handling all those events as
michael@0 16 * `handleEvent` property.
michael@0 17 */
michael@0 18 exports.DOMEventAssembler = Trait({
michael@0 19 /**
michael@0 20 * Function that is supposed to handle all the supported events (that are
michael@0 21 * present in the `supportedEventsTypes`) from all the observed
michael@0 22 * `eventTargets`.
michael@0 23 * @param {Event} event
michael@0 24 * Event being dispatched.
michael@0 25 */
michael@0 26 handleEvent: Trait.required,
michael@0 27 /**
michael@0 28 * Array of supported event names.
michael@0 29 * @type {String[]}
michael@0 30 */
michael@0 31 supportedEventsTypes: Trait.required,
michael@0 32 /**
michael@0 33 * Adds `eventTarget` to the list of observed `eventTarget`s. Listeners for
michael@0 34 * supported events will be registered on the given `eventTarget`.
michael@0 35 * @param {EventTarget} eventTarget
michael@0 36 */
michael@0 37 observe: function observe(eventTarget) {
michael@0 38 this.supportedEventsTypes.forEach(function(eventType) {
michael@0 39 on(eventTarget, eventType, this);
michael@0 40 }, this);
michael@0 41 },
michael@0 42 /**
michael@0 43 * Removes `eventTarget` from the list of observed `eventTarget`s. Listeners
michael@0 44 * for all supported events will be unregistered from the given `eventTarget`.
michael@0 45 * @param {EventTarget} eventTarget
michael@0 46 */
michael@0 47 ignore: function ignore(eventTarget) {
michael@0 48 this.supportedEventsTypes.forEach(function(eventType) {
michael@0 49 removeListener(eventTarget, eventType, this);
michael@0 50 }, this);
michael@0 51 }
michael@0 52 });

mercurial