Java Code Examples for org.chromium.content.browser.ContentViewCore#onSizeChanged()
The following examples show how to use
org.chromium.content.browser.ContentViewCore#onSizeChanged() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OverlayPanel.java From delion with Apache License 2.0 | 5 votes |
/** * Resize the panel's ContentViewCore manually since it is not attached to the view hierarchy. * TODO(mdjones): Remove the need for this method by supporting multiple ContentViewCores * existing simultaneously in the view hierarchy. * @param width The new width in dp. * @param height The new height in dp. */ private void resizePanelContentViewCore(float width, float height) { if (!isShowing()) return; ContentViewCore panelContent = getContentViewCore(); if (panelContent != null) { // Take the height of the toolbar into consideration. int toolbarHeightPx = getTopControlsOffsetDp() > 0 ? 0 : (int) (getToolbarHeight() / mPxToDp); panelContent.onSizeChanged((int) (width / mPxToDp), (int) (height / mPxToDp) + toolbarHeightPx, panelContent.getViewportWidthPix(), panelContent.getViewportHeightPix()); panelContent.onPhysicalBackingSizeChanged( (int) (width / mPxToDp), (int) (height / mPxToDp)); } }
Example 2
Source File: OverlayPanel.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Resize the panel's ContentViewCore manually since it is not attached to the view hierarchy. * TODO(mdjones): Remove the need for this method by supporting multiple ContentViewCores * existing simultaneously in the view hierarchy. * @param width The new width in dp. * @param height The new height in dp. */ protected void resizePanelContentViewCore(float width, float height) { if (!isShowing()) return; ContentViewCore panelContent = getContentViewCore(); if (panelContent != null) { panelContent.onSizeChanged((int) (width / mPxToDp), (int) (height / mPxToDp), panelContent.getViewportWidthPix(), panelContent.getViewportHeightPix()); panelContent.onPhysicalBackingSizeChanged( (int) (width / mPxToDp), (int) (height / mPxToDp)); } }
Example 3
Source File: Tab.java From 365browser with Apache License 2.0 | 5 votes |
/** * Called to swap out the current view with the one passed in. * * @param newContentViewCore The content view that should be swapped into the tab. * @param deleteOldNativeWebContents Whether to delete the native web * contents of old view. * @param didStartLoad Whether * WebContentsObserver::DidStartProvisionalLoadForFrame() has * already been called. * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has * already been called. */ public void swapContentViewCore(ContentViewCore newContentViewCore, boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) { int originalWidth = 0; int originalHeight = 0; if (mContentViewCore != null) { originalWidth = mContentViewCore.getViewportWidthPix(); originalHeight = mContentViewCore.getViewportHeightPix(); mContentViewCore.onHide(); } Rect bounds = new Rect(); if (originalWidth == 0 && originalHeight == 0) { bounds = ExternalPrerenderHandler.estimateContentSize( (Application) getApplicationContext(), false); originalWidth = bounds.right - bounds.left; originalHeight = bounds.bottom - bounds.top; } 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); if (!bounds.isEmpty()) { nativeOnPhysicalBackingSizeChanged(mNativeTabAndroid, newContentViewCore.getWebContents(), bounds.right, bounds.bottom); } newContentViewCore.onShow(); setContentViewCore(newContentViewCore); destroyNativePageInternal(previousNativePage); for (TabObserver observer : mObservers) { observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad); } }
Example 4
Source File: Tab.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Called to swap out the current view with the one passed in. * * @param newContentViewCore The content view that should be swapped into the tab. * @param deleteOldNativeWebContents Whether to delete the native web * contents of old view. * @param didStartLoad Whether * WebContentsObserver::DidStartProvisionalLoadForFrame() has * already been called. * @param didFinishLoad Whether WebContentsObserver::DidFinishLoad() has * already been called. */ public void swapContentViewCore(ContentViewCore newContentViewCore, boolean deleteOldNativeWebContents, boolean didStartLoad, boolean didFinishLoad) { int originalWidth = 0; int originalHeight = 0; if (mContentViewCore != null) { originalWidth = mContentViewCore.getViewportWidthPix(); originalHeight = mContentViewCore.getViewportHeightPix(); mContentViewCore.onHide(); } Rect bounds = new Rect(); if (originalWidth == 0 && originalHeight == 0) { bounds = ExternalPrerenderHandler.estimateContentSize( (Application) getApplicationContext(), false); originalWidth = bounds.right - bounds.left; originalHeight = bounds.bottom - bounds.top; } 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); if (!bounds.isEmpty()) { newContentViewCore.onPhysicalBackingSizeChanged(bounds.right, bounds.bottom); } newContentViewCore.onShow(); setContentViewCore(newContentViewCore); mContentViewCore.attachImeAdapter(); // If the URL has already committed (e.g. prerendering), tell process management logic that // it can rely on the process visibility signal for binding management. // TODO: Call ChildProcessLauncher#determinedVisibility() at a more intuitive time. // See crbug.com/537671 if (!mContentViewCore.getWebContents().getLastCommittedUrl().equals("")) { ChildProcessLauncher.determinedVisibility(mContentViewCore.getCurrentRenderProcessId()); } destroyNativePageInternal(previousNativePage); for (TabObserver observer : mObservers) { observer.onWebContentsSwapped(this, didStartLoad, didFinishLoad); } }