Bug 1411707 - hg copy findbar XBL to findbar.js;
This'll make blame easier to follow when reviewing the next changeset
MozReview-Commit-ID: 5BYvzivlH9I
copy from toolkit/content/widgets/findbar.xml
copy to toolkit/content/widgets/findbar.js
--- a/toolkit/content/widgets/findbar.xml
+++ b/toolkit/content/widgets/findbar.js
@@ -1,164 +1,8 @@
-<?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/. -->
-
-<!DOCTYPE bindings [
-<!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findbar.dtd" >
-%findBarDTD;
-]>
-
-<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 = document.getBindingParent(this);
- </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>
<binding id="findbar">
<resources>
<stylesheet src="chrome://global/skin/findBar.css"/>
</resources>
<content hidden="true">
<xul:hbox anonid="findbar-container" class="findbar-container" flex="1" align="center">