Reland [views-ax] Migrating attributes being set from `GetData`

This CL relands CL:5868477.

It was originally reverted due seemingly have caused a regression on Mac
https://issues.chromium.org/issues/377172674.

After some investigation, we were able to determine that the overall
issue was a flaw in the logic when reparenting a View that was set
to be invisible by inheritance, to a tree where it shouldn't be
marked as invisible by inheritance. This CL fixes that logic
in `ViewAccessibility::OnViewHasNewAncestor` and adds a test for this
scenario.

From the original description:

This CL "migrates" the attributes being set in
`ViewAXPlatformNodeDelegate::GetData` from being computed every time
`GetData` was called, to being cached in `ViewAccessibility`

There are two attributes that are explicitly migrated:
  * kInvisible
  * kIgnored

However, kInvisible affects the focusable state of a view, since
a view that is invisible should not be marked as focusable,
and the focusable state affects the ignored state since
a view that is unfocusable and is a descendant of a focusable view
should be marked as ignored (minus in ChromeOS it seems).
Therefore, these two (really three) attributes had to be migrated
from `GetData` in this same CL.

For kInvisible:
Any descendant of an invisible view should also NOT be visible.
As a result, there are two main places we want to recurse and
update the visible states of descendants:
1) When a View's visibility changes in `SetVisible`
2) When a View is added to be a child of another View.

For kIgnored:
Any unfocusable descendant of a focusable view should be
marked as ignored.
As a result, there are two main places where we need to
recurse and update the ignored state
1) When the focus behavior of a view changes.
2) When a view gets added as a child of another View and now has
a focusable ancestor.

This CL makes the following updates to the function
`UpdateStatesForViewAndDescendants`:
1) Changes the name to make it clear that this function is used
when the View gets added to a Views tree.
2) It includes the recursive updating for kIgnored and kInvisible
so that we don't have to add a different function that walks
the tree again.

This CL includes a change to LockContentsView:

The reason we needed this change is because now with this CL
we started failing a test involving this View. The reason for this
was that now we are updating the View's accessible focusable state
not only when queried now, and this led to a failure because
LockContentsView is setting the FocusBehavior to be ALWAYS, but
at the same time we are inheriting from NonAccessibleView which
is setting the invisible state in the accessibility cache
(due to a recent migration). This state is invalid, for a11y,
a View can't be both invisible and focusable. So now we make sure
that this View is not set to invisible.

To prevent this in the future, I've added checks in relevant
functions that should catch this.

This CL is part of the ViewsAX project:
https://docs.google.com/document/d/1Ku7HOyDsiZem1yaV6ccZ-tz3lO2XR2NEcm8HjR6d-VY/edit#heading=h.ke1u3utej413

Bug: 325137417, 371237539
Change-Id: I07a92a5cd17321c881a15954ed964b2448dbe586
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6190622
Reviewed-by: Dirk Pranke <dpranke@google.com>
Reviewed-by: Benjamin Beaudry <benjamin.beaudry@microsoft.com>
Commit-Queue: Javier Contreras <javiercon@microsoft.com>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1413761}
8 files changed
tree: 64d637cf1ce392d4de2462236758941e41df7411
  1. android_webview/
  2. apps/
  3. ash/
  4. base/
  5. build/
  6. build_overrides/
  7. buildtools/
  8. cc/
  9. chrome/
  10. chromecast/
  11. chromeos/
  12. codelabs/
  13. components/
  14. content/
  15. crypto/
  16. dbus/
  17. device/
  18. docs/
  19. extensions/
  20. fuchsia_web/
  21. gin/
  22. google_apis/
  23. gpu/
  24. headless/
  25. infra/
  26. ios/
  27. ipc/
  28. media/
  29. mojo/
  30. native_client_sdk/
  31. net/
  32. pdf/
  33. ppapi/
  34. printing/
  35. remoting/
  36. rlz/
  37. sandbox/
  38. services/
  39. skia/
  40. sql/
  41. storage/
  42. styleguide/
  43. testing/
  44. third_party/
  45. tools/
  46. ui/
  47. url/
  48. webkit/
  49. .clang-format
  50. .clang-tidy
  51. .clangd
  52. .git-blame-ignore-revs
  53. .gitallowed
  54. .gitattributes
  55. .gitignore
  56. .gitmodules
  57. .gn
  58. .mailmap
  59. .rustfmt.toml
  60. .vpython3
  61. .yapfignore
  62. ATL_OWNERS
  63. AUTHORS
  64. BUILD.gn
  65. CODE_OF_CONDUCT.md
  66. codereview.settings
  67. CPPLINT.cfg
  68. CRYPTO_OWNERS
  69. DEPS
  70. DIR_METADATA
  71. LICENSE
  72. LICENSE.chromium_os
  73. OWNERS
  74. PRESUBMIT.py
  75. PRESUBMIT_test.py
  76. PRESUBMIT_test_mocks.py
  77. README.md
  78. WATCHLISTS
README.md

Logo Chromium

Chromium is an open-source browser project that aims to build a safer, faster, and more stable way for all users to experience the web.

The project's web site is https://www.chromium.org.

To check out the source code locally, don't use git clone! Instead, follow the instructions on how to get the code.

Documentation in the source is rooted in docs/README.md.

Learn how to Get Around the Chromium Source Code Directory Structure.

For historical reasons, there are some small top level directories. Now the guidance is that new top level directories are for product (e.g. Chrome, Android WebView, Ash). Even if these products have multiple executables, the code should be in subdirectories of the product.

If you found a bug, please file it at https://crbug.com/new.