backing out my fix for bug #399664, due to 2% Ts regression (see bug #402668 for details)

This commit is contained in:
sspitzer@mozilla.org 2007-11-06 00:43:53 -08:00
Родитель a2314bff24
Коммит b549e4d71f
15 изменённых файлов: 198 добавлений и 798 удалений

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

@ -200,7 +200,6 @@ pref("browser.urlbar.doubleClickSelectsAll", false);
#endif
pref("browser.urlbar.autoFill", false);
pref("browser.urlbar.matchOnlyTyped", false);
pref("browser.urlbar.maxResults", 50);
pref("browser.download.useDownloadDir", true);
pref("browser.download.folderList", 0);

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

@ -11,10 +11,6 @@ searchbar {
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#urlbar-result-popup");
}
#PopupAutoCompleteRichResult {
-moz-binding: url("chrome://browser/content/urlbarBindings.xml#urlbar-rich-result-popup");
}
/* ::::: print preview toolbar ::::: */
toolbar[printpreview="true"] {
-moz-binding: url("chrome://global/content/printPreviewBindings.xml#printpreviewtoolbar");

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

@ -99,12 +99,8 @@
onclick="checkForMiddleClick(this, event);"/>
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/>
<!-- for search and content formfill/pw manager -->
<panel type="autocomplete" chromedir="&locale.dir;" id="PopupAutoComplete" noautofocus="true"/>
<!-- for url bar autocomplete -->
<panel type="autocomplete-richlistbox" chromedir="&locale.dir;" id="PopupAutoCompleteRichResult" noautofocus="true"/>
<panel id="editBookmarkPanel" orient="vertical">
<vbox id="editBookmarkPanelContent" flex="1"/>
<hbox flex="1">
@ -254,10 +250,12 @@
<textbox id="urlbar" flex="1"
chromedir="&locale.dir;"
type="autocomplete"
autocompletesearch="history"
autocompletepopup="PopupAutoCompleteRichResult"
autocompletesearch="history"
autocompletepopup="PopupAutoComplete"
completeselectedindex="true"
tabscrolling="true"
showcommentcolumn="true"
showimagecolumn="true"
enablehistory="true"
maxrows="10"
newlines="stripsurroundingwhitespace"

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

@ -233,9 +233,19 @@
}
// completely ignore right-clicks
else if (aEvent.button != 2) {
if (this.mInput._getParentSearchbar) {
if (gURLBar && this.mInput == gURLBar) {
// handle address bar click
var url = controller.getValueAt(this.tree.view.selection.currentIndex);
// close the autocomplete popup and revert the entered address
this.closePopup();
controller.handleEscape();
// respect the usual clicking subtleties
openUILink(url, aEvent);
}
else if (this.mInput._getParentSearchbar) {
// handle search bar click
var search = controller.getValueAt(this.selectedIndex);
var search = controller.getValueAt(this.tree.view.selection.currentIndex);
var textbox = this.mInput;
// close the autocomplete popup and copy the selected value to the search box
@ -250,55 +260,7 @@
controller.handleEnter();
}
}
]]></body>
</method>
</implementation>
</binding>
<binding id="urlbar-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-rich-result-popup">
<implementation>
<field name="_maxResults">0</field>
<property name="maxResults" readonly="true">
<getter>
<![CDATA[
if (!this._maxResults) {
var prefService =
Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
this._maxResults = prefService.getIntPref("browser.urlbar.maxResults");
}
return this._maxResults;
]]>
</getter>
</property>
<method name="onPopupClick">
<parameter name="aEvent"/>
<body>
<![CDATA[
var controller = this.view.QueryInterface(Components.interfaces.nsIAutoCompleteController);
// default action on unmodified left-click
if (aEvent.button == 0 && !aEvent.shiftKey && !aEvent.ctrlKey &&
!aEvent.altKey && !aEvent.metaKey) {
controller.handleEnter();
}
// completely ignore right-clicks
else if (aEvent.button != 2) {
if (gURLBar && this.mInput == gURLBar) {
// handle address bar click
var url = controller.getValueAt(this.selectedIndex);
// close the autocomplete popup and revert the entered address
this.closePopup();
controller.handleEscape();
// respect the usual clicking subtleties
openUILink(url, aEvent);
}
}
]]>
</body>
]]></body>
</method>
</implementation>
</binding>

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

