Bug 1550559 - Convert findbar XUL textbox to HTML input. r=bgrins

Differential Revision: https://phabricator.services.mozilla.com/D30542

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tim Nguyen 2019-05-20 21:54:15 +00:00
Родитель 37d54b0154
Коммит cce8333093
13 изменённых файлов: 57 добавлений и 52 удалений

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

@ -13,7 +13,7 @@
<script type="application/javascript"><![CDATA[
// Global variable that holds a reference to the find bar.
var gFindBar;
// Define the generator-iterator for the tests.
var tests = testIterator();
@ -25,7 +25,7 @@
}
////
// Generator function for test steps for bug 298622:
// Generator function for test steps for bug 298622:
// Find should work correctly on a page loaded from the
// bfcache.
//
@ -33,7 +33,7 @@
{
// Make sure bfcache is on.
enableBFCache(true);
// Load a test page which contains some text to be found.
doPageNavigation({
uri: "data:text/html,<html><head><title>test1</title></head>" +
@ -79,12 +79,12 @@
// before continuing
waitForTrue(function() {
return (
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
"a generic page");
}, nextTest, 20);
yield undefined;
is(gFindBar._findField.inputField.value, "A generic page",
is(gFindBar._findField.value, "A generic page",
"expected text not present in find input field");
is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
"a generic page",
@ -103,7 +103,7 @@
yield undefined;
// Search for some text that's on the original page (but not
// the dummy page loaded above), and verify that it can
// the dummy page loaded above), and verify that it can
// be found.
gFindBar = document.getElementById("FindToolbar");
document.getElementById("cmd_find").doCommand();
@ -117,12 +117,12 @@
isnot(gFindBar._findField.getAttribute("status"), "notfound",
"Findfield status attribute should not have been 'notfound'" +
" after Find");
// Make sure the key events above have time to be processed
// before continuing
waitForTrue(function() {
return (
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
TestWindow.getWindow().getSelection().toString().toLowerCase() ==
"find this");
}, nextTest, 20);
yield undefined;
@ -130,11 +130,11 @@
is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
"find this",
"find failed on page loaded from bfcache");
// Tell the framework the test is finished.
finish();
}
]]></script>
<commandset>

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

@ -40,7 +40,7 @@ add_task(async function() {
findBar._findField.value = "xy";
findBar.startFind();
is(findBar._findField.value, "xy", "findbar should have xy initial query");
is(findBar._findField.mInputField,
is(findBar._findField,
document.activeElement,
"findbar is now focused");
@ -55,7 +55,7 @@ add_task(async function() {
findBar.startFind();
ok(findBar._startFindDeferred, "prefilled value hasn't been fetched yet");
is(findBar._findField.mInputField,
is(findBar._findField,
document.activeElement,
"findbar is still focused");

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

@ -185,7 +185,7 @@ add_task(async function e10sLostKeys() {
// We can't afford to wait for the promise to resolve, by then the
// find bar is visible and focused, so sending characters to the
// content browser wouldn't work.
isnot(document.activeElement, findBar._findField.inputField,
isnot(document.activeElement, findBar._findField,
"findbar is not yet focused");
EventUtils.synthesizeKey("a");
EventUtils.synthesizeKey("b");
@ -194,7 +194,7 @@ add_task(async function e10sLostKeys() {
});
await BrowserTestUtils.waitForCondition(() => findBar._findField.value.length == 3);
is(document.activeElement, findBar._findField.inputField,
is(document.activeElement, findBar._findField,
"findbar is now focused");
is(findBar._findField.value, "abc", "abc fully entered as find query");

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

@ -85,7 +85,7 @@
charCode: code,
bubbles: true
});
gFindBar._findField.inputField.dispatchEvent(ev);
gFindBar._findField.dispatchEvent(ev);
}
});
}

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

@ -65,7 +65,7 @@
var searchStr = "text inside an input element";
await promiseEnterStringIntoFindField(searchStr);
is(document.commandDispatcher.focusedElement,
gFindBar._findField.inputField, "Find field isn't focused");
gFindBar._findField, "Find field isn't focused");
// Make sure "find again" correctly transfers focus to the content element
// when the find bar is closed.
@ -107,7 +107,7 @@
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
}
return promise;
}

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

@ -42,7 +42,7 @@
var event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, aString.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
}
}
@ -68,9 +68,9 @@
var event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, KeyEvent.DOM_VK_BACK_SPACE, 0);
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
var notRed = !findField.hasAttribute("status") ||
var notRed = !findField.hasAttribute("status") ||
(findField.getAttribute("status") != "notfound");
ok(notRed, "Find Bar textbox is correct colour");
finish();

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

