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

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

Issue 476113004: Replace overdraw_bottom_height with top_controls_layout_height. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ScrollViewportRounding test Created 6 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser; 5 package org.chromium.content.browser;
6 6
7 import android.annotation.SuppressLint; 7 import android.annotation.SuppressLint;
8 import android.app.Activity; 8 import android.app.Activity;
9 import android.app.SearchManager; 9 import android.app.SearchManager;
10 import android.content.ClipboardManager; 10 import android.content.ClipboardManager;
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 253
254 private PopupTouchHandleDrawableDelegate mTouchHandleDelegate; 254 private PopupTouchHandleDrawableDelegate mTouchHandleDelegate;
255 255
256 private PositionObserver mPositionObserver; 256 private PositionObserver mPositionObserver;
257 257
258 // Size of the viewport in physical pixels as set from onSizeChanged. 258 // Size of the viewport in physical pixels as set from onSizeChanged.
259 private int mViewportWidthPix; 259 private int mViewportWidthPix;
260 private int mViewportHeightPix; 260 private int mViewportHeightPix;
261 private int mPhysicalBackingWidthPix; 261 private int mPhysicalBackingWidthPix;
262 private int mPhysicalBackingHeightPix; 262 private int mPhysicalBackingHeightPix;
263 private int mOverdrawBottomHeightPix; 263 private int mTopControlsLayoutHeightPix;
264 private int mViewportSizeOffsetWidthPix;
265 private int mViewportSizeOffsetHeightPix;
266 264
267 // Cached copy of all positions and scales as reported by the renderer. 265 // Cached copy of all positions and scales as reported by the renderer.
268 private final RenderCoordinates mRenderCoordinates; 266 private final RenderCoordinates mRenderCoordinates;
269 267
270 // Tracks whether a selection is currently active. When applied to selected text, indicates 268 // Tracks whether a selection is currently active. When applied to selected text, indicates
271 // whether the last selected text is still highlighted. 269 // whether the last selected text is still highlighted.
272 private boolean mHasSelection; 270 private boolean mHasSelection;
273 private boolean mHasInsertion; 271 private boolean mHasInsertion;
274 private String mLastSelectedText; 272 private String mLastSelectedText;
275 private boolean mFocusedNodeEditable; 273 private boolean mFocusedNodeEditable;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 return mContainerView; 388 return mContainerView;
391 } 389 }
392 390
393 /** 391 /**
394 * @return The WebContents currently being rendered. 392 * @return The WebContents currently being rendered.
395 */ 393 */
396 public WebContents getWebContents() { 394 public WebContents getWebContents() {
397 return mWebContents; 395 return mWebContents;
398 } 396 }
399 397
398 /* TODO(aelias): Remove this after downstream callers switch to setTopContro lsLayoutHeight. */
399 public void setViewportSizeOffset(int offsetXPix, int offsetYPix) {
400 setTopControlsLayoutHeight(offsetYPix);
401 }
402
400 /** 403 /**
401 * Specifies how much smaller the WebKit layout size should be relative to t he size of this 404 * Specifies how much smaller the Blink layout size should be relative to th e size of this
402 * view. 405 * view.
403 * @param offsetXPix The X amount in pixels to shrink the viewport by. 406 * @param topControlsLayoutHeightPix The Y amount in pixels to shrink the vi ewport by.
404 * @param offsetYPix The Y amount in pixels to shrink the viewport by.
405 */ 407 */
406 public void setViewportSizeOffset(int offsetXPix, int offsetYPix) { 408 public void setTopControlsLayoutHeight(int topControlsLayoutHeightPix) {
407 if (offsetXPix != mViewportSizeOffsetWidthPix || 409 if (topControlsLayoutHeightPix != mTopControlsLayoutHeightPix) {
408 offsetYPix != mViewportSizeOffsetHeightPix) { 410 mTopControlsLayoutHeightPix = topControlsLayoutHeightPix;
409 mViewportSizeOffsetWidthPix = offsetXPix;
410 mViewportSizeOffsetHeightPix = offsetYPix;
411 if (mNativeContentViewCore != 0) nativeWasResized(mNativeContentView Core); 411 if (mNativeContentViewCore != 0) nativeWasResized(mNativeContentView Core);
412 } 412 }
413 } 413 }
414 414
415 /** 415 /**
416 * Returns a delegate that can be used to add and remove views from the Cont ainerView. 416 * Returns a delegate that can be used to add and remove views from the Cont ainerView.
417 * 417 *
418 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same 418 * NOTE: Use with care, as not all ContentViewCore users setup their Contain erView in the same
419 * way. In particular, the Android WebView has limitations on what implement ation details can 419 * way. In particular, the Android WebView has limitations on what implement ation details can
420 * be provided via a child view, as they are visible in the API and could in troduce 420 * be provided via a child view, as they are visible in the API and could in troduce
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 @CalledByNative 925 @CalledByNative
926 public int getPhysicalBackingWidthPix() { return mPhysicalBackingWidthPix; } 926 public int getPhysicalBackingWidthPix() { return mPhysicalBackingWidthPix; }
927 927
928 /** 928 /**
929 * @return Height of underlying physical surface. 929 * @return Height of underlying physical surface.
930 */ 930 */
931 @CalledByNative 931 @CalledByNative
932 public int getPhysicalBackingHeightPix() { return mPhysicalBackingHeightPix; } 932 public int getPhysicalBackingHeightPix() { return mPhysicalBackingHeightPix; }
933 933
934 /** 934 /**
935 * @return Amount the output surface extends past the bottom of the window v iewport. 935 * @return The amount that the viewport size given to Blink is shrunk by the URL-bar..
936 */ 936 */
937 @CalledByNative 937 @CalledByNative
938 public int getOverdrawBottomHeightPix() { return mOverdrawBottomHeightPix; } 938 public int getTopControlsLayoutHeightPix() { return mTopControlsLayoutHeight Pix; }
939
940 /**
941 * @return The amount to shrink the viewport relative to {@link #getViewport WidthPix()}.
942 */
943 @CalledByNative
944 public int getViewportSizeOffsetWidthPix() { return mViewportSizeOffsetWidth Pix; }
945
946 /**
947 * @return The amount to shrink the viewport relative to {@link #getViewport HeightPix()}.
948 */
949 @CalledByNative
950 public int getViewportSizeOffsetHeightPix() { return mViewportSizeOffsetHeig htPix; }
951 939
952 /** 940 /**
953 * @see android.webkit.WebView#getContentHeight() 941 * @see android.webkit.WebView#getContentHeight()
954 */ 942 */
955 public float getContentHeightCss() { 943 public float getContentHeightCss() {
956 return mRenderCoordinates.getContentHeightCss(); 944 return mRenderCoordinates.getContentHeightCss();
957 } 945 }
958 946
959 /** 947 /**
960 * @see android.webkit.WebView#getContentWidth() 948 * @see android.webkit.WebView#getContentWidth()
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1573 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return; 1561 if (mPhysicalBackingWidthPix == wPix && mPhysicalBackingHeightPix == hPi x) return;
1574 1562
1575 mPhysicalBackingWidthPix = wPix; 1563 mPhysicalBackingWidthPix = wPix;
1576 mPhysicalBackingHeightPix = hPix; 1564 mPhysicalBackingHeightPix = hPix;
1577 1565
1578 if (mNativeContentViewCore != 0) { 1566 if (mNativeContentViewCore != 0) {
1579 nativeWasResized(mNativeContentViewCore); 1567 nativeWasResized(mNativeContentViewCore);
1580 } 1568 }
1581 } 1569 }
1582 1570
1583 /** 1571 /* TODO(aelias): Remove this after downstream callers disappear. */
1584 * Called when the amount the surface is overdrawing off the bottom has chan ged.
1585 * @param overdrawHeightPix The overdraw height.
1586 */
1587 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) { 1572 public void onOverdrawBottomHeightChanged(int overdrawHeightPix) {
1588 if (mOverdrawBottomHeightPix == overdrawHeightPix) return;
1589
1590 mOverdrawBottomHeightPix = overdrawHeightPix;
1591
1592 if (mNativeContentViewCore != 0) {
1593 nativeWasResized(mNativeContentViewCore);
1594 }
1595 } 1573 }
1596 1574
1597 private void updateAfterSizeChanged() { 1575 private void updateAfterSizeChanged() {
1598 mPopupZoomer.hide(false); 1576 mPopupZoomer.hide(false);
1599 1577
1600 // Execute a delayed form focus operation because the OSK was brought 1578 // Execute a delayed form focus operation because the OSK was brought
1601 // up earlier. 1579 // up earlier.
1602 if (!mFocusPreOSKViewportRect.isEmpty()) { 1580 if (!mFocusPreOSKViewportRect.isEmpty()) {
1603 Rect rect = new Rect(); 1581 Rect rect = new Rect();
1604 getContainerView().getWindowVisibleDisplayFrame(rect); 1582 getContainerView().getWindowVisibleDisplayFrame(rect);
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 getContentViewClient().onImeStateChangeRequested(false); 2191 getContentViewClient().onImeStateChangeRequested(false);
2214 } 2192 }
2215 2193
2216 @SuppressWarnings("unused") 2194 @SuppressWarnings("unused")
2217 @CalledByNative 2195 @CalledByNative
2218 private void updateFrameInfo( 2196 private void updateFrameInfo(
2219 float scrollOffsetX, float scrollOffsetY, 2197 float scrollOffsetX, float scrollOffsetY,
2220 float pageScaleFactor, float minPageScaleFactor, float maxPageScaleF actor, 2198 float pageScaleFactor, float minPageScaleFactor, float maxPageScaleF actor,
2221 float contentWidth, float contentHeight, 2199 float contentWidth, float contentHeight,
2222 float viewportWidth, float viewportHeight, 2200 float viewportWidth, float viewportHeight,
2223 float controlsOffsetYCss, float contentOffsetYCss, 2201 float controlsOffsetYCss, float contentOffsetYCss) {
2224 float overdrawBottomHeightCss) {
2225 TraceEvent.begin("ContentViewCore:updateFrameInfo"); 2202 TraceEvent.begin("ContentViewCore:updateFrameInfo");
2226 // Adjust contentWidth/Height to be always at least as big as 2203 // Adjust contentWidth/Height to be always at least as big as
2227 // the actual viewport (as set by onSizeChanged). 2204 // the actual viewport (as set by onSizeChanged).
2228 final float deviceScale = mRenderCoordinates.getDeviceScaleFactor(); 2205 final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
2229 contentWidth = Math.max(contentWidth, 2206 contentWidth = Math.max(contentWidth,
2230 mViewportWidthPix / (deviceScale * pageScaleFactor)); 2207 mViewportWidthPix / (deviceScale * pageScaleFactor));
2231 contentHeight = Math.max(contentHeight, 2208 contentHeight = Math.max(contentHeight,
2232 mViewportHeightPix / (deviceScale * pageScaleFactor)); 2209 mViewportHeightPix / (deviceScale * pageScaleFactor));
2233 final float contentOffsetYPix = mRenderCoordinates.fromDipToPix(contentO ffsetYCss); 2210 final float contentOffsetYPix = mRenderCoordinates.fromDipToPix(contentO ffsetYCss);
2234 2211
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2273 mGestureStateListenersIterator.next().onScrollOffsetOrExtentChan ged( 2250 mGestureStateListenersIterator.next().onScrollOffsetOrExtentChan ged(
2274 computeVerticalScrollOffset(), 2251 computeVerticalScrollOffset(),
2275 computeVerticalScrollExtent()); 2252 computeVerticalScrollExtent());
2276 } 2253 }
2277 } 2254 }
2278 2255
2279 if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls(); 2256 if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls();
2280 2257
2281 // Update offsets for fullscreen. 2258 // Update offsets for fullscreen.
2282 final float controlsOffsetPix = controlsOffsetYCss * deviceScale; 2259 final float controlsOffsetPix = controlsOffsetYCss * deviceScale;
2283 final float overdrawBottomHeightPix = overdrawBottomHeightCss * deviceSc ale; 2260 // TODO(aelias): Remove last argument after downstream removes it.
2284 getContentViewClient().onOffsetsForFullscreenChanged( 2261 getContentViewClient().onOffsetsForFullscreenChanged(
2285 controlsOffsetPix, contentOffsetYPix, overdrawBottomHeightPix); 2262 controlsOffsetPix, contentOffsetYPix, 0);
2286 2263
2287 if (mBrowserAccessibilityManager != null) { 2264 if (mBrowserAccessibilityManager != null) {
2288 mBrowserAccessibilityManager.notifyFrameInfoInitialized(); 2265 mBrowserAccessibilityManager.notifyFrameInfoInitialized();
2289 } 2266 }
2290 TraceEvent.end("ContentViewCore:updateFrameInfo"); 2267 TraceEvent.end("ContentViewCore:updateFrameInfo");
2291 } 2268 }
2292 2269
2293 @CalledByNative 2270 @CalledByNative
2294 private void updateImeAdapter(long nativeImeAdapterAndroid, int textInputTyp e, 2271 private void updateImeAdapter(long nativeImeAdapterAndroid, int textInputTyp e,
2295 int textInputFlags, String text, int selectionStart, int selectionEn d, 2272 int textInputFlags, String text, int selectionStart, int selectionEn d,
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
3207 private native void nativeWasResized(long nativeContentViewCoreImpl); 3184 private native void nativeWasResized(long nativeContentViewCoreImpl);
3208 3185
3209 private native void nativeSetAccessibilityEnabled( 3186 private native void nativeSetAccessibilityEnabled(
3210 long nativeContentViewCoreImpl, boolean enabled); 3187 long nativeContentViewCoreImpl, boolean enabled);
3211 3188
3212 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, 3189 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l,
3213 int x, int y, int w, int h); 3190 int x, int y, int w, int h);
3214 3191
3215 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); 3192 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque);
3216 } 3193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698