Bug 1365105 - Clear all find highlights, in the PDF Viewer, when the findbar is closed. r=bdahl,paolo

In order to support this, a new "findbarclose" event (mirroring the pre-existing "findbaropen" one) was added to the `MozFindbar.close` method in the findbar.js file.
This commit is contained in:
Jonas Jenwald 2018-10-25 15:52:02 +02:00
Родитель 14f53f5a65
Коммит 2265e713ff
3 изменённых файлов: 27 добавлений и 14 удалений

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

@ -27,7 +27,10 @@ add_task(async function findbar_test() {
ok(!gFindBar.hidden, "the Find bar isn't hidden after the location of a " +
"subdocument changes");
let findBarClosePromise = promiseWaitForEvent(gBrowser, "findbarclose");
gFindBar.close();
await findBarClosePromise;
gBrowser.removeTab(newTab);
});

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

@ -192,24 +192,27 @@ var PdfjsChromeUtils = {
},
handleEvent(aEvent) {
const type = aEvent.type;
// Handle the tab find initialized event specially:
if (aEvent.type == "TabFindInitialized") {
if (type == "TabFindInitialized") {
let browser = aEvent.target.linkedBrowser;
this._hookupEventListeners(browser);
aEvent.target.removeEventListener(aEvent.type, this);
aEvent.target.removeEventListener(type, this);
return;
}
// To avoid forwarding the message as a CPOW, create a structured cloneable
// version of the event for both performance, and ease of usage, reasons.
let type = aEvent.type;
let detail = {
query: aEvent.detail.query,
caseSensitive: aEvent.detail.caseSensitive,
entireWord: aEvent.detail.entireWord,
highlightAll: aEvent.detail.highlightAll,
findPrevious: aEvent.detail.findPrevious,
};
let detail = null;
if (type !== "findbarclose") {
detail = {
query: aEvent.detail.query,
caseSensitive: aEvent.detail.caseSensitive,
entireWord: aEvent.detail.entireWord,
highlightAll: aEvent.detail.highlightAll,
findPrevious: aEvent.detail.findPrevious,
};
}
let browser = aEvent.currentTarget.browser;
if (!this._browsers.has(browser)) {
@ -222,10 +225,13 @@ var PdfjsChromeUtils = {
aEvent.preventDefault();
},
_types: ["find",
"findagain",
"findhighlightallchange",
"findcasesensitivitychange"],
_types: [
"find",
"findagain",
"findhighlightallchange",
"findcasesensitivitychange",
"findbarclose",
],
_addEventListener(aMsg) {
let browser = aMsg.target;

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

@ -668,6 +668,10 @@ class MozFindbar extends XULElement {
this.setAttribute("noanim", true);
this.hidden = true;
let event = document.createEvent("Events");
event.initEvent("findbarclose", true, false);
this.dispatchEvent(event);
// 'focusContent()' iterates over all listeners in the chrome
// process, so we need to call it from here.
this.browser.finder.focusContent();