https://bugs.webkit.org/show_bug.cgi?id=146549
Reviewed by Mario Sanchez Prada.
Source/WebCore:
Allow AXExpanded to be writeable for <details> element, which, when set
will toggle the opening and closing of the element.
Post a notification when that happens as well.
Modified test: platform/mac/accessibility/details-summary.html
* accessibility/AccessibilityNodeObject.cpp:
(WebCore::AccessibilityNodeObject::hierarchicalLevel):
(WebCore::AccessibilityNodeObject::setIsExpanded):
(WebCore::shouldUseAccessibilityObjectInnerText):
* accessibility/AccessibilityNodeObject.h:
* accessibility/AccessibilityObject.cpp:
(WebCore::AccessibilityObject::supportsPressAction):
* accessibility/AccessibilityRenderObject.cpp:
(WebCore::AccessibilityRenderObject::canSetExpandedAttribute):
* accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
(-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
(-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
* html/HTMLDetailsElement.cpp:
(WebCore::HTMLDetailsElement::toggleOpen):
LayoutTests:
* platform/mac/accessibility/details-summary-expected.txt:
* platform/mac/accessibility/details-summary.html:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@186598
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-07-02 Chris Fleizach <cfleizach@apple.com>
+
+ AX: <details> element should allow expand/close through AX API
+ https://bugs.webkit.org/show_bug.cgi?id=146549
+
+ Reviewed by Mario Sanchez Prada.
+
+ * platform/mac/accessibility/details-summary-expected.txt:
+ * platform/mac/accessibility/details-summary.html:
+
2015-07-09 Alex Christensen <achristensen@webkit.org>
[Content Extensions] Prevent crashes with plugins.
PASS details1.isExpanded is true
PASS details1.childAtIndex(0).role is 'AXRole: AXGroup'
PASS details1.childAtIndex(0).subrole is 'AXSubrole: AXSummary'
+PASS details1.isAttributeSettable('AXExpanded') is true
+PASS details1.isExpanded is false
+PASS details1.isExpanded is false
+PASS details1.isExpanded is true
+PASS details1.isExpanded is true
PASS details2.subrole is 'AXSubrole: AXDetails'
PASS details2.isExpanded is false
+Received AXExpandedChanged notification
+Received AXExpandedChanged notification
PASS successfullyParsed is true
TEST COMPLETE
description("This tests some basic attributes about the details element.");
+ var callbackCount = 0;
if (window.accessibilityController) {
+ window.jsTestIsAsync = true;
+
+ var body = accessibilityController.rootElement.childAtIndex(0);
+ body.addNotificationListener(function(notification) {
+ if (notification == "AXExpandedChanged") {
+ callbackCount++;
+ debug("Received " + notification + " notification ");
+
+ if (callbackCount == 2) {
+ finishJSTest();
+ }
+ }
+ });
var details1 = accessibilityController.accessibleElementById("details1");
shouldBe("details1.role", "'AXRole: AXGroup'");
shouldBeTrue("details1.isExpanded");
shouldBe("details1.childAtIndex(0).role", "'AXRole: AXGroup'");
shouldBe("details1.childAtIndex(0).subrole", "'AXSubrole: AXSummary'");
+ shouldBeTrue("details1.isAttributeSettable('AXExpanded')");
+
+ // Toggle the expanded state.
+ details1.setBoolAttributeValue("AXExpanded", false);
+ details1 = accessibilityController.accessibleElementById("details1");
+ shouldBeFalse("details1.isExpanded");
+
+ // Give it the same value to make sure we don't expand.
+ details1.setBoolAttributeValue("AXExpanded", false);
+ details1 = accessibilityController.accessibleElementById("details1");
+ shouldBeFalse("details1.isExpanded");
+
+ // Set to expand again.
+ details1.setBoolAttributeValue("AXExpanded", true);
+ details1 = accessibilityController.accessibleElementById("details1");
+ shouldBeTrue("details1.isExpanded");
+
+ // And duplicate the true state to make sure it doesn't toggle off.
+ details1.setBoolAttributeValue("AXExpanded", true);
+ details1 = accessibilityController.accessibleElementById("details1");
+ shouldBeTrue("details1.isExpanded");
var details2 = accessibilityController.accessibleElementById("details2");
shouldBe("details2.subrole", "'AXSubrole: AXDetails'");
+2015-07-02 Chris Fleizach <cfleizach@apple.com>
+
+ AX: <details> element should allow expand/close through AX API
+ https://bugs.webkit.org/show_bug.cgi?id=146549
+
+ Reviewed by Mario Sanchez Prada.
+
+ Allow AXExpanded to be writeable for <details> element, which, when set
+ will toggle the opening and closing of the element.
+ Post a notification when that happens as well.
+
+ Modified test: platform/mac/accessibility/details-summary.html
+
+ * accessibility/AccessibilityNodeObject.cpp:
+ (WebCore::AccessibilityNodeObject::hierarchicalLevel):
+ (WebCore::AccessibilityNodeObject::setIsExpanded):
+ (WebCore::shouldUseAccessibilityObjectInnerText):
+ * accessibility/AccessibilityNodeObject.h:
+ * accessibility/AccessibilityObject.cpp:
+ (WebCore::AccessibilityObject::supportsPressAction):
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::AccessibilityRenderObject::canSetExpandedAttribute):
+ * accessibility/mac/WebAccessibilityObjectWrapperMac.mm:
+ (-[WebAccessibilityObjectWrapper accessibilityIsAttributeSettable:]):
+ (-[WebAccessibilityObjectWrapper _accessibilitySetValue:forAttribute:]):
+ * html/HTMLDetailsElement.cpp:
+ (WebCore::HTMLDetailsElement::toggleOpen):
+
2015-07-09 Alex Christensen <achristensen@webkit.org>
[Content Extensions] Prevent crashes with plugins.
#include "FrameView.h"
#include "HTMLAreaElement.h"
#include "HTMLCanvasElement.h"
+#include "HTMLDetailsElement.h"
#include "HTMLFieldSetElement.h"
#include "HTMLFormElement.h"
#include "HTMLFrameElementBase.h"
return level;
}
+void AccessibilityNodeObject::setIsExpanded(bool expand)
+{
+ if (is<HTMLDetailsElement>(node())) {
+ HTMLDetailsElement* details = downcast<HTMLDetailsElement>(node());
+ if ((expand && !details->isOpen()) || (!expand && details->isOpen()))
+ details->toggleOpen();
+ }
+}
+
// When building the textUnderElement for an object, determine whether or not
// we should include the inner text of this given descendant object or skip it.
static bool shouldUseAccessibilityObjectInnerText(AccessibilityObject* obj, AccessibilityTextUnderElementMode mode)
virtual void colorValue(int& r, int& g, int& b) const override;
virtual String ariaLabeledByAttribute() const override;
virtual bool hasAttributesRequiredForInclusion() const override final;
+ virtual void setIsExpanded(bool) override;
virtual Element* actionElement() const override;
Element* mouseButtonListener(MouseButtonListenerResultFilter = ExcludeBodyElement) const;
{
if (isButton())
return true;
+ if (roleValue() == DetailsRole)
+ return true;
Element* actionElement = this->actionElement();
if (!actionElement)
bool AccessibilityRenderObject::canSetExpandedAttribute() const
{
+ if (roleValue() == DetailsRole)
+ return true;
+
// An object can be expanded if it aria-expanded is true or false.
const AtomicString& ariaExpanded = getAttribute(aria_expandedAttr);
return equalIgnoringCase(ariaExpanded, "true") || equalIgnoringCase(ariaExpanded, "false");
if ([attributeName isEqualToString: NSAccessibilitySelectedChildrenAttribute])
return m_object->canSetSelectedChildrenAttribute();
- if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute])
+ if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute]
+ || [attributeName isEqualToString:NSAccessibilityExpandedAttribute])
return m_object->canSetExpandedAttribute();
if ([attributeName isEqualToString:NSAccessibilitySelectedRowsAttribute])
} else if ([attributeName isEqualToString: NSAccessibilityVisibleCharacterRangeAttribute]) {
m_object->makeRangeVisible(PlainTextRange(range.location, range.length));
}
- } else if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute])
+ } else if ([attributeName isEqualToString:NSAccessibilityDisclosingAttribute] || [attributeName isEqualToString:NSAccessibilityExpandedAttribute])
m_object->setIsExpanded([number boolValue]);
else if ([attributeName isEqualToString:NSAccessibilitySelectedRowsAttribute]) {
AccessibilityObject::AccessibilityChildrenVector selectedRows;