Skip to content

Commit

Permalink
Set expanded on buttons with popup triggering attributes
Browse files Browse the repository at this point in the history
This CL sets kExpandedExpanded and kExpandedCollapsed for any
HTMLButtonElement that contains a popup triggering attribute
(togglepopup, showpopup, or hidepopup), and for which the target element
is a valid kPopup popup (i.e. not a popup=hint or popup=async).

Note that per guidance [1] this CL does not set HasPopup::kMenu at all.

[1] openui/open-ui#329

Bug: 1307772
Change-Id: I7a344e49cfc7667c379937d19a636e29804879b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3617148
Auto-Submit: Mason Freed <[email protected]>
Reviewed-by: Aaron Leventhal <[email protected]>
Commit-Queue: Mason Freed <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1000811}
NOKEYCHECK=True
GitOrigin-RevId: 2e924a036dc1806ab62d2561abf6736e635469bc
  • Loading branch information
mfreed7 authored and copybara-github committed May 8, 2022
1 parent 4f2a86b commit bc23271
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion blink/renderer/core/html/forms/html_button_element.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

namespace blink {

class HTMLButtonElement final : public HTMLFormControlElement {
class CORE_EXPORT HTMLButtonElement final : public HTMLFormControlElement {
DEFINE_WRAPPERTYPEINFO();

public:
Expand Down
13 changes: 13 additions & 0 deletions blink/renderer/modules/accessibility/ax_node_object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "third_party/blink/renderer/core/html/canvas/image_data.h"
#include "third_party/blink/renderer/core/html/custom/element_internals.h"
#include "third_party/blink/renderer/core/html/fenced_frame/html_fenced_frame_element.h"
#include "third_party/blink/renderer/core/html/forms/html_button_element.h"
#include "third_party/blink/renderer/core/html/forms/html_field_set_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/forms/html_label_element.h"
Expand Down Expand Up @@ -1835,6 +1836,18 @@ AccessibilityExpanded AXNodeObject::IsExpanded() const {
: kExpandedCollapsed;
}

// For buttons that contain the |togglepopup|, |showpopup|, or |hidepopup|
// popup triggering attributes, and the pointed-to element is a valid popup
// with type kPopup, then set aria-expanded=false when the popup is hidden,
// and aria-expanded=true when it is showing.
if (auto* button = DynamicTo<HTMLButtonElement>(element)) {
if (auto* popup = button->togglePopupElement()) {
if (popup->PopupType() == PopupValueType::kPopup) {
return popup->popupOpen() ? kExpandedExpanded : kExpandedCollapsed;
}
}
}

if (IsA<HTMLSummaryElement>(*element)) {
if (element->parentNode() &&
IsA<HTMLDetailsElement>(element->parentNode())) {
Expand Down

0 comments on commit bc23271

Please sign in to comment.