Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(305)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2561463004: Refactor ZoomControlsDelegate out of ContentViewCore (Closed)
Patch Set: Rebase (no actual changes needed) Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index a3ad4b8711211796c209d01c859a00d21659dfcd..1ed433cfebb18d71914f8247db44544e2a3757bb 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -98,16 +98,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
// produce little visible difference.
private static final float ZOOM_CONTROLS_EPSILON = 0.007f;
- private static final ZoomControlsDelegate NO_OP_ZOOM_CONTROLS_DELEGATE =
- new ZoomControlsDelegate() {
- @Override
- public void invokeZoomPicker() {}
- @Override
- public void dismissZoomPicker() {}
- @Override
- public void updateZoomControls() {}
- };
-
// If the embedder adds a JavaScript interface object that contains an indirect reference to
// the ContentViewCore, then storing a strong ref to the interface object on the native
// side would prevent garbage collection of the ContentViewCore (as that strong ref would
@@ -276,26 +266,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
/**
- * An interface for controlling visibility and state of embedder-provided zoom controls.
- */
- public interface ZoomControlsDelegate {
- /**
- * Called when it's reasonable to show zoom controls.
- */
- void invokeZoomPicker();
-
- /**
- * Called when zoom controls need to be hidden (e.g. when the view hides).
- */
- void dismissZoomPicker();
-
- /**
- * Called when page scale has been changed, so the controls can update their state.
- */
- void updateZoomControls();
- }
-
- /**
* An interface that allows the embedder to be notified when the results of
* extractSmartClipData are available.
*/
@@ -318,7 +288,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private boolean mAttachedToWindow;
private final ObserverList<GestureStateListener> mGestureStateListeners;
private final RewindableIterator<GestureStateListener> mGestureStateListenersIterator;
- private ZoomControlsDelegate mZoomControlsDelegate;
private PopupZoomer mPopupZoomer;
private SelectPopup mSelectPopup;
@@ -623,8 +592,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
long windowNativePointer = windowAndroid.getNativePointer();
assert windowNativePointer != 0;
- mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE;
-
final float dipScale = windowAndroid.getDisplay().getDipScale();
mRenderCoordinates.reset();
@@ -836,7 +803,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
mWebContentsObserver.destroy();
mWebContentsObserver = null;
setSmartClipDataListener(null);
- setZoomControlsDelegate(null);
mImeAdapter.resetAndHideKeyboard();
// TODO(igsolla): address TODO in ContentViewClient because ContentViewClient is not
// currently a real Null Object.
@@ -1177,14 +1143,12 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
private void onScrollBeginEventAck() {
setTouchScrollInProgress(true);
hidePastePopup();
- mZoomControlsDelegate.invokeZoomPicker();
updateGestureStateListener(GestureEventType.SCROLL_START);
}
@SuppressWarnings("unused")
@CalledByNative
private void onScrollUpdateGestureConsumed() {
- mZoomControlsDelegate.invokeZoomPicker();
for (mGestureStateListenersIterator.rewind();
mGestureStateListenersIterator.hasNext();) {
mGestureStateListenersIterator.next().onScrollUpdateGestureConsumed();
@@ -1420,7 +1384,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
mAttachedToWindow = false;
mImeAdapter.onViewDetachedFromWindow();
mJoystickScrollProvider.onViewDetachedFromWindow();
- mZoomControlsDelegate.dismissZoomPicker();
removeDisplayAndroidObserver();
GamepadList.onDetachedFromWindow();
mAccessibilityManager.removeAccessibilityStateChangeListener(this);
@@ -1435,15 +1398,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
/**
- * @see View#onVisibilityChanged(android.view.View, int)
- */
- public void onVisibilityChanged(View changedView, int visibility) {
- if (visibility != View.VISIBLE) {
- mZoomControlsDelegate.dismissZoomPicker();
- }
- }
-
- /**
* @see View#onCreateInputConnection(EditorInfo)
*/
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
@@ -1836,14 +1790,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
if (!mPopupZoomer.isShowing()) mPopupZoomer.setLastTouch(xPix, yPix);
}
- public void setZoomControlsDelegate(ZoomControlsDelegate zoomControlsDelegate) {
- if (zoomControlsDelegate == null) {
- mZoomControlsDelegate = NO_OP_ZOOM_CONTROLS_DELEGATE;
- return;
- }
- mZoomControlsDelegate = zoomControlsDelegate;
- }
-
public void updateMultiTouchZoomSupport(boolean supportsMultiTouchZoom) {
if (mNativeContentViewCore == 0) return;
nativeSetMultiTouchZoomSupportEnabled(mNativeContentViewCore, supportsMultiTouchZoom);
@@ -1946,7 +1892,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
.getContentOffsetYPixBottom()) != 0;
final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged;
- final boolean needUpdateZoomControls = scaleLimitsChanged || scrollChanged;
if (needHidePopupZoomer) mPopupZoomer.hide(true);
@@ -1974,7 +1919,13 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
}
- if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls();
+ if (scaleLimitsChanged) {
+ for (mGestureStateListenersIterator.rewind();
+ mGestureStateListenersIterator.hasNext();) {
+ mGestureStateListenersIterator.next().onScaleLimitsChanged(
+ minPageScaleFactor, maxPageScaleFactor);
+ }
+ }
if (topBarChanged) {
float topBarTranslate = topBarShownPix - browserControlsHeightDp * deviceScale;
@@ -2333,13 +2284,6 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Displa
}
/**
- * Invokes the graphical zoom picker widget for this ContentView.
- */
- public void invokeZoomPicker() {
- mZoomControlsDelegate.invokeZoomPicker();
- }
-
- /**
* Enables or disables inspection of JavaScript objects added via
* {@link #addJavascriptInterface(Object, String)} by means of Object.keys() method and
* &quot;for .. in&quot; loop. Being able to inspect JavaScript objects is useful

Powered by Google App Engine
This is Rietveld 408576698