Search in sources :

Example 21 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class CompositorViewHolder method dispatchDragEvent.

@Override
public boolean dispatchDragEvent(DragEvent e) {
    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null)
        return false;
    if (mLayoutManager != null)
        mLayoutManager.getViewportPixel(mCacheViewport);
    contentViewCore.setCurrentTouchEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    boolean ret = super.dispatchDragEvent(e);
    int action = e.getAction();
    if (action == DragEvent.ACTION_DRAG_EXITED || action == DragEvent.ACTION_DRAG_ENDED || action == DragEvent.ACTION_DROP) {
        contentViewCore.setCurrentTouchEventOffsets(0.f, 0.f);
    }
    return ret;
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) Paint(android.graphics.Paint)

Example 22 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class OverlayPanelEventFilter method propagateEventToContentViewCore.

/**
     * Propagates the given {@link MotionEvent} to the {@link ContentViewCore}.
     * @param e The {@link MotionEvent} to be propagated.
     */
protected void propagateEventToContentViewCore(MotionEvent e) {
    MotionEvent event = e;
    int action = event.getActionMasked();
    boolean isSyntheticEvent = false;
    if (mGestureOrientation == GestureOrientation.HORIZONTAL && !mPanel.isMaximized()) {
        // Ignores multitouch events to prevent the Content View from scrolling.
        if (action == MotionEvent.ACTION_POINTER_UP || action == MotionEvent.ACTION_POINTER_DOWN) {
            return;
        }
        // NOTE(pedrosimonetti): Lock horizontal motion, ignoring all vertical changes,
        // when the Panel is not maximized. This is to prevent the Content View
        // from scrolling when side swiping on the expanded Panel. Also, note that the
        // method {@link OverlayPanelEventFilter#lockEventHorizontallty} will always
        // return an event with a single pointer, which is necessary to prevent
        // the app from crashing when the motion involves multiple pointers.
        // See: crbug.com/486901
        event = MotionEvent.obtain(e.getDownTime(), e.getEventTime(), // may have the pointer Id associated to it.
        e.getActionMasked(), e.getX(), mInitialEventY, e.getMetaState());
        isSyntheticEvent = true;
    }
    final float contentViewOffsetXPx = mPanel.getContentX() / mPxToDp;
    final float contentViewOffsetYPx = mPanel.getContentY() / mPxToDp;
    // Adjust the offset to be relative to the Content View.
    event.offsetLocation(-contentViewOffsetXPx, -contentViewOffsetYPx);
    // Get the container view to propagate the event to.
    ContentViewCore cvc = mPanel.getContentViewCore();
    ViewGroup containerView = cvc == null ? null : cvc.getContainerView();
    boolean wasEventCanceled = false;
    if (mWasActionDownEventSynthetic && action == MotionEvent.ACTION_UP) {
        float deltaX = event.getX() - mSyntheticActionDownX;
        float deltaY = event.getY() - mSyntheticActionDownY;
        // Content View. See crbug.com/408654
        if (!isDistanceGreaterThanTouchSlop(deltaX, deltaY)) {
            event.setAction(MotionEvent.ACTION_CANCEL);
            if (containerView != null)
                containerView.dispatchTouchEvent(event);
            wasEventCanceled = true;
        }
    } else if (action == MotionEvent.ACTION_DOWN) {
        mPanel.onTouchSearchContentViewAck();
    }
    if (!wasEventCanceled && containerView != null)
        containerView.dispatchTouchEvent(event);
    // Synthetic events should be recycled.
    if (isSyntheticEvent)
        event.recycle();
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) ViewGroup(android.view.ViewGroup) MotionEvent(android.view.MotionEvent)

Example 23 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class LayoutManagerDocument method getCurrentTabContentViewCore.

private ContentViewCore getCurrentTabContentViewCore() {
    if (getTabModelSelector() == null)
        return null;
    Tab tab = getTabModelSelector().getCurrentTab();
    if (tab == null)
        return null;
    ContentViewCore cvc = tab.getContentViewCore();
    return cvc;
}
Also used : LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) Tab(org.chromium.chrome.browser.tab.Tab) ContentViewCore(org.chromium.content.browser.ContentViewCore)

Example 24 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class LayoutManagerDocumentTabSwitcher method toggleOverview.

