Commit 5415ae79 authored by Jinsuk Kim's avatar Jinsuk Kim Committed by Commit Bot

Remove |onSizeChanged| from ContentView/Core

The event flow was migrated to ViewAndroid. This CL removes
the remaining handler, and moves the post-event task in
ContentViewCore.onSizeChanged to ImeAdapterAndroid/PopupZoomer.

Bug: 622847
Change-Id: I1814d435365a3aa0f7685b26c860cf56e2856a9a
Reviewed-on: https://chromium-review.googlesource.com/784731
Commit-Queue: Jinsuk Kim <jinsukkim@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522351}
parent bc728217
...@@ -3463,7 +3463,6 @@ public class AwContents implements SmartClipProvider { ...@@ -3463,7 +3463,6 @@ public class AwContents implements SmartClipProvider {
// update. // update.
mLayoutSizer.onSizeChanged(w, h, ow, oh); mLayoutSizer.onSizeChanged(w, h, ow, oh);
nativeOnSizeChanged(mNativeAwContents, w, h, ow, oh); nativeOnSizeChanged(mNativeAwContents, w, h, ow, oh);
mContentViewCore.onSizeChanged(w, h, ow, oh);
} }
@Override @Override
......
...@@ -512,8 +512,6 @@ public class OverlayPanelContent { ...@@ -512,8 +512,6 @@ public class OverlayPanelContent {
void onSizeChanged(int width, int height) { void onSizeChanged(int width, int height) {
if (mContentViewCore == null || getWebContents() == null) return; if (mContentViewCore == null || getWebContents() == null) return;
getWebContents().setSize(width, height); getWebContents().setSize(width, height);
mContentViewCore.onSizeChanged(width, height, mContentViewCore.getViewportWidthPix(),
mContentViewCore.getViewportHeightPix());
} }
void onPhysicalBackingSizeChanged(int width, int height) { void onPhysicalBackingSizeChanged(int width, int height) {
......
...@@ -2550,12 +2550,10 @@ public class Tab ...@@ -2550,12 +2550,10 @@ public class Tab
destroyContentViewCore(deleteOldNativeWebContents); destroyContentViewCore(deleteOldNativeWebContents);
NativePage previousNativePage = mNativePage; NativePage previousNativePage = mNativePage;
mNativePage = null; mNativePage = null;
// Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(), // Size of the new content is zero at this point. Set the view size in advance
// next onShow() call would send a resize message with the current ContentViewCore size // so that next onShow() call won't send a resize message with zero size
// (zero) to the renderer process, although the new size will be set soon. // to the renderer process. This prevents the size fluttering that may confuse
// However, this size fluttering may confuse Blink and rendered result can be broken // Blink and break rendered result (see http://crbug.com/340987).
// (see http://crbug.com/340987).
newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
newContentViewCore.getWebContents().setSize(originalWidth, originalHeight); newContentViewCore.getWebContents().setSize(originalWidth, originalHeight);
if (!bounds.isEmpty()) { if (!bounds.isEmpty()) {
...@@ -3186,7 +3184,6 @@ public class Tab ...@@ -3186,7 +3184,6 @@ public class Tab
Rect bounds = getEstimatedContentSize(context); Rect bounds = getEstimatedContentSize(context);
int width = bounds.right - bounds.left; int width = bounds.right - bounds.left;
int height = bounds.bottom - bounds.top; int height = bounds.bottom - bounds.top;
tab.getContentViewCore().onSizeChanged(width, height, 0, 0);
tab.getWebContents().setSize(width, height); tab.getWebContents().setSize(width, height);
tab.detach(); tab.detach();
......
...@@ -510,7 +510,6 @@ public class VrShellImpl ...@@ -510,7 +510,6 @@ public class VrShellImpl
mContentVirtualDisplay.update(size, dpr, null, null, null, null, null); mContentVirtualDisplay.update(size, dpr, null, null, null, null, null);
assert mTab != null; assert mTab != null;
if (mTab.getContentViewCore() != null) { if (mTab.getContentViewCore() != null) {
mTab.getContentViewCore().onSizeChanged(surfaceWidth, surfaceHeight, 0, 0);
nativeOnPhysicalBackingSizeChanged( nativeOnPhysicalBackingSizeChanged(
mNativeVrShell, mTab.getWebContents(), surfaceWidth, surfaceHeight); mNativeVrShell, mTab.getWebContents(), surfaceWidth, surfaceHeight);
} }
...@@ -605,7 +604,6 @@ public class VrShellImpl ...@@ -605,7 +604,6 @@ public class VrShellImpl
if (mTab.getContentViewCore() != null) { if (mTab.getContentViewCore() != null) {
View parent = mTab.getContentViewCore().getContainerView(); View parent = mTab.getContentViewCore().getContainerView();
mTab.getWebContents().setSize(parent.getWidth(), parent.getHeight()); mTab.getWebContents().setSize(parent.getWidth(), parent.getHeight());
mTab.getContentViewCore().onSizeChanged(parent.getWidth(), parent.getHeight(), 0, 0);
} }
mTab.updateBrowserControlsState(BrowserControlsState.SHOWN, true); mTab.updateBrowserControlsState(BrowserControlsState.SHOWN, true);
......
...@@ -184,6 +184,14 @@ void ImeAdapterAndroid::UpdateState(const TextInputState& state) { ...@@ -184,6 +184,14 @@ void ImeAdapterAndroid::UpdateState(const TextInputState& state) {
state.composition_end, state.reply_to_request); state.composition_end, state.reply_to_request);
} }
void ImeAdapterAndroid::UpdateAfterViewSizeChanged() {
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> obj = java_ime_adapter_.get(env);
if (obj.is_null())
return;
Java_ImeAdapter_updateAfterViewSizeChanged(env, obj);
}
void ImeAdapterAndroid::UpdateFrameInfo( void ImeAdapterAndroid::UpdateFrameInfo(
const gfx::SelectionBound& selection_start, const gfx::SelectionBound& selection_start,
float dip_scale, float dip_scale,
......
...@@ -105,6 +105,7 @@ class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector { ...@@ -105,6 +105,7 @@ class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector {
} }
void UpdateState(const TextInputState& state); void UpdateState(const TextInputState& state);
void UpdateAfterViewSizeChanged();
void AdvanceFocusInForm(JNIEnv*, void AdvanceFocusInForm(JNIEnv*,
const base::android::JavaParamRef<jobject>&, const base::android::JavaParamRef<jobject>&,
......
...@@ -2230,6 +2230,13 @@ void RenderWidgetHostViewAndroid::OnGestureEvent( ...@@ -2230,6 +2230,13 @@ void RenderWidgetHostViewAndroid::OnGestureEvent(
SendGestureEvent(web_gesture); SendGestureEvent(web_gesture);
} }
void RenderWidgetHostViewAndroid::OnSizeChanged() {
if (ime_adapter_android_)
ime_adapter_android_->UpdateAfterViewSizeChanged();
if (popup_zoomer_)
popup_zoomer_->HidePopup();
}
void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() { void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() {
EvictFrameIfNecessary(); EvictFrameIfNecessary();
WasResized(); WasResized();
......
...@@ -199,6 +199,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid ...@@ -199,6 +199,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
bool OnMouseEvent(const ui::MotionEventAndroid& m) override; bool OnMouseEvent(const ui::MotionEventAndroid& m) override;
bool OnMouseWheelEvent(const ui::MotionEventAndroid& event) override; bool OnMouseWheelEvent(const ui::MotionEventAndroid& event) override;
bool OnGestureEvent(const ui::GestureEventAndroid& event) override; bool OnGestureEvent(const ui::GestureEventAndroid& event) override;
void OnSizeChanged() override;
void OnPhysicalBackingSizeChanged() override; void OnPhysicalBackingSizeChanged() override;
// ui::ViewAndroidObserver implementation: // ui::ViewAndroidObserver implementation:
......
...@@ -127,17 +127,6 @@ public class ContentView extends FrameLayout ...@@ -127,17 +127,6 @@ public class ContentView extends FrameLayout
super.onScrollChanged(l, t, oldl, oldt); super.onScrollChanged(l, t, oldl, oldt);
} }
@Override
protected void onSizeChanged(int w, int h, int ow, int oh) {
try {
TraceEvent.begin("ContentView.onSizeChanged");
super.onSizeChanged(w, h, ow, oh);
mContentViewCore.onSizeChanged(w, h, ow, oh);
} finally {
TraceEvent.end("ContentView.onSizeChanged");
}
}
@Override @Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return mContentViewCore.onCreateInputConnection(outAttrs); return mContentViewCore.onCreateInputConnection(outAttrs);
......
...@@ -324,11 +324,6 @@ public interface ContentViewCore { ...@@ -324,11 +324,6 @@ public interface ContentViewCore {
*/ */
void onConfigurationChanged(Configuration newConfig); void onConfigurationChanged(Configuration newConfig);
/**
* @see View#onSizeChanged(int, int, int, int)
*/
void onSizeChanged(int wPix, int hPix, int owPix, int ohPix);
/** /**
* @see View#onGenericMotionEvent(MotionEvent) * @see View#onGenericMotionEvent(MotionEvent)
*/ */
......
...@@ -809,12 +809,6 @@ public class ContentViewCoreImpl ...@@ -809,12 +809,6 @@ public class ContentViewCoreImpl
} }
} }
@SuppressWarnings("javadoc")
@Override
public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) {
updateAfterSizeChanged();
}
@CalledByNative @CalledByNative
private void onTouchDown(MotionEvent event) { private void onTouchDown(MotionEvent event) {
if (mShouldRequestUnbufferedDispatch) requestUnbufferedDispatch(event); if (mShouldRequestUnbufferedDispatch) requestUnbufferedDispatch(event);
......
...@@ -442,6 +442,25 @@ public class ImeAdapter { ...@@ -442,6 +442,25 @@ public class ImeAdapter {
return mFocusPreOSKViewportRect; return mFocusPreOSKViewportRect;
} }
@CalledByNative
private void updateAfterViewSizeChanged() {
// Execute a delayed form focus operation because the OSK was brought up earlier.
if (!mFocusPreOSKViewportRect.isEmpty()) {
Rect rect = new Rect();
mContainerView.getWindowVisibleDisplayFrame(rect);
if (!rect.equals(mFocusPreOSKViewportRect)) {
// Only assume the OSK triggered the onSizeChanged if width was preserved.
if (rect.width() == mFocusPreOSKViewportRect.width()) {
assert mWebContents != null;
mWebContents.scrollFocusedEditableNodeIntoView();
}
// Zero the rect to prevent the above operation from issuing the delayed
// form focus event.
mFocusPreOSKViewportRect.setEmpty();
}
}
}
@VisibleForTesting @VisibleForTesting
public ResultReceiver getNewShowKeyboardReceiver() { public ResultReceiver getNewShowKeyboardReceiver() {
if (mShowKeyboardResultReceiver == null) { if (mShowKeyboardResultReceiver == null) {
......
...@@ -222,9 +222,6 @@ public class TestContentViewCore implements ContentViewCore { ...@@ -222,9 +222,6 @@ public class TestContentViewCore implements ContentViewCore {
@Override @Override
public void onConfigurationChanged(Configuration newConfig) {} public void onConfigurationChanged(Configuration newConfig) {}
@Override
public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) {}
@Override @Override
public boolean onGenericMotionEvent(MotionEvent event) { public boolean onGenericMotionEvent(MotionEvent event) {
return false; return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment