Bug 876277 - Clicking on global search results lines (not matches) was broken after 877686, fix it, r=past

This commit is contained in:
Victor Porof 2013-09-13 16:23:15 +03:00
parent a1d3fc95ba
commit 82bd81a21a
2 changed files with 14 additions and 6 deletions

View File

@ -2131,7 +2131,7 @@ LineResults.prototype.__iterator__ = function() {
*/
SourceResults.getItemForElement =
LineResults.getItemForElement = function(aElement) {
return WidgetMethods.getItemForElement.call(this, aElement);
return WidgetMethods.getItemForElement.call(this, aElement, { noSiblings: true });
};
/**

View File

@ -1237,15 +1237,23 @@ this.WidgetMethods = {
*
* @param nsIDOMNode aElement
* The element used to identify the item.
* @param object aFlags [optional]
* Additional options for showing the source. Supported options:
* - noSiblings: if siblings shouldn't be taken into consideration
* when searching for the associated item.
* @return Item
* The matched item, or null if nothing is found.
*/
getItemForElement: function(aElement) {
getItemForElement: function(aElement, aFlags = {}) {
while (aElement) {
let item =
this._itemsByElement.get(aElement) ||
this._itemsByElement.get(aElement.nextElementSibling) ||
this._itemsByElement.get(aElement.previousElementSibling);
let item = this._itemsByElement.get(aElement);
// Also search the siblings if allowed.
if (!aFlags.noSiblings) {
item = item ||
this._itemsByElement.get(aElement.nextElementSibling) ||
this._itemsByElement.get(aElement.previousElementSibling);
}
if (item) {
return item;
}