Search in sources :

Example 1 with ContentViewCore

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

the class CompositorViewHolder method initializeTab.

/**
     * Sets the correct size for {@link View} on {@code tab} and sets the correct rendering
     * parameters on {@link ContentViewCore} on {@code tab}.
     * @param tab The {@link Tab} to initialize.
     */
private void initializeTab(Tab tab) {
    ContentViewCore content = tab.getActiveContentViewCore();
    if (content != null)
        initializeContentViewCore(content);
    View view = tab.getContentView();
    if (view != tab.getView() || !tab.isNativePage())
        setSizeOfUnattachedView(view);
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore) SurfaceView(android.view.SurfaceView) View(android.view.View) VirtualView(org.chromium.chrome.browser.compositor.layouts.components.VirtualView)

Example 2 with ContentViewCore

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

the class OverlayPanel method setBasePageTextControlsVisibility.

/**
     * Set the visibility of the base page text selection controls. This will also attempt to
     * remove focus from the base page to clear any open controls.
     * TODO(mdjones): This should be replaced with focusing the panel's ContentViewCore.
     * @param visible If the text controls are visible.
     */
protected void setBasePageTextControlsVisibility(boolean visible) {
    if (mActivity == null || mActivity.getActivityTab() == null)
        return;
    ContentViewCore baseContentView = mActivity.getActivityTab().getContentViewCore();
    if (baseContentView == null)
        return;
    // If the panel does not have focus or isn't open, return.
    if (isPanelOpened() && mDidClearTextControls && !visible)
        return;
    if (!isPanelOpened() && !mDidClearTextControls && visible)
        return;
    mDidClearTextControls = !visible;
    if (!visible) {
        baseContentView.preserveSelectionOnNextLossOfFocus();
        baseContentView.getContainerView().clearFocus();
    }
    baseContentView.updateTextSelectionUI(visible);
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore)

Example 3 with ContentViewCore

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

the class ChromeActivity method onBackPressed.

@Override
public final void onBackPressed() {
    RecordUserAction.record("SystemBack");
    if (mCompositorViewHolder != null) {
        LayoutManager layoutManager = mCompositorViewHolder.getLayoutManager();
        if (layoutManager != null && layoutManager.onBackPressed())
            return;
    }
    ContentViewCore contentViewCore = getContentViewCore();
    if (contentViewCore != null && contentViewCore.isSelectActionBarShowing()) {
        contentViewCore.clearSelection();
        return;
    }
    if (mContextualSearchManager != null && mContextualSearchManager.onBackPressed())
        return;
    if (handleBackPressed())
        return;
    super.onBackPressed();
}
Also used : LayoutManager(org.chromium.chrome.browser.compositor.layouts.LayoutManager) ContentViewCore(org.chromium.content.browser.ContentViewCore)

Example 4 with ContentViewCore

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

the class ContextualSearchManager method handleValidTap.

@Override
public void handleValidTap() {
    if (mIsAccessibilityModeEnabled)
        return;
    if (isTapSupported()) {
        // Here we are starting a new Contextual Search with a Tap gesture, therefore
        // we need to clear to properly reflect that a search just started and we don't
        // have the resolved search term yet.
        mSearchRequest = null;
        // Let the policy know that a tap gesture has been received.
        mPolicy.registerTap();
        ContentViewCore baseContentView = getBaseContentView();
        if (baseContentView != null)
            baseContentView.getWebContents().selectWordAroundCaret();
    }
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore)

Example 5 with ContentViewCore

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

the class ContextualSearchSelectionController method handleSelectionEvent.

/**
     * Handles a notification that a selection event took place.
     * @param eventType The type of event that took place.
     * @param posXPix The x coordinate of the selection start handle.
     * @param posYPix The y coordinate of the selection start handle.
     */
void handleSelectionEvent(int eventType, float posXPix, float posYPix) {
    boolean shouldHandleSelection = false;
    switch(eventType) {
        case SelectionEventType.SELECTION_HANDLES_SHOWN:
            if (!mIsContextMenuShown) {
                mWasTapGestureDetected = false;
                mSelectionType = SelectionType.LONG_PRESS;
                shouldHandleSelection = true;
                // Since we're showing pins, we don't care if the previous tap was invalid
                // anymore.
                unscheduleInvalidTapNotification();
            }
            break;
        case SelectionEventType.SELECTION_HANDLES_CLEARED:
            mHandler.handleSelectionDismissal();
            resetAllStates();
            break;
        case SelectionEventType.SELECTION_HANDLE_DRAG_STOPPED:
            shouldHandleSelection = mShouldHandleSelectionModification;
            break;
        case SelectionEventType.SELECTION_ESTABLISHED:
            mIsSelectionEstablished = true;
            break;
        case SelectionEventType.SELECTION_DISSOLVED:
            mIsSelectionEstablished = false;
            break;
        default:
    }
    if (shouldHandleSelection) {
        ContentViewCore baseContentView = getBaseContentView();
        if (baseContentView != null) {
            String selection = baseContentView.getSelectedText();
            if (selection != null) {
                mX = posXPix;
                mY = posYPix;
                mSelectedText = selection;
                handleSelection(selection, SelectionType.LONG_PRESS);
            }
        }
    }
}
Also used : ContentViewCore(org.chromium.content.browser.ContentViewCore)

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