Bug 431842, support autocomplete list and findbar, r=gavin

--HG--
rename : mobile/chrome/content/deckbrowser.css => mobile/chrome/content/browser.css
This commit is contained in:
Neil Deakin 2008-07-16 17:41:38 +02:00
Родитель 3c60647de5
Коммит d546a39270
14 изменённых файлов: 338 добавлений и 25 удалений

Просмотреть файл

@ -133,3 +133,27 @@ pref("keyword.enabled", true);
pref("keyword.URL", "http://www.google.com/search?q=");
pref("snav.enabled", true);
pref("accessibility.typeaheadfind", false);
pref("accessibility.typeaheadfind.timeout", 5000);
pref("accessibility.typeaheadfind.flashBar", 1);
pref("accessibility.typeaheadfind.linksonly", false);
pref("accessibility.typeaheadfind.casesensitive", false);
// pointer to the default engine name
pref("browser.search.defaultenginename", "chrome://browser/locale/region.properties");
// disable logging for the search service by default
pref("browser.search.log", false);
// Ordering of Search Engines in the Engine list.
pref("browser.search.order.1", "chrome://browser/locale/region.properties");
pref("browser.search.order.2", "chrome://browser/locale/region.properties");
// disable updating
pref("browser.search.update", false);
pref("browser.search.update.log", false);
pref("browser.search.updateinterval", 6);
// enable search suggestions by default
pref("browser.search.suggest.enabled", true);

Просмотреть файл

