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

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

Issue 1923613002: Fix a nasty scroll bug for Chrome Now-on-tap feature. Also combine the code paths for Android Webvi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: 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 ee6ccc951339585b9e847d5b0f540fd3715d3d55..7d9e5c99b714864a67932719354b1b56675afd37 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
@@ -3038,45 +3038,55 @@ 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("");
+ viewRoot.setHint(mContentViewClient.getProductVersion());
+ 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)
@@ -3086,8 +3096,7 @@ 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), true);
}
viewNode.asyncCommit();
}

Powered by Google App Engine
This is Rietveld 408576698