Bug 907001 - Location bar is slow with long text runs.r=adw

MozReview-Commit-ID: KIfaGfsm26x

--HG--
extra : rebase_source : e38e49e5dc9ef6e5535d515be8354752599c6654
This commit is contained in:
Marco Bonardo 2016-04-28 13:59:24 +02:00
Родитель 5e1c917f09
Коммит f68466d5da
3 изменённых файлов: 41 добавлений и 10 удалений

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

@ -133,6 +133,12 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
<field name="gotResultForCurrentQuery">false</field>
<field name="handleEnterWhenGotResult">false</field>
<!--
For performance reasons we want to limit the size of the text runs we
build and show to the user.
-->
<field name="textRunsMaxLen">255</field>
<!--
onBeforeValueGet is called by the base-binding's .value getter.
It can return an object with a "value" property, to override the

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

@ -18,6 +18,10 @@
#include "mozilla/Likely.h"
#include "nsVariant.h"
// Maximum number of chars to search through.
// MatchAutoCompleteFunction won't look for matches over this threshold.
#define MAX_CHARS_TO_SEARCH_THROUGH 255
using namespace mozilla::storage;
// Keep the GUID-related parts of this file in sync with toolkit/downloads/SQLFunctions.cpp!
@ -388,11 +392,17 @@ namespace places {
searchFunctionPtr searchFunction = getSearchFunction(matchBehavior);
// Clean up our URI spec and prepare it for searching.
nsCString fixedURI;
fixupURISpec(url, matchBehavior, fixedURI);
nsCString fixedUrl;
fixupURISpec(url, matchBehavior, fixedUrl);
// Limit the number of chars we search through.
const nsDependentCSubstring& trimmedUrl =
Substring(fixedUrl, 0, MAX_CHARS_TO_SEARCH_THROUGH);
nsAutoCString title;
(void)aArguments->GetUTF8String(kArgIndexTitle, title);
// Limit the number of chars we search through.
const nsDependentCSubstring& trimmedTitle =
Substring(title, 0, MAX_CHARS_TO_SEARCH_THROUGH);
// Determine if every token matches either the bookmark title, tags, page
// title, or page URL.
@ -401,19 +411,21 @@ namespace places {
const nsDependentCSubstring &token = tokenizer.nextToken();
if (HAS_BEHAVIOR(TITLE) && HAS_BEHAVIOR(URL)) {
matches = (searchFunction(token, title) || searchFunction(token, tags)) &&
searchFunction(token, fixedURI);
matches = (searchFunction(token, trimmedTitle) ||
searchFunction(token, tags)) &&
searchFunction(token, trimmedUrl);
}
else if (HAS_BEHAVIOR(TITLE)) {
matches = searchFunction(token, title) || searchFunction(token, tags);
matches = searchFunction(token, trimmedTitle) ||
searchFunction(token, tags);
}
else if (HAS_BEHAVIOR(URL)) {
matches = searchFunction(token, fixedURI);
matches = searchFunction(token, trimmedUrl);
}
else {
matches = searchFunction(token, title) ||
matches = searchFunction(token, trimmedTitle) ||
searchFunction(token, tags) ||
searchFunction(token, fixedURI);
searchFunction(token, trimmedUrl);
}
}

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

@ -1834,7 +1834,8 @@ extends="chrome://global/content/bindings/popup.xml#popup">
<method name="_adjustAcItem">
<body>
<![CDATA[
if (!this.parentNode.parentNode.popupOpen) {
let popup = this.parentNode.parentNode;
if (!popup.popupOpen) {
// Removing the max-width and resetting it later when overflow is
// handled is jarring when the item is visible, so skip this when
// the popup is open.
@ -1946,12 +1947,16 @@ extends="chrome://global/content/bindings/popup.xml#popup">
}
if (!displayUrl) {
let input = this.parentNode.parentNode.input;
let input = popup.input;
let url = typeof(input.trimValue) == "function" ?
input.trimValue(originalUrl) :
originalUrl;
displayUrl = this._unescapeUrl(url);
}
// For performance reasons we may want to limit the displayUrl size.
if (popup.textRunsMaxLen) {
displayUrl = displayUrl.substr(0, popup.textRunsMaxLen);
}
this.setAttribute("displayurl", displayUrl);
// Show the domain as the title if we don't have a title.
@ -2009,8 +2014,16 @@ extends="chrome://global/content/bindings/popup.xml#popup">
this.setAttribute("type", type);
if (Array.isArray(title)) {
// For performance reasons we may want to limit the title size.
if (popup.textRunsMaxLen) {
title = title.map(t => t.substr(0, popup.textRunsMaxLen));
}
this._setUpEmphasisedSections(this._titleText, title);
} else {
// For performance reasons we may want to limit the title size.
if (popup.textRunsMaxLen) {
title = title.substr(0, popup.textRunsMaxLen);
}
this._setUpDescription(this._titleText, title, false);
}
this._setUpDescription(this._urlText, displayUrl, !emphasiseUrl);