/**
  * Initializes the rendering surface parameters of {@code contentViewCore}. Note that this does
  * not size the actual {@link ContentViewCore}.
  *
  * @param contentViewCore The {@link ContentViewCore} to initialize.
  */
 private void initializeContentViewCore(ContentViewCore contentViewCore) {
   contentViewCore.setCurrentMotionEventOffsets(0.f, 0.f);
   contentViewCore.setTopControlsHeight(
       getTopControlsHeightPixels(), contentViewCore.doTopControlsShrinkBlinkSize());
   contentViewCore.onPhysicalBackingSizeChanged(
       mCompositorView.getWidth(), mCompositorView.getHeight());
   contentViewCore.onOverdrawBottomHeightChanged(mCompositorView.getOverdrawBottomHeight());
 }
  private void setContentViewMotionEventOffsets(MotionEvent e, boolean canClear) {
    // TODO(dtrainor): Factor this out to LayoutDriver.
    if (e == null || mTabVisible == null) return;

    ContentViewCore contentViewCore = mTabVisible.getContentViewCore();
    if (contentViewCore == null) return;

    int actionMasked = e.getActionMasked();

    if (SPenSupport.isSPenSupported(getContext())) {
      actionMasked = SPenSupport.convertSPenEventAction(actionMasked);
    }

    if (actionMasked == MotionEvent.ACTION_DOWN || actionMasked == MotionEvent.ACTION_HOVER_ENTER) {
      if (mLayoutManager != null) mLayoutManager.getViewportPixel(mCacheViewport);
      contentViewCore.setCurrentMotionEventOffsets(-mCacheViewport.left, -mCacheViewport.top);
    } else if (canClear
        && (actionMasked == MotionEvent.ACTION_UP
            || actionMasked == MotionEvent.ACTION_CANCEL
            || actionMasked == MotionEvent.ACTION_HOVER_EXIT)) {
      contentViewCore.setCurrentMotionEventOffsets(0.f, 0.f);
    }
  }