private final RenderCoordinates.NormalizedPoint mEndHandlePoint;
private final RenderCoordinates.NormalizedPoint mInsertionHandlePoint;
- // Cached copy of the visible rectangle defined by two points. Needed to determine
- // visibility of insertion/selection handles.
- private final RenderCoordinates.NormalizedPoint mTopLeftVisibilityClippingPoint;
- private final RenderCoordinates.NormalizedPoint mBottomRightVisibilityClippingPoint;
-
// Tracks whether a selection is currently active. When applied to selected text, indicates
// whether the last selected text is still highlighted.
private boolean mHasSelection;
mStartHandlePoint = mRenderCoordinates.createNormalizedPoint();
mEndHandlePoint = mRenderCoordinates.createNormalizedPoint();
mInsertionHandlePoint = mRenderCoordinates.createNormalizedPoint();
- mTopLeftVisibilityClippingPoint = mRenderCoordinates.createNormalizedPoint();
- mBottomRightVisibilityClippingPoint = mRenderCoordinates.createNormalizedPoint();
mAccessibilityManager = (AccessibilityManager)
getContext().getSystemService(Context.ACCESSIBILITY_SERVICE);
mGestureStateListeners = new ObserverList<GestureStateListener>();
@Override
public void didStartLoading(String url) {
hidePopupDialog();
+ resetScrollInProgress();
resetGestureDetectors();
}
};
@SuppressWarnings("unused")
@CalledByNative
private void onScrollEndEventAck() {
+ if (!mTouchScrollInProgress) return;
mTouchScrollInProgress = false;
updateGestureStateListener(GestureEventType.SCROLL_END);
}
};
mSelectionHandleController.hideAndDisallowAutomaticShowing();
- updateInsertionSelectionVisibleBounds();
}
return mSelectionHandleController;
};
mInsertionHandleController.hideAndDisallowAutomaticShowing();
- updateInsertionSelectionVisibleBounds();
}
return mInsertionHandleController;
TraceEvent.instant("ContentViewCore:updateFrameInfo");
// Adjust contentWidth/Height to be always at least as big as
// the actual viewport (as set by onSizeChanged).
+ final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
contentWidth = Math.max(contentWidth,
- mRenderCoordinates.fromPixToLocalCss(mViewportWidthPix));
+ mViewportWidthPix / (deviceScale * pageScaleFactor));
contentHeight = Math.max(contentHeight,
- mRenderCoordinates.fromPixToLocalCss(mViewportHeightPix));
-
+ mViewportHeightPix / (deviceScale * pageScaleFactor));
final float contentOffsetYPix = mRenderCoordinates.fromDipToPix(contentOffsetYCss);
final boolean contentSizeChanged =
if (contentOffsetChanged) updateHandleScreenPositions();
// Update offsets for fullscreen.
- final float deviceScale = mRenderCoordinates.getDeviceScaleFactor();
final float controlsOffsetPix = controlsOffsetYCss * deviceScale;
final float overdrawBottomHeightPix = overdrawBottomHeightCss * deviceScale;
getContentViewClient().onOffsetsForFullscreenChanged(
}
}
- @CalledByNative
- private void setSelectionRootBounds(Rect bounds) {
- mTopLeftVisibilityClippingPoint.setLocalDip(bounds.left, bounds.top);
- mBottomRightVisibilityClippingPoint.setLocalDip(bounds.right, bounds.bottom);
- updateInsertionSelectionVisibleBounds();
- }
-
- private void updateInsertionSelectionVisibleBounds() {
- if (mSelectionHandleController == null && mInsertionHandleController == null) {
- return;
- }
-
- int x1 = Math.round(mTopLeftVisibilityClippingPoint.getXPix());
- int y1 = Math.round(mTopLeftVisibilityClippingPoint.getYPix());
- int x2 = Math.round(mBottomRightVisibilityClippingPoint.getXPix());
- int y2 = Math.round(mBottomRightVisibilityClippingPoint.getYPix());
-
- if (mSelectionHandleController != null) {
- mSelectionHandleController.setVisibleClippingRectangle(x1, y1, x2, y2);
- }
-
- if (mInsertionHandleController != null) {
- mInsertionHandleController.setVisibleClippingRectangle(x1, y1, x2, y2);
- }
- }
-
@SuppressWarnings("unused")
@CalledByNative
private static void onEvaluateJavaScriptResult(
*/
public boolean isDeviceAccessibilityScriptInjectionEnabled() {
try {
- if (!CommandLine.getInstance().hasSwitch(
- ContentSwitches.ENABLE_ACCESSIBILITY_SCRIPT_INJECTION)) {
+ // On JellyBean and higher, native accessibility is the default so script
+ // injection is only allowed if enabled via a flag.
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN &&
+ !CommandLine.getInstance().hasSwitch(
+ ContentSwitches.ENABLE_ACCESSIBILITY_SCRIPT_INJECTION)) {
return false;
}
}
/**
+ * Returns true if accessibility is on and touch exploration is enabled.
+ */
+ public boolean isTouchExplorationEnabled() {
+ return mTouchExplorationEnabled;
+ }
+
+ /**
* Turns browser accessibility on or off.
* If |state| is |false|, this turns off both native and injected accessibility.
* Otherwise, if accessibility script injection is enabled, this will enable the injected
return mContainerView.performLongClick();
}
+ /**
+ * Reset scroll and fling accounting, notifying listeners as appropriate.
+ * This is useful as a failsafe when the input stream may have been interruped.
+ */
+ private void resetScrollInProgress() {
+ if (!isScrollInProgress()) return;
+
+ final boolean touchScrollInProgress = mTouchScrollInProgress;
+ final int potentiallyActiveFlingCount = mPotentiallyActiveFlingCount;
+
+ mTouchScrollInProgress = false;
+ mPotentiallyActiveFlingCount = 0;
+
+ if (touchScrollInProgress) updateGestureStateListener(GestureEventType.SCROLL_END);
+ if (potentiallyActiveFlingCount > 0) updateGestureStateListener(GestureEventType.FLING_END);
+ }
+
private native long nativeInit(long webContentsPtr,
long viewAndroidPtr, long windowAndroidPtr);
// Note that mTouchScrollInProgress should normally be false at this
// point, but we reset it anyway as another failsafe.
mTouchScrollInProgress = false;
- if (mPotentiallyActiveFlingCount > 0) mPotentiallyActiveFlingCount--;
+ if (mPotentiallyActiveFlingCount <= 0) return;
+ mPotentiallyActiveFlingCount--;
updateGestureStateListener(GestureEventType.FLING_END);
}