@ -869,12 +869,6 @@ toolbar[iconsize="small"] #paste-button:hover:active {
display: none;
}
/* Keep the URL bar LTR */
#PopupAutoCompleteRichResult {
direction: ltr !important;
}
/* ----- PAGE PROXY ICON ----- */
#page-proxy-deck,
@ -920,15 +914,19 @@ statusbarpanel#statusbar-display {
height: 16px;
}
.ac-result-type-tag {
list-style-image: url("chrome://browser/skin/places/tag.png");
width: 16px;
#treecolAutoCompleteImage {
max-width : 36px;
}
.autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
width: 16px;
height: 16px;
}
.ac-result-type-bookmark {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
width: 16px;
.autocomplete-treebody::-moz-tree-image(tag, treecolAutoCompleteImage) {
list-style-image: url("chrome://browser/skin/places/tag.png");
width: 16px;
height: 16px;
}

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

@ -905,10 +905,6 @@ toolbar[iconsize="small"] #paste-button:not([disabled="true"]):hover:active {
direction: ltr;
}
#PopupAutoCompleteRichResult {
direction: ltr !important;
}
/* ::::: page proxy icon ::::: */
#page-proxy-deck,
@ -953,15 +949,19 @@ statusbarpanel#statusbar-display {
height: 16px;
}
.ac-result-type-tag {
list-style-image: url("chrome://browser/skin/places/tag.png");
width: 16px;
#treecolAutoCompleteImage {
max-width : 36px;
}
.autocomplete-treebody::-moz-tree-image(bookmark, treecolAutoCompleteImage) {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
width: 16px;
height: 16px;
}
.ac-result-type-bookmark {
list-style-image: url("chrome://browser/skin/places/pageStarred.png");
width: 16px;
.autocomplete-treebody::-moz-tree-image(tag, treecolAutoCompleteImage) {
list-style-image: url("chrome://browser/skin/places/tag.png");
width: 16px;
height: 16px;
}

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

@ -41,7 +41,7 @@
interface nsIAutoCompleteInput;
[scriptable, uuid(b8883380-8cb3-444b-b929-0872b1cb7e73)]
[scriptable, uuid(bb4d04f6-997b-437a-9216-7a3dbbd848d0)]
interface nsIAutoCompleteController : nsISupports
{
/*
@ -148,7 +148,7 @@ interface nsIAutoCompleteController : nsISupports
AString getImageAt(in long index);
/*
* Get / set the current search string. Note, setting will not start searching
* Set the current search string, but don't start searching
*/
attribute AString searchString;
void setSearchString(in AString aSearchString);
};

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

@ -40,7 +40,7 @@
interface nsIAutoCompletePopup;
[scriptable, uuid(916aa9a0-e049-4ef9-a6dc-ff2f9f0f210b)]
[scriptable, uuid(8a5918dc-89ba-4bd0-934c-90e9c21568b8)]
interface nsIAutoCompleteInput : nsISupports
{
/*
@ -98,6 +98,12 @@ interface nsIAutoCompleteInput : nsISupports
*/
attribute boolean showCommentColumn;
/*
* Option to show a third column in the popup which contains
* an additional image for each autocomplete result
*/
attribute boolean showImageColumn;
/*
* Number of milliseconds after a keystroke before a search begins
*/

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

@ -628,17 +628,10 @@ NS_IMETHODIMP
nsAutoCompleteController::SetSearchString(const nsAString &aSearchString)
{
mSearchString = aSearchString;
return NS_OK;
}
NS_IMETHODIMP
nsAutoCompleteController::GetSearchString(nsAString &aSearchString)
{
aSearchString = mSearchString;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////
//// nsIAutoCompleteObserver

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

@ -118,12 +118,12 @@
// should not normally be required.
#define DEFAULT_DB_CACHE_PERCENTAGE 6
// We set the default database page size to be larger. sqlite's default is 1K.
// This gives good performance when many small parts of the file have to be
// loaded for each statement. Because we try to keep large chunks of the file
// in memory, a larger page size should give better I/O performance. 32K is
// sqlite's default max page size.
#define DEFAULT_DB_PAGE_SIZE 4096
// We set the default database page size to be larger. sqlite's default is 1K.
// This gives good performance when many small parts of the file have to be
// loaded for each statement. Because we try to keep large chunks of the file
// in memory, a larger page size should give better I/O performance. 32K is
// sqlite's default max page size.
#define DEFAULT_DB_PAGE_SIZE 4096
// the value of mLastNow expires every 3 seconds
#define HISTORY_EXPIRE_NOW_TIMEOUT (3 * PR_MSEC_PER_SEC)

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

@ -313,6 +313,19 @@ nsFormFillController::SetMaxRows(PRUint32 aMaxRows)
return NS_OK;
}
NS_IMETHODIMP
nsFormFillController::GetShowImageColumn(PRBool *aShowImageColumn)
{
*aShowImageColumn = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP nsFormFillController::SetShowImageColumn(PRBool aShowImageColumn)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsFormFillController::GetShowCommentColumn(PRBool *aShowCommentColumn)
{

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

@ -67,7 +67,7 @@
</xul:hbox>
<children includes="hbox"/>
</xul:hbox>
<xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
allowevents="true"
xbl:inherits="open,enablehistory"/>
@ -81,7 +81,7 @@
<field name="mIgnoreInput">false</field>
<field name="mEnterEvent">null</field>
<field name="mConsumeRollupEvent">false</field>
<field name="mInputElt">
document.getAnonymousElementByAttribute(this, "anonid", "input");
</field>
@ -120,7 +120,7 @@
popup.mInput = this;
popup;
]]></field>
<property name="controller" onget="return this.mController;" readonly="true"/>
<property name="popupOpen"
@ -151,6 +151,10 @@
onset="this.setAttribute('showcommentcolumn', val); return val;"
onget="return this.getAttribute('showcommentcolumn') == 'true';"/>
<property name="showImageColumn"
onset="this.setAttribute('showimagecolumn', val); return val;"
onget="return this.getAttribute('showimagecolumn') == 'true';"/>
<property name="timeout"
onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 50;"/>
@ -165,10 +169,10 @@
<property name="consumeRollupEvent" readonly="true"
onget="return this.mConsumeRollupEvent;"/>
<!-- This is the maximum number of drop-down rows we get when we
<!-- This is the maximum number of drop-down rows we get when we
hit the drop marker beside fields that have it (like the URLbar).-->
<field name="maxDropMarkerRows" readonly="true">14</field>
<field name="maxDropMarkerRows" readonly="true">14</field>
<method name="getSearchAt">
<parameter name="aIndex"/>
<body><![CDATA[
@ -228,7 +232,7 @@
<!-- =================== nsIDOMXULMenuListElement =================== -->
<property name="editable" readonly="true"
onget="return true;" />
onget="return true;" />
<property name="crop"
onset="this.setAttribute('crop',val); return val;"
@ -293,7 +297,7 @@
<property name="ignoreBlurWhileSearching"
onset="this.setAttribute('ignoreblurwhilesearching', val); return val;"
onget="return this.getAttribute('ignoreblurwhilesearching') == 'true';"/>
<!-- =================== PRIVATE MEMBERS =================== -->
<!-- ::::::::::::: autocomplete controller ::::::::::::: -->
@ -350,7 +354,7 @@
this.mController.startSearch("");
]]></body>
</method>
<method name="toggleHistoryPopup">
<body><![CDATA[
if (!this.popup.mPopupOpen)
@ -480,8 +484,7 @@
]]></body>
</method>
<method name="_focus">
<!-- doesn't reset this.mController -->
<method name="_focus"> <!-- doesn't reset this.mController -->
<body><![CDATA[
this._dontBlur = true;
this.focus();
@ -515,13 +518,13 @@
</handlers>
</binding>
<binding id="autocomplete-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
<binding id="autocomplete-result-popup" extends="chrome://global/content/bindings/popup.xml#popup">
<resources>
<stylesheet src="chrome://global/skin/tree.css"/>
<stylesheet src="chrome://global/skin/autocomplete.css"/>
</resources>
<content ignorekeys="true">
<content>
<xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1">
<xul:treecols anonid="treecols">
<xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/>
@ -529,51 +532,24 @@
<xul:treechildren class="autocomplete-treebody"/>
</xul:tree>
</content>
<implementation implements="nsIAutoCompletePopup">
<field name="mInput">null</field>
<field name="mPopupOpen">false</field>
<field name="mShowCommentCol">false</field>
<field name="mShowImageCol">false</field>
<implementation>
<field name="mShowCommentColumn">false</field>
<constructor><![CDATA[
this.setAttribute("ignorekeys", "true");
]]></constructor>
<property name="showCommentColumn"
onget="return this.mShowCommentColumn;">
<setter>
<![CDATA[
if (!val && this.mShowCommentColumn) {
// reset the flex on the value column and remove the comment column
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 1);
this.removeColumn("treecolAutoCompleteComment");
} else if (val && !this.mShowCommentColumn) {
// reset the flex on the value column and add the comment column
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 2);
this.addColumn({id: "treecolAutoCompleteComment", flex: 1});
}
this.mShowCommentColumn = val;
return val;
]]>
</setter>
</property>
<!-- =================== nsIAutoCompletePopup =================== -->
<method name="addColumn">
<parameter name="aAttrs"/>
<body>
<![CDATA[
var col = document.createElement("treecol");
col.setAttribute("class", "autocomplete-treecol");
for (var name in aAttrs)
col.setAttribute(name, aAttrs[name]);
this.treecols.appendChild(col);
return col;
]]>
</body>
</method>
<property name="input"
onget="return this.mInput"/>
<method name="removeColumn">
<parameter name="aColId"/>
<body>
<![CDATA[
return this.treecols.removeChild(document.getElementById(aColId));
]]>
</body>
</method>
<property name="overrideValue" readonly="true"
onget="return null;"/>
<property name="selectedIndex"
onget="return this.tree.currentIndex;">
@ -590,32 +566,8 @@
]]></setter>
</property>
<method name="adjustHeight">
<body>
<![CDATA[
// detect the desired height of the tree
var bx = this.tree.treeBoxObject;
var view = this.tree.view;
if (!view)
return;
var rows = this.maxRows;
if (!view.rowCount || (rows && view.rowCount < rows))
rows = view.rowCount;
var height = rows * bx.rowHeight;
if (height == 0)
this.tree.setAttribute("collapsed", "true");
else {
if (this.tree.hasAttribute("collapsed"))
this.tree.removeAttribute("collapsed");
this.tree.setAttribute("height", height);
}
this.tree.setAttribute("hidescrollbar", view.rowCount <= rows);
]]>
</body>
</method>
<property name="popupOpen" readonly="true"
onget="return this.mPopupOpen;"/>
<method name="openAutocompletePopup">
<parameter name="aInput"/>
@ -625,8 +577,9 @@
this.mInput = aInput;
this.view = aInput.controller.QueryInterface(Components.interfaces.nsITreeView);
this.invalidate();
this.showCommentColumn = this.mInput.showCommentColumn;
this.showImageColumn = this.mInput.showImageColumn;
document.popupNode = null;
@ -640,6 +593,17 @@
]]></body>
</method>
<method name="closePopup">
<body><![CDATA[
if (this.mPopupOpen) {
this.hidePopup();
document.popupNode = null;
// this.setAttribute("hidden", "true");
this.removeAttribute("width");
}
]]></body>
</method>
<method name="invalidate">
<body><![CDATA[
this.adjustHeight();
@ -686,37 +650,6 @@
]]></setter>
</property>
</implementation>
</binding>
<binding id="autocomplete-base-popup" extends="chrome://global/content/bindings/popup.xml#popup">
<implementation implements="nsIAutoCompletePopup">
<field name="mInput">null</field>
<field name="mPopupOpen">false</field>
<!-- =================== nsIAutoCompletePopup =================== -->
<property name="input" readonly="true"
onget="return this.mInput"/>
<property name="overrideValue" readonly="true"
onget="return null;"/>
<property name="popupOpen" readonly="true"
onget="return this.mPopupOpen;"/>
<method name="closePopup">
<body>
<![CDATA[
if (this.mPopupOpen) {
this.hidePopup();
document.popupNode = null;
this.removeAttribute("width");
}
]]>
</body>
</method>
<!-- This is the default number of rows that we give the autocomplete
popup when the textbox doesn't have a "maxrows" attribute
for us to use. -->
@ -734,13 +667,89 @@
<field name="_normalMaxRows">-1</field>
<property name="maxRows" readonly="true">
<getter>
<![CDATA[
<getter><![CDATA[
return (this.mInput && this.mInput.maxRows) || this.defaultMaxRows;
]]>
</getter>
]]></getter>
</property>
<property name="showCommentColumn"
onget="return this.mShowCommentColumn;">
<setter><![CDATA[
if (!val && this.mShowCommentColumn) {
// reset the flex on the value column and remove the comment column
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 1);
this.removeColumn("treecolAutoCompleteComment");
} else if (val && !this.mShowCommentColumn) {
// reset the flex on the value column and add the comment column
document.getElementById("treecolAutoCompleteValue").setAttribute("flex", 2);
this.addColumn({id: "treecolAutoCompleteComment", flex: 1});
}
this.mShowCommentColumn = val;
return val;
]]></setter>
</property>
<property name="showImageColumn"
onget="return this.mShowImageColumn;">
<setter>
<![CDATA[
if (!val && this.mShowImageColumn) {
// remove the image column
this.removeColumn("treecolAutoCompleteImage");
} else if (val && !this.mShowImageColumn) {
// add the image column
this.addColumn({id: "treecolAutoCompleteImage", flex: 1});
}
this.mShowImageColumn = val;
return val;
]]>
</setter>
</property>
<method name="addColumn">
<parameter name="aAttrs"/>
<body><![CDATA[
var col = document.createElement("treecol");
col.setAttribute("class", "autocomplete-treecol");
for (var name in aAttrs)
col.setAttribute(name, aAttrs[name]);
this.treecols.appendChild(col);
return col;
]]></body>
</method>
<method name="removeColumn">
<parameter name="aColId"/>
<body><![CDATA[
return this.treecols.removeChild(document.getElementById(aColId));
]]></body>
</method>
<method name="adjustHeight">
<body><![CDATA[
// detect the desired height of the tree
var bx = this.tree.treeBoxObject;
var view = this.tree.view;
if (!view)
return;
var rows = this.maxRows;
if (!view.rowCount || (rows && view.rowCount < rows))
rows = view.rowCount;
var height = rows * bx.rowHeight;
if (height == 0)
this.tree.setAttribute("collapsed", "true");
else {
if (this.tree.hasAttribute("collapsed"))
this.tree.removeAttribute("collapsed");
this.tree.setAttribute("height", height);
}
this.tree.setAttribute("hidescrollbar", view.rowCount <= rows);
]]></body>
</method>
<method name="getNextIndex">
<parameter name="aReverse"/>
<parameter name="aAmount"/>
@ -772,6 +781,7 @@
controller.handleEnter();
]]></body>
</method>
</implementation>
<handlers>
@ -799,401 +809,6 @@
</handlers>
</binding>
<binding id="autocomplete-rich-result-popup" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete-base-popup">
<resources>
<stylesheet src="chrome://global/skin/autocomplete.css"/>
</resources>
<content ignorekeys="true">
<xul:richlistbox anonid="richlistbox" class="autocomplete-richlistbox" flex="1"/>
</content>
<implementation implements="nsIAutoCompletePopup">
<field name="_currentIndex">0</field>
<field name="_rowHeight">0</field>
<!-- =================== nsIAutoCompletePopup =================== -->
<property name="selectedIndex"
onget="return this.richlistbox.selectedIndex;">
<setter>
<![CDATA[
this.richlistbox.selectedIndex = val;
this.richlistbox.ensureSelectedElementIsVisible();
return val;
]]>
</setter>
</property>
<method name="openAutocompletePopup">
<parameter name="aInput"/>
<parameter name="aElement"/>
<body>
<![CDATA[
if (!this.mPopupOpen) {
this.mInput = aInput;
document.popupNode = null;
var rect = aElement.getBoundingClientRect();
var width = rect.right - rect.left;
this.setAttribute("width", width > 100 ? width : 100);
// invalidate() depends on the width attribute
this.invalidate();
this.openPopup(aElement, "after_start", 0, 0, false, false);
this.popupBoxObject.setConsumeRollupEvent(this.mInput.consumeRollupEvent);
}
]]>
</body>
</method>
<method name="invalidate">
<body>
<![CDATA[
// collapsed if no matches
this.richlistbox.collapsed = (this._matchCount == 0);
// make sure to collapse any existing richlistitems
// that aren't going to be used
var existingItemsCount = this.richlistbox.childNodes.length;
for (var i = this._matchCount; i < existingItemsCount; i++)
this.richlistbox.childNodes[i].collapsed = true;
this._currentIndex = 0;
this._appendCurrentResult();
]]>
</body>
</method>
<property name="maxResults" readonly="true">
<getter>
<![CDATA[
// this is how many richlistitems will be kept around
// (note, this getter may be overridden)
return 20;
]]>
</getter>
</property>
<property name="_matchCount" readonly="true">
<getter>
<![CDATA[
return Math.min(this.mInput.controller.matchCount, this.maxResults);
]]>
</getter>
</property>
<method name="_appendCurrentResult">
<body>
<![CDATA[
var controller = this.mInput.controller;
// detect the desired height of the tree
var rows = this.maxRows;
if (!this._matchCount || (rows && this._matchCount < rows))
rows = this._matchCount;
// until we have support for "rows" on richlistbox,
// determine the height dynamically. (see bug #401939)
if (!this._rowHeight && this.richlistbox.childNodes.length)
this._rowHeight = this.richlistbox.childNodes[0].boxObject.height;
var height = this._rowHeight * rows;
if (this._rowHeight && this.richlistbox.height != height)
this.richlistbox.height = height;
if (this._currentIndex < this._matchCount) {
var existingItemsCount = this.richlistbox.childNodes.length;
var item;
// trim the leading/trailing whitespace
var trimmedSearchString = controller.searchString.replace(/^\s+/, "").replace(/\s+$/, "");
if (this._currentIndex < existingItemsCount) {
// re-use the existing item
item = this.richlistbox.childNodes[this._currentIndex];
}
else {
// need to create a new item
item = document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", "richlistitem");
}
// set these attributes before we set the class
// so that we can use them from the contructor
item.setAttribute("image", controller.getImageAt(this._currentIndex));
item.setAttribute("url", controller.getValueAt(this._currentIndex));
item.setAttribute("title", controller.getCommentAt(this._currentIndex));
item.setAttribute("type", controller.getStyleAt(this._currentIndex));
item.setAttribute("text", trimmedSearchString);
var width = this.getAttribute("width");
if (this._currentIndex < existingItemsCount) {
// re-use the existing item
item._adjustAcItem();
item.collapsed = false;
var current_width = item.getAttribute("current_width");
if (width && current_width != width) {
item.setAttribute("current_width", width);
item._adjustWidth();
}
}
else {
// created a new item
if (width)
item.setAttribute("current_width", width);
// set the class at the end so we can use the attributes
// in the xbl constructor
item.className = "autocomplete-richlistitem";
this.richlistbox.appendChild(item);
}
this._currentIndex++;
// yield after creating each item so that the UI is responsive
var self = this;
setTimeout(function() { self._appendCurrentResult(); }, 0);
}
]]>
</body>
</method>
<method name="selectBy">
<parameter name="aReverse"/>
<parameter name="aPage"/>
<body>
<![CDATA[
try {
var amount = aPage ? 5 : 1;
// because we collapsed unused items, we can't use this.richlistbox.getRowCount(), we need to use the matchCount
this.selectedIndex = this.getNextIndex(aReverse, amount, this.selectedIndex, this._matchCount - 1);
if (this.selectedIndex == -1) {
this.input._focus();
}
} catch (ex) {
// do nothing - occasionally timer-related js errors happen here
// e.g. "this.selectedIndex has no properties", when you type fast and hit a
// navigation key before this popup has opened
}
]]>
</body>
</method>
<field name="richlistbox">
document.getAnonymousElementByAttribute(this, "anonid", "richlistbox");
</field>
<property name="view"
onget="return this.mInput.controller;"
onset="return val;"/>
</implementation>
</binding>
<binding id="autocomplete-richlistitem" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<content>
<xul:image xbl:inherits="src=image" class="ac-site-icon"/>
<xul:label anonid="pre-url-overflow-ellipsis" class="ac-ellipsis-before"/>
<xul:scrollbox anonid="url-scrollbox" class="ac-url">
<!-- note, we rely on the newlines here so that we have
a textNode before and after the label. see _setUpDescription()
for more details -->
<xul:description anonid="url" class="ac-normal-text">
<xul:label class="ac-emphasize-text"/>
</xul:description>
</xul:scrollbox>
<xul:label anonid="url-overflow-ellipsis" class="ac-ellipsis-between"/>
<xul:label anonid="pre-title-overflow-ellipsis" class="ac-ellipsis-before"/>
<xul:scrollbox anonid="title-scrollbox" class="ac-title">
<!-- note, we rely on the newlines here so that we have
a textNode before and after the label. see _setUpDescription()
for more details -->
<xul:description anonid="title" class="ac-normal-text">
<xul:label class="ac-emphasize-text"/>
</xul:description>
</xul:scrollbox>
<xul:label anonid="title-overflow-ellipsis" class="ac-ellipsis-after"/>
<xul:image anonid="type-image" class="ac-type-icon"/>
</content>
<implementation>
<constructor>
<![CDATA[
this._preUrlOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "pre-url-overflow-ellipsis");
this._urlOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "url-overflow-ellipsis");
this._preTitleOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "pre-title-overflow-ellipsis");
this._titleOverflowEllipsis = document.getAnonymousElementByAttribute(this, "anonid", "title-overflow-ellipsis");
this._typeImage = document.getAnonymousElementByAttribute(this, "anonid", "type-image");
this._urlScrollbox = document.getAnonymousElementByAttribute(this, "anonid", "url-scrollbox");
this._url = document.getAnonymousElementByAttribute(this, "anonid", "url");
this._titleScrollbox = document.getAnonymousElementByAttribute(this, "anonid", "title-scrollbox");
this._title = document.getAnonymousElementByAttribute(this, "anonid", "title");
// XXX hack
// for the first richlistitem, when we call _adjustWidth()
// from the xbl constructor, these elements don't have widths
// but we rely on those widths to properly set the widths
// of the scrollboxes. if we don't have the widths
// try again on a timeout.
if (!this._preUrlOverflowEllipsis.boxObject.width ||
!this._urlOverflowEllipsis.boxObject.width ||
!this._preTitleOverflowEllipsis.boxObject.width ||
!this._titleOverflowEllipsis.boxObject.width) {
var self = this;
setTimeout(function() { self._adjustWidth(); }, 0);
}
else
this._adjustWidth();
this._adjustAcItem();
]]>
</constructor>
<method name="_setUpDescription">
<parameter name="aDescriptionElement"/>
<parameter name="aText"/>
<parameter name="aScrollBoxObject"/>
<parameter name="aPreEllipsis"/>
<parameter name="aEllipsis"/>
<parameter name="aMatchIndex"/>
<parameter name="aMatchLength"/>
<body>
<![CDATA[
// scroll to the beginning part of the description
aScrollBoxObject.scrollToElement(aDescriptionElement);
if (aMatchIndex == -1) {
aDescriptionElement.childNodes[0].textContent = aText;
aDescriptionElement.childNodes[1].value = "";
aDescriptionElement.childNodes[2].textContent = "";
}
else {
aDescriptionElement.childNodes[0].textContent =
aText.substring(0, aMatchIndex);
aDescriptionElement.childNodes[1].value =
aText.substring(aMatchIndex, aMatchIndex + aMatchLength);
aDescriptionElement.childNodes[2].textContent =
aText.substring(aMatchIndex + aMatchLength);
// now ensure the emphasized part is visible
aScrollBoxObject.scrollToElement(aDescriptionElement.childNodes[1]);
}
// need to set up the ellipsis on a time out,
// because the width of the description element may still be 0
// even though the aText length is non-zero
var self = this;
setTimeout(function() { self._setUpEllipsis(aScrollBoxObject, aDescriptionElement, aPreEllipsis, aEllipsis); }, 0);
]]>
</body>
</method>
<method name="_setUpEllipsis">
<parameter name="aScrollBoxObject"/>
<parameter name="aDescriptionElement"/>
<parameter name="aPreEllipsis"/>
<parameter name="aEllipsis"/>
<body>
<![CDATA[
var scrollPos = {};
aScrollBoxObject.getPosition(scrollPos, {});
// determine if we need to show the "pre" ellipsis
// since we're at the beginning part, there is no "pre" ellipsis
if (scrollPos.value + aScrollBoxObject.x == aDescriptionElement.boxObject.x)
aPreEllipsis.value = "";
else
aPreEllipsis.value = "\u2026";
// determine if we need to show the "post" ellipsis
if ((aScrollBoxObject.x + aScrollBoxObject.width) >= (aDescriptionElement.boxObject.x + aDescriptionElement.boxObject.width))
aEllipsis.value = "";
else
aEllipsis.value = "\u2026";
]]>
</body>
</method>
<method name="_adjustAcItem">
<body>
<![CDATA[
var text = this.getAttribute("text");
var url = this.getAttribute("url");
var title = this.getAttribute("title");
var type = this.getAttribute("type");
var url_sbo = this._urlScrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
var title_sbo = this._titleScrollbox.boxObject.QueryInterface(Components.interfaces.nsIScrollBoxObject);
this._typeImage.className = type ? ("ac-result-type-" + type) : "";
// if we aren't matching any text
// (the user has clicked on the history drop down
// or this result is a "tag" match, don't bold any matching text
if (text == "" || type == "tag") {
this._setUpDescription(this._url, url, url_sbo, this._preUrlOverflowEllipsis, this._urlOverflowEllipsis, -1, -1);
this._setUpDescription(this._title, title, title_sbo, this._preTitleOverflowEllipsis, this._titleOverflowEllipsis, -1, -1);
return;
}
// emphasize the matching text, first try url, and then try title
var needle = text.toLowerCase();
var hay = url.toLowerCase();
var index = hay.indexOf(needle);
this._setUpDescription(this._url, url, url_sbo, this._preUrlOverflowEllipsis, this._urlOverflowEllipsis, index, text.length);
// if we didn't find it in the url, check the title
if (index == -1) {
hay = title.toLowerCase();
index = hay.indexOf(needle);
}
else
index = -1;
this._setUpDescription(this._title, title, title_sbo, this._preTitleOverflowEllipsis, this._titleOverflowEllipsis, index, text.length);
]]>
</body>
</method>
<method name="_adjustWidth">
<body>
<![CDATA[
// XXX hack
// see bug #399644 comment #39 for some details
// add 16px for the site image, 16px for the tpye image
// and 24px for scroll bar
var pixelsUsedForNonText = 16 + 16 + 24 +
this._preUrlOverflowEllipsis.boxObject.width +
this._urlOverflowEllipsis.boxObject.width +
this._preTitleOverflowEllipsis.boxObject.width +
this._titleOverflowEllipsis.boxObject.width;
var current_width = this.getAttribute("current_width") -
pixelsUsedForNonText;
var titleWidth = (current_width / 3); // 1/3
var urlWidth = (titleWidth * 2); // 2/3
this._urlScrollbox.minWidth = urlWidth;
this._urlScrollbox.maxWidth = urlWidth;
this._titleScrollbox.minWidth = titleWidth;
this._titleScrollbox.maxWidth = titleWidth;
]]>
</body>
</method>
</implementation>
</binding>
<binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<content>
<children includes="treecols"/>
@ -1203,53 +818,11 @@
</content>
</binding>
<binding id="autocomplete-richlistbox" extends="chrome://global/content/bindings/richlistbox.xml#richlistbox">
<implementation>
<field name="mLastMoveTime">Date.now()</field>
</implementation>
<handlers>
<handler event="mouseup">
<![CDATA[
// don't call onPopupClick for the scrollbar buttons, thumb, slider, etc.
var item = event.originalTarget;
while (item && item.localName != "richlistitem")
item = item.parentNode;
if (!item)
return;
this.parentNode.onPopupClick(event);
]]>
</handler>
<handler event="mousedown" action="event.preventDefault();"/>
<handler event="mousemove">
<![CDATA[
if (Date.now() - this.mLastMoveTime > 30) {
var item = event.target;
while (item && item.localName != "richlistitem")
item = item.parentNode;
if (!item)
return;
var rc = this.getIndexOfItem(item);
if (rc != this.selectedIndex)
this.selectedIndex = rc;
this.mLastMoveTime = Date.now();
}
]]>
</handler>
</handlers>
</binding>
<binding id="autocomplete-treebody">
<implementation>
<field name="mLastMoveTime">Date.now()</field>
<field name="mLastMoveTime">new Date()</field>
</implementation>
<handlers>
<handler event="mouseup" action="this.parentNode.parentNode.onPopupClick(event);"/>
@ -1260,11 +833,11 @@
]]></handler>
<handler event="mousemove"><![CDATA[
if (Date.now() - this.mLastMoveTime > 30) {
if (new Date() - this.mLastMoveTime > 30) {
var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
if (rc != this.parentNode.currentIndex)
this.parentNode.view.selection.select(rc);
this.mLastMoveTime = Date.now();
this.mLastMoveTime = new Date();
}
]]></handler>
</handlers>
@ -1288,7 +861,7 @@
]]></body>
</method>
</implementation>
<handlers>
<handler event="mousedown" button="0"><![CDATA[
this.showPopup();

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

@ -746,10 +746,6 @@ panel[type="autocomplete"] {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-result-popup");
}
panel[type="rich-autocomplete"] {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-rich-result-popup");
}
.autocomplete-tree {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-tree");
}
@ -758,14 +754,6 @@ panel[type="rich-autocomplete"] {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-treebody");
}
.autocomplete-richlistbox {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-richlistbox");
}
.autocomplete-richlistitem {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-richlistitem");
}
.autocomplete-treerows {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-treerows");
}

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

@ -75,7 +75,6 @@ textbox.padded {
/* ::::: autocomplete popups ::::: */
panel[type="autocomplete"],
panel[type="autocomplete-richlistbox"],
.autocomplete-history-popup {
padding: 0px !important;
background-color: -moz-Field !important;
@ -118,68 +117,6 @@ treechildren.autocomplete-treebody::-moz-tree-cell-text(selected) {
color: HighlightText !important;
}
/* ::::: richlistbox autocomplete ::::: */
.autocomplete-richlistbox {
-moz-appearance: none !important;
margin: 0;
border: none !important;
background-color: transparent !important;
}
.autocomplete-richlistbox > richlistitem[selected="true"] {
background-color: Highlight;
color: HighlightText;
}
.autocomplete-richlistitem {
overflow: hidden;
padding: 1px 0px 1px 2px;
}
.ac-site-icon {
width: 16px;
height: 16px;
}
.ac-type-icon {
width: 16px;
height: 16px;
}
.ac-ellipsis-before {
margin: 2px -2px 0px 2px !important;
padding: 0;
min-width: 1.1em;
}
.ac-ellipsis-between {
margin: 2px 0px 0px 0px !important;
-moz-padding-end: 8px;
min-width: 2em;
}
.ac-ellipsis-after {
margin: 2px 0px 0px 0px !important;
padding: 0;
min-width: 1.1em ;
}
.ac-normal-text {
margin: 2px 0px 0px 0px !important;
padding: 0;
}
.ac-emphasize-text {
margin: 0 !important;
padding: 0;
font-weight: bold;
}
.ac-title, .ac-url {
overflow: hidden;
}
/* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input {

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

@ -168,7 +168,6 @@ textbox[chromedir="rtl"] .autocomplete-history-dropmarker {
/* ::::: autocomplete popups ::::: */
panel[type="autocomplete"],
panel[type="autocomplete-richlistbox"],
.autocomplete-history-popup {
-moz-appearance: none;
border-width: 1px;
@ -211,68 +210,6 @@ treechildren.autocomplete-treebody::-moz-tree-cell-text(selected) {
color: HighlightText !important;
}
/* ::::: richlistbox autocomplete ::::: */
.autocomplete-richlistbox {
-moz-appearance: none !important;
margin: 0;
border: none !important;
background-color: transparent !important;
}
.autocomplete-richlistbox > richlistitem[selected="true"] {
background-color: Highlight;
color: HighlightText;
}
.autocomplete-richlistitem {
overflow: hidden;
padding: 1px 0px 1px 2px;
}
.ac-site-icon {
width: 16px;
height: 16px;
}
.ac-type-icon {
width: 16px;
height: 16px;
}
.ac-ellipsis-before {
margin: 2px -2px 0px 2px !important;
padding: 0;
min-width: 1em;
}
.ac-ellipsis-between {
margin: 2px 0px 0px 0px !important;
-moz-padding-end: 8px;
min-width: 2em;
}
.ac-ellipsis-after {
margin: 2px 0px 0px 0px !important;
padding: 0;
min-width: 1em;
}
.ac-normal-text {
margin: 2px 0px 0px 0px !important;
padding: 0;
}
.ac-emphasize-text {
margin: 0 !important;
padding: 0;
font-weight: bold;
}
.ac-title, .ac-url {
overflow: hidden;
}
/* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input {