Java Code Examples for org.chromium.content.browser.ContentViewCore#onPhysicalBackingSizeChanged()

The following examples show how to use org.chromium.content.browser.ContentViewCore#onPhysicalBackingSizeChanged() . 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: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the physical backing size of a given ContentViewCore. This method will first check
 * if the ContentViewCore's client wants to override the size and, if so, it will use the
 * values provided by the {@link ContentViewClient#getDesiredWidthMeasureSpec()} and
 * {@link ContentViewClient#getDesiredHeightMeasureSpec()} methods. If no value is provided
 * in one of these methods, the values from the |width| and |height| arguments will be
 * used instead.
 *
 * @param contentViewCore The {@link ContentViewCore} to resize.
 * @param width The default width.
 * @param height The default height.
 */
private void adjustPhysicalBackingSize(ContentViewCore contentViewCore, int width, int height) {
    ContentViewClient client = contentViewCore.getContentViewClient();

    int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
    if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        width = MeasureSpec.getSize(desiredWidthMeasureSpec);
    }

    int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
    if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        height = MeasureSpec.getSize(desiredHeightMeasureSpec);
    }

    contentViewCore.onPhysicalBackingSizeChanged(width, height);
}
 
Example 2
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Adjusts the physical backing size of a given ContentViewCore. This method will first check
 * if the ContentViewCore's client wants to override the size and, if so, it will use the
 * values provided by the {@link ContentViewClient#getDesiredWidthMeasureSpec()} and
 * {@link ContentViewClient#getDesiredHeightMeasureSpec()} methods. If no value is provided
 * in one of these methods, the values from the |width| and |height| arguments will be
 * used instead.
 *
 * @param contentViewCore The {@link ContentViewCore} to resize.
 * @param width The default width.
 * @param height The default height.
 */
private void adjustPhysicalBackingSize(ContentViewCore contentViewCore, int width, int height) {
    ContentViewClient client = contentViewCore.getContentViewClient();

    int desiredWidthMeasureSpec = client.getDesiredWidthMeasureSpec();
    if (MeasureSpec.getMode(desiredWidthMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        width = MeasureSpec.getSize(desiredWidthMeasureSpec);
    }

    int desiredHeightMeasureSpec = client.getDesiredHeightMeasureSpec();
    if (MeasureSpec.getMode(desiredHeightMeasureSpec) != MeasureSpec.UNSPECIFIED) {
        height = MeasureSpec.getSize(desiredHeightMeasureSpec);
    }

    contentViewCore.onPhysicalBackingSizeChanged(width, height);
}
 
Example 3
Source File: OverlayPanel.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * 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 4
Source File: OverlayPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * 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 5
Source File: Tab.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
    }
}