зеркало из https://github.com/mozilla/pjs.git
Bug 386949 - Browsers should share autoscroll popups when possible; otherwise, a browser should delete its popup when it's closed
r=mano
This commit is contained in:
Родитель
40e116efc8
Коммит
b71961df8a
|
@ -639,6 +639,11 @@
|
||||||
this.removeEventListener("pageshow", this.onPageShow, true);
|
this.removeEventListener("pageshow", this.onPageShow, true);
|
||||||
this.removeEventListener("pagehide", this.onPageHide, true);
|
this.removeEventListener("pagehide", this.onPageHide, true);
|
||||||
this.removeEventListener("DOMPopupBlocked", this.onPopupBlocked, true);
|
this.removeEventListener("DOMPopupBlocked", this.onPopupBlocked, true);
|
||||||
|
|
||||||
|
if (this._autoScrollNeedsCleanup) {
|
||||||
|
// we polluted the global scope, so clean it up
|
||||||
|
this._autoScrollPopup.parentNode.removeChild(this._autoScrollPopup);
|
||||||
|
}
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
@ -679,6 +684,7 @@
|
||||||
<field name="_screenX">null</field>
|
<field name="_screenX">null</field>
|
||||||
<field name="_screenY">null</field>
|
<field name="_screenY">null</field>
|
||||||
<field name="_autoScrollPopup">null</field>
|
<field name="_autoScrollPopup">null</field>
|
||||||
|
<field name="_autoScrollNeedsCleanup">false</field>
|
||||||
|
|
||||||
<method name="stopScroll">
|
<method name="stopScroll">
|
||||||
<body>
|
<body>
|
||||||
|
@ -695,18 +701,36 @@
|
||||||
</body>
|
</body>
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
|
<method name="_createAutoScrollPopup">
|
||||||
|
<body>
|
||||||
|
<![CDATA[
|
||||||
|
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||||
|
var popup = document.createElementNS(XUL_NS, "popup");
|
||||||
|
popup.id = "autoscroller";
|
||||||
|
return popup;
|
||||||
|
]]>
|
||||||
|
</body>
|
||||||
|
</method>
|
||||||
|
|
||||||
<method name="startScroll">
|
<method name="startScroll">
|
||||||
<parameter name="event"/>
|
<parameter name="event"/>
|
||||||
<body>
|
<body>
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
// if the tabbrowser didn't point us to a cached popup, we're not in a tabbrowser, so use global scope
|
|
||||||
if (!this._autoScrollPopup) {
|
if (!this._autoScrollPopup) {
|
||||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
if (this.hasAttribute("autoscrollpopup")) {
|
||||||
this._autoScrollPopup = document.createElementNS(XUL_NS, "popup");
|
// our creator provided a popup to share
|
||||||
this._autoScrollPopup.id = "autoscroller";
|
this._autoScrollPopup = document.getElementById(this.getAttribute("autoscrollpopup"));
|
||||||
this._autoScrollPopup.addEventListener("popuphidden", this, true);
|
|
||||||
document.documentElement.appendChild(this._autoScrollPopup);
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
// we weren't provided a popup; we have to use the global scope
|
||||||
|
this._autoScrollPopup = this._createAutoScrollPopup();
|
||||||
|
document.documentElement.appendChild(this._autoScrollPopup);
|
||||||
|
this._autoScrollNeedsCleanup = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this._autoScrollPopup.addEventListener("popuphidden", this, true);
|
||||||
|
|
||||||
this._scrollingView = event.originalTarget.ownerDocument.defaultView;
|
this._scrollingView = event.originalTarget.ownerDocument.defaultView;
|
||||||
if (this._scrollingView.scrollMaxX > 0) {
|
if (this._scrollingView.scrollMaxX > 0) {
|
||||||
this._autoScrollPopup.setAttribute("scrolldir", this._scrollingView.scrollMaxY > 0 ? "NSEW" : "EW");
|
this._autoScrollPopup.setAttribute("scrolldir", this._scrollingView.scrollMaxY > 0 ? "NSEW" : "EW");
|
||||||
|
@ -853,6 +877,7 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "popuphidden": {
|
case "popuphidden": {
|
||||||
|
this._autoScrollPopup.removeEventListener("popuphidden", this, true);
|
||||||
this.stopScroll();
|
this.stopScroll();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,6 +198,9 @@
|
||||||
<field name="_blockDblClick">
|
<field name="_blockDblClick">
|
||||||
false
|
false
|
||||||
</field>
|
</field>
|
||||||
|
<field name="_autoScrollPopup">
|
||||||
|
null
|
||||||
|
</field>
|
||||||
|
|
||||||
<method name="getBrowserAtIndex">
|
<method name="getBrowserAtIndex">
|
||||||
<parameter name="aIndex"/>
|
<parameter name="aIndex"/>
|
||||||
|
@ -1217,6 +1220,7 @@
|
||||||
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
b.setAttribute("tooltip", this.getAttribute("contenttooltip"));
|
||||||
if (this.hasAttribute("autocompletepopup"))
|
if (this.hasAttribute("autocompletepopup"))
|
||||||
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
|
b.setAttribute("autocompletepopup", this.getAttribute("autocompletepopup"));
|
||||||
|
b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
|
||||||
|
|
||||||
// Add the Message and the Browser to the box
|
// Add the Message and the Browser to the box
|
||||||
var notificationbox = document.createElementNS(
|
var notificationbox = document.createElementNS(
|
||||||
|
@ -2452,6 +2456,11 @@
|
||||||
this.mTabContainer.childNodes[0].linkedPanel = uniqueId;
|
this.mTabContainer.childNodes[0].linkedPanel = uniqueId;
|
||||||
this.mTabContainer.childNodes[0]._tPos = 0;
|
this.mTabContainer.childNodes[0]._tPos = 0;
|
||||||
this.mTabContainer.childNodes[0].linkedBrowser = this.mPanelContainer.childNodes[0].firstChild;
|
this.mTabContainer.childNodes[0].linkedBrowser = this.mPanelContainer.childNodes[0].firstChild;
|
||||||
|
|
||||||
|
// set up the shared autoscroll popup
|
||||||
|
this._autoScrollPopup = this.mCurrentBrowser._createAutoScrollPopup();
|
||||||
|
this.appendChild(this._autoScrollPopup);
|
||||||
|
this.mCurrentBrowser.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
|
||||||
]]>
|
]]>
|
||||||
</constructor>
|
</constructor>
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче