summaryrefslogtreecommitdiff
path: root/chromium/ui/views/controls/focus_ring.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/ui/views/controls/focus_ring.cc')
-rw-r--r--chromium/ui/views/controls/focus_ring.cc33
1 files changed, 18 insertions, 15 deletions
diff --git a/chromium/ui/views/controls/focus_ring.cc b/chromium/ui/views/controls/focus_ring.cc
index 443c199003c..0ee9512f5c3 100644
--- a/chromium/ui/views/controls/focus_ring.cc
+++ b/chromium/ui/views/controls/focus_ring.cc
@@ -8,6 +8,8 @@
#include <utility>
#include "base/memory/ptr_util.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_node_data.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/focusable_border.h"
#include "ui/views/controls/highlight_path_generator.h"
@@ -53,15 +55,15 @@ SkPath GetHighlightPathInternal(const View* view) {
} // namespace
// static
-std::unique_ptr<FocusRing> FocusRing::Install(View* parent) {
+FocusRing* FocusRing::Install(View* parent) {
auto ring = base::WrapUnique<FocusRing>(new FocusRing());
- ring->set_owned_by_client();
- parent->AddChildView(ring.get());
ring->InvalidateLayout();
ring->SchedulePaint();
- return ring;
+ return parent->AddChildView(std::move(ring));
}
+FocusRing::~FocusRing() = default;
+
void FocusRing::SetPathGenerator(
std::unique_ptr<HighlightPathGenerator> generator) {
path_generator_ = std::move(generator);
@@ -102,14 +104,14 @@ void FocusRing::ViewHierarchyChanged(
if (details.is_add) {
// Need to start observing the parent.
- details.parent->AddObserver(this);
- } else {
+ view_observer_.Add(details.parent);
+ RefreshLayer();
+ } else if (view_observer_.IsObserving(details.parent)) {
// This view is being removed from its parent. It needs to remove itself
- // from its parent's observer list. Otherwise, since its |parent_| will
- // become a nullptr, it won't be able to do so in its destructor.
- details.parent->RemoveObserver(this);
+ // from its parent's observer list in the case where the FocusView is
+ // removed from its parent but not deleted.
+ view_observer_.Remove(details.parent);
}
- RefreshLayer();
}
void FocusRing::OnPaint(gfx::Canvas* canvas) {
@@ -155,6 +157,12 @@ void FocusRing::OnPaint(gfx::Canvas* canvas) {
}
}
+void FocusRing::GetAccessibleNodeData(ui::AXNodeData* node_data) {
+ // Mark the focus ring in the accessibility tree as invisible so that it will
+ // not be accessed by assistive technologies.
+ node_data->AddState(ax::mojom::State::kInvisible);
+}
+
void FocusRing::OnViewFocused(View* view) {
RefreshLayer();
}
@@ -168,11 +176,6 @@ FocusRing::FocusRing() {
set_can_process_events_within_subtree(false);
}
-FocusRing::~FocusRing() {
- if (parent())
- parent()->RemoveObserver(this);
-}
-
void FocusRing::RefreshLayer() {
// TODO(pbos): This always keeps the layer alive if |has_focus_predicate_| is
// set. This is done because we're not notified when the predicate might