Bug 1411707 - Fold the findbar-textbox XBL binding into findbar;
MozReview-Commit-ID: 9BgKABCy7h3
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -70,17 +70,16 @@ toolkit.jar:
content/global/bindings/colorpicker.xml (widgets/colorpicker.xml)
content/global/bindings/datekeeper.js (widgets/datekeeper.js)
content/global/bindings/datepicker.js (widgets/datepicker.js)
content/global/bindings/datetimepopup.xml (widgets/datetimepopup.xml)
content/global/bindings/datetimebox.xml (widgets/datetimebox.xml)
content/global/bindings/datetimebox.css (widgets/datetimebox.css)
* content/global/bindings/dialog.xml (widgets/dialog.xml)
content/global/bindings/editor.xml (widgets/editor.xml)
- content/global/bindings/findbar.xml (widgets/findbar.xml)
content/global/bindings/general.xml (widgets/general.xml)
content/global/bindings/groupbox.xml (widgets/groupbox.xml)
content/global/bindings/listbox.xml (widgets/listbox.xml)
content/global/bindings/menu.xml (widgets/menu.xml)
content/global/bindings/menulist.xml (widgets/menulist.xml)
content/global/bindings/notification.xml (widgets/notification.xml)
content/global/bindings/numberbox.xml (widgets/numberbox.xml)
content/global/bindings/popup.xml (widgets/popup.xml)
--- a/toolkit/content/widgets/findbar.js
+++ b/toolkit/content/widgets/findbar.js
@@ -162,16 +162,122 @@ class MozFindbar extends XULElement {
if (this.close)
this.close();
event.preventDefault();
}
}, true);
this.destroy = this.destroy.bind(this);
window.addEventListener("unload", this.destroy);
+
+ this._findField.addEventListener("input", (event) => {
+ // We should do nothing during composition. E.g., composing string
+ // before converting may matches a forward word of expected word.
+ // After that, even if user converts the composition string to the
+ // expected word, it may find second or later searching word in the
+ // document.
+ if (this._isIMEComposing) {
+ return;
+ }
+
+ const value = this._findField.value;
+ if (this._hadValue && !value) {
+ this._willfullyDeleted = true;
+ this._hadValue = false;
+ } else if (value.trim()) {
+ this._hadValue = true;
+ this._willfullyDeleted = false;
+ }
+ this._find(value);
+ });
+
+ this._findField.addEventListener("keypress", (event) => {
+ switch (event.keyCode) {
+ case KeyEvent.DOM_VK_RETURN:
+ if (this._findMode == this.FIND_NORMAL) {
+ let findString = this._findField;
+ if (!findString.value)
+ return;
+ if (event.getModifierState("Accel")) {
+ this.getElement("highlight").click();
+ return;
+ }
+
+ this.onFindAgainCommand(event.shiftKey);
+ } else {
+ this._finishFAYT(event);
+ }
+ break;
+ case KeyEvent.DOM_VK_TAB:
+ let shouldHandle = !event.altKey && !event.ctrlKey &&
+ !event.metaKey;
+ if (shouldHandle &&
+ this._findMode != this.FIND_NORMAL) {
+
+ this._finishFAYT(event);
+ }
+ break;
+ case KeyEvent.DOM_VK_PAGE_UP:
+ case KeyEvent.DOM_VK_PAGE_DOWN:
+ if (!event.altKey && !event.ctrlKey &&
+ !event.metaKey && !event.shiftKey) {
+ this.browser.finder.keyPress(event);
+ event.preventDefault();
+ }
+ break;
+ case KeyEvent.DOM_VK_UP:
+ case KeyEvent.DOM_VK_DOWN:
+ this.browser.finder.keyPress(event);
+ event.preventDefault();
+ break;
+ }
+ });
+
+ this._findField.addEventListener("blur", (event) => {
+ // Note: This code used to remove the selection
+ // if it matched an editable.
+ this.browser.finder.enableSelection();
+ });
+
+ this._findField.addEventListener("focus", (event) => {
+ if (/Mac/.test(navigator.platform)) {
+ this._onFindFieldFocus();
+ }
+ this._updateBrowserWithState();
+ });
+
+ this._findField.addEventListener("compositionstart", (event) => {
+ // Don't close the find toolbar while IME is composing.
+ let findbar = this;
+ findbar._isIMEComposing = true;
+ if (findbar._quickFindTimeout) {
+ clearTimeout(findbar._quickFindTimeout);
+ findbar._quickFindTimeout = null;
+ findbar._updateBrowserWithState();
+ }
+ });
+
+ this._findField.addEventListener("compositionend", (event) => {
+ this._isIMEComposing = false;
+ if (this._findMode != this.FIND_NORMAL)
+ this._setFindCloseTimeout();
+ });
+
+ this._findField.addEventListener("dragover", (event) => {
+ if (event.dataTransfer.types.includes("text/plain"))
+ event.preventDefault();
+ });
+
+ this._findField.addEventListener("drop", (event) => {
+ let value = event.dataTransfer.getData("text/plain");
+ this._findField.value = value;
+ this._find(value);
+ event.stopPropagation();
+ event.preventDefault();
+ });
}
set _findMode(val) {
this.__findMode = val;
this._updateBrowserWithState();
return val;
}
deleted file mode 100644
--- a/toolkit/content/widgets/findbar.xml
+++ /dev/null
@@ -1,152 +0,0 @@
-<?xml version="1.0"?>
-
-<!-- This Source Code Form is subject to the terms of the Mozilla Public
- - License, v. 2.0. If a copy of the MPL was not distributed with this
- - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
-
-<bindings id="findbarBindings"
- xmlns="http://www.mozilla.org/xbl"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
- xmlns:xbl="http://www.mozilla.org/xbl">
-
- <!-- Private binding -->
- <binding id="findbar-textbox"
- extends="chrome://global/content/bindings/textbox.xml#textbox">
- <implementation>
-
- <field name="_findbar">null</field>
- <property name="findbar" readonly="true">
- <getter>
- return this._findbar ?
- this._findbar : this._findbar = this.closest("findbar");
- </getter>
- </property>
-
- <method name="_handleEnter">
- <parameter name="aEvent"/>
- <body><![CDATA[
- if (this.findbar._findMode == this.findbar.FIND_NORMAL) {
- let findString = this.findbar._findField;
- if (!findString.value)
- return;
- if (aEvent.getModifierState("Accel")) {
- this.findbar.getElement("highlight").click();
- return;
- }
-
- this.findbar.onFindAgainCommand(aEvent.shiftKey);
- } else {
- this.findbar._finishFAYT(aEvent);
- }
- ]]></body>
- </method>
-
- <method name="_handleTab">
- <parameter name="aEvent"/>
- <body><![CDATA[
- let shouldHandle = !aEvent.altKey && !aEvent.ctrlKey &&
- !aEvent.metaKey;
- if (shouldHandle &&
- this.findbar._findMode != this.findbar.FIND_NORMAL) {
-
- this.findbar._finishFAYT(aEvent);
- }
- ]]></body>
- </method>
- </implementation>
-
- <handlers>
- <handler event="input"><![CDATA[
- // We should do nothing during composition. E.g., composing string
- // before converting may matches a forward word of expected word.
- // After that, even if user converts the composition string to the
- // expected word, it may find second or later searching word in the
- // document.
- if (this.findbar._isIMEComposing) {
- return;
- }
-
- if (this._hadValue && !this.value) {
- this._willfullyDeleted = true;
- this._hadValue = false;
- } else if (this.value.trim()) {
- this._hadValue = true;
- this._willfullyDeleted = false;
- }
- this.findbar._find(this.value);
- ]]></handler>
-
- <handler event="keypress"><![CDATA[
- let shouldHandle = !event.altKey && !event.ctrlKey &&
- !event.metaKey && !event.shiftKey;
-
- switch (event.keyCode) {
- case KeyEvent.DOM_VK_RETURN:
- this._handleEnter(event);
- break;
- case KeyEvent.DOM_VK_TAB:
- this._handleTab(event);
- break;
- case KeyEvent.DOM_VK_PAGE_UP:
- case KeyEvent.DOM_VK_PAGE_DOWN:
- if (shouldHandle) {
- this.findbar.browser.finder.keyPress(event);
- event.preventDefault();
- }
- break;
- case KeyEvent.DOM_VK_UP:
- case KeyEvent.DOM_VK_DOWN:
- this.findbar.browser.finder.keyPress(event);
- event.preventDefault();
- break;
- }
- ]]></handler>
-
- <handler event="blur"><![CDATA[
- let findbar = this.findbar;
- // Note: This code used to remove the selection
- // if it matched an editable.
- findbar.browser.finder.enableSelection();
- ]]></handler>
-
- <handler event="focus"><![CDATA[
- let findbar = this.findbar;
- if (/Mac/.test(navigator.platform)) {
- findbar._onFindFieldFocus();
- }
- findbar._updateBrowserWithState();
- ]]></handler>
-
- <handler event="compositionstart"><![CDATA[
- // Don't close the find toolbar while IME is composing.
- let findbar = this.findbar;
- findbar._isIMEComposing = true;
- if (findbar._quickFindTimeout) {
- clearTimeout(findbar._quickFindTimeout);
- findbar._quickFindTimeout = null;
- findbar._updateBrowserWithState();
- }
- ]]></handler>
-
- <handler event="compositionend"><![CDATA[
- let findbar = this.findbar;
- findbar._isIMEComposing = false;
- if (findbar._findMode != findbar.FIND_NORMAL)
- findbar._setFindCloseTimeout();
- ]]></handler>
-
- <handler event="dragover"><![CDATA[
- if (event.dataTransfer.types.includes("text/plain"))
- event.preventDefault();
- ]]></handler>
-
- <handler event="drop"><![CDATA[
- let value = event.dataTransfer.getData("text/plain");
- this.value = value;
- this.findbar._find(value);
- event.stopPropagation();
- event.preventDefault();
- ]]></handler>
- </handlers>
- </binding>
-</bindings>
--- a/toolkit/content/xul.css
+++ b/toolkit/content/xul.css
@@ -947,20 +947,16 @@ richlistbox > listheader {
}
/*********** findbar ************/
findbar {
overflow-x: hidden;
}
-.findbar-textbox {
- -moz-binding: url("chrome://global/content/bindings/findbar.xml#findbar-textbox");
-}
-
/*********** tabmodalprompt ************/
tabmodalprompt {
-moz-binding: url("chrome://global/content/tabprompts.xml#tabmodalprompt");
overflow: hidden;
text-shadow: none;
}
.button-highlightable-text:not([highlightable="true"]),