@ -49,6 +49,7 @@ var BrowserUI = {
_caption : null,
_edit : null,
_throbber : null,
_autocompleteNavbuttons : null,
_favicon : null,
_faviconAdded : false,
_fadeoutID : null,
@ -138,10 +139,12 @@ var BrowserUI = {
this._edit = document.getElementById("urlbar-edit");
this._edit.addEventListener("focus", this, false);
this._edit.addEventListener("blur", this, false);
this._edit.addEventListener("keypress", this, false);
this._edit.addEventListener("keypress", this, true);
this._edit.addEventListener("input", this, false);
this._throbber = document.getElementById("urlbar-throbber");
this._favicon = document.getElementById("urlbar-favicon");
this._favicon.addEventListener("error", this, false);
this._autocompleteNavbuttons = document.getElementById("autocomplete_navbuttons");
getBrowser().addEventListener("DOMTitleChanged", this, true);
getBrowser().addEventListener("DOMLinkAdded", this, true);
@ -219,6 +222,8 @@ var BrowserUI = {
},
goToURI : function(aURI) {
this._edit.reallyClosePopup();
if (!aURI)
aURI = this._edit.value;
@ -234,6 +239,64 @@ var BrowserUI = {
this._showMode(PANELMODE_VIEW);
},
sizeAutocompletePopup : function () {
var rect = document.getElementById("browser-container").getBoundingClientRect();
var popup = document.getElementById("popup_autocomplete");
popup.height = rect.bottom - rect.top;
},
openDefaultHistory : function () {
if (!this._edit.value) {
this._autocompleteNavbuttons.hidden = true;
this._edit.showHistoryPopup();
}
},
doButtonSearch : function(button)
{
if (!("engine" in button) || !button.engine)
return;
var urlbar = this._edit;
urlbar.open = false;
var value = urlbar.value;
if (!value)
return;
var submission = button.engine.getSubmission(value, null);
getBrowser().loadURI(submission.uri.spec, null, submission.postData, false);
},
engines : null,
updateSearchEngines : function () {
if (this.engines)
return;
// XXXndeakin remove the try-catch once the search service is properly built
try {
var searchService = Cc["@mozilla.org/browser/search-service;1"].
getService(Ci.nsIBrowserSearchService);
} catch (ex) {
this.engines = [ ];
return;
}
var engines = searchService.getVisibleEngines({ });
this.engines = engines;
const kXULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var container = this._autocompleteNavbuttons;
for (var e = 0; e < engines.length; e++) {
var button = document.createElementNS(kXULNS, "toolbarbutton");
var engine = engines[e];
button.id = engine.name;
button.setAttribute("label", engine.name);
if (engine.iconURI)
button.setAttribute("image", engine.iconURI.spec);
container.insertBefore(button, container.firstChild);
button.engine = engine;
}
},
_showMode : function(aMode) {
if (this._fadeoutID) {
clearTimeout(this._fadeoutID);
@ -255,11 +318,9 @@ var BrowserUI = {
this._caption.hidden = true;
this._edit.hidden = false;
this._edit.focus();
this.showHistory();
bookmark.hidden = true;
urllist.hidden = false;
urllist.hidden = true;
this.openDefaultHistory();
}
else if (aMode == PANELMODE_BOOKMARK) {
toolbar.setAttribute("mode", "view");
@ -353,14 +414,20 @@ var BrowserUI = {
case "click":
this._showMode(PANELMODE_EDIT);
break;
case "input":
if (this._edit.value) {
this.updateSearchEngines();
this._autocompleteNavbuttons.hidden = false;
}
break;
case "focus":
setTimeout(function() { aEvent.target.select(); }, 0);
break;
case "keypress":
if (aEvent.keyCode == aEvent.DOM_VK_RETURN)
this.goToURI();
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE)
if (aEvent.keyCode == aEvent.DOM_VK_ESCAPE) {
this._edit.reallyClosePopup();
this._showMode(PANELMODE_VIEW);
}
break;
// Favicon events
case "error":

Просмотреть файл

@ -0,0 +1,7 @@
deckbrowser {
-moz-binding: url("chrome://browser/content/deckbrowser.xml#deckbrowser");
}
#urlbar-edit {
-moz-binding: url("chrome://browser/content/urlbar.xml#autocomplete-aligned");
}

Просмотреть файл

@ -43,6 +43,10 @@ const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const FINDSTATE_FIND = 0;
const FINDSTATE_FIND_AGAIN = 1;
const FINDSTATE_FIND_PREVIOUS = 2;
Cu.import("resource://gre/modules/SpatialNavigation.js");
// create a lazy-initialized handle for the pref service on the global object
@ -225,7 +229,34 @@ var Browser = {
getNotificationBox : function() {
return document.getElementById("notifications");
}
},
findState: FINDSTATE_FIND,
openFind: function(aState) {
this.findState = aState;
var findbar = document.getElementById("findbar");
var browser = findbar.browser;
if (!browser) {
browser = this.content.browser;
findbar.browser = browser;
}
var panel = document.getElementById("findpanel");
if (panel.state == "open")
this.doFind(null);
else
panel.openPopup(document.getElementById("findpanel-placeholder"), "before_start");
},
doFind: function (aEvent) {
var findbar = document.getElementById("findbar");
if (Browser.findState == FINDSTATE_FIND)
findbar.onFindCommand();
else
findbar.onFindAgainCommand(Browser.findState == FINDSTATE_FIND_PREVIOUS);
}
};
function ProgressController(aTabBrowser) {

Просмотреть файл

@ -39,7 +39,7 @@
- ***** END LICENSE BLOCK ***** -->
<?xml-stylesheet href="chrome://browser/skin/browser.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/deckbrowser.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/content/browser.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % browserDTD SYSTEM "chrome://browser/locale/browser.dtd">
@ -94,6 +94,10 @@
<command id="cmd_paste" label="&paste.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_delete" label="&delete.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_selectAll" label="&selectAll.label;" oncommand="CommandUpdater.doCommand(this.id);"/>
<command id="cmd_find" oncommand="Browser.openFind(FINDSTATE_FIND);"/>
<command id="cmd_findAgain" oncommand="Browser.openFind(FINDSTATE_FIND_AGAIN);"/>
<command id="cmd_findPrevious" oncommand="Browser.openFind(FINDSTATE_FIND_PREVIOUS);"/>
</commandset>
<keyset id="mainKeyset">
@ -113,11 +117,25 @@
<key id="key_fullscreen" keycode="VK_F6" command="cmd_fullscreen"/>
<key id="key_addons" key="E" command="cmd_addons" modifiers="control"/>
<key id="key_downloads" key="J" command="cmd_downloads" modifiers="control"/>
<key id="key_find" key="&findOnCmd.commandkey;" command="cmd_find" modifiers="accel"/>
<key id="key_findAgain" key="&findAgainCmd.commandkey;" command="cmd_findAgain" modifiers="accel"/>
<key id="key_findPrevious" key="&findAgainCmd.commandkey;" command="cmd_findPrevious" modifiers="accel,shift"/>
<key keycode="&findAgainCmd.commandkey2;" command="cmd_findAgain"/>
<key keycode="&findAgainCmd.commandkey2;" command="cmd_findPrevious" modifiers="shift"/>
</keyset>
<popupset id="mainPopupSet">
<panel type="autocomplete-richlistbox" id="popup_autocomplete"
noautofocus="true" onpopupshowing="BrowserUI.sizeAutocompletePopup()">
<hbox id="autocomplete_navbuttons" align="center" flex="1"
oncommand="BrowserUI.doButtonSearch(event.target);">
<image class="tool-search"/>
</hbox>
</panel>
<!-- popup for content autocomplete -->
<panel type="autocomplete" id="popup_autocomplete" noautofocus="true"/>
<panel type="autocomplete" id="popup_autocomplete_content" noautofocus="true"/>
<!-- popup for site identity information -->
<panel id="identity-popup" position="after_start" hidden="true" noautofocus="true"
@ -156,7 +174,10 @@
</stack>
</box>
<description id="urlbar-caption" crop="end" flex="1"/>
<textbox id="urlbar-edit" flex="1" hidden="true"/>
<textbox id="urlbar-edit" type="autocomplete" autocompletesearch="history" enablehistory="false"
maxrows="6" completeselectedindex="true" minresultsforpopup="0" flex="1" hidden="true"
autocompletepopup="popup_autocomplete"
ontextentered="BrowserUI.goToURI();"/>
</hbox>
<hbox id="urlbar-icons">
<toolbarbutton id="tool-reload" class="urlbar-icon-button" command="cmd_reload"/>
@ -170,7 +191,7 @@
<hbox id="browser-container" flex="1">
<vbox id="browser" flex="1">
<notificationbox id="notifications" flex="1">
<deckbrowser id="content" autocompletepopup="popup_autocomplete" flex="1"/>
<deckbrowser id="content" autocompletepopup="popup_autocomplete_content" flex="1"/>
</notificationbox>
</vbox>
<vbox id="browser-controls" collapsed="true">
@ -185,11 +206,11 @@
<vbox id="urllist-container" flex="1" hidden="true">
<hbox id="urllist-items-container" flex="1">
<richlistbox id="urllist-items" flex="1"/>
</hbox>
<separator class="thin"/>
<hbox id="urllist-search">
<image id="tool-search"/>
</hbox>
</hbox>
<separator class="thin"/>
<hbox id="urllist-search">
<image class="tool-search"/>
</hbox>
</vbox>
<vbox id="bookmark-container" flex="1" hidden="true">
@ -227,4 +248,10 @@
</vbox>
</stack>
<vbox id="findpanel-placeholder" sizetopopup="always">
<panel id="findpanel" onpopupshown="Browser.doFind()">
<findbar id="findbar"/>
</panel>
</vbox>
</window>

Просмотреть файл

@ -1,3 +0,0 @@
deckbrowser {
-moz-binding: url("chrome://browser/content/deckbrowser.xml#deckbrowser");
}

Просмотреть файл

@ -0,0 +1,30 @@
<?xml version="1.0"?>
<!DOCTYPE bindings PUBLIC "-//MOZILLA//DTD XBL V1.0//EN" "http://www.mozilla.org/xbl">
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="autocomplete-aligned" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
<implementation>
<method name="openPopup">
<body><![CDATA[
this.popup.openAutocompletePopup(this, document.getElementById("toolbar-main"));
]]></body>
</method>
<method name="closePopup">
<body><![CDATA[
// do nothing
]]></body>
</method>
<method name="reallyClosePopup">
<body><![CDATA[
this.mConsumeRollupEvent = false;
this.popup.closePopup();
]]></body>
</method>
</implementation>
</binding>
</bindings>

Просмотреть файл

@ -6,8 +6,9 @@ browser.jar:
content/browser.js (content/browser.js)
content/browser-ui.js (content/browser-ui.js)
content/commandUtil.js (content/commandUtil.js)
content/urlbar.xml (content/urlbar.xml)
content/deckbrowser.xml (content/deckbrowser.xml)
content/deckbrowser.css (content/deckbrowser.css)
content/browser.css (content/browser.css)
content/scrollbars.css (content/scrollbars.css)
content/content.css (content/content.css)
% content branding %branding/
@ -23,6 +24,8 @@ classic.jar:
images/default-favicon.png (skin/images/default-favicon.png)
images/identity.png (skin/images/identity.png)
images/starred48.png (skin/images/starred48.png)
images/page-starred.png (skin/images/page-starred.png)
images/tag.png (skin/images/tag.png)
images/throbber.png (skin/images/throbber.png)
images/throbber.gif (skin/images/throbber.gif)
images/toolbar.png (skin/images/toolbar.png)
@ -33,3 +36,5 @@ classic.jar:
% locale browser @AB_CD@ %
browser.dtd (locale/@AB_CD@/browser.dtd)
browser.properties (locale/@AB_CD@/browser.properties)
search.properties (locale/@AB_CD@/search.properties)
region.properties (locale/@AB_CD@/region.properties)

Просмотреть файл

@ -31,6 +31,14 @@
<!ENTITY bookmarkCancel.label "Cancel">
<!ENTITY bookmarkDone.label "Done">
<!ENTITY findOnCmd.label "Find in This Page…">
<!ENTITY findOnCmd.accesskey "F">
<!ENTITY findOnCmd.commandkey "f">
<!ENTITY findAgainCmd.label "Find Again">
<!ENTITY findAgainCmd.accesskey "g">
<!ENTITY findAgainCmd.commandkey "g">
<!ENTITY findAgainCmd.commandkey2 "VK_F3">
<!ENTITY identity.unverifiedsite2 "This web site does not supply identity information.">
<!ENTITY identity.connectedTo "You are connected to">
<!-- Localization note (identity.runBy) : This string appears between a

Просмотреть файл

@ -0,0 +1,34 @@
# Default search engine
browser.search.defaultenginename=Google
# Search engine order (order displayed in the search bar dropdown)s
browser.search.order.1=Google
browser.search.order.2=Yahoo
# This is the default set of web based feed handlers shown in the reader
# selection UI
browser.contentHandlers.types.0.title=Bloglines
browser.contentHandlers.types.0.uri=http://www.bloglines.com/login?r=/sub/%s
browser.contentHandlers.types.1.title=My Yahoo
browser.contentHandlers.types.1.uri=http://add.my.yahoo.com/rss?url=%s
browser.contentHandlers.types.2.title=Google
browser.contentHandlers.types.2.uri=http://fusion.google.com/add?feedurl=%s
# Keyword URL (for location bar searches)
keyword.URL=http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=
# increment this number when anything gets changed in the list below. This will
# cause Firefox to re-read these prefs and inject any new handlers into the
# profile database. Note that "new" is defined as "has a different URL"; this
# means that it's not possible to update the name of existing handler, so
# don't make any spelling errors here.
gecko.handlerService.defaultHandlersVersion=1
# The default set of protocol handlers for webcal:
gecko.handlerService.schemes.webcal.0.name=30 Boxes
gecko.handlerService.schemes.webcal.0.uriTemplate=http://30boxes.com/external/widget?refer=ff&url=%s
# The default set of protocol handlers for mailto:
gecko.handlerService.schemes.mailto.0.name=Yahoo! Mail
gecko.handlerService.schemes.mailto.0.uriTemplate=http://compose.mail.yahoo.com/?To=%s

Просмотреть файл

@ -0,0 +1,25 @@
searchtip=Search using %S
cmd_clearHistory=Clear Search History
cmd_clearHistory_accesskey=C
cmd_showSuggestions=Show Suggestions
cmd_showSuggestions_accesskey=S
addEngineConfirmTitle=Add Search Engine
addEngineConfirmation=Add "%S" to the list of engines available in the search bar?\n\nFrom: %S
addEngineUseNowText=Start &using it right away
addEngineAddButtonLabel=Add
error_loading_engine_title=Download Error
# LOCALIZATION NOTE (error_loading_engine_msg2): %1$S = brandShortName, %2$S = location
error_loading_engine_msg2=%S could not download the search plugin from:\n%S
error_duplicate_engine_msg=%S could not install the search plugin from "%S" because an engine with the same name already exists.
error_invalid_engine_title=Install Error
# LOCALIZATION NOTE (error_invalid_engine_msg): %S = brandShortName
error_invalid_engine_msg=This search engine isn't supported by %S and can't be installed.
cmd_addFoundEngine=Add "%S"
suggestion_label=Suggestions

Просмотреть файл

@ -155,7 +155,7 @@ toolbarbutton.browser-control-button {
-moz-image-region: rect(0px 242px 45px 197px);
}
#tool-search {
.tool-search {
list-style-image: url("chrome://browser/skin/images/mono-toolbar.png");
-moz-image-region: rect(0px 36px 36px 0px);
}
@ -221,7 +221,7 @@ toolbarbutton.browser-control-button {
padding: 8px;
}
#urllist-items {
#urllist-items, .autocomplete-richlistbox {
-moz-appearance: none !important;
background-color: rgba(207,207,207,0.9);
border: 2px solid #fff !important;
@ -239,13 +239,71 @@ toolbarbutton.browser-control-button {
height: 24px;
}
#urllist-search {
#urllist-search, #autocomplete_navbuttons {
background-color: rgba(207,207,207,0.9);
border: 2px solid #fff !important;
-moz-border-radius: 10px;
_moz-box-align: start;
}
/* autocomplete */
#popup_autocomplete {
moz-appearance: none;
background-color: rgba(207,207,207,0.9);
}
#autocomplete_navbuttons {
margin-top: 12px;
}
#PopupAutoCompleteRichResult {
direction: ltr !important;
}
.ac-result-type-bookmark {
list-style-image: url("chrome://browser/skin/images/page-starred.png");
width: 16px;
height: 16px;
}
.ac-result-type-tag {
list-style-image: url("chrome://browser/skin/images/tag.png");
width: 16px;
height: 16px;
}
.ac-comment {
font-size: 1.15em;
}
.ac-extra > .ac-comment {
font-size: inherit;
}
.ac-url-box {
display: none;
}
.ac-url-text {
color: GrayText;
}
.ac-comment[selected="true"], .ac-url-text[selected="true"] {
color: inherit !important;
}
/* find bar */
#findpanel {
padding: 0 !important;
-moz-appearance: none;
background: transparent;
}
findbar {
background: rgba(128, 128, 128, 0.75);
}
/* Bookmark editor */
#bookmark-container {

Двоичные данные
mobile/chrome/skin/images/page-starred.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 718 B

Двоичные данные
mobile/chrome/skin/images/tag.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 517 B