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 08:43:55 +00:00
Родитель 8fe2c05da8
Коммит c2f80eb36e
15 изменённых файлов: 198 добавлений и 798 удалений

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

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

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

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

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

@ -99,12 +99,8 @@
onclick="checkForMiddleClick(this, event);"/> onclick="checkForMiddleClick(this, event);"/>
<tooltip id="aHTMLTooltip" onpopupshowing="return FillInHTMLTooltip(document.tooltipNode);"/> <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"/> <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"> <panel id="editBookmarkPanel" orient="vertical">
<vbox id="editBookmarkPanelContent" flex="1"/> <vbox id="editBookmarkPanelContent" flex="1"/>
<hbox flex="1"> <hbox flex="1">
@ -255,9 +251,11 @@
chromedir="&locale.dir;" chromedir="&locale.dir;"
type="autocomplete" type="autocomplete"
autocompletesearch="history" autocompletesearch="history"
autocompletepopup="PopupAutoCompleteRichResult" autocompletepopup="PopupAutoComplete"
completeselectedindex="true" completeselectedindex="true"
tabscrolling="true" tabscrolling="true"
showcommentcolumn="true"
showimagecolumn="true"
enablehistory="true" enablehistory="true"
maxrows="10" maxrows="10"
newlines="stripsurroundingwhitespace" newlines="stripsurroundingwhitespace"

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

@ -233,9 +233,19 @@
} }
// completely ignore right-clicks // completely ignore right-clicks
else if (aEvent.button != 2) { 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 // handle search bar click
var search = controller.getValueAt(this.selectedIndex); var search = controller.getValueAt(this.tree.view.selection.currentIndex);
var textbox = this.mInput; var textbox = this.mInput;
// close the autocomplete popup and copy the selected value to the search box // close the autocomplete popup and copy the selected value to the search box
@ -254,52 +264,4 @@
</method> </method>
</implementation> </implementation>
</binding> </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>
</method>
</implementation>
</binding>
</bindings> </bindings>

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

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

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

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

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

@ -41,7 +41,7 @@
interface nsIAutoCompleteInput; interface nsIAutoCompleteInput;
[scriptable, uuid(b8883380-8cb3-444b-b929-0872b1cb7e73)] [scriptable, uuid(bb4d04f6-997b-437a-9216-7a3dbbd848d0)]
interface nsIAutoCompleteController : nsISupports interface nsIAutoCompleteController : nsISupports
{ {
/* /*
@ -148,7 +148,7 @@ interface nsIAutoCompleteController : nsISupports
AString getImageAt(in long index); 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; interface nsIAutoCompletePopup;
[scriptable, uuid(916aa9a0-e049-4ef9-a6dc-ff2f9f0f210b)] [scriptable, uuid(8a5918dc-89ba-4bd0-934c-90e9c21568b8)]
interface nsIAutoCompleteInput : nsISupports interface nsIAutoCompleteInput : nsISupports
{ {
/* /*
@ -98,6 +98,12 @@ interface nsIAutoCompleteInput : nsISupports
*/ */
attribute boolean showCommentColumn; 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 * Number of milliseconds after a keystroke before a search begins
*/ */

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

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

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

@ -313,6 +313,19 @@ nsFormFillController::SetMaxRows(PRUint32 aMaxRows)
return NS_OK; 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 NS_IMETHODIMP
nsFormFillController::GetShowCommentColumn(PRBool *aShowCommentColumn) nsFormFillController::GetShowCommentColumn(PRBool *aShowCommentColumn)
{ {

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

@ -151,6 +151,10 @@
onset="this.setAttribute('showcommentcolumn', val); return val;" onset="this.setAttribute('showcommentcolumn', val); return val;"
onget="return this.getAttribute('showcommentcolumn') == 'true';"/> 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" <property name="timeout"
onset="this.setAttribute('timeout', val); return val;" onset="this.setAttribute('timeout', val); return val;"
onget="return parseInt(this.getAttribute('timeout')) || 50;"/> onget="return parseInt(this.getAttribute('timeout')) || 50;"/>
@ -480,8 +484,7 @@
]]></body> ]]></body>
</method> </method>
<method name="_focus"> <method name="_focus"> <!-- doesn't reset this.mController -->
<!-- doesn't reset this.mController -->
<body><![CDATA[ <body><![CDATA[
this._dontBlur = true; this._dontBlur = true;
this.focus(); this.focus();
@ -515,13 +518,13 @@
</handlers> </handlers>
</binding> </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> <resources>
<stylesheet src="chrome://global/skin/tree.css"/> <stylesheet src="chrome://global/skin/tree.css"/>
<stylesheet src="chrome://global/skin/autocomplete.css"/> <stylesheet src="chrome://global/skin/autocomplete.css"/>
</resources> </resources>
<content ignorekeys="true"> <content>
<xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1"> <xul:tree anonid="tree" class="autocomplete-tree plain" hidecolumnpicker="true" flex="1">
<xul:treecols anonid="treecols"> <xul:treecols anonid="treecols">
<xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/> <xul:treecol id="treecolAutoCompleteValue" class="autocomplete-treecol" flex="1" overflow="true"/>
@ -530,50 +533,23 @@
</xul:tree> </xul:tree>
</content> </content>
<implementation> <implementation implements="nsIAutoCompletePopup">
<field name="mShowCommentColumn">false</field> <field name="mInput">null</field>
<field name="mPopupOpen">false</field>
<field name="mShowCommentCol">false</field>
<field name="mShowImageCol">false</field>
<property name="showCommentColumn" <constructor><![CDATA[
onget="return this.mShowCommentColumn;"> this.setAttribute("ignorekeys", "true");
<setter> ]]></constructor>
<![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>
<method name="addColumn"> <!-- =================== nsIAutoCompletePopup =================== -->
<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"> <property name="input"
<parameter name="aColId"/> onget="return this.mInput"/>
<body>
<![CDATA[ <property name="overrideValue" readonly="true"
return this.treecols.removeChild(document.getElementById(aColId)); onget="return null;"/>
]]>
</body>
</method>
<property name="selectedIndex" <property name="selectedIndex"
onget="return this.tree.currentIndex;"> onget="return this.tree.currentIndex;">
@ -590,32 +566,8 @@
]]></setter> ]]></setter>
</property> </property>
<method name="adjustHeight"> <property name="popupOpen" readonly="true"
<body> onget="return this.mPopupOpen;"/>
<![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="openAutocompletePopup"> <method name="openAutocompletePopup">
<parameter name="aInput"/> <parameter name="aInput"/>
@ -627,6 +579,7 @@
this.invalidate(); this.invalidate();
this.showCommentColumn = this.mInput.showCommentColumn; this.showCommentColumn = this.mInput.showCommentColumn;
this.showImageColumn = this.mInput.showImageColumn;
document.popupNode = null; document.popupNode = null;
@ -640,6 +593,17 @@
]]></body> ]]></body>
</method> </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"> <method name="invalidate">
<body><![CDATA[ <body><![CDATA[
this.adjustHeight(); this.adjustHeight();
@ -686,37 +650,6 @@
]]></setter> ]]></setter>
</property> </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 <!-- This is the default number of rows that we give the autocomplete
popup when the textbox doesn't have a "maxrows" attribute popup when the textbox doesn't have a "maxrows" attribute
for us to use. --> for us to use. -->
@ -734,13 +667,89 @@
<field name="_normalMaxRows">-1</field> <field name="_normalMaxRows">-1</field>
<property name="maxRows" readonly="true"> <property name="maxRows" readonly="true">
<getter> <getter><![CDATA[
<![CDATA[
return (this.mInput && this.mInput.maxRows) || this.defaultMaxRows; return (this.mInput && this.mInput.maxRows) || this.defaultMaxRows;
]]> ]]></getter>
</getter>
</property> </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"> <method name="getNextIndex">
<parameter name="aReverse"/> <parameter name="aReverse"/>
<parameter name="aAmount"/> <parameter name="aAmount"/>
@ -772,6 +781,7 @@
controller.handleEnter(); controller.handleEnter();
]]></body> ]]></body>
</method> </method>
</implementation> </implementation>
<handlers> <handlers>
@ -799,401 +809,6 @@
</handlers> </handlers>
</binding> </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"> <binding id="autocomplete-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<content> <content>
<children includes="treecols"/> <children includes="treecols"/>
@ -1203,51 +818,9 @@
</content> </content>
</binding> </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"> <binding id="autocomplete-treebody">
<implementation> <implementation>
<field name="mLastMoveTime">Date.now()</field> <field name="mLastMoveTime">new Date()</field>
</implementation> </implementation>
<handlers> <handlers>
@ -1260,11 +833,11 @@
]]></handler> ]]></handler>
<handler event="mousemove"><![CDATA[ <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); var rc = this.parentNode.treeBoxObject.getRowAt(event.clientX, event.clientY);
if (rc != this.parentNode.currentIndex) if (rc != this.parentNode.currentIndex)
this.parentNode.view.selection.select(rc); this.parentNode.view.selection.select(rc);
this.mLastMoveTime = Date.now(); this.mLastMoveTime = new Date();
} }
]]></handler> ]]></handler>
</handlers> </handlers>

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

