Bug 597581 - Switching tabs should update location bar immediately, even if a link is hovered. r=dao, a=blocking2.0-final

This commit is contained in:
Drew Willcoxon 2010-11-16 14:39:41 -08:00
parent 378f1ef8c9
commit 9f27896d7c
3 changed files with 80 additions and 25 deletions

View File

@ -167,14 +167,14 @@ html|*.urlbar-input {
/* over-link in location bar */
.urlbar-over-link-layer[overlinkstate="fade-in"],
.urlbar-textbox-container:not([overlinkstate]) {
.urlbar-textbox-container[overlinkstate="fade-out"] {
-moz-transition-property: color;
-moz-transition-duration: 150ms;
-moz-transition-timing-function: cubic-bezier(0.0, 0.6, 1.0, 1.0);
}
.urlbar-textbox-container[overlinkstate="fade-in"],
.urlbar-over-link-layer:not([overlinkstate]) {
.urlbar-over-link-layer[overlinkstate="fade-out"] {
-moz-transition-property: color;
-moz-transition-duration: 150ms;
-moz-transition-timing-function: linear;
@ -182,14 +182,14 @@ html|*.urlbar-input {
}
.urlbar-over-link-box[overlinkstate="fade-in"],
.urlbar-textbox-container-children:not([overlinkstate]) {
.urlbar-textbox-container-children[overlinkstate="fade-out"] {
-moz-transition-property: opacity;
-moz-transition-duration: 150ms;
opacity: 1;
}
.urlbar-textbox-container-children[overlinkstate="fade-in"],
.urlbar-over-link-box:not([overlinkstate]) {
.urlbar-over-link-box[overlinkstate="fade-out"] {
-moz-transition-property: opacity;
-moz-transition-duration: 150ms;
opacity: 0;
@ -207,6 +207,14 @@ html|*.urlbar-input {
opacity: 0;
}
.urlbar-over-link-layer:not([overlinkstate]) {
color: transparent;
}
.urlbar-over-link-box:not([overlinkstate]) {
opacity: 0;
}
/* For results that are actions, their description text is shown instead of
the URL - this needs to follow the locale's direction, unlike URLs. */
richlistitem[type~="action"]:-moz-locale-dir(rtl) > .ac-url-box {

View File

@ -3994,14 +3994,16 @@ var XULBrowserWindow = {
this.defaultStatus = status;
},
setOverLink: function (link) {
// Encode bidirectional formatting characters.
// (RFC 3987 sections 3.2 and 4.1 paragraph 6)
link = link.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
setOverLink: function (url, anchorElt) {
if (gURLBar) {
// Encode bidirectional formatting characters.
// (RFC 3987 sections 3.2 and 4.1 paragraph 6)
url = url.replace(/[\u200e\u200f\u202a\u202b\u202c\u202d\u202e]/g,
encodeURIComponent);
gURLBar.setOverLink(link);
gURLBar.setOverLink(url);
}
},
// Called before links are navigated to to allow us to retarget them if needed.
onBeforeLinkTraversal: function(originalTarget, linkURI, linkNode, isAppTab) {
// Don't modify non-default targets or targets that aren't in top-level app
@ -4198,7 +4200,9 @@ var XULBrowserWindow = {
else
this.isImage.setAttribute('disabled', 'true');
this.hideOverLinkImmediately = true;
this.setOverLink("", null);
this.hideOverLinkImmediately = false;
// We should probably not do this if the value has changed since the user
// searched

View File

@ -200,6 +200,7 @@
<method name="onBeforeValueSet">
<parameter name="aValue"/>
<body><![CDATA[
this._hideOverLink();
this._value = aValue;
var returnValue = aValue;
var action = this._parseActionUrl(aValue);
@ -642,19 +643,21 @@
<method name="setOverLink">
<parameter name="aURL"/>
<body><![CDATA[
// If the over-link is already scheduled to appear or hide, cancel it.
if (this._overLinkDelayTimer) {
clearTimeout(this._overLinkDelayTimer);
this._overLinkDelayTimer = null;
this._cancelOverLinkDelayTimer();
// Hide the over-link immediately if necessary.
if (!aURL && (XULBrowserWindow.hideOverLinkImmediately ||
this._hideOverLinkImmediately)) {
this._setOverLinkState(null);
return;
}
// Hide the over-link if aURL is falsey or if the URL bar is focused.
if (!aURL || this.focused) {
// If aURL is falsey, fade it out after a delay. This happens on
// mouseout for example.
if (!aURL) {
this._overLinkDelayTimer = setTimeout(function overLinkOut(self) {
self._overLinkDelayTimer = null;
let style = window.getComputedStyle(self._overLinkBox, null);
self._overLinkTransitioning = style.opacity != 0;
self.removeAttribute("overlinkstate");
self._setOverLinkState("fade-out");
}, this._overLinkOutDelay, this);
return;
}
@ -662,8 +665,7 @@
// If it's in transition, update and show it immediately.
if (this._overLinkTransitioning) {
this._updateOverLink(aURL);
this._overLinkTransitioning = false;
this.setAttribute("overlinkstate", "showing");
this._setOverLinkState("showing");
return;
}
@ -673,13 +675,54 @@
this._overLinkDelayTimer = setTimeout(function overLinkIn(self) {
self._overLinkDelayTimer = null;
self._updateOverLink(aURL);
let style = window.getComputedStyle(self._overLinkBox, null);
self._overLinkTransitioning = style.opacity != 1;
self.setAttribute("overlinkstate", "fade-in");
self._setOverLinkState("fade-in");
}, this._overLinkInDelay, this);
]]></body>
</method>
<method name="_hideOverLink">
<body><![CDATA[
this._hideOverLinkImmediately = true;
this.setOverLink("");
this._hideOverLinkImmediately = false;
]]></body>
</method>
<method name="_cancelOverLinkDelayTimer">
<body><![CDATA[
if (this._overLinkDelayTimer) {
clearTimeout(this._overLinkDelayTimer);
this._overLinkDelayTimer = null;
}
]]></body>
</method>
<method name="_setOverLinkState">
<parameter name="aVal"/>
<body><![CDATA[
switch (aVal) {
case "fade-in":
var style = window.getComputedStyle(this._overLinkBox);
this._overLinkTransitioning = style.opacity != 1;
this.setAttribute("overlinkstate", aVal);
break;
case "fade-out":
style = window.getComputedStyle(this._overLinkBox);
this._overLinkTransitioning = style.opacity != 0;
this.setAttribute("overlinkstate", aVal);
break;
case "showing":
this._overLinkTransitioning = false;
this.setAttribute("overlinkstate", aVal);
break;
default:
this._overLinkTransitioning = false;
this.removeAttribute("overlinkstate");
break;
}
]]></body>
</method>
<method name="_updateOverLink">
<parameter name="aURL"/>
<body><![CDATA[
@ -761,8 +804,8 @@
]]></handler>
<handler event="focus" phase="capturing"><![CDATA[
this._hideOverLink();
this._hideURLTooltip();
this.setOverLink(null);
]]></handler>
<handler event="dragover" phase="capturing" action="this.onDragOver(event, this);"/>