Bug 1467537 - The delete trigger on moz_updateoriginsinsert_temp is recalculating the whole table every time. r=adw

The trigger is missing a WHERE clause, and as such it ends up doing a lot more work than necessary.

The nsAutoCompleteController changes cover a bug where VK_RIGHT autofills when it's not necessary,
and by doing that it will move the caret to an unexpected position (far right) even if it didn't
actually complete some preselected text.

MozReview-Commit-ID: 1mVbxCdqVSr

--HG--
extra : rebase_source : 9a7e13cc62dfe0ae95210e7a75068d07a0b7c275
This commit is contained in:
Marco Bonardo 2018-06-08 11:31:13 +02:00
Родитель 8235ee12de
Коммит 944f20e73f
3 изменённых файлов: 24 добавлений и 15 удалений

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

@ -4,6 +4,7 @@
add_task(async function() {
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
await promiseAutocompleteResultPopup("www.mozilla.org");
await waitForAutocompleteResultAt(0);
gURLBar.selectTextRange(4, 4);

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

@ -574,32 +574,30 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool *_retval)
// For completeSelectedIndex autocomplete fields, if the popup shouldn't
// close when the caret is moved, don't adjust the text value or caret
// position.
bool completeSelection;
input->GetCompleteSelectedIndex(&completeSelection);
if (isOpen) {
bool noRollup;
input->GetNoRollupOnCaretMove(&noRollup);
if (noRollup) {
bool completeSelection;
input->GetCompleteSelectedIndex(&completeSelection);
if (completeSelection) {
return NS_OK;
}
}
}
int32_t selectionEnd;
input->GetSelectionEnd(&selectionEnd);
int32_t selectionStart;
input->GetSelectionStart(&selectionStart);
bool shouldCompleteSelection =
(uint32_t)selectionEnd == mPlaceholderCompletionString.Length() &&
selectionStart < selectionEnd;
int32_t selectedIndex;
popup->GetSelectedIndex(&selectedIndex);
bool shouldComplete;
input->GetCompleteDefaultIndex(&shouldComplete);
if (selectedIndex >= 0) {
// The pop-up is open and has a selection, take its value
nsAutoString value;
if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, false, value))) {
SetValueOfInputTo(
value, nsIAutoCompleteInput::TEXTVALUE_REASON_COMPLETESELECTED);
input->SelectTextRange(value.Length(), value.Length());
}
}
else if (shouldComplete) {
bool completeDefaultIndex;
input->GetCompleteDefaultIndex(&completeDefaultIndex);
if (completeDefaultIndex && shouldCompleteSelection) {
// We usually try to preserve the casing of what user has typed, but
// if he wants to autocomplete, we will replace the value with the
// actual autocomplete result. Note that the autocomplete input can also
@ -625,6 +623,15 @@ nsAutoCompleteController::HandleKeyNavigation(uint32_t aKey, bool *_retval)
input->SelectTextRange(value.Length(), value.Length());
}
}
} else if (!completeDefaultIndex && !completeSelection &&
selectedIndex >= 0) {
// The pop-up is open and has a selection, take its value
nsAutoString value;
if (NS_SUCCEEDED(GetResultValueAt(selectedIndex, false, value))) {
SetValueOfInputTo(
value, nsIAutoCompleteInput::TEXTVALUE_REASON_COMPLETESELECTED);
input->SelectTextRange(value.Length(), value.Length());
}
}
// Close the pop-up even if nothing was selected

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

@ -144,7 +144,8 @@
"SELECT IFNULL(MAX(frecency), 0) " \
"FROM moz_places " \
"WHERE moz_places.origin_id = moz_origins.id " \
"); " \
") " \
"WHERE prefix = OLD.prefix AND host = OLD.host; " \
"END" \
)