mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 704879 - (4/6) Make FormAssistant in charge of hiding an empty popup. r=lucasr
This commit is contained in:
parent
8752fbb750
commit
7873ab994b
@ -92,27 +92,30 @@ public class FormAssistPopup extends ListView implements GeckoEventListener {
|
||||
});
|
||||
|
||||
GeckoAppShell.registerGeckoEventListener("FormAssist:AutoComplete", this);
|
||||
GeckoAppShell.registerGeckoEventListener("FormAssist:Hide", this);
|
||||
}
|
||||
|
||||
public void handleMessage(String event, JSONObject message) {
|
||||
try {
|
||||
if (event.equals("FormAssist:AutoComplete")) {
|
||||
final JSONArray suggestions = message.getJSONArray("suggestions");
|
||||
if (suggestions.length() == 0) {
|
||||
hide();
|
||||
} else {
|
||||
final JSONArray rect = message.getJSONArray("rect");
|
||||
final double zoom = message.getDouble("zoom");
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
// Don't show autocomplete popup when using fullscreen VKB
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (!imm.isFullscreenMode())
|
||||
show(suggestions, rect, zoom);
|
||||
}
|
||||
});
|
||||
}
|
||||
final JSONArray rect = message.getJSONArray("rect");
|
||||
final double zoom = message.getDouble("zoom");
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
// Don't show autocomplete popup when using fullscreen // VKB
|
||||
InputMethodManager imm =
|
||||
(InputMethodManager) GeckoApp.mAppContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
if (!imm.isFullscreenMode())
|
||||
show(suggestions, rect, zoom);
|
||||
}
|
||||
});
|
||||
} else if (event.equals("FormAssist:Hide")) {
|
||||
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
|
||||
public void run() {
|
||||
hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Log.e(LOGTAG, "Exception handling message \"" + event + "\":", e);
|
||||
@ -211,7 +214,7 @@ public class FormAssistPopup extends ListView implements GeckoEventListener {
|
||||
public void hide() {
|
||||
if (isShown()) {
|
||||
setVisibility(View.GONE);
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FormAssist:Closed", null));
|
||||
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("FormAssist:Hidden", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2838,14 +2838,14 @@ var FormAssistant = {
|
||||
|
||||
init: function() {
|
||||
Services.obs.addObserver(this, "FormAssist:AutoComplete", false);
|
||||
Services.obs.addObserver(this, "FormAssist:Closed", false);
|
||||
Services.obs.addObserver(this, "FormAssist:Hidden", false);
|
||||
|
||||
BrowserApp.deck.addEventListener("input", this, false);
|
||||
},
|
||||
|
||||
uninit: function() {
|
||||
Services.obs.removeObserver(this, "FormAssist:AutoComplete");
|
||||
Services.obs.removeObserver(this, "FormAssist:Closed");
|
||||
Services.obs.removeObserver(this, "FormAssist:Hidden");
|
||||
},
|
||||
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
@ -2859,7 +2859,7 @@ var FormAssistant = {
|
||||
this._currentInputElement.value = aData;
|
||||
break;
|
||||
|
||||
case "FormAssist:Closed":
|
||||
case "FormAssist:Hidden":
|
||||
this._currentInputElement = null;
|
||||
break;
|
||||
}
|
||||
@ -2869,7 +2869,11 @@ var FormAssistant = {
|
||||
switch (aEvent.type) {
|
||||
case "input":
|
||||
let currentElement = aEvent.target;
|
||||
this._showAutoCompleteSuggestions(currentElement);
|
||||
if (this._showAutoCompleteSuggestions(currentElement))
|
||||
break;
|
||||
|
||||
// If we're not showing autocomplete suggestions, hide the form assist popup
|
||||
this._hideFormAssistPopup();
|
||||
}
|
||||
},
|
||||
|
||||
@ -2928,6 +2932,10 @@ var FormAssistant = {
|
||||
|
||||
let suggestions = this._getAutoCompleteSuggestions(aElement.value, aElement);
|
||||
|
||||
// Return false if there are no suggestions to show
|
||||
if (!suggestions.length)
|
||||
return false;
|
||||
|
||||
let positionData = this._getElementPositionData(aElement);
|
||||
sendMessageToJava({
|
||||
gecko: {
|
||||
@ -2943,6 +2951,12 @@ var FormAssistant = {
|
||||
this._currentInputElement = aElement;
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
_hideFormAssistPopup: function _hideFormAssistPopup() {
|
||||
sendMessageToJava({
|
||||
gecko: { type: "FormAssist:Hide" }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user