diff options
Diffstat (limited to 'chromium/content/browser/accessibility/browser_accessibility_manager.h')
-rw-r--r-- | chromium/content/browser/accessibility/browser_accessibility_manager.h | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/chromium/content/browser/accessibility/browser_accessibility_manager.h b/chromium/content/browser/accessibility/browser_accessibility_manager.h index e64372b96b9..8892004aaac 100644 --- a/chromium/content/browser/accessibility/browser_accessibility_manager.h +++ b/chromium/content/browser/accessibility/browser_accessibility_manager.h @@ -86,10 +86,10 @@ class CONTENT_EXPORT BrowserAccessibilityDelegate { virtual ~BrowserAccessibilityDelegate() {} virtual void AccessibilityPerformAction(const ui::AXActionData& data) = 0; - virtual bool AccessibilityViewHasFocus() const = 0; + virtual bool AccessibilityViewHasFocus() = 0; virtual void AccessibilityViewSetFocus() = 0; - virtual gfx::Rect AccessibilityGetViewBounds() const = 0; - virtual float AccessibilityGetDeviceScaleFactor() const = 0; + virtual gfx::Rect AccessibilityGetViewBounds() = 0; + virtual float AccessibilityGetDeviceScaleFactor() = 0; virtual void AccessibilityFatalError() = 0; virtual gfx::AcceleratedWidget AccessibilityGetAcceleratedWidget() = 0; virtual gfx::NativeViewAccessible AccessibilityGetNativeViewAccessible() = 0; @@ -99,16 +99,7 @@ class CONTENT_EXPORT BrowserAccessibilityDelegate { // Returns true if this delegate represents the main (topmost) frame in a // tree of frames. - virtual bool AccessibilityIsMainFrame() const = 0; -}; - -class CONTENT_EXPORT BrowserAccessibilityFactory { - public: - virtual ~BrowserAccessibilityFactory() {} - - // Create an instance of BrowserAccessibility and return a new - // reference to it. - virtual BrowserAccessibility* Create(); + virtual bool AccessibilityIsMainFrame() = 0; }; // This is all of the information about the current find in page result, @@ -146,8 +137,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, // with no parent window pointer. Only useful for unit tests. static BrowserAccessibilityManager* Create( const ui::AXTreeUpdate& initial_tree, - BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory = new BrowserAccessibilityFactory()); + BrowserAccessibilityDelegate* delegate); static BrowserAccessibilityManager* FromID(ui::AXTreeID ax_tree_id); @@ -185,6 +175,11 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, // If this tree has a parent tree, return the parent node in that tree. BrowserAccessibility* GetParentNodeFromParentTree() const; + // In general, there is only a single node with the role of kRootWebArea, + // but if a popup is opened, a second nested "root" is created in the same + // tree as the "true" root. This will keep track of the nested root node. + BrowserAccessibility* GetPopupRoot() const; + // Get the AXTreeData for this frame. const ui::AXTreeData& GetTreeData() const; @@ -204,7 +199,10 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, virtual void UserIsReloading(); void NavigationSucceeded(); void NavigationFailed(); + + // WebContentsObserver overrides void DidStopLoading() override; + void DidActivatePortal(WebContents* predecessor_contents) override; // Keep track of if this page is hidden by an interstitial, in which case // we need to suppress all events. @@ -245,9 +243,11 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, void DoDefaultAction(const BrowserAccessibility& node); void GetImageData(const BrowserAccessibility& node, const gfx::Size& max_size); - // See third_party/blink/renderer/core/layout/hit_test_location.h for - // information on hit test coordinates expected by Blink. - void HitTest(const gfx::Point& page_point) const; + // Per third_party/blink/renderer/core/layout/hit_test_location.h, Blink + // expects hit test points in page coordinates. However, WebAXObject::HitTest + // applies the visual viewport offset, so we want to pass that function a + // point in frame coordinates. + void HitTest(const gfx::Point& frame_point) const; void Increment(const BrowserAccessibility& node); void LoadInlineTextBoxes(const BrowserAccessibility& node); void ScrollToMakeVisible( @@ -345,7 +345,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, BrowserAccessibility* GetActiveDescendant(BrowserAccessibility* focus) const; // Returns true if native focus is anywhere in this WebContents or not. - bool NativeViewHasFocus() const; + bool NativeViewHasFocus(); // True by default, but some platforms want to treat the root // scroll offsets separately. @@ -416,6 +416,10 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, void OnNodeCreated(ui::AXTree* tree, ui::AXNode* node) override; void OnNodeDeleted(ui::AXTree* tree, int32_t node_id) override; void OnNodeReparented(ui::AXTree* tree, ui::AXNode* node) override; + void OnRoleChanged(ui::AXTree* tree, + ui::AXNode* node, + ax::mojom::Role old_role, + ax::mojom::Role new_role) override; void OnAtomicUpdateFinished( ui::AXTree* tree, bool root_changed, @@ -461,17 +465,19 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, // call to CachingAsyncHitTest(). void CacheHitTestResult(BrowserAccessibility* hit_test_result) const; - // Called when |this| is an accessibility manager for a portal's main frame, - // and when that portal is activated. - void OnPortalActivated(); + // Updates the page scale factor for this frame. + void SetPageScaleFactor(float page_scale_factor); + + // Returns the current page scale factor for this frame. + float GetPageScaleFactor() const; protected: - BrowserAccessibilityManager(BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory); + FRIEND_TEST_ALL_PREFIXES(BrowserAccessibilityManagerTest, + TestShouldFireEventForNode); + explicit BrowserAccessibilityManager(BrowserAccessibilityDelegate* delegate); BrowserAccessibilityManager(const ui::AXTreeUpdate& initial_tree, - BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory); + BrowserAccessibilityDelegate* delegate); // Send platform-specific notifications to each of these objects that // their location has changed. This is called by OnLocationChanges @@ -487,15 +493,14 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, const std::vector<ui::AXTreeObserver::Change>& changes, std::set<ui::AXPlatformNode*>* nodes_needing_update); + bool ShouldFireEventForNode(BrowserAccessibility* node) const; + static void SetLastFocusedNode(BrowserAccessibility* node); static BrowserAccessibility* GetLastFocusedNode(); // The object that can perform actions on our behalf. BrowserAccessibilityDelegate* delegate_; - // Factory to create BrowserAccessibility objects (for dependency injection). - std::unique_ptr<BrowserAccessibilityFactory> factory_; - // A mapping from a node id to its wrapper of type BrowserAccessibility. std::map<int32_t, BrowserAccessibility*> id_wrapper_map_; @@ -528,6 +533,10 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, // cached each time there's any update to the accessibility tree. float device_scale_factor_; + // The page scale factor for the view associated with this frame, + // cached when we get an update via SetPageScaleFactor(). + float page_scale_factor_ = 1.0f; + // For testing only: If true, the manually-set device scale factor will be // used and it won't be updated from the delegate. bool use_custom_device_scale_factor_for_testing_; @@ -540,6 +549,10 @@ class CONTENT_EXPORT BrowserAccessibilityManager : public ui::AXTreeObserver, // For testing only: A function to call when a generated event is fired. GeneratedEventCallbackForTesting generated_event_callback_for_testing_; + // Keeps track of the nested popup root's id, if it exists. See GetPopupRoot() + // for details. + std::set<int32_t> popup_root_ids_; + // Fire all events regardless of focus and with no delay, to avoid test // flakiness. See NeverSuppressOrDelayEventsForTesting() for details. static bool never_suppress_or_delay_events_for_testing_; |