Bug 1200181 - Zoomed view and Form Assistant should not be displayed at the same time. r=mcomella

This commit is contained in:
dominique vincent 2015-09-14 14:10:16 +02:00
parent c16b4428e3
commit 616a353f75
2 changed files with 28 additions and 3 deletions

View File

@ -78,6 +78,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
private int containterSize; // shadow, margin, ...
private Point lastPosition;
private boolean shouldSetVisibleOnUpdate;
private boolean isBlockedFromAppearing; // Prevent the display of the zoomedview while FormAssistantPopup is visible
private PointF returnValue;
private final PointF animationStart;
private ImageView closeButton;
@ -228,6 +229,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
public ZoomedView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
isSimplifiedUI = true;
isBlockedFromAppearing = false;
getPrefs();
currentZoomFactorIndex = 0;
returnValue = new PointF();
@ -241,7 +243,8 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
touchListener = new ZoomedViewTouchListener();
EventDispatcher.getInstance().registerGeckoThreadListener(this,
"Gesture:clusteredLinksClicked", "Window:Resize", "Content:LocationChange",
"Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect");
"Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect",
"FormAssist:AutoComplete", "FormAssist:Hide");
}
void destroy() {
@ -250,7 +253,8 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
ThreadUtils.removeCallbacksFromUiThread(requestRenderRunnable);
EventDispatcher.getInstance().unregisterGeckoThreadListener(this,
"Gesture:clusteredLinksClicked", "Window:Resize", "Content:LocationChange",
"Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect");
"Gesture:CloseZoomedView", "Browser:ZoomToPageWidth", "Browser:ZoomToRect",
"FormAssist:AutoComplete", "FormAssist:Hide");
}
// This method (onFinishInflate) is called only when the zoomed view class is used inside
@ -541,6 +545,9 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
}
private void startZoomDisplay(LayerView aLayerView, final int leftFromGecko, final int topFromGecko) {
if (isBlockedFromAppearing) {
return;
}
if (layerView == null) {
layerView = aLayerView;
layerView.addZoomedViewListener(this);
@ -625,6 +632,11 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
event.equals("Browser:ZoomToPageWidth") ||
event.equals("Browser:ZoomToRect")) {
stopZoomDisplay(true);
} else if (event.equals("FormAssist:AutoComplete")) {
isBlockedFromAppearing = true;
stopZoomDisplay(true);
} else if (event.equals("FormAssist:Hide")) {
isBlockedFromAppearing = false;
}
} catch (JSONException e) {
Log.e(LOGTAG, "JSON exception", e);

View File

@ -4808,10 +4808,12 @@ var BrowserEventHandler = {
break;
case "Gesture:SingleTap": {
let focusedElement = null;
try {
// If the element was previously focused, show the caret attached to it.
let element = this._highlightElement;
if (element && element == BrowserApp.getFocusedInput(BrowserApp.selectedBrowser)) {
focusedElement = BrowserApp.getFocusedInput(BrowserApp.selectedBrowser);
if (element && element == focusedElement) {
let result = SelectionHandler.attachCaret(element);
if (result !== SelectionHandler.ERROR_NONE) {
dump("Unexpected failure during caret attach: " + result);
@ -4825,6 +4827,17 @@ var BrowserEventHandler = {
let {x, y} = data;
if (this._inCluster && this._clickInZoomedView != true) {
// If there is a focused element, the display of the zoomed view won't remove the focus.
// In this case, the form assistant linked to the focused element will never be closed.
// To avoid this situation, the focus is moved and the form assistant is closed.
if (focusedElement) {
try {
Services.focus.moveFocus(BrowserApp.selectedBrowser.contentWindow, null, Services.focus.MOVEFOCUS_ROOT, 0);
} catch(e) {
Cu.reportError(e);
}
Messaging.sendRequest({ type: "FormAssist:Hide" });
}
this._clusterClicked(x, y);
} else {
if (this._clickInZoomedView != true) {