diff options
Diffstat (limited to 'chromium/ui/views/controls/focus_ring.h')
-rw-r--r-- | chromium/ui/views/controls/focus_ring.h | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/chromium/ui/views/controls/focus_ring.h b/chromium/ui/views/controls/focus_ring.h index 9ac2f4ebeeb..c3e42b6a4da 100644 --- a/chromium/ui/views/controls/focus_ring.h +++ b/chromium/ui/views/controls/focus_ring.h @@ -19,38 +19,25 @@ namespace views { class HighlightPathGenerator; // FocusRing is a View that is designed to act as an indicator of focus for its -// parent. It is a stand-alone view that paints to a layer which extends beyond -// the bounds of its parent view. -// -// Using FocusRing looks something like this: -// -// class MyView : public View { -// ... -// private: -// std::unique_ptr<FocusRing> focus_ring_; -// }; -// -// MyView::MyView() { -// focus_ring_ = FocusRing::Install(this); -// ... -// } -// +// parent. It is a view that paints to a layer which extends beyond the bounds +// of its parent view. // If MyView should show a rounded rectangular focus ring when it has focus and // hide the ring when it loses focus, no other configuration is necessary. In // other cases, it might be necessary to use the Set*() functions on FocusRing; // these take care of repainting it when the state changes. +// TODO(tluk): FocusRing should not be a view but instead a new concept which +// only participates in view painting ( https://crbug.com/840796 ). class VIEWS_EXPORT FocusRing : public View, public ViewObserver { public: METADATA_HEADER(FocusRing); using ViewPredicate = std::function<bool(View* view)>; - ~FocusRing() override; - // Create a FocusRing and adds it to |parent|. The returned focus ring is - // owned by the client (the code calling FocusRing::Install), *not* by - // |parent|. - static std::unique_ptr<FocusRing> Install(View* parent); + // owned by the |parent|. + static FocusRing* Install(View* parent); + + ~FocusRing() override; // Sets the HighlightPathGenerator to draw this FocusRing around. // Note: This method should only be used if the focus ring needs to differ @@ -77,6 +64,7 @@ class VIEWS_EXPORT FocusRing : public View, public ViewObserver { void ViewHierarchyChanged( const ViewHierarchyChangedDetails& details) override; void OnPaint(gfx::Canvas* canvas) override; + void GetAccessibleNodeData(ui::AXNodeData* node_data) override; // ViewObserver: void OnViewFocused(View* view) override; @@ -108,6 +96,8 @@ class VIEWS_EXPORT FocusRing : public View, public ViewObserver { // The predicate used to determine whether the parent has focus. base::Optional<ViewPredicate> has_focus_predicate_; + ScopedObserver<View, ViewObserver> view_observer_{this}; + DISALLOW_COPY_AND_ASSIGN(FocusRing); }; |