@ -746,10 +746,6 @@ panel[type="autocomplete"] {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-result-popup"); -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 { .autocomplete-tree {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#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"); -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 { .autocomplete-treerows {
-moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-treerows"); -moz-binding: url("chrome://global/content/bindings/autocomplete.xml#autocomplete-treerows");
} }

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

@ -75,7 +75,6 @@ textbox.padded {
/* ::::: autocomplete popups ::::: */ /* ::::: autocomplete popups ::::: */
panel[type="autocomplete"], panel[type="autocomplete"],
panel[type="autocomplete-richlistbox"],
.autocomplete-history-popup { .autocomplete-history-popup {
padding: 0px !important; padding: 0px !important;
background-color: -moz-Field !important; background-color: -moz-Field !important;
@ -118,68 +117,6 @@ treechildren.autocomplete-treebody::-moz-tree-cell-text(selected) {
color: HighlightText !important; 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 ::::: */ /* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input { toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input {

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

@ -168,7 +168,6 @@ textbox[chromedir="rtl"] .autocomplete-history-dropmarker {
/* ::::: autocomplete popups ::::: */ /* ::::: autocomplete popups ::::: */
panel[type="autocomplete"], panel[type="autocomplete"],
panel[type="autocomplete-richlistbox"],
.autocomplete-history-popup { .autocomplete-history-popup {
-moz-appearance: none; -moz-appearance: none;
border-width: 1px; border-width: 1px;
@ -211,68 +210,6 @@ treechildren.autocomplete-treebody::-moz-tree-cell-text(selected) {
color: HighlightText !important; 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 ::::: */ /* ::::: textboxes inside toolbarpaletteitems ::::: */
toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input { toolbarpaletteitem > toolbaritem > textbox > hbox > hbox > html|*.textbox-input {