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 {
// update.
mLayoutSizer.onSizeChanged(w, h, ow, oh);
nativeOnSizeChanged(mNativeAwContents, w, h, ow, oh);
mContentViewCore.onSizeChanged(w, h, ow, oh);
}
@Override
......
......@@ -512,8 +512,6 @@ public class OverlayPanelContent {
void onSizeChanged(int width, int height) {
if (mContentViewCore == null || getWebContents() == null) return;
getWebContents().setSize(width, height);
mContentViewCore.onSizeChanged(width, height, mContentViewCore.getViewportWidthPix(),
mContentViewCore.getViewportHeightPix());
}
void onPhysicalBackingSizeChanged(int width, int height) {
......
......@@ -2550,12 +2550,10 @@ public class Tab
destroyContentViewCore(deleteOldNativeWebContents);
NativePage previousNativePage = mNativePage;
mNativePage = null;
// Size of the new ContentViewCore is zero at this point. If we don't call onSizeChanged(),
// next onShow() call would send a resize message with the current ContentViewCore size
// (zero) to the renderer process, although the new size will be set soon.
// However, this size fluttering may confuse Blink and rendered result can be broken
// (see http://crbug.com/340987).
newContentViewCore.onSizeChanged(originalWidth, originalHeight, 0, 0);
// Size of the new content is zero at this point. Set the view size in advance
// so that next onShow() call won't send a resize message with zero size
// to the renderer process. This prevents the size fluttering that may confuse
// Blink and break rendered result (see http://crbug.com/340987).
newContentViewCore.getWebContents().setSize(originalWidth, originalHeight);
if (!bounds.isEmpty()) {
......@@ -3186,7 +3184,6 @@ public class Tab
Rect bounds = getEstimatedContentSize(context);
int width = bounds.right - bounds.left;
int height = bounds.bottom - bounds.top;
tab.getContentViewCore().onSizeChanged(width, height, 0, 0);
tab.getWebContents().setSize(width, height);
tab.detach();
......
......@@ -510,7 +510,6 @@ public class VrShellImpl
mContentVirtualDisplay.update(size, dpr, null, null, null, null, null);
assert mTab != null;
if (mTab.getContentViewCore() != null) {
mTab.getContentViewCore().onSizeChanged(surfaceWidth, surfaceHeight, 0, 0);
nativeOnPhysicalBackingSizeChanged(
mNativeVrShell, mTab.getWebContents(), surfaceWidth, surfaceHeight);
}
......@@ -605,7 +604,6 @@ public class VrShellImpl
if (mTab.getContentViewCore() != null) {
View parent = mTab.getContentViewCore().getContainerView();
mTab.getWebContents().setSize(parent.getWidth(), parent.getHeight());
mTab.getContentViewCore().onSizeChanged(parent.getWidth(), parent.getHeight(), 0, 0);
}
mTab.updateBrowserControlsState(BrowserControlsState.SHOWN, true);
......
......@@ -184,6 +184,14 @@ void ImeAdapterAndroid::UpdateState(const TextInputState& state) {
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(
const gfx::SelectionBound& selection_start,
float dip_scale,
......
......@@ -105,6 +105,7 @@ class CONTENT_EXPORT ImeAdapterAndroid : public RenderWidgetHostConnector {
}
void UpdateState(const TextInputState& state);
void UpdateAfterViewSizeChanged();
void AdvanceFocusInForm(JNIEnv*,
const base::android::JavaParamRef<jobject>&,
......
......@@ -2230,6 +2230,13 @@ void RenderWidgetHostViewAndroid::OnGestureEvent(
SendGestureEvent(web_gesture);
}
void RenderWidgetHostViewAndroid::OnSizeChanged() {
if (ime_adapter_android_)
ime_adapter_android_->UpdateAfterViewSizeChanged();
if (popup_zoomer_)
popup_zoomer_->HidePopup();
}
void RenderWidgetHostViewAndroid::OnPhysicalBackingSizeChanged() {
EvictFrameIfNecessary();
WasResized();
......
......@@ -199,6 +199,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAndroid
bool OnMouseEvent(const ui::MotionEventAndroid& m) override;
bool OnMouseWheelEvent(const ui::MotionEventAndroid& event) override;
bool OnGestureEvent(const ui::GestureEventAndroid& event) override;
void OnSizeChanged() override;
void OnPhysicalBackingSizeChanged() override;
// ui::ViewAndroidObserver implementation:
......
......@@ -127,17 +127,6 @@ public class ContentView extends FrameLayout
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
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return mContentViewCore.onCreateInputConnection(outAttrs);
......
......@@ -324,11 +324,6 @@ public interface ContentViewCore {
*/
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)
*/
......
......@@ -809,12 +809,6 @@ public class ContentViewCoreImpl
}
}
@SuppressWarnings("javadoc")
@Override
public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) {
updateAfterSizeChanged();
}
@CalledByNative
private void onTouchDown(MotionEvent event) {
if (mShouldRequestUnbufferedDispatch) requestUnbufferedDispatch(event);
......
......@@ -442,6 +442,25 @@ public class ImeAdapter {
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
public ResultReceiver getNewShowKeyboardReceiver() {
if (mShowKeyboardResultReceiver == null) {
......
......@@ -222,9 +222,6 @@ public class TestContentViewCore implements ContentViewCore {
@Override
public void onConfigurationChanged(Configuration newConfig) {}
@Override
public void onSizeChanged(int wPix, int hPix, int owPix, int ohPix) {}
@Override
public boolean onGenericMotionEvent(MotionEvent event) {
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