зеркало из https://github.com/mozilla/gecko-dev.git
Bug 646038 - URL destination flickers when the mouse pointer is over a link positioned at the bottom corner. r=gavin
This commit is contained in:
Родитель
c1fdf87b38
Коммит
bb817daa90
|
@ -479,6 +479,7 @@ statuspanel {
|
|||
margin-top: -3em;
|
||||
left: 0;
|
||||
max-width: 50%;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
statuspanel:-moz-locale-dir(ltr)[mirror],
|
||||
|
@ -505,7 +506,6 @@ statuspanel[type=overLink] {
|
|||
statuspanel[inactive] {
|
||||
-moz-transition: none;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
statuspanel[inactive][previoustype=overLink] {
|
||||
|
|
|
@ -1751,6 +1751,9 @@ function delayedStartup(isLoadingBlank, mustLoadSidebar) {
|
|||
document.getElementById("appmenu_charsetMenu").hidden = true;
|
||||
#endif
|
||||
|
||||
window.addEventListener("mousemove", MousePosTracker, false);
|
||||
window.addEventListener("dragover", MousePosTracker, false);
|
||||
|
||||
Services.obs.notifyObservers(window, "browser-delayed-startup-finished", "");
|
||||
}
|
||||
|
||||
|
@ -9056,6 +9059,69 @@ XPCOMUtils.defineLazyGetter(window, "gShowPageResizers", function () {
|
|||
#endif
|
||||
});
|
||||
|
||||
|
||||
var MousePosTracker = {
|
||||
_listeners: [],
|
||||
_x: 0,
|
||||
_y: 0,
|
||||
get _windowUtils() {
|
||||
delete this._windowUtils;
|
||||
return this._windowUtils = window.getInterface(Ci.nsIDOMWindowUtils);
|
||||
},
|
||||
|
||||
addListener: function (listener) {
|
||||
if (this._listeners.indexOf(listener) >= 0)
|
||||
return;
|
||||
|
||||
listener._hover = false;
|
||||
this._listeners.push(listener);
|
||||
|
||||
this._callListener(listener);
|
||||
},
|
||||
|
||||
removeListener: function (listener) {
|
||||
var index = this._listeners.indexOf(listener);
|
||||
if (index < 0)
|
||||
return;
|
||||
|
||||
this._listeners.splice(index, 1);
|
||||
},
|
||||
|
||||
handleEvent: function (event) {
|
||||
var screenPixelsPerCSSPixel = this._windowUtils.screenPixelsPerCSSPixel;
|
||||
this._x = event.screenX / screenPixelsPerCSSPixel - window.mozInnerScreenX;
|
||||
this._y = event.screenY / screenPixelsPerCSSPixel - window.mozInnerScreenY;
|
||||
|
||||
this._listeners.forEach(function (listener) {
|
||||
try {
|
||||
this._callListener(listener);
|
||||
} catch (e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
_callListener: function (listener) {
|
||||
let rect = listener.getMouseTargetRect();
|
||||
let hover = this._x >= rect.left &&
|
||||
this._x <= rect.right &&
|
||||
this._y >= rect.top &&
|
||||
this._y <= rect.bottom;
|
||||
|
||||
if (hover == listener._hover)
|
||||
return;
|
||||
|
||||
listener._hover = hover;
|
||||
|
||||
if (hover) {
|
||||
if (listener.onMouseEnter)
|
||||
listener.onMouseEnter();
|
||||
} else {
|
||||
if (listener.onMouseLeave)
|
||||
listener.onMouseLeave();
|
||||
}
|
||||
}
|
||||
};
|
||||
function focusNextFrame(event) {
|
||||
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
|
||||
let dir = event.shiftKey ? fm.MOVEFOCUS_BACKWARDDOC : fm.MOVEFOCUS_FORWARDDOC;
|
||||
|
|
|
@ -4007,10 +4007,13 @@
|
|||
<implementation implements="nsIDOMEventListener">
|
||||
<constructor><![CDATA[
|
||||
window.addEventListener("findbaropen", this, false);
|
||||
window.addEventListener("resize", this, false);
|
||||
]]></constructor>
|
||||
|
||||
<destructor><![CDATA[
|
||||
window.removeEventListener("findbaropen", this, false);
|
||||
window.removeEventListener("resize", this, false);
|
||||
MousePosTracker.removeListener(this);
|
||||
]]></destructor>
|
||||
|
||||
<property name="label">
|
||||
|
@ -4029,8 +4032,11 @@
|
|||
if (val) {
|
||||
this.setAttribute("label", val);
|
||||
this.removeAttribute("inactive");
|
||||
this._calcMouseTargetRect();
|
||||
MousePosTracker.addListener(this);
|
||||
} else {
|
||||
this.setAttribute("inactive", "true");
|
||||
MousePosTracker.removeListener(this);
|
||||
}
|
||||
|
||||
return val;
|
||||
|
@ -4040,12 +4046,56 @@
|
|||
</getter>
|
||||
</property>
|
||||
|
||||
<method name="getMouseTargetRect">
|
||||
<body><![CDATA[
|
||||
return this._mouseTargetRect;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="onMouseEnter">
|
||||
<body>
|
||||
this._mirror();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="onMouseLeave">
|
||||
<body>
|
||||
this._mirror();
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="handleEvent">
|
||||
<parameter name="event"/>
|
||||
<body><![CDATA[
|
||||
if (event.type == "findbaropen" &&
|
||||
this.label)
|
||||
this.setAttribute("mirror", "true");
|
||||
if (!this.label)
|
||||
return;
|
||||
|
||||
switch (event.type) {
|
||||
case "findbaropen":
|
||||
this.setAttribute("mirror", "true");
|
||||
this._calcMouseTargetRect();
|
||||
break;
|
||||
case "resize":
|
||||
this._calcMouseTargetRect();
|
||||
break;
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="_calcMouseTargetRect">
|
||||
<body><![CDATA[
|
||||
let alignRight = (window.gFindBarInitialized && !window.gFindBar.hidden);
|
||||
|
||||
if (getComputedStyle(document.documentElement).direction == "rtl")
|
||||
alighRight = !alignRight;
|
||||
|
||||
let rect = this.getBoundingClientRect();
|
||||
this._mouseTargetRect = {
|
||||
top: rect.top,
|
||||
bottom: rect.bottom,
|
||||
left: alignRight ? window.innerWidth - rect.width : 0,
|
||||
right: alignRight ? window.innerWidth : rect.width
|
||||
};
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
|
@ -4058,11 +4108,6 @@
|
|||
</body>
|
||||
</method>
|
||||
</implementation>
|
||||
|
||||
<handlers>
|
||||
<handler event="mouseover" action="this._mirror();"/>
|
||||
<handler event="dragover" action="this._mirror();"/>
|
||||
</handlers>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
||||
|
|
Загрузка…
Ссылка в новой задаче