@ -152,7 +152,7 @@
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
if (waitForResult) {
await promise;
}
@ -250,7 +250,7 @@
});
ok(!gFindBar.hidden, "testQuickfind: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testQuickfind: find field is not focused");
ok(!gFindBar.getElement("entire-word-status").hidden,
"testQuickfind: entire word mode status text should be visible");

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

@ -106,7 +106,7 @@
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, query.charCodeAt(0));
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
let e = await promise;
ok(e.detail.query === query, "find event query should match '" + query + "'");

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

@ -152,7 +152,7 @@
async function testFindbarSelection() {
function checkFindbarState(aTestName, aExpSelection) {
ok(!gFindBar.hidden, "testFindbarSelection: failed to open findbar: " + aTestName);
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testFindbarSelection: find field is not focused: " + aTestName);
if (!gHasFindClipboard) {
ok(gFindBar._findField.value == aExpSelection,
@ -201,7 +201,7 @@
// use an dummy image to start the drag so it doesn't get interrupted by a selection
var img = gBrowser.contentDocument.getElementById("img");
synthesizeDrop(img, gFindBar._findField, [[ {type: "text/plain", data: "Rabbits" } ]], "copy", window);
is(gFindBar._findField.inputField.value, "Rabbits", "drop on findbar");
is(gFindBar._findField.value, "Rabbits", "drop on findbar");
gFindBar.close();
}
@ -273,7 +273,7 @@
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
gFindBar._findField.inputField.dispatchEvent(event);
gFindBar._findField.dispatchEvent(event);
if (waitForResult) {
await promise;
}
@ -296,7 +296,7 @@
document.getElementById("cmd_find").doCommand();
ok(!gFindBar.hidden, "testNormalFind: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testNormalFind: find field is not focused");
let promise;
@ -340,7 +340,7 @@
async function testNormalFindWithComposition() {
ok(!gFindBar.hidden, "testNormalFindWithComposition: findbar should be open");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testNormalFindWithComposition: find field should be focused");
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
@ -350,7 +350,7 @@
clicked = true;
}
gFindBar._findField.inputField.focus();
gFindBar._findField.focus();
var searchStr = "text";
@ -433,7 +433,7 @@
});
ok(!gFindBar.hidden, "testQuickFindLink: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testQuickFindLink: find field is not focused");
var searchStr = "Link Test";
@ -552,7 +552,7 @@
});
ok(!gFindBar.hidden, "testQuickFindText: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testQuickFindText: find field is not focused");
await enterStringIntoFindField(SEARCH_TEXT);
@ -579,7 +579,7 @@
}
ok(!gFindBar.hidden, "testFindCountUI: failed to open findbar");
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
ok(document.commandDispatcher.focusedElement == gFindBar._findField,
"testFindCountUI: find field is not focused");
let promise;

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

