/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; const Cc = Components.classes; const Ci = Components.interfaces; const Cu = Components.utils; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils", "resource://gre/modules/BrowserUtils.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "DOMUtils", "@mozilla.org/inspector/dom-utils;1", "inIDOMUtils"); XPCOMUtils.defineLazyModuleGetter(this, "DeferredTask", "resource://gre/modules/DeferredTask.jsm"); const kStateActive = 0x00000001; // NS_EVENT_STATE_ACTIVE const kStateHover = 0x00000004; // NS_EVENT_STATE_HOVER // A process global state for whether or not content thinks // that a while it was open, so // we'll poke a DeferredTask to update the parent sometime // in the very near future. this._updateTimer.arm(); }); this.mut.observe(this.element, {childList: true, subtree: true}); }, uninit: function() { this.element.openInParentProcess = false; this.global.removeMessageListener("Forms:SelectDropDownItem", this); this.global.removeMessageListener("Forms:DismissedDropDown", this); this.global.removeMessageListener("Forms:MouseOver", this); this.global.removeMessageListener("Forms:MouseOut", this); this.global.removeEventListener("pagehide", this); this.global.removeEventListener("mozhidedropdown", this); this.element = null; this.global = null; this.mut.disconnect(); this._updateTimer.disarm(); this._updateTimer = null; gOpen = false; }, showDropDown: function() { this.element.openInParentProcess = true; let rect = this._getBoundingContentRect(); this.global.sendAsyncMessage("Forms:ShowDropDown", { rect: rect, options: this._buildOptionList(), selectedIndex: this.element.selectedIndex, direction: getComputedStyles(this.element).direction, isOpenedViaTouch: this.isOpenedViaTouch }); gOpen = true; }, _getBoundingContentRect: function() { return BrowserUtils.getElementBoundingScreenRect(this.element); }, _buildOptionList: function() { return buildOptionListForChildren(this.element); }, _update() { // The