Bug 1370491 - Show arrow indicator in menuitem r=jaws

MozReview-Commit-ID: IoTjj4UQBgk

--HG--
extra : rebase_source : 3eb4747f9641a4e2e4d9c0f7f1c0870a3defb357
This commit is contained in:
Ricky Chien 2017-06-09 20:40:50 +08:00
parent 04a15dccb6
commit 582afb3462
6 changed files with 79 additions and 11 deletions

View File

@ -6,7 +6,8 @@
var gSearchResultsPane = {
findSelection: null,
listSearchTooltips: [],
listSearchTooltips: new Set(),
listSearchMenuitemIndicators: new Set(),
searchResultsCategory: null,
searchInput: null,
@ -193,6 +194,7 @@ var gSearchResultsPane = {
let query = event.target.value.trim().toLowerCase();
this.findSelection.removeAllRanges();
this.removeAllSearchTooltips();
this.removeAllSearchMenuitemIndicators();
let srHeader = document.getElementById("header-searchResults");
@ -242,9 +244,7 @@ var gSearchResultsPane = {
strings.getFormattedString("searchResults.needHelp2", [helpUrl, brandName]);
} else {
// Creating tooltips for all the instances found
for (let node of this.listSearchTooltips) {
this.createSearchTooltip(node, query);
}
this.listSearchTooltips.forEach((node) => this.createSearchTooltip(node, query));
}
} else {
this.searchResultsCategory.hidden = true;
@ -300,9 +300,18 @@ var gSearchResultsPane = {
// Searching some elements, such as xul:button, buttons to open subdialogs.
let keywordsResult = this.stringMatchesFilters(nodeObject.getAttribute("searchkeywords"), searchPhrase);
// Creating tooltips for buttons and menulists.
// Creating tooltips for buttons
if (keywordsResult && (nodeObject.tagName === "button" || nodeObject.tagName == "menulist")) {
this.listSearchTooltips.push(nodeObject);
this.listSearchTooltips.add(nodeObject);
}
if (keywordsResult && nodeObject.tagName === "menuitem") {
nodeObject.setAttribute("indicator", "true");
this.listSearchMenuitemIndicators.add(nodeObject);
let menulist = nodeObject.closest("menulist");
menulist.setAttribute("indicator", "true");
this.listSearchMenuitemIndicators.add(menulist);
}
if ((nodeObject.tagName == "button" ||
@ -349,7 +358,7 @@ var gSearchResultsPane = {
result = this.searchWithinNode(nodeObject.childNodes[index], searchPhrase);
// Creating tooltips for menulist element
if (result && nodeObject.tagName === "menulist") {
this.listSearchTooltips.push(nodeObject);
this.listSearchTooltips.add(nodeObject);
}
}
return result;
@ -395,6 +404,14 @@ var gSearchResultsPane = {
searchTooltip.parentElement.classList.remove("search-tooltip-parent");
searchTooltip.remove();
}
this.listSearchTooltips = [];
this.listSearchTooltips.clear();
},
/**
* Remove all indicators on menuitem.
*/
removeAllSearchMenuitemIndicators() {
this.listSearchMenuitemIndicators.forEach((node) => node.removeAttribute("indicator"));
this.listSearchMenuitemIndicators.clear();
}
}

View File

@ -168,6 +168,7 @@ function gotoPref(aCategory) {
gSearchResultsPane.searchResultsCategory.hidden = true;
gSearchResultsPane.findSelection.removeAllRanges();
gSearchResultsPane.removeAllSearchTooltips();
gSearchResultsPane.removeAllSearchMenuitemIndicators();
} else if (!gSearchResultsPane.searchInput.value) {
// Something tried to send us to the search results pane without
// a query string. Default to the General pane instead.

View File

@ -191,9 +191,31 @@
</label>
<menulist id="historyMode">
<menupopup>
<menuitem label="&historyHeader.remember.label;" value="remember"/>
<menuitem label="&historyHeader.dontremember.label;" value="dontremember"/>
<menuitem label="&historyHeader.custom.label;" value="custom"/>
<menuitem label="&historyHeader.remember.label;" value="remember" searchkeywords="&rememberDescription.label;
&rememberActions.pre.label;
&rememberActions.clearHistory.label;
&rememberActions.middle.label;
&rememberActions.removeCookies.label;
&rememberActions.post.label;"/>
<menuitem label="&historyHeader.dontremember.label;" value="dontremember" searchkeywords="&dontrememberDescription.label;
&dontrememberActions.pre.label;
&dontrememberActions.clearHistory.label;
&dontrememberActions.post.label;"/>
<menuitem label="&historyHeader.custom.label;" value="custom" searchkeywords="&privateBrowsingPermanent2.label;
&rememberHistory2.label;
&rememberSearchForm.label;
&acceptCookies.label;
&cookieExceptions.label;
&acceptThirdParty.pre.label;
&acceptThirdParty.always.label;
&acceptThirdParty.visited.label;
&acceptThirdParty.never.label;
&keepUntil.label;
&expire.label;
&close.label;
&showCookies.label;
&clearOnClose.label;
&clearOnCloseSettings.label;"/>
</menupopup>
</menulist>
<label>&historyHeader.post.label;</label>

View File

@ -637,3 +637,17 @@ description > html|a {
.search-tooltip-parent {
position: relative;
}
menulist[indicator=true] > menupopup menuitem:not([image]) > .menu-iconic-left {
display: -moz-box;
width: 10px;
min-width: auto; /* Override the min-width defined in menu.css */
height: 10px;
margin-inline-end: 6px;
}
menulist[indicator=true] > menupopup menuitem[indicator=true]:not([image]) > .menu-iconic-left {
background-image: url(chrome://global/skin/icons/search-arrow-indicator.svg);
background-repeat: no-repeat;
background-size: 12px 10px;
}

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 10">
<defs>
<path id="anchor" d="M33 20l5 8H28z"/>
</defs>
<g fill="none" fill-rule="evenodd" transform="rotate(90 28 0)">
<use fill="#FFEB19" href="#anchor"/>
<path stroke="#0C0C0D" stroke-opacity=".2" d="M33 20.94l-4.1 6.56h8.2L33 20.94z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 581 B

View File

@ -33,6 +33,7 @@ toolkit.jar:
skin/classic/global/icons/input-clear.svg (../../shared/icons/input-clear.svg)
skin/classic/global/icons/loading.png (../../shared/icons/loading.png)
skin/classic/global/icons/loading@2x.png (../../shared/icons/loading@2x.png)
skin/classic/global/icons/search-arrow-indicator.svg (../../shared/icons/search-arrow-indicator.svg)
skin/classic/global/icons/spinner-arrow-down.svg (../../shared/icons/spinner-arrow-down.svg)
skin/classic/global/icons/spinner-arrow-up.svg (../../shared/icons/spinner-arrow-up.svg)
skin/classic/global/icons/menubutton-dropmarker.svg (../../shared/icons/menubutton-dropmarker.svg)