mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset 5807dfe3b873 (bug 1218351)
This commit is contained in:
parent
46882003f0
commit
1134ee1010
@ -32,8 +32,6 @@ Cc["@mozilla.org/globalmessagemanager;1"]
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
|
||||
"resource:///modules/E10SUtils.jsm");
|
||||
|
||||
var gSendCharCount = 0;
|
||||
|
||||
this.BrowserTestUtils = {
|
||||
/**
|
||||
* Loads a page in a new tab, executes a Task and closes the tab.
|
||||
@ -665,21 +663,12 @@ this.BrowserTestUtils = {
|
||||
*/
|
||||
sendChar(char, browser) {
|
||||
return new Promise(resolve => {
|
||||
let seq = ++gSendCharCount;
|
||||
let mm = browser.messageManager;
|
||||
|
||||
mm.addMessageListener("Test:SendCharDone", function charMsg(message) {
|
||||
if (message.data.seq != seq)
|
||||
return;
|
||||
|
||||
mm.removeMessageListener("Test:SendCharDone", charMsg);
|
||||
resolve(message.data.sendCharResult);
|
||||
});
|
||||
|
||||
mm.sendAsyncMessage("Test:SendChar", {
|
||||
char: char,
|
||||
seq: seq
|
||||
});
|
||||
mm.sendAsyncMessage("Test:SendChar", { char: char });
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -53,8 +53,5 @@ addMessageListener("Test:SynthesizeMouse", (message) => {
|
||||
|
||||
addMessageListener("Test:SendChar", message => {
|
||||
let result = EventUtils.sendChar(message.data.char, content);
|
||||
sendAsyncMessage("Test:SendCharDone", {
|
||||
sendCharResult: result,
|
||||
seq: message.data.seq
|
||||
});
|
||||
sendAsyncMessage("Test:SendCharDone", { sendCharResult: result });
|
||||
});
|
||||
|
@ -580,10 +580,15 @@ var FindBar = {
|
||||
FIND_NORMAL: 0,
|
||||
FIND_TYPEAHEAD: 1,
|
||||
FIND_LINKS: 2,
|
||||
FAYT_LINKS_KEY: "'".charCodeAt(0),
|
||||
FAYT_TEXT_KEY: "/".charCodeAt(0),
|
||||
|
||||
_findMode: 0,
|
||||
_findAsYouType: false,
|
||||
|
||||
init() {
|
||||
this._findAsYouType =
|
||||
Services.prefs.getBoolPref("accessibility.typeaheadfind");
|
||||
addMessageListener("Findbar:UpdateState", this);
|
||||
Services.els.addSystemEventListener(global, "keypress", this, false);
|
||||
Services.els.addSystemEventListener(global, "mouseup", this, false);
|
||||
@ -593,6 +598,7 @@ var FindBar = {
|
||||
switch (msg.name) {
|
||||
case "Findbar:UpdateState":
|
||||
this._findMode = msg.data.findMode;
|
||||
this._findAsYouType = msg.data.findAsYouType;
|
||||
break;
|
||||
}
|
||||
},
|
||||
@ -626,9 +632,16 @@ var FindBar = {
|
||||
if (event.ctrlKey || event.altKey || event.metaKey || event.defaultPrevented) {
|
||||
return;
|
||||
}
|
||||
// Not interested in random keypresses most of the time:
|
||||
if (this._findMode == this.FIND_NORMAL && !this._findAsYouType &&
|
||||
event.charCode != this.FAYT_LINKS_KEY && event.charCode != this.FAYT_TEXT_KEY) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the focused element etc.
|
||||
let shouldFastFind = this._shouldFastFind();
|
||||
if (!this._shouldFastFind()) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fakeEvent = {};
|
||||
for (let k in event) {
|
||||
@ -637,10 +650,7 @@ var FindBar = {
|
||||
}
|
||||
}
|
||||
// sendSyncMessage returns an array of the responses from all listeners
|
||||
let rv = sendSyncMessage("Findbar:Keypress", {
|
||||
fakeEvent: fakeEvent,
|
||||
shouldFastFind: shouldFastFind
|
||||
});
|
||||
let rv = sendSyncMessage("Findbar:Keypress", fakeEvent);
|
||||
if (rv.indexOf(false) !== -1) {
|
||||
event.preventDefault();
|
||||
return false;
|
||||
|
@ -158,45 +158,6 @@ add_task(function * test_reinitialization_at_remoteness_change() {
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
/**
|
||||
* Ensure that the initial typed characters aren't lost immediately after
|
||||
* opening the find bar.
|
||||
*/
|
||||
add_task(function* () {
|
||||
// This test only makes sence in e10s evironment.
|
||||
if (!gMultiProcessBrowser) {
|
||||
info("Skipping this test because of non-e10s environment.");
|
||||
return true;
|
||||
}
|
||||
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_PAGE_URI);
|
||||
let browser = tab.linkedBrowser;
|
||||
|
||||
ok(!gFindBarInitialized, "findbar isn't initialized yet");
|
||||
|
||||
let findBar = gFindBar;
|
||||
let initialValue = findBar._findField.value;
|
||||
|
||||
EventUtils.synthesizeKey("f", { accelKey: true }, window);
|
||||
|
||||
let promises = [
|
||||
BrowserTestUtils.sendChar("a", browser),
|
||||
BrowserTestUtils.sendChar("b", browser),
|
||||
BrowserTestUtils.sendChar("c", browser)
|
||||
];
|
||||
|
||||
isnot(document.activeElement, findBar._findField.inputField,
|
||||
"findbar is not yet focused");
|
||||
is(findBar._findField.value, initialValue, "still has initial find query");
|
||||
|
||||
yield Promise.all(promises);
|
||||
is(document.activeElement, findBar._findField.inputField,
|
||||
"findbar is now focused");
|
||||
is(findBar._findField.value, "abc", "abc fully entered as find query");
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
||||
|
||||
function promiseFindFinished(searchText, highlightOn) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
|
@ -285,7 +285,7 @@
|
||||
|
||||
this._browser = val;
|
||||
if (this._browser) {
|
||||
// Need to do this to ensure the correct initial state.
|
||||
// Need to do this in case FAYT
|
||||
this._updateBrowserWithState();
|
||||
this._browser.messageManager.addMessageListener("Findbar:Keypress", this);
|
||||
this._browser.messageManager.addMessageListener("Findbar:Mouseup", this);
|
||||
@ -320,6 +320,7 @@
|
||||
switch (aPrefName) {
|
||||
case "accessibility.typeaheadfind":
|
||||
this._self._findAsYouType = prefsvc.getBoolPref(aPrefName);
|
||||
this._self._updateBrowserWithState();
|
||||
break;
|
||||
case "accessibility.typeaheadfind.linksonly":
|
||||
this._self._typeAheadLinksOnly = prefsvc.getBoolPref(aPrefName);
|
||||
@ -740,21 +741,10 @@
|
||||
on the real event. -->
|
||||
<method name="_onBrowserKeypress">
|
||||
<parameter name="aFakeEvent"/>
|
||||
<parameter name="aShouldFastFind"/>
|
||||
<body><![CDATA[
|
||||
const FAYT_LINKS_KEY = "'";
|
||||
const FAYT_TEXT_KEY = "/";
|
||||
|
||||
// Fast keypresses can stack up when the content process is slow or
|
||||
// hangs when in e10s mode. We make sure the findbar isn't 'opened'
|
||||
// several times in a row, because then the find query is selected
|
||||
// each time, losing characters typed initially.
|
||||
let inputField = this._findField.inputField;
|
||||
if (!this.hidden && document.activeElement == inputField) {
|
||||
this._dispatchKeypressEvent(inputField, aFakeEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this._findMode != this.FIND_NORMAL && this._quickFindTimeout) {
|
||||
if (!aFakeEvent.charCode)
|
||||
return true;
|
||||
@ -765,9 +755,6 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aShouldFastFind)
|
||||
return true;
|
||||
|
||||
let key = aFakeEvent.charCode ? String.fromCharCode(aFakeEvent.charCode) : null;
|
||||
let manualstartFAYT = (key == FAYT_LINKS_KEY || key == FAYT_TEXT_KEY);
|
||||
let autostartFAYT = !manualstartFAYT && this._findAsYouType &&
|
||||
@ -810,8 +797,7 @@
|
||||
break;
|
||||
|
||||
case "Findbar:Keypress":
|
||||
return this._onBrowserKeypress(aMessage.data.fakeEvent,
|
||||
aMessage.data.shouldFastFind);
|
||||
return this._onBrowserKeypress(aMessage.data);
|
||||
}
|
||||
]]></body>
|
||||
</method>
|
||||
@ -820,7 +806,8 @@
|
||||
<body><![CDATA[
|
||||
if (this._browser && this._browser.messageManager) {
|
||||
this._browser.messageManager.sendAsyncMessage("Findbar:UpdateState", {
|
||||
findMode: this._findMode
|
||||
findMode: this._findMode,
|
||||
findAsYouType: this._findAsYouType,
|
||||
});
|
||||
}
|
||||
]]></body>
|
||||
|
Loading…
Reference in New Issue
Block a user