Bug 1575563 - Improve Megabar input layout. r=harry

Differential Revision: https://phabricator.services.mozilla.com/D42864

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Dão Gottwald 2019-08-21 19:13:15 +00:00
parent 3ad0ca9116
commit a25a70aaf0
8 changed files with 100 additions and 85 deletions

View File

@ -610,18 +610,18 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
/* Visible if the urlbar is not focused and it overflows at the start.
Uses the required-valid trick to check if it contains a value */
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > #urlbar-scheme:valid {
#urlbar[textoverflow="start"]:not([focused]) > #urlbar-input-container > .urlbar-input-box > #urlbar-scheme:valid {
visibility: visible;
}
/* Fade out URL on overflow
This mask may be overriden when a Contextual Feature Recommendation is shown,
see browser/themes/shared/urlbar-searchbar.inc.css for details */
#urlbar[textoverflow="end"]:not([focused]) > .urlbar-input-box > #urlbar-input {
#urlbar[textoverflow="end"]:not([focused]) > #urlbar-input-container > .urlbar-input-box > #urlbar-input {
mask-image: linear-gradient(to left, transparent, black 3ch);
}
#urlbar[textoverflow="start"]:not([focused]) > .urlbar-input-box > #urlbar-input {
#urlbar[textoverflow="start"]:not([focused]) > #urlbar-input-container > .urlbar-input-box > #urlbar-input {
mask-image: linear-gradient(to right, transparent var(--urlbar-scheme-size), black calc(var(--urlbar-scheme-size) + 3ch));
}
@ -636,10 +636,10 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
}
}
#urlbar[actionoverride] > #urlbar-display-box,
#urlbar:not([actiontype="switchtab"]):not([actiontype="extension"]) > #urlbar-display-box,
#urlbar:not([actiontype="switchtab"]) > #urlbar-display-box > #switchtab,
#urlbar:not([actiontype="extension"]) > #urlbar-display-box > #extension {
#urlbar[actionoverride] > #urlbar-input-container > #urlbar-display-box,
#urlbar:not([actiontype="switchtab"]):not([actiontype="extension"]) > #urlbar-input-container > #urlbar-display-box,
#urlbar:not([actiontype="switchtab"]) > #urlbar-input-container > #urlbar-display-box > #switchtab,
#urlbar:not([actiontype="extension"]) > #urlbar-input-container > #urlbar-display-box > #extension {
display: none;
}
@ -687,11 +687,11 @@ toolbar:not(#TabsToolbar) > #personal-bookmarks {
margin-inline-start: 0;
}
#urlbar[pageproxystate=invalid] > #page-action-buttons > .urlbar-page-action,
#urlbar-input-container[pageproxystate=invalid] > #page-action-buttons > .urlbar-page-action,
#identity-box.chromeUI ~ #page-action-buttons > .urlbar-page-action:not(#star-button-box),
#urlbar[usertyping] > .urlbar-history-dropmarker,
#urlbar:not([usertyping]) > #urlbar-go-button,
#urlbar:not([focused]) > #urlbar-go-button {
#urlbar[usertyping] > #urlbar-input-container > .urlbar-history-dropmarker,
#urlbar:not([usertyping]) > #urlbar-input-container > #urlbar-go-button,
#urlbar:not([focused]) > #urlbar-input-container > #urlbar-go-button {
display: none;
}

View File

@ -3483,10 +3483,7 @@ function SetPageProxyState(aState, updatePopupNotifications) {
}
let oldPageProxyState = gURLBar.getAttribute("pageproxystate");
// The "browser_urlbar_stop_pending.js" test uses a MutationObserver to do
// some verifications at this point, and it breaks if we don't write the
// attribute, even if it hasn't changed (bug 1338115).
gURLBar.setAttribute("pageproxystate", aState);
gURLBar.setPageProxyState(aState);
// the page proxy state is set to valid via OnLocationChange, which
// gets called when we switch tabs.

