{ delete content[getter]; return content[getter] = document.getAnonymousElementByAttribute( this, "anonid", anonid); }); } } let mm = this.content.messageManager; // process this._callbacks, then set to null so the chatbox creator // knows to make new callbacks immediately. if (this._callbacks) { for (let callback of this._callbacks) { callback(this); } this._callbacks = null; } mm.addMessageListener("Social:DOMTitleChanged", this); mm.sendAsyncMessage("WaitForDOMContentLoaded"); mm.addMessageListener("DOMContentLoaded", function DOMContentLoaded(event) { mm.removeMessageListener("DOMContentLoaded", DOMContentLoaded); this.isActive = !this.minimized; this._chat.loadButtonSet(this, this.getAttribute("buttonSet")); this._deferredChatLoaded.resolve(this); }.bind(this)); this.setActiveBrowser(); ]]> Promise.defer(); return this._deferredChatLoaded.promise; return document.getAnonymousElementByAttribute(this, "anonid", (this.remote ? "remote-" : "") + "content"); Cu.import("resource:///modules/Chat.jsm", {}).Chat; return this.getAttribute("minimized") == "true"; if (this.parentNode.nodeName == "chatbar") return this.parentNode; return null; return this.content.docShellIsActive; this.content.docShellIsActive = !!val; // let the chat frame know if it is being shown or hidden this.content.messageManager.sendAsyncMessage("Social:CustomEvent", { name: val ? "socialFrameShow" : "socialFrameHide" }); false { chatbox.content.messageManager.sendAsyncMessage("Social:SetDocumentTitle", { title: title }); deferred.resolve(chatbox); } ); } else { // attach this chatbox to the topmost browser window let Chat = Cu.import("resource:///modules/Chat.jsm").Chat; let win = Chat.findChromeWindowForChats(); let chatbar = win.document.getElementById("pinnedchats"); let origin = this.content.getAttribute("origin"); let cb = chatbar.openChat({ origin: origin, title: title, url: "about:blank" }); cb.promiseChatLoaded.then( () => { this.setDecorationAttributes(cb); this.swapDocShells(cb); chatbar.focus(); this.swappingWindows = true; this.close(); // chatboxForURL is a map of URL -> chatbox used to avoid opening // duplicate chat windows. Ensure reattached chat windows aren't // registered with about:blank as their URL, otherwise reattaching // more than one chat window isn't possible. chatbar.chatboxForURL.delete("about:blank"); chatbar.chatboxForURL.set(this.src, Cu.getWeakReference(cb)); cb.content.messageManager.sendAsyncMessage("Social:CustomEvent", { name: "socialFrameAttached" }); deferred.resolve(cb); } ); } return deferred.promise; ]]> if (this.chatbar) this.chatbar.selectedChat = this; this.setTitle(); if (this.isActive == this.minimized) this.isActive = !this.minimized; // to avoid reflows we cache the width of the nub. this.cachedWidthNub = 0; this._selectedChat = null; document.getAnonymousElementByAttribute(this, "anonid", "innerbox"); document.getAnonymousElementByAttribute(this, "anonid", "nubMenu"); document.getAnonymousElementByAttribute(this, "anonid", "nub"); new WeakMap() new Map(); as it // must exist before the (possibly delayed) bindings are created. cb._callbacks.push(aCallback); } cb.remote = !!aOptions.remote; // src also a javascript property; the src attribute is set in the ctor. cb.src = url; if (mode == "minimized") cb.setAttribute("minimized", "true"); cb.setAttribute("origin", origin); cb.setAttribute("label", title); this.insertBefore(cb, this.firstChild); this.selectedChat = cb; this.chatboxForURL.set(url, Cu.getWeakReference(cb)); this.resize(); return cb; ]]> availWidth) { // we need to collapse some. let toCollapse = []; for (let child of this.collapsibleChildren()) { if (currentWidth <= availWidth) break; toCollapse.push(child); currentWidth -= this.getTotalChildWidth(child); } if (toCollapse.length) { for (let child of toCollapse) this.collapseChat(child); } } else if (currentWidth < availWidth) { // we *might* be able to expand some - see how many. // XXX - if this was clever, it could know when removing the nub // leaves enough space to show all collapsed let toShow = []; for (let child of this.collapsedChildren()) { currentWidth += this.getTotalChildWidth(child); if (currentWidth > availWidth) break; toShow.push(child); } for (let child of toShow) this._showChat(child); // If none remain collapsed remove the nub. if (!this.hasCollapsedChildren) { this.nub.collapsed = true; } } // else: achievement unlocked - we are pixel-perfect! ]]>