public void toggleOverview() {
    Tab tab = getTabModelSelector().getCurrentTab();
    ContentViewCore contentViewCore = tab != null ? tab.getContentViewCore() : null;
    if (!overviewVisible()) {
        mHost.hideKeyboard(new Runnable() {

            @Override
            public void run() {
                showOverview(true);
            }
        });
        if (contentViewCore != null) {
            contentViewCore.setAccessibilityState(false);
        }
    } else {
        Layout activeLayout = getActiveLayout();
        if (activeLayout instanceof StackLayout) {
            ((StackLayout) activeLayout).commitOutstandingModelState(LayoutManager.time());
        }
        if (getTabModelSelector().getCurrentModel().getCount() != 0) {
            // Don't hide overview if current tab stack is empty()
            hideOverview(true);
            // hideOverview could change the current tab.  Update the local variables.
            tab = getTabModelSelector().getCurrentTab();
            contentViewCore = tab != null ? tab.getContentViewCore() : null;
            if (contentViewCore != null) {
                contentViewCore.setAccessibilityState(true);
            }
        }
    }
}
Also used : Tab(org.chromium.chrome.browser.tab.Tab) LayoutTab(org.chromium.chrome.browser.compositor.layouts.components.LayoutTab) ContentViewCore(org.chromium.content.browser.ContentViewCore) OverviewListLayout(org.chromium.chrome.browser.widget.OverviewListLayout) StackLayout(org.chromium.chrome.browser.compositor.layouts.phone.StackLayout) StackLayout(org.chromium.chrome.browser.compositor.layouts.phone.StackLayout)

Example 25 with ContentViewCore

use of org.chromium.content.browser.ContentViewCore in project AndroidChromium by JackyAndroid.

the class ReaderModePanel method createNewOverlayPanelContent.

@Override
public OverlayPanelContent createNewOverlayPanelContent() {
    OverlayContentDelegate delegate = new OverlayContentDelegate() {

        /**
             * Track if a navigation/load is the first one for this content.
             */
        private boolean mIsInitialLoad = true;

        @Override
        public void onContentViewCreated(ContentViewCore contentView) {
            mContentViewDelegate.setOverlayPanelContentViewCore(contentView);
            WebContents distilledWebContents = contentView.getWebContents();
            if (distilledWebContents == null)
                return;
            WebContents sourceWebContents = mManagerDelegate.getBasePageWebContents();
            if (sourceWebContents == null)
                return;
            DomDistillerTabUtils.distillAndView(sourceWebContents, distilledWebContents);
        }

        @Override
        public void onContentViewDestroyed() {
            mContentViewDelegate.releaseOverlayPanelContentViewCore();
            mIsInitialLoad = true;
        }

        @Override
        public boolean shouldInterceptNavigation(ExternalNavigationHandler externalNavHandler, NavigationParams navigationParams) {
            // clicks.
            if (mIsInitialLoad) {
                mIsInitialLoad = false;
                return true;
            }
            if (!navigationParams.isExternalProtocol) {
                mManagerDelegate.createNewTab(navigationParams.url);
                return false;
            }
            return true;
        }
    };
    return new OverlayPanelContent(delegate, new OverlayContentProgressObserver(), mActivity);
}
Also used : WebContents(org.chromium.content_public.browser.WebContents) OverlayContentProgressObserver(org.chromium.chrome.browser.compositor.bottombar.OverlayContentProgressObserver) ExternalNavigationHandler(org.chromium.chrome.browser.externalnav.ExternalNavigationHandler) ContentViewCore(org.chromium.content.browser.ContentViewCore) OverlayContentDelegate(org.chromium.chrome.browser.compositor.bottombar.OverlayContentDelegate) OverlayPanelContent(org.chromium.chrome.browser.compositor.bottombar.OverlayPanelContent) NavigationParams(org.chromium.components.navigation_interception.NavigationParams)

Aggregations

ContentViewCore (org.chromium.content.browser.ContentViewCore)32 View (android.view.View)5 Tab (org.chromium.chrome.browser.tab.Tab)4 WindowAndroid (org.chromium.ui.base.WindowAndroid)4 ViewGroup (android.view.ViewGroup)3 ContentView (org.chromium.content.browser.ContentView)3 Paint (android.graphics.Paint)2 FrameLayout (android.widget.FrameLayout)2 CalledByNative (org.chromium.base.annotations.CalledByNative)2 LayoutTab (org.chromium.chrome.browser.compositor.layouts.components.LayoutTab)2 StackLayout (org.chromium.chrome.browser.compositor.layouts.phone.StackLayout)2 WebContents (org.chromium.content_public.browser.WebContents)2 SuppressLint (android.annotation.SuppressLint)1 Activity (android.app.Activity)1 Nullable (android.support.annotation.Nullable)1 CoordinatorLayout (android.support.design.widget.CoordinatorLayout)1 MotionEvent (android.view.MotionEvent)1 SurfaceView (android.view.SurfaceView)1 OnLayoutChangeListener (android.view.View.OnLayoutChangeListener)1 LayoutParams (android.view.ViewGroup.LayoutParams)1