View File

@ -856,10 +856,13 @@
<toolbaritem id="urlbar-container" flex="400" persist="width"
removable="false"
class="chromeclass-location" overflows="false">
<toolbartabstop/>
<hbox id="urlbar" flex="1"
defaultPlaceholder="&urlbar.placeholder2;"
focused="true"
<toolbartabstop/>
<hbox id="urlbar" flex="1"
defaultPlaceholder="&urlbar.placeholder2;"
focused="true"
pageproxystate="invalid">
<hbox id="urlbar-input-container"
flex="1"
pageproxystate="invalid">
<!-- Use onclick instead of normal popup= syntax since the popup
code fires onmousedown, and hence eats our favicon drag events. -->
@ -883,6 +886,7 @@
<box id="identity-box" role="button"
align="center"
aria-label="&urlbar.viewSiteInfo.label;"
pageproxystate="invalid"
onclick="gIdentityHandler.handleIdentityButtonEvent(event);"
onkeypress="gIdentityHandler.handleIdentityButtonEvent(event);"
ondragstart="gIdentityHandler.onDragStart(event);">
@ -1055,24 +1059,25 @@
</hbox>
</hbox>
</hbox>
<vbox class="urlbarView"
role="group"
tooltip="aHTMLTooltip"
hidden="true">
<html:div class="urlbarView-body-outer">
<html:div class="urlbarView-body-inner">
<html:div id="urlbar-results"
class="urlbarView-results"
role="listbox"/>
</html:div>
</html:div>
<hbox class="search-one-offs"
compact="true"
includecurrentengine="true"
disabletab="true"/>
</vbox>
</hbox>
<toolbartabstop/>
<vbox class="urlbarView"
role="group"
tooltip="aHTMLTooltip"
hidden="true">
<html:div class="urlbarView-body-outer">
<html:div class="urlbarView-body-inner">
<html:div id="urlbar-results"
class="urlbarView-results"
role="listbox"/>
</html:div>
</html:div>
<hbox class="search-one-offs"
compact="true"
includecurrentengine="true"
disabletab="true"/>
</vbox>
</hbox>
<toolbartabstop/>
</toolbaritem>
<toolbarspring cui-areatype="toolbar" class="chromeclass-toolbar-additional"/>

View File

@ -21,13 +21,13 @@ function test() {
];
// set the valid attribute so dropping is allowed
var oldstate = gURLBar.getAttribute("pageproxystate");
gURLBar.setAttribute("pageproxystate", "valid");
gURLBar.setPageProxyState("valid");
var dt = EventUtils.synthesizeDragStart(
document.getElementById("identity-box"),
expected
);
is(dt, null, "drag on proxy icon");
gURLBar.setAttribute("pageproxystate", oldstate);
gURLBar.setPageProxyState(oldstate);
// Now, the identity information panel is opened by the proxy icon click.
// We need to close it for next tests.
EventUtils.synthesizeKey("VK_ESCAPE", {}, window);

View File

