| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package com.android.webview.chromium; | 5 package com.android.webview.chromium; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.assist.AssistStructure.ViewNode; | |
| 10 import android.content.Context; | 9 import android.content.Context; |
| 11 import android.content.Intent; | 10 import android.content.Intent; |
| 12 import android.content.res.Configuration; | 11 import android.content.res.Configuration; |
| 13 import android.graphics.Bitmap; | 12 import android.graphics.Bitmap; |
| 14 import android.graphics.Canvas; | 13 import android.graphics.Canvas; |
| 15 import android.graphics.Paint; | 14 import android.graphics.Paint; |
| 16 import android.graphics.Picture; | 15 import android.graphics.Picture; |
| 17 import android.graphics.Rect; | 16 import android.graphics.Rect; |
| 18 import android.graphics.drawable.Drawable; | 17 import android.graphics.drawable.Drawable; |
| 19 import android.net.Uri; | 18 import android.net.Uri; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 import android.webkit.WebViewProvider; | 50 import android.webkit.WebViewProvider; |
| 52 import android.widget.TextView; | 51 import android.widget.TextView; |
| 53 | 52 |
| 54 import org.chromium.android_webview.AwContents; | 53 import org.chromium.android_webview.AwContents; |
| 55 import org.chromium.android_webview.AwContentsStatics; | 54 import org.chromium.android_webview.AwContentsStatics; |
| 56 import org.chromium.android_webview.AwPrintDocumentAdapter; | 55 import org.chromium.android_webview.AwPrintDocumentAdapter; |
| 57 import org.chromium.android_webview.AwSettings; | 56 import org.chromium.android_webview.AwSettings; |
| 58 import org.chromium.base.ThreadUtils; | 57 import org.chromium.base.ThreadUtils; |
| 59 import org.chromium.base.annotations.SuppressFBWarnings; | 58 import org.chromium.base.annotations.SuppressFBWarnings; |
| 60 import org.chromium.content.browser.SmartClipProvider; | 59 import org.chromium.content.browser.SmartClipProvider; |
| 61 import org.chromium.content_public.browser.AccessibilitySnapshotCallback; | |
| 62 import org.chromium.content_public.browser.AccessibilitySnapshotNode; | |
| 63 import org.chromium.content_public.browser.NavigationHistory; | 60 import org.chromium.content_public.browser.NavigationHistory; |
| 64 | 61 |
| 65 import java.io.BufferedWriter; | 62 import java.io.BufferedWriter; |
| 66 import java.io.File; | 63 import java.io.File; |
| 67 import java.lang.reflect.Method; | 64 import java.lang.reflect.Method; |
| 68 import java.util.Iterator; | |
| 69 import java.util.Map; | 65 import java.util.Map; |
| 70 import java.util.Queue; | 66 import java.util.Queue; |
| 71 import java.util.concurrent.Callable; | 67 import java.util.concurrent.Callable; |
| 72 import java.util.concurrent.ConcurrentLinkedQueue; | 68 import java.util.concurrent.ConcurrentLinkedQueue; |
| 73 import java.util.concurrent.FutureTask; | 69 import java.util.concurrent.FutureTask; |
| 74 import java.util.concurrent.TimeUnit; | 70 import java.util.concurrent.TimeUnit; |
| 75 | 71 |
| 76 /** | 72 /** |
| 77 * This class is the delegate to which WebViewProxy forwards all API calls. | 73 * This class is the delegate to which WebViewProxy forwards all API calls. |
| 78 * | 74 * |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1553 mFactory.startYourEngines(false); | 1549 mFactory.startYourEngines(false); |
| 1554 if (checkNeedsPost()) { | 1550 if (checkNeedsPost()) { |
| 1555 runVoidTaskOnUiThreadBlocking(new Runnable() { | 1551 runVoidTaskOnUiThreadBlocking(new Runnable() { |
| 1556 @Override | 1552 @Override |
| 1557 public void run() { | 1553 public void run() { |
| 1558 onProvideVirtualStructure(structure); | 1554 onProvideVirtualStructure(structure); |
| 1559 } | 1555 } |
| 1560 }); | 1556 }); |
| 1561 return; | 1557 return; |
| 1562 } | 1558 } |
| 1563 structure.setChildCount(1); | 1559 mAwContents.onProvideVirtualStructure(structure); |
| 1564 final ViewStructure viewRoot = structure.asyncNewChild(0); | |
| 1565 mAwContents.requestAccessibilitySnapshot(new AccessibilitySnapshotCallba
ck() { | |
| 1566 @Override | |
| 1567 public void onAccessibilitySnapshot(AccessibilitySnapshotNode root)
{ | |
| 1568 viewRoot.setHint(AwContentsStatics.getProductVersion()); | |
| 1569 if (root == null) { | |
| 1570 viewRoot.setClassName("android.webkit.WebView"); | |
| 1571 viewRoot.asyncCommit(); | |
| 1572 return; | |
| 1573 } | |
| 1574 createAssistStructure(viewRoot, root, 0, 0); | |
| 1575 } | |
| 1576 }); | |
| 1577 } | |
| 1578 | |
| 1579 // When creating the Assist structure, the left and top are relative to the
parent node, and | |
| 1580 // scroll offsets are not needed. | |
| 1581 @TargetApi(Build.VERSION_CODES.M) | |
| 1582 private void createAssistStructure(ViewStructure viewNode, AccessibilitySnap
shotNode node, | |
| 1583 int parentX, int parentY) { | |
| 1584 viewNode.setClassName(node.className); | |
| 1585 if (node.hasSelection) { | |
| 1586 viewNode.setText(node.text, node.startSelection, node.endSelection); | |
| 1587 } else { | |
| 1588 viewNode.setText(node.text); | |
| 1589 } | |
| 1590 // Do not pass scroll information. | |
| 1591 viewNode.setDimens(node.x - parentX, node.y - parentY, 0, 0, node.width,
node.height); | |
| 1592 viewNode.setChildCount(node.children.size()); | |
| 1593 if (node.hasStyle) { | |
| 1594 int style = (node.bold ? ViewNode.TEXT_STYLE_BOLD : 0) | |
| 1595 | (node.italic ? ViewNode.TEXT_STYLE_ITALIC : 0) | |
| 1596 | (node.underline ? ViewNode.TEXT_STYLE_UNDERLINE : 0) | |
| 1597 | (node.lineThrough ? ViewNode.TEXT_STYLE_STRIKE_THRU : 0); | |
| 1598 viewNode.setTextStyle(node.textSize, node.color, node.bgcolor, style
); | |
| 1599 } | |
| 1600 final Iterator<AccessibilitySnapshotNode> children = node.children.listI
terator(); | |
| 1601 int i = 0; | |
| 1602 while (children.hasNext()) { | |
| 1603 createAssistStructure(viewNode.asyncNewChild(i++), children.next(),
node.x, node.y); | |
| 1604 } | |
| 1605 viewNode.asyncCommit(); | |
| 1606 } | 1560 } |
| 1607 | 1561 |
| 1608 @Override | 1562 @Override |
| 1609 public void onInitializeAccessibilityNodeInfo(final AccessibilityNodeInfo in
fo) { | 1563 public void onInitializeAccessibilityNodeInfo(final AccessibilityNodeInfo in
fo) { |
| 1610 mFactory.startYourEngines(false); | 1564 mFactory.startYourEngines(false); |
| 1611 if (checkNeedsPost()) { | 1565 if (checkNeedsPost()) { |
| 1612 runVoidTaskOnUiThreadBlocking(new Runnable() { | 1566 runVoidTaskOnUiThreadBlocking(new Runnable() { |
| 1613 @Override | 1567 @Override |
| 1614 public void run() { | 1568 public void run() { |
| 1615 onInitializeAccessibilityNodeInfo(info); | 1569 onInitializeAccessibilityNodeInfo(info); |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 mAwContents.extractSmartClipData(x, y, width, height); | 2316 mAwContents.extractSmartClipData(x, y, width, height); |
| 2363 } | 2317 } |
| 2364 | 2318 |
| 2365 // Implements SmartClipProvider | 2319 // Implements SmartClipProvider |
| 2366 @Override | 2320 @Override |
| 2367 public void setSmartClipResultHandler(final Handler resultHandler) { | 2321 public void setSmartClipResultHandler(final Handler resultHandler) { |
| 2368 checkThread(); | 2322 checkThread(); |
| 2369 mAwContents.setSmartClipResultHandler(resultHandler); | 2323 mAwContents.setSmartClipResultHandler(resultHandler); |
| 2370 } | 2324 } |
| 2371 } | 2325 } |
| OLD | NEW |