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

View File

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

View File

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