@ -132,6 +132,8 @@ class UrlbarInput {
this.inputField = this.querySelector("#urlbar-input");
this.dropmarker = this.querySelector(".urlbar-history-dropmarker");
this._inputContainer = this.querySelector("#urlbar-input-container");
this._identityBox = this.querySelector("#identity-box");
XPCOMUtils.defineLazyGetter(this, "valueFormatter", () => {
return new UrlbarValueFormatter(this);
@ -890,6 +892,12 @@ class UrlbarInput {
}
}
setPageProxyState(state) {
this.setAttribute("pageproxystate", state);
this._inputContainer.setAttribute("pageproxystate", state);
this._identityBox.setAttribute("pageproxystate", state);
}
// Private methods below.
_setOpenViewOnFocus() {

View File

@ -57,7 +57,7 @@ var UrlbarTestUtils = {
// This is necessary to get the urlbar to set gBrowser.userTypedValue.
this.fireInputEvent(window);
} else {
window.gURLBar.setAttribute("pageproxystate", "invalid");
window.gURLBar.setPageProxyState("invalid");
}
// An input event will start a new search, with a couple of exceptions, so
// be careful not to call _startSearch if we fired an input event since that
@ -112,7 +112,7 @@ var UrlbarTestUtils = {
urlbar.selectionEnd = selectionEnd;
urlbar.selectionStart = selectionStart;
}
urlbar.setAttribute("pageproxystate", "invalid");
urlbar.setPageProxyState("invalid");
urlbar.startQuery();
},

View File

@ -19,18 +19,18 @@
/* The tracking protection icon will be hidden if it is a chrome page. There
will be only the brand icon in the url bar. So, we need to change the padding
start for proper positing the icon. */
#urlbar[pageproxystate="valid"] > #identity-box.chromeUI {
#identity-box[pageproxystate="valid"].chromeUI {
padding-inline-start: 8px;
}
#urlbar[pageproxystate="invalid"] > #identity-box > #blocked-permissions-container,
#urlbar[pageproxystate="invalid"] > #identity-box > #notification-popup-box,
#urlbar[pageproxystate="invalid"] > #identity-box > #identity-icon-labels,
#urlbar[pageproxystate="invalid"] > #identity-box > #remote-control-icon {
#identity-box[pageproxystate="invalid"] > #blocked-permissions-container,
#identity-box[pageproxystate="invalid"] > #notification-popup-box,
#identity-box[pageproxystate="invalid"] > #identity-icon-labels,
#identity-box[pageproxystate="invalid"] > #remote-control-icon {
display: none;
}
#urlbar[pageproxystate="invalid"] > #identity-box {
#identity-box[pageproxystate="invalid"] {
pointer-events: none;
/* This would make the spaces around the glass icon balanced. */
margin-inline-end: 2px;
@ -58,15 +58,15 @@
-moz-outline-radius: var(--toolbarbutton-border-radius);
}
#urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity > #identity-icon-labels {
#identity-box[pageproxystate="valid"].verifiedIdentity > #identity-icon-labels {
color: #058B00;
}
:root[lwt-toolbar-field-brighttext] #urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity > #identity-icon-labels {
:root[lwt-toolbar-field-brighttext] #identity-box[pageproxystate="valid"].verifiedIdentity > #identity-icon-labels {
color: #30e60b;
}
#urlbar[pageproxystate="valid"] > #identity-box.chromeUI > #identity-icon-labels {
#identity-box[pageproxystate="valid"].chromeUI > #identity-icon-labels {
opacity: .6;
}
@ -79,14 +79,14 @@
#identity-box:not(.chromeUI):not(.extensionPage):not(.notSecureText) {
--urlbar-separator-color: transparent;
}
#urlbar[pageproxystate=valid] > #identity-box.verifiedIdentity {
#identity-box[pageproxystate="valid"].verifiedIdentity {
--urlbar-separator-color: rgba(18, 188, 0, .5);
}
#urlbar[pageproxystate=valid] > #identity-box.notSecureText,
#urlbar[pageproxystate=valid] > #identity-box.verifiedIdentity,
#urlbar[pageproxystate=valid] > #identity-box.chromeUI,
#urlbar[pageproxystate=valid] > #identity-box.extensionPage,
#identity-box[pageproxystate="valid"].notSecureText,
#identity-box[pageproxystate="valid"].verifiedIdentity,
#identity-box[pageproxystate="valid"].chromeUI,
#identity-box[pageproxystate="valid"].extensionPage,
#urlbar-display-box {
margin-inline-end: 8px;
border-inline-end: 1px solid var(--urlbar-separator-color);
@ -94,10 +94,10 @@
border-image-slice: 1;
}
#urlbar[pageproxystate=valid] > #identity-box.notSecureText,
#urlbar[pageproxystate=valid] > #identity-box.verifiedIdentity,
#urlbar[pageproxystate=valid] > #identity-box.chromeUI,
#urlbar[pageproxystate=valid] > #identity-box.extensionPage {
#identity-box[pageproxystate="valid"].notSecureText,
#identity-box[pageproxystate="valid"].verifiedIdentity,
#identity-box[pageproxystate="valid"].chromeUI,
#identity-box[pageproxystate="valid"].extensionPage {
padding-inline-end: 8px;
}
@ -129,55 +129,55 @@
list-style-image: url(chrome://browser/skin/identity-icon.svg);
}
#urlbar[pageproxystate="valid"] > #identity-box.chromeUI > #identity-icon {
#identity-box[pageproxystate="valid"].chromeUI > #identity-icon {
list-style-image: url(chrome://branding/content/identity-icons-brand.svg);
}
#urlbar[pageproxystate="invalid"] > #identity-box > #identity-icon {
#identity-box[pageproxystate="invalid"] > #identity-icon {
list-style-image: url(chrome://browser/skin/search-glass.svg);
fill-opacity: .4;
}
#urlbar[actiontype="extension"] > #identity-box > #identity-icon {
#urlbar[actiontype="extension"] > #urlbar-input-container > #identity-box > #identity-icon {
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric-16.svg);
}
#urlbar[pageproxystate="valid"] #identity-box.extensionPage > #identity-icon {
#identity-box[pageproxystate="valid"].extensionPage > #identity-icon {
list-style-image: url(chrome://mozapps/skin/extensions/extensionGeneric-16.svg);
}
#urlbar[pageproxystate="valid"] > #identity-box.verifiedDomain > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.mixedActiveBlocked > #identity-icon {
#identity-box[pageproxystate="valid"].verifiedDomain > #identity-icon,
#identity-box[pageproxystate="valid"].verifiedIdentity > #identity-icon,
#identity-box[pageproxystate="valid"].mixedActiveBlocked > #identity-icon {
list-style-image: url(chrome://browser/skin/connection-secure.svg);
-moz-context-properties: fill;
fill: #12BC00;
}
#urlbar[pageproxystate="valid"] > #identity-box.verifiedDomain > #identity-icon[lock-icon-gray],
#urlbar[pageproxystate="valid"] > #identity-box.verifiedIdentity > #identity-icon[lock-icon-gray],
#urlbar[pageproxystate="valid"] > #identity-box.mixedActiveBlocked > #identity-icon[lock-icon-gray] {
#identity-box[pageproxystate="valid"].verifiedDomain > #identity-icon[lock-icon-gray],
#identity-box[pageproxystate="valid"].verifiedIdentity > #identity-icon[lock-icon-gray],
#identity-box[pageproxystate="valid"].mixedActiveBlocked > #identity-icon[lock-icon-gray] {
fill-opacity: 0.6;
-moz-context-properties: fill, fill-opacity;
fill: currentColor;
}
#urlbar[pageproxystate="valid"] > #identity-box.weakCipher > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.mixedDisplayContent > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.mixedDisplayContentLoadedActiveBlocked > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.certUserOverridden > #identity-icon {
#identity-box[pageproxystate="valid"].weakCipher > #identity-icon,
#identity-box[pageproxystate="valid"].mixedDisplayContent > #identity-icon,
#identity-box[pageproxystate="valid"].mixedDisplayContentLoadedActiveBlocked > #identity-icon,
#identity-box[pageproxystate="valid"].certUserOverridden > #identity-icon {
list-style-image: url(chrome://browser/skin/connection-mixed-passive-loaded.svg);
fill: unset;
-moz-context-properties: fill, fill-opacity;
}
#urlbar[pageproxystate="valid"] > #identity-box.notSecure > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.insecureLoginForms > #identity-icon,
#urlbar[pageproxystate="valid"] > #identity-box.mixedActiveContent > #identity-icon {
#identity-box[pageproxystate="valid"].notSecure > #identity-icon,
#identity-box[pageproxystate="valid"].insecureLoginForms > #identity-icon,
#identity-box[pageproxystate="valid"].mixedActiveContent > #identity-icon {
list-style-image: url(chrome://browser/skin/connection-mixed-active-loaded.svg);
}
#urlbar[pageproxystate="valid"] > #identity-box.grantedPermissions::before {
#identity-box[pageproxystate="valid"].grantedPermissions::before {
background: url(chrome://browser/skin/badge-blue.svg);
content: "";
position: absolute;
@ -187,7 +187,7 @@
width: 14px;
}
#urlbar[pageproxystate="valid"] > #identity-box.grantedPermissions:-moz-locale-dir(rtl)::before {
#identity-box[pageproxystate="valid"].grantedPermissions:-moz-locale-dir(rtl)::before {
left: unset;
right: 16px;
}
@ -239,7 +239,7 @@
position: relative;
}
#urlbar[pageproxystate="valid"] > #tracking-protection-icon-container.chromeUI {
#urlbar-input-container[pageproxystate="valid"] > #tracking-protection-icon-container.chromeUI {
display: none;
}
@ -313,19 +313,19 @@
max-width: 500px;
}
#urlbar[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box > #tracking-protection-icon {
#urlbar-input-container[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box > #tracking-protection-icon {
list-style-image: url(chrome://browser/skin/tracking-protection.svg);
}
#urlbar[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box[hasException] > #tracking-protection-icon {
#urlbar-input-container[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box[hasException] > #tracking-protection-icon {
list-style-image: url(chrome://browser/skin/tracking-protection-disabled.svg);
}
#urlbar[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box > #tracking-protection-icon:-moz-locale-dir(rtl) {
#urlbar-input-container[pageproxystate="valid"] > #tracking-protection-icon-container > #tracking-protection-icon-box > #tracking-protection-icon:-moz-locale-dir(rtl) {
transform: scaleX(-1);
}
#urlbar[pageproxystate="invalid"] > #tracking-protection-icon-container {
#urlbar-input-container[pageproxystate="invalid"] > #tracking-protection-icon-container {
visibility: collapse;
}

