mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1301515 - Remove FormAssistPopup dependency in geckoview; r=sebastian
Remove the input method change notification that GeckoInputConnection sends to FormAssistPopup, so there's no dependency on FormAssistPopup from inside GeckoInputConnection or GeckoInterface. Instead, FormAssistPopup now actively queries the current input method, and performs blocklisting based on that.
This commit is contained in:
parent
cbdc48211c
commit
3a8af38a02
@ -122,10 +122,11 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
|
||||
private void handleAutoCompleteMessage(JSONObject message) throws JSONException {
|
||||
final JSONArray suggestions = message.getJSONArray("suggestions");
|
||||
final JSONObject rect = message.getJSONObject("rect");
|
||||
final boolean isEmpty = message.getBoolean("isEmpty");
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showAutoCompleteSuggestions(suggestions, rect);
|
||||
showAutoCompleteSuggestions(suggestions, rect, isEmpty);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -150,7 +151,15 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
|
||||
});
|
||||
}
|
||||
|
||||
private void showAutoCompleteSuggestions(JSONArray suggestions, JSONObject rect) {
|
||||
private void showAutoCompleteSuggestions(JSONArray suggestions, JSONObject rect, boolean isEmpty) {
|
||||
final String inputMethod = InputMethods.getCurrentInputMethod(mContext);
|
||||
if (!isEmpty && sInputMethodBlocklist.contains(inputMethod)) {
|
||||
// Don't display the form auto-complete popup after the user starts typing
|
||||
// to avoid confusing somes IME. See bug 758820 and bug 632744.
|
||||
hide();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mAutoCompleteList == null) {
|
||||
LayoutInflater inflater = LayoutInflater.from(mContext);
|
||||
mAutoCompleteList = (ListView) inflater.inflate(R.layout.autocomplete_list, null);
|
||||
@ -378,11 +387,6 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
|
||||
}
|
||||
}
|
||||
|
||||
void onInputMethodChanged(String newInputMethod) {
|
||||
boolean blocklisted = sInputMethodBlocklist.contains(newInputMethod);
|
||||
broadcastGeckoEvent("FormAssist:Blocklisted", String.valueOf(blocklisted));
|
||||
}
|
||||
|
||||
void onTranslationChanged() {
|
||||
ThreadUtils.assertOnUiThread();
|
||||
if (!isShown()) {
|
||||
|
@ -342,11 +342,6 @@ public abstract class GeckoApp
|
||||
mAppStateListeners.remove(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FormAssistPopup getFormAssistPopup() {
|
||||
return mFormAssistPopup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabChanged(Tab tab, Tabs.TabEvents msg, String data) {
|
||||
// When a tab is closed, it is always unselected first.
|
||||
|
@ -4999,14 +4999,11 @@ var FormAssistant = {
|
||||
// Whether we're in the middle of an autocomplete
|
||||
_doingAutocomplete: false,
|
||||
|
||||
_isBlocklisted: false,
|
||||
|
||||
// Keep track of whether or not an invalid form has been submitted
|
||||
_invalidSubmit: false,
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, "FormAssist:AutoComplete", false);
|
||||
Services.obs.addObserver(this, "FormAssist:Blocklisted", false);
|
||||
Services.obs.addObserver(this, "FormAssist:Hidden", false);
|
||||
Services.obs.addObserver(this, "FormAssist:Remove", false);
|
||||
Services.obs.addObserver(this, "invalidformsubmit", false);
|
||||
@ -5072,10 +5069,6 @@ var FormAssistant = {
|
||||
|
||||
break;
|
||||
|
||||
case "FormAssist:Blocklisted":
|
||||
this._isBlocklisted = (aData == "true");
|
||||
break;
|
||||
|
||||
case "FormAssist:Hidden":
|
||||
this._currentInputElement = null;
|
||||
break;
|
||||
@ -5279,12 +5272,7 @@ var FormAssistant = {
|
||||
return;
|
||||
}
|
||||
|
||||
// Don't display the form auto-complete popup after the user starts typing
|
||||
// to avoid confusing somes IME. See bug 758820 and bug 632744.
|
||||
if (this._isBlocklisted && aElement.value.length > 0) {
|
||||
aCallback(false);
|
||||
return;
|
||||
}
|
||||
let isEmpty = (aElement.value.length === 0);
|
||||
|
||||
let resultsAvailable = autoCompleteSuggestions => {
|
||||
// On desktop, we show datalist suggestions below autocomplete suggestions,
|
||||
@ -5301,7 +5289,8 @@ var FormAssistant = {
|
||||
Messaging.sendRequest({
|
||||
type: "FormAssist:AutoComplete",
|
||||
suggestions: suggestions,
|
||||
rect: ElementTouchHelper.getBoundingContentRect(aElement)
|
||||
rect: ElementTouchHelper.getBoundingContentRect(aElement),
|
||||
isEmpty: isEmpty,
|
||||
});
|
||||
|
||||
// Keep track of input element so we can fill it in if the user
|
||||
|
@ -99,12 +99,6 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
|
||||
@Override
|
||||
public void notifyWakeLockChanged(String topic, String state) {}
|
||||
|
||||
// Bug 908790: Implement this
|
||||
@Override
|
||||
public FormAssistPopup getFormAssistPopup() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areTabsShown() {
|
||||
return false;
|
||||
|
@ -1753,7 +1753,6 @@ public class GeckoAppShell
|
||||
public void removeAppStateListener(AppStateListener listener);
|
||||
public View getCameraView();
|
||||
public void notifyWakeLockChanged(String topic, String state);
|
||||
public FormAssistPopup getFormAssistPopup();
|
||||
public boolean areTabsShown();
|
||||
public AbsoluteLayout getPluginContainer();
|
||||
public void notifyCheckUpdateResult(String result);
|
||||
|
@ -684,14 +684,6 @@ class GeckoInputConnection
|
||||
Log.d(LOGTAG, "IME: CurrentInputMethod=" + mCurrentInputMethod);
|
||||
}
|
||||
|
||||
// If the user has changed IMEs, then notify input method observers.
|
||||
if (!mCurrentInputMethod.equals(prevInputMethod) && GeckoAppShell.getGeckoInterface() != null) {
|
||||
FormAssistPopup popup = GeckoAppShell.getGeckoInterface().getFormAssistPopup();
|
||||
if (popup != null) {
|
||||
popup.onInputMethodChanged(mCurrentInputMethod);
|
||||
}
|
||||
}
|
||||
|
||||
if (mIMEState == IME_STATE_PLUGIN) {
|
||||
// Since we are using a temporary string as the editable, the selection is at 0
|
||||
outAttrs.initialSelStart = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user