@ -29,7 +29,7 @@ class MozFindbar extends XULElement {
this.content = MozXULElement.parseXULToFragment(`
<hbox anonid="findbar-container" class="findbar-container" flex="1" align="center">
<hbox anonid="findbar-textbox-wrapper" align="stretch">
<textbox anonid="findbar-textbox" class="findbar-textbox findbar-find-fast" />
<html:input anonid="findbar-textbox" class="findbar-textbox findbar-find-fast" />
<toolbarbutton anonid="find-previous" class="findbar-find-previous tabbable" data-l10n-attrs="tooltiptext" data-l10n-id="findbar-previous" oncommand="onFindAgainCommand(true);" disabled="true" />
<toolbarbutton anonid="find-next" class="findbar-find-next tabbable" data-l10n-id="findbar-next" oncommand="onFindAgainCommand(false);" disabled="true" />
</hbox>
@ -683,7 +683,11 @@ class MozFindbar extends XULElement {
clear() {
this.browser.finder.removeSelection();
this._findField.reset();
// Clear value and undo/redo transactions
this._findField.value = "";
if (this._findField.editor) {
this._findField.editor.transactionManager.clear();
}
this.toggleHighlight(false);
this._updateStatusUI();
this._enableFindButtons(false);
@ -749,15 +753,15 @@ class MozFindbar extends XULElement {
const FAYT_LINKS_KEY = "'";
const FAYT_TEXT_KEY = "/";
if (!this.hidden && this._findField.inputField == document.activeElement) {
this._dispatchKeypressEvent(this._findField.inputField, aFakeEvent);
if (!this.hidden && this._findField == document.activeElement) {
this._dispatchKeypressEvent(this._findField, aFakeEvent);
return;
}
if (this._findMode != this.FIND_NORMAL && this._quickFindTimeout) {
this._findField.select();
this._findField.focus();
this._dispatchKeypressEvent(this._findField.inputField, aFakeEvent);
this._dispatchKeypressEvent(this._findField, aFakeEvent);
return;
}
@ -781,7 +785,7 @@ class MozFindbar extends XULElement {
this._findField.focus();
if (autostartFAYT)
this._dispatchKeypressEvent(this._findField.inputField, aFakeEvent);
this._dispatchKeypressEvent(this._findField, aFakeEvent);
else
this._updateStatusUI(this.nsITypeAheadFind.FIND_FOUND);
}
@ -810,7 +814,7 @@ class MozFindbar extends XULElement {
if (this._browser && this._browser.messageManager) {
this._browser.messageManager.sendAsyncMessage("Findbar:UpdateState", {
findMode: this._findMode,
isOpenAndFocused: !this.hidden && document.activeElement == this._findField.inputField,
isOpenAndFocused: !this.hidden && document.activeElement == this._findField,
hasQuickFindTimeout: !!this._quickFindTimeout,
});
}
@ -1195,8 +1199,8 @@ class MozFindbar extends XULElement {
if (!focusedElement)
return false;
let bindingParent = document.getBindingParent(focusedElement);
if (bindingParent != this && bindingParent != this._findField)
let focusedParent = focusedElement.closest("findbar");
if (focusedParent != this && focusedParent != this._findField)
return false;
return true;

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

@ -65,7 +65,7 @@ function promiseEnterStringIntoFindField(findbar, str) {
let event = document.createEvent("KeyboardEvent");
event.initKeyEvent("keypress", true, true, null, false, false,
false, false, 0, str.charCodeAt(i));
findbar._findField.inputField.dispatchEvent(event);
findbar._findField.dispatchEvent(event);
}
return promise;
}

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

@ -65,13 +65,13 @@ label.findbar-find-fast:-moz-lwtheme {
}
@media (-moz-mac-yosemite-theme: 0) {
.findbar-textbox,
html|input.findbar-textbox,
.findbar-find-next {
border-radius: 10000px;
}
}
.findbar-textbox {
html|input.findbar-textbox {
border: @roundButtonBorderWidth@ @roundButtonBorderStyle@ var(--lwt-toolbar-field-border-color, @roundButtonBorderColor@);
-moz-context-properties: fill, fill-opacity;
fill: currentColor;
@ -83,11 +83,11 @@ label.findbar-find-fast:-moz-lwtheme {
padding-inline-start: 19px;
}
.findbar-textbox[focused="true"] {
html|input.findbar-textbox:focus {
box-shadow: 0 0 0 1px var(--toolbar-field-focus-border-color) inset,
0 0 0 1px var(--toolbar-field-focus-border-color);
}
.findbar-textbox:-moz-locale-dir(rtl) {
html|input.findbar-textbox:-moz-locale-dir(rtl) {
background-position-x: right 5px;
}

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

@ -3,6 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");
@namespace html url("http://www.w3.org/1999/xhtml");
findbar {
border-top: 1px solid ThreeDShadow;
@ -48,7 +49,7 @@ contrast issues, see bug 1506913 */
--lwt-toolbar-field-focus-color: initial;
}
.findbar-textbox {
html|input.findbar-textbox {
-moz-appearance: none;
background-color: -moz-Field;
border: 1px solid var(--lwt-toolbar-field-border-color, ThreeDShadow);
@ -59,28 +60,28 @@ contrast issues, see bug 1506913 */
width: 14em;
}
.findbar-textbox:-moz-lwtheme {
html|input.findbar-textbox:-moz-lwtheme {
background-color: var(--lwt-toolbar-field-background-color, -moz-Field);
color: var(--lwt-toolbar-field-color, -moz-FieldText);
}
.findbar-textbox[focused="true"] {
html|input.findbar-textbox:focus {
background-color: var(--lwt-toolbar-field-focus, var(--lwt-toolbar-field-background-color, -moz-Field));
color: var(--lwt-toolbar-field-focus-color, var(--lwt-toolbar-field-color, -moz-FieldText));
border-color: var(--toolbar-field-focus-border-color, Highlight);
}
.findbar-textbox[status="notfound"] {
html|input.findbar-textbox[status="notfound"] {
background-color: rgba(255,0,57,.3);
color: inherit;
}
.findbar-textbox[flash="true"] {
html|input.findbar-textbox[flash="true"] {
background-color: rgba(255,233,0,.3);
color: inherit;
}
.findbar-textbox.minimal {
html|input.findbar-textbox.minimal {
border-radius: 2px;
}