Bug 1472491: Part 5λ - Add Split RemoteFinder into FinderChild and FinderParent actors. r=gijs

MozReview-Commit-ID: JAv8lh2gJoB

--HG--
rename : toolkit/modules/RemoteFinder.jsm => toolkit/actors/FinderChild.jsm
rename : toolkit/modules/RemoteFinder.jsm => toolkit/modules/FinderParent.jsm
extra : rebase_source : 08eaf28894b0cd89f082b4cf14d428fa43668988
This commit is contained in:
Kris Maglione 2018-07-30 12:25:58 -07:00
Родитель 2ab798f156
Коммит be97cc14bc
10 изменённых файлов: 175 добавлений и 165 удалений

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

@ -12,8 +12,6 @@ ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(this, "BrowserUtils",
"resource://gre/modules/BrowserUtils.jsm");
ChromeUtils.defineModuleGetter(this, "RemoteFinder",
"resource://gre/modules/RemoteFinder.jsm");
class FindBarChild extends ActorChild {
constructor(mm) {
@ -73,13 +71,19 @@ class FindBarChild extends ActorChild {
if (event.charCode && BrowserUtils.shouldFastFind(event.target)) {
let key = String.fromCharCode(event.charCode);
if ((key == "/" || key == "'") && RemoteFinder._manualFAYT) {
if ((key == "/" || key == "'") && FindBarChild.manualFAYT) {
return FindBarContent.startQuickFind(event);
}
if (key != " " && RemoteFinder._findAsYouType) {
if (key != " " && FindBarChild.findAsYouType) {
return FindBarContent.startQuickFind(event, true);
}
}
return null;
}
}
XPCOMUtils.defineLazyPreferenceGetter(FindBarChild, "findAsYouType",
"accessibility.typeaheadfind");
XPCOMUtils.defineLazyPreferenceGetter(FindBarChild, "manualFAYT",
"accessibility.typeaheadfind.manual");

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

@ -0,0 +1,137 @@
// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-
// vim: set ts=2 sw=2 sts=2 et tw=80: */
// 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/.
var EXPORTED_SYMBOLS = ["FinderChild"];
ChromeUtils.import("resource://gre/modules/ActorChild.jsm");
ChromeUtils.defineModuleGetter(this, "Finder",
"resource://gre/modules/Finder.jsm");
const MESSAGES = [
"Finder:CaseSensitive",
"Finder:EntireWord",
"Finder:FastFind",
"Finder:FindAgain",
"Finder:SetSearchStringToSelection",
"Finder:GetInitialSelection",
"Finder:Highlight",
"Finder:HighlightAllChange",
"Finder:EnableSelection",
"Finder:RemoveSelection",
"Finder:FocusContent",
"Finder:FindbarClose",
"Finder:FindbarOpen",
"Finder:KeyPress",
"Finder:MatchesCount",
"Finder:ModalHighlightChange"
];
class FinderChild extends ActorChild {
constructor(mm) {
super(mm);
this._finder = new Finder(mm.docShell);
this._finder.addResultListener(this);
for (let msg of MESSAGES) {
mm.addMessageListener(msg, this);
}
}
onFindResult(aData) {
this.mm.sendAsyncMessage("Finder:Result", aData);
}
// When the child receives messages with results of requestMatchesCount,
// it passes them forward to the parent.
onMatchesCountResult(aData) {
this.mm.sendAsyncMessage("Finder:MatchesResult", aData);
}
onHighlightFinished(aData) {
this.mm.sendAsyncMessage("Finder:HighlightFinished", aData);
}
receiveMessage(aMessage) {
let data = aMessage.data;
switch (aMessage.name) {
case "Finder:CaseSensitive":
this._finder.caseSensitive = data.caseSensitive;
break;
case "Finder:EntireWord":
this._finder.entireWord = data.entireWord;
break;
case "Finder:SetSearchStringToSelection": {
let selection = this._finder.setSearchStringToSelection();
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult",
{ selection,
initial: false });
break;
}
case "Finder:GetInitialSelection": {
let selection = this._finder.getActiveSelectionText();
this.mm.sendAsyncMessage("Finder:CurrentSelectionResult",
{ selection,
initial: true });
break;
}
case "Finder:FastFind":
this._finder.fastFind(data.searchString, data.linksOnly, data.drawOutline);
break;
case "Finder:FindAgain":
this._finder.findAgain(data.findBackwards, data.linksOnly, data.drawOutline);
break;
case "Finder:Highlight":
this._finder.highlight(data.highlight, data.word, data.linksOnly);
break;
case "Finder:HighlightAllChange":
this._finder.onHighlightAllChange(data.highlightAll);
break;
case "Finder:EnableSelection":
this._finder.enableSelection();
break;
case "Finder:RemoveSelection":
this._finder.removeSelection();
break;
case "Finder:FocusContent":
this._finder.focusContent();
break;
case "Finder:FindbarClose":
this._finder.onFindbarClose();
break;
case "Finder:FindbarOpen":
this._finder.onFindbarOpen();
break;
case "Finder:KeyPress":
var KeyboardEvent = this._finder._getWindow().KeyboardEvent;
this._finder.keyPress(new KeyboardEvent("keypress", data));
break;
case "Finder:MatchesCount":
this._finder.requestMatchesCount(data.searchString, data.linksOnly);
break;
case "Finder:ModalHighlightChange":
this._finder.onModalHighlightChange(data.useModalHighlight);
break;
}
}
}

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

@ -4,11 +4,15 @@
# 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/.
with Files('Finder*.jsm'):
BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
FINAL_TARGET_FILES.actors += [
'AudioPlaybackChild.jsm',
'ControllersChild.jsm',
'DateTimePickerChild.jsm',
'FindBarChild.jsm',
'FinderChild.jsm',
'PopupBlockingChild.jsm',
'PrintingChild.jsm',
'PurgeSessionHistoryChild.jsm',

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

@ -26,12 +26,6 @@ XPCOMUtils.defineLazyServiceGetter(this, "formFill",
var global = this;
// Lazily load the finder code
addMessageListener("Finder:Initialize", function() {
let {RemoteFinderListener} = ChromeUtils.import("resource://gre/modules/RemoteFinder.jsm", {});
new RemoteFinderListener(global);
});
var AutoScrollListener = {
handleEvent(event) {
if (event.isTrusted &

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

@ -63,9 +63,9 @@
if (!this.messageManager)
return null;
let jsm = "resource://gre/modules/RemoteFinder.jsm";
let { RemoteFinder } = ChromeUtils.import(jsm, {});
this._remoteFinder = new RemoteFinder(this);
let jsm = "resource://gre/modules/FinderParent.jsm";
let { FinderParent } = ChromeUtils.import(jsm, {});
this._remoteFinder = new FinderParent(this);
}
return this._remoteFinder;
]]></getter>

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

@ -140,6 +140,15 @@ let ACTORS = {
},
},
Finder: {
child: {
module: "resource://gre/actors/FinderChild.jsm",
messages: [
"Finder:Initialize",
],
},
},
ManifestMessages: {
child: {
module: "resource://gre/modules/ManifestMessagesChild.jsm",

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

@ -6,8 +6,8 @@
var EXPORTED_SYMBOLS = ["FindBarContent"];
ChromeUtils.defineModuleGetter(this, "RemoteFinder",
"resource://gre/modules/RemoteFinder.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.defineModuleGetter(this, "Services",
"resource://gre/modules/Services.jsm");
@ -35,7 +35,7 @@ class FindBarContent {
startQuickFind(event, autostart = false) {
let mode = FIND_TYPEAHEAD;
if (event.charCode == "'".charAt(0) ||
autostart && RemoteFinder._typeAheadLinksOnly) {
autostart && FindBarContent.typeAheadLinksOnly) {
mode = FIND_LINKS;
}
@ -97,3 +97,6 @@ class FindBarContent {
this.mm.sendAsyncMessage("Findbar:Mouseup");
}
}
XPCOMUtils.defineLazyPreferenceGetter(FindBarContent, "typeAheadLinksOnly",
"accessibility.typeaheadfind.linksonly");

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

@ -4,26 +4,22 @@
// 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/.
var EXPORTED_SYMBOLS = ["RemoteFinder", "RemoteFinderListener"];
var EXPORTED_SYMBOLS = ["FinderParent"];
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Geometry.jsm");
ChromeUtils.defineModuleGetter(this, "GetClipboardSearchString",
"resource://gre/modules/Finder.jsm");
XPCOMUtils.defineLazyGetter(this, "GetClipboardSearchString",
() => ChromeUtils.import("resource://gre/modules/Finder.jsm", {}).GetClipboardSearchString
);
XPCOMUtils.defineLazyGetter(this, "Rect",
() => ChromeUtils.import("resource://gre/modules/Geometry.jsm", {}).Rect
);
ChromeUtils.defineModuleGetter(this, "Rect",
"resource://gre/modules/Geometry.jsm");
function RemoteFinder(browser) {
function FinderParent(browser) {
this._listeners = new Set();
this._searchString = null;
this.swapBrowser(browser);
}
RemoteFinder.prototype = {
FinderParent.prototype = {
destroy() {},
swapBrowser(aBrowser) {
@ -204,136 +200,3 @@ RemoteFinder.prototype = {
linksOnly: aLinksOnly });
}
};
function RemoteFinderListener(global) {
let {Finder} = ChromeUtils.import("resource://gre/modules/Finder.jsm", {});
this._finder = new Finder(global.docShell);
this._finder.addResultListener(this);
this._global = global;
for (let msg of this.MESSAGES) {
global.addMessageListener(msg, this);
}
}
RemoteFinderListener.prototype = {
MESSAGES: [
"Finder:CaseSensitive",
"Finder:EntireWord",
"Finder:FastFind",
"Finder:FindAgain",
"Finder:SetSearchStringToSelection",
"Finder:GetInitialSelection",
"Finder:Highlight",
"Finder:HighlightAllChange",
"Finder:EnableSelection",
"Finder:RemoveSelection",
"Finder:FocusContent",
"Finder:FindbarClose",
"Finder:FindbarOpen",
"Finder:KeyPress",
"Finder:MatchesCount",
"Finder:ModalHighlightChange"
],
onFindResult(aData) {
this._global.sendAsyncMessage("Finder:Result", aData);
},
// When the child receives messages with results of requestMatchesCount,
// it passes them forward to the parent.
onMatchesCountResult(aData) {
this._global.sendAsyncMessage("Finder:MatchesResult", aData);
},
onHighlightFinished(aData) {
this._global.sendAsyncMessage("Finder:HighlightFinished", aData);
},
receiveMessage(aMessage) {
let data = aMessage.data;
switch (aMessage.name) {
case "Finder:CaseSensitive":
this._finder.caseSensitive = data.caseSensitive;
break;
case "Finder:EntireWord":
this._finder.entireWord = data.entireWord;
break;
case "Finder:SetSearchStringToSelection": {
let selection = this._finder.setSearchStringToSelection();
this._global.sendAsyncMessage("Finder:CurrentSelectionResult",
{ selection,
initial: false });
break;
}
case "Finder:GetInitialSelection": {
let selection = this._finder.getActiveSelectionText();
this._global.sendAsyncMessage("Finder:CurrentSelectionResult",
{ selection,
initial: true });
break;
}
case "Finder:FastFind":
this._finder.fastFind(data.searchString, data.linksOnly, data.drawOutline);
break;
case "Finder:FindAgain":
this._finder.findAgain(data.findBackwards, data.linksOnly, data.drawOutline);
break;
case "Finder:Highlight":
this._finder.highlight(data.highlight, data.word, data.linksOnly);
break;
case "Finder:HighlightAllChange":
this._finder.onHighlightAllChange(data.highlightAll);
break;
case "Finder:EnableSelection":
this._finder.enableSelection();
break;
case "Finder:RemoveSelection":
this._finder.removeSelection();
break;
case "Finder:FocusContent":
this._finder.focusContent();
break;
case "Finder:FindbarClose":
this._finder.onFindbarClose();
break;
case "Finder:FindbarOpen":
this._finder.onFindbarOpen();
break;
case "Finder:KeyPress":
var KeyboardEvent = this._finder._getWindow().KeyboardEvent;
this._finder.keyPress(new KeyboardEvent("keypress", data));
break;
case "Finder:MatchesCount":
this._finder.requestMatchesCount(data.searchString, data.linksOnly);
break;
case "Finder:ModalHighlightChange":
this._finder.onModalHighlightChange(data.useModalHighlight);
break;
}
}
};
XPCOMUtils.defineLazyPreferenceGetter(RemoteFinder, "_typeAheadLinksOnly",
"accessibility.typeaheadfind.linksonly");
XPCOMUtils.defineLazyPreferenceGetter(RemoteFinder, "_findAsYouType",
"accessibility.typeaheadfind");
XPCOMUtils.defineLazyPreferenceGetter(RemoteFinder, "_manualFAYT",
"accessibility.typeaheadfind.manual");

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

@ -127,9 +127,6 @@ with Files('Promise*.jsm'):
with Files('RemoteController.js'):
BUG_COMPONENT = ('Core', 'Widget')
with Files('RemoteFinder.jsm'):
BUG_COMPONENT = ('Toolkit', 'Find Toolbar')
with Files('RemoteSecurityUI.jsm'):
BUG_COMPONENT = ('Firefox', 'Tabbed Browser')
@ -206,6 +203,7 @@ EXTRA_JS_MODULES += [
'Finder.jsm',
'FinderHighlighter.jsm',
'FinderIterator.jsm',
'FinderParent.jsm',
'FormLikeFactory.jsm',
'Geometry.jsm',
'GMPExtractorWorker.js',
@ -234,7 +232,6 @@ EXTRA_JS_MODULES += [
'PromiseMessage.jsm',
'PromiseUtils.jsm',
'RemoteController.js',
'RemoteFinder.jsm',
'RemoteSecurityUI.jsm',
'RemoteWebProgress.jsm',
'ResetProfile.jsm',

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

@ -167,7 +167,6 @@
"recursive_importA.jsm": ["foo", "bar"],
"recursive_importB.jsm": ["baz", "qux"],
"reflect.jsm": ["Reflect"],
"RemoteFinder.jsm": ["RemoteFinder", "RemoteFinderListener"],
"RemotePageManagerChild.jsm": ["ChildMessagePort"],
"RemotePageManagerParent.jsm": ["RemotePages", "RemotePageManager"],
"RemoteWebProgress.jsm": ["RemoteWebProgressManager"],