View File

@ -100,6 +100,11 @@
padding-bottom: 0 !important;
}
#urlbar.megabar:not(.hidden-focus)[focused="true"] > #urlbar-input-container,
#urlbar.megabar[open="true"] > #urlbar-input-container {
width: 100%;
}
#urlbar:not(.hidden-focus):-moz-lwtheme[focused="true"],
#navigator-toolbox #searchbar:focus-within:-moz-lwtheme {
background-color: var(--lwt-toolbar-field-focus, var(--lwt-toolbar-field-background-color, white));
@ -386,12 +391,12 @@
transition: opacity 0.15s ease;
}
#urlbar[switchingtabs] > .urlbar-history-dropmarker {
#urlbar[switchingtabs] > #urlbar-input-container > .urlbar-history-dropmarker {
transition: none;
}
#nav-bar:not([customizing="true"]) > #nav-bar-customization-target > #urlbar-container:not(:hover) > #urlbar:not([focused]) > .urlbar-history-dropmarker,
#nav-bar:not([customizing="true"]) > #nav-bar-customization-target > #urlbar-container:not(:hover) > #urlbar.hidden-focus > .urlbar-history-dropmarker {
#nav-bar:not([customizing="true"]) > #nav-bar-customization-target > #urlbar-container:not(:hover) > #urlbar:not([focused]) > #urlbar-input-container > .urlbar-history-dropmarker,
#nav-bar:not([customizing="true"]) > #nav-bar-customization-target > #urlbar-container:not(:hover) > #urlbar.hidden-focus > #urlbar-input-container > .urlbar-history-dropmarker {
opacity: 0;
}