Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1317)

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 1907703002: Fix a nasty scroll bug for Chrome Now-on-tap feature. Also combine the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: further cleanup Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 554ab09cbff1b135b48e8de8b8445378ef5f9bec..ed4f314da33fde8d97bd5169427e57cdf289657c 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -3060,45 +3060,54 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
@TargetApi(Build.VERSION_CODES.M)
- public void onProvideVirtualStructure(final ViewStructure structure) {
+ public void onProvideVirtualStructure(
+ final ViewStructure structure, final boolean ignoreScrollOffset) {
// Do not collect accessibility tree in incognito mode
if (getWebContents().isIncognito()) {
structure.setChildCount(0);
return;
}
-
structure.setChildCount(1);
final ViewStructure viewRoot = structure.asyncNewChild(0);
- getWebContents().requestAccessibilitySnapshot(
- new AccessibilitySnapshotCallback() {
- @Override
- public void onAccessibilitySnapshot(AccessibilitySnapshotNode root) {
- viewRoot.setClassName("");
- if (root == null) {
- viewRoot.asyncCommit();
- return;
- }
- createVirtualStructure(viewRoot, root, 0, 0);
- }
- },
- mRenderCoordinates.getContentOffsetYPix() - mRenderCoordinates.getScrollYPix(),
- mRenderCoordinates.getScrollXPix());
+ getWebContents().requestAccessibilitySnapshot(new AccessibilitySnapshotCallback() {
+ @Override
+ public void onAccessibilitySnapshot(AccessibilitySnapshotNode root) {
+ viewRoot.setClassName("");
+ if (root == null) {
+ viewRoot.asyncCommit();
+ return;
+ }
+ createVirtualStructure(viewRoot, root, ignoreScrollOffset);
+ }
+ });
}
// When creating the View structure, the left and top are relative to the parent node.
- // The X scroll is not used, rather compensated through X-position, while the Y scroll
- // is provided.
@TargetApi(Build.VERSION_CODES.M)
private void createVirtualStructure(ViewStructure viewNode, AccessibilitySnapshotNode node,
- int parentX, int parentY) {
+ final boolean ignoreScrollOffset) {
viewNode.setClassName(node.className);
if (node.hasSelection) {
viewNode.setText(node.text, node.startSelection, node.endSelection);
} else {
viewNode.setText(node.text);
}
- viewNode.setDimens(node.x - parentX - node.scrollX, node.y - parentY, 0, node.scrollY,
- node.width, node.height);
+ int left = (int) mRenderCoordinates.fromLocalCssToPix(node.x);
+ int top = (int) mRenderCoordinates.fromLocalCssToPix(node.y);
+ int width = (int) mRenderCoordinates.fromLocalCssToPix(node.width);
+ int height = (int) mRenderCoordinates.fromLocalCssToPix(node.height);
+
+ Rect boundsInParent = new Rect(left, top, left + width, top + height);
+ if (node.isRootNode) {
+ // Offset of the web content relative to the View.
+ boundsInParent.offset(0, (int) mRenderCoordinates.getContentOffsetYPix());
+ if (!ignoreScrollOffset) {
+ boundsInParent.offset(-(int) mRenderCoordinates.getScrollXPix(),
+ -(int) mRenderCoordinates.getScrollYPix());
+ }
+ }
+
+ viewNode.setDimens(boundsInParent.left, boundsInParent.top, 0, 0, width, height);
viewNode.setChildCount(node.children.size());
if (node.hasStyle) {
int style = (node.bold ? ViewNode.TEXT_STYLE_BOLD : 0)
@@ -3108,8 +3117,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
viewNode.setTextStyle(node.textSize, node.color, node.bgcolor, style);
}
for (int i = 0; i < node.children.size(); i++) {
- createVirtualStructure(viewNode.asyncNewChild(i), node.children.get(i), node.x,
- node.y);
+ createVirtualStructure(
+ viewNode.asyncNewChild(i), node.children.get(i), ignoreScrollOffset);
dmazzoni 2016/04/21 17:35:32 It's slightly confusing to me to pass ignoreScroll
sgurun-gerrit only 2016/04/21 21:02:58 Done.
}
viewNode.asyncCommit();
}

Powered by Google App Engine
This is Rietveld 408576698