diff options
author | aboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-13 22:57:01 +0000 |
---|---|---|
committer | aboxhall@chromium.org <aboxhall@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-13 22:57:01 +0000 |
commit | 7f2d9f6bf46e1f16b6ebb997f2b42c77a9070620 (patch) | |
tree | d352d7539ee4d4002131151bd8b9a8c9aeaae388 /content/browser/accessibility/browser_accessibility_manager_android.h | |
parent | 4dbecc37e310947f2ff7c3ada1dc9b934158d2b7 (diff) | |
download | chromium_src-7f2d9f6bf46e1f16b6ebb997f2b42c77a9070620.zip chromium_src-7f2d9f6bf46e1f16b6ebb997f2b42c77a9070620.tar.gz chromium_src-7f2d9f6bf46e1f16b6ebb997f2b42c77a9070620.tar.bz2 |
Content side of changes to enable native accessibility on android.
This code has been written collaboratively by dmazzoni and aboxhall; see https://codereview.chromium.org/15741009/ for the first-pass review on all code changes.
BUG=242953
TBR=piman
Review URL: https://chromiumcodereview.appspot.com/16661006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@206193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/accessibility/browser_accessibility_manager_android.h')
-rw-r--r-- | content/browser/accessibility/browser_accessibility_manager_android.h | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/content/browser/accessibility/browser_accessibility_manager_android.h b/content/browser/accessibility/browser_accessibility_manager_android.h new file mode 100644 index 0000000..0ca04e5 --- /dev/null +++ b/content/browser/accessibility/browser_accessibility_manager_android.h @@ -0,0 +1,85 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ +#define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ + +#include "base/android/scoped_java_ref.h" +#include "content/browser/accessibility/browser_accessibility_manager.h" +#include "content/browser/android/content_view_core_impl.h" + +namespace content { + +namespace aria_strings { + extern const char kAriaLivePolite[]; + extern const char kAriaLiveAssertive[]; +} + +class CONTENT_EXPORT BrowserAccessibilityManagerAndroid + : public BrowserAccessibilityManager { + public: + BrowserAccessibilityManagerAndroid( + base::android::ScopedJavaLocalRef<jobject> content_view_core, + const AccessibilityNodeData& src, + BrowserAccessibilityDelegate* delegate, + BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); + + virtual ~BrowserAccessibilityManagerAndroid(); + + static AccessibilityNodeData GetEmptyDocument(); + + // Implementation of BrowserAccessibilityManager. + virtual void NotifyAccessibilityEvent(int type, + BrowserAccessibility* node) OVERRIDE; + + // -------------------------------------------------------------------------- + // Methods called from Java via JNI + // -------------------------------------------------------------------------- + + // Tree methods. + jint GetRootId(JNIEnv* env, jobject obj); + jint HitTest(JNIEnv* env, jobject obj, jint x, jint y); + + // Gets a temporary pointer to a specific node, only valid in this scope. + // May return 0 if that node id is no longer valid. + jint GetNativeNodeById(JNIEnv* env, jobject obj, jint id); + + protected: + virtual void NotifyRootChanged() OVERRIDE; + + virtual bool UseRootScrollOffsetsWhenComputingBounds() OVERRIDE; + + private: + // This gives BrowserAccessibilityManager::Create access to the class + // constructor. + friend class BrowserAccessibilityManager; + + // A weak reference to the Java BrowserAccessibilityManager object. + // This avoids adding another reference to BrowserAccessibilityManager and + // preventing garbage collection. + // Premature garbage collection is prevented by the long-lived reference in + // ContentViewCore. + JavaObjectWeakGlobalRef java_ref_; + + // Searches through the children of start_node to find the nearest + // accessibility focus candidate for a touch which has not landed directly on + // an accessibility focus candidate. + BrowserAccessibility* FuzzyHitTest( + int x, int y, BrowserAccessibility* start_node); + + static void FuzzyHitTestImpl(int x, int y, BrowserAccessibility* start_node, + BrowserAccessibility** nearest_candidate, int* min_distance); + + // Calculates the distance from the point (x, y) to the nearest point on the + // edge of |node|. + static int CalculateDistanceSquared(int x, int y, BrowserAccessibility* node); + + DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerAndroid); +}; + +bool RegisterBrowserAccessibilityManager(JNIEnv* env); + +} + +#endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_ANDROID_H_ |