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;
}
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();
}
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;
}
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);
}
}
}
}
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);
}
Aggregations