Diff
Modified: trunk/LayoutTests/ChangeLog (210264 => 210265)
--- trunk/LayoutTests/ChangeLog 2017-01-04 02:10:55 UTC (rev 210264)
+++ trunk/LayoutTests/ChangeLog 2017-01-04 03:07:03 UTC (rev 210265)
@@ -1,3 +1,13 @@
+2017-01-03 Nan Wang <[email protected]>
+
+ AX: Focus should jump into modal dialogs when one appears
+ https://bugs.webkit.org/show_bug.cgi?id=166670
+
+ Reviewed by Chris Fleizach.
+
+ * accessibility/mac/aria-modal-auto-focus-expected.txt: Added.
+ * accessibility/mac/aria-modal-auto-focus.html: Added.
+
2017-01-03 Brian Burg <[email protected]>
Web Inspector: WrappedPromise constructor should behave like the Promise constructor
Added: trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus-expected.txt (0 => 210265)
--- trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus-expected.txt (rev 0)
+++ trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus-expected.txt 2017-01-04 03:07:03 UTC (rev 210265)
@@ -0,0 +1,19 @@
+This tests that focus will automatically move to aria-modal dialogs
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS backgroundAccessible() is true
+PASS newBtn.isFocused is true
+PASS closeBtn.isFocused is true
+PASS okBtn.isFocused is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Other page content with a dummy focusable element
+
+Display a dialog
+
+Just an example.
+
+OK New
Added: trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus.html (0 => 210265)
--- trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus.html (rev 0)
+++ trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus.html 2017-01-04 03:07:03 UTC (rev 210265)
@@ -0,0 +1,95 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src=""
+</head>
+
+<style>
+.box-hidden {
+ display: none;
+}
+</style>
+
+<body id="body">
+
+<div id="bg">
+<p id="bgContent">Other page content with <a href="" dummy focusable element</a></p>
+<p><a _onclick_="toggleDialog(document.getElementById('box'),'show'); document.getElementById('new').focus(); return false;" href="" role="button" id="displayBtn">Display a dialog</a></p>
+</div>
+
+<div role="dialog" aria-labelledby="myDialog" id="box" class="box-hidden" tabindex="-1" aria-modal="false">
+ <h3 id="myDialog">Just an example.</h3>
+ <button id="ok" _onclick_="toggleDialog(document.getElementById('box'),'hide');" class="close-button">OK</button>
+ <button _onclick_="toggleDialog(document.getElementById('box2'),'show');" id="new">New</button>
+</div>
+
+<div role="dialog" aria-labelledby="myDialog2" id="box2" class="box-hidden" tabindex="-1">
+ <h3 id="myDialog2">Another dialog.</h3>
+ <button id="close" _onclick_="toggleDialog(document.getElementById('box2'),'hide');" class="close-button">Close</button>
+</div>
+
+
+<script>
+
+ description("This tests that focus will automatically move to aria-modal dialogs");
+
+ if (window.accessibilityController) {
+ window.jsTestIsAsync = true;
+
+ shouldBeTrue("backgroundAccessible()");
+ var newBtn;
+ var okBtn;
+ var closeBtn;
+
+ // 1. Click the display button, dialog1 shows and focus shouldn't move since we have
+ // _javascript_ code to focus on the "new" button.
+ document.getElementById("displayBtn").click();
+ newBtn = accessibilityController.accessibleElementById("new");
+ setTimeout(function(){
+ shouldBeTrue("newBtn.isFocused");
+
+ // 2. Click the new button, dialog2 shows and focus should move to the close button.
+ document.getElementById("new").click();
+ closeBtn = accessibilityController.accessibleElementById("close");
+ setTimeout(function(){
+ shouldBeTrue("closeBtn.isFocused");
+
+ // 3. Click the close button, dialog2 closes and focus should go back to the
+ // first focusable child of dialog1.
+ document.getElementById("close").click();
+ okBtn = accessibilityController.accessibleElementById("ok");
+ setTimeout(function(){
+ shouldBeTrue("okBtn.isFocused");
+ finishJSTest();
+ }, 50);
+ }, 50);
+ }, 50);
+ }
+
+ function backgroundAccessible() {
+ var displayBtn = accessibilityController.accessibleElementById("displayBtn");
+ var bgContent = accessibilityController.accessibleElementById("bgContent");
+
+ if (!displayBtn || !bgContent)
+ return false;
+
+ return !displayBtn.isIgnored && !bgContent.isIgnored;
+ }
+
+ function toggleDialog(dialog, sh) {
+ if (sh == "show") {
+ // show the dialog
+ dialog.style.display = 'block';
+ dialog.setAttribute("aria-modal", "true");
+ } else {
+ dialog.style.display = 'none';
+ dialog.setAttribute("aria-modal", "false");
+ }
+ }
+
+</script>
+
+
+<script src=""
+</body>
+</html>
\ No newline at end of file
Modified: trunk/Source/WebCore/ChangeLog (210264 => 210265)
--- trunk/Source/WebCore/ChangeLog 2017-01-04 02:10:55 UTC (rev 210264)
+++ trunk/Source/WebCore/ChangeLog 2017-01-04 03:07:03 UTC (rev 210265)
@@ -1,3 +1,25 @@
+2017-01-03 Nan Wang <[email protected]>
+
+ AX: Focus should jump into modal dialogs when one appears
+ https://bugs.webkit.org/show_bug.cgi?id=166670
+
+ Reviewed by Chris Fleizach.
+
+ Added a timer to let focus jump into a modal dialog if the web
+ author didn't handle the focus movement.
+
+ Test: accessibility/mac/aria-modal-auto-focus.html
+
+ * accessibility/AXObjectCache.cpp:
+ (WebCore::AXObjectCache::AXObjectCache):
+ (WebCore::AXObjectCache::~AXObjectCache):
+ (WebCore::firstFocusableChild):
+ (WebCore::AXObjectCache::focusAriaModalNode):
+ (WebCore::AXObjectCache::focusAriaModalNodeTimerFired):
+ (WebCore::AXObjectCache::handleAriaModalChange):
+ * accessibility/AXObjectCache.h:
+ (WebCore::AXObjectCache::focusAriaModalNode):
+
2017-01-03 Andy Estes <[email protected]>
Rename SharedBufferMac.mm to SharedBufferCocoa.mm
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (210264 => 210265)
--- trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2017-01-04 02:10:55 UTC (rev 210264)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.cpp 2017-01-04 03:07:03 UTC (rev 210265)
@@ -112,6 +112,7 @@
// Post value change notifications for password fields or elements contained in password fields at a 40hz interval to thwart analysis of typing cadence
static double AccessibilityPasswordValueChangeNotificationInterval = 0.025;
static double AccessibilityLiveRegionChangedNotificationInterval = 0.020;
+static double AccessibilityFocusAriaModalNodeNotificationInterval = 0.050;
AccessibilityObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID id) const
{
@@ -187,6 +188,7 @@
, m_notificationPostTimer(*this, &AXObjectCache::notificationPostTimerFired)
, m_passwordNotificationPostTimer(*this, &AXObjectCache::passwordNotificationPostTimerFired)
, m_liveRegionChangedPostTimer(*this, &AXObjectCache::liveRegionChangedNotificationPostTimerFired)
+ , m_focusAriaModalNodeTimer(*this, &AXObjectCache::focusAriaModalNodeTimerFired)
, m_currentAriaModalNode(nullptr)
{
findAriaModalNodes();
@@ -196,6 +198,7 @@
{
m_notificationPostTimer.stop();
m_liveRegionChangedPostTimer.stop();
+ m_focusAriaModalNodeTimer.stop();
for (const auto& object : m_objects.values()) {
detachWrapper(object.get(), CacheDestroyed);
@@ -1350,6 +1353,44 @@
m_liveRegionObjectsSet.clear();
}
+static AccessibilityObject* firstFocusableChild(AccessibilityObject* obj)
+{
+ if (!obj)
+ return nullptr;
+
+ for (auto* child = obj->firstChild(); child; child = child->nextSibling()) {
+ if (child->canSetFocusAttribute())
+ return child;
+ if (AccessibilityObject* focusable = firstFocusableChild(child))
+ return focusable;
+ }
+ return nullptr;
+}
+
+void AXObjectCache::focusAriaModalNode()
+{
+ if (m_focusAriaModalNodeTimer.isActive())
+ m_focusAriaModalNodeTimer.stop();
+
+ m_focusAriaModalNodeTimer.startOneShot(AccessibilityFocusAriaModalNodeNotificationInterval);
+}
+
+void AXObjectCache::focusAriaModalNodeTimerFired()
+{
+ if (!m_currentAriaModalNode)
+ return;
+
+ // Don't set focus if we are already focusing onto some element within
+ // the dialog.
+ if (m_currentAriaModalNode->contains(document().focusedElement()))
+ return;
+
+ if (AccessibilityObject* currentAriaModalNodeObject = getOrCreate(m_currentAriaModalNode)) {
+ if (AccessibilityObject* focusable = firstFocusableChild(currentAriaModalNodeObject))
+ focusable->setFocused(true);
+ }
+}
+
void AXObjectCache::handleScrollbarUpdate(ScrollView* view)
{
if (!view)
@@ -1439,6 +1480,9 @@
m_ariaModalNodesSet.remove(node);
updateCurrentAriaModalNode();
}
+ if (m_currentAriaModalNode)
+ focusAriaModalNode();
+
startCachingComputedObjectAttributesUntilTreeMutates();
}
Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (210264 => 210265)
--- trunk/Source/WebCore/accessibility/AXObjectCache.h 2017-01-04 02:10:55 UTC (rev 210264)
+++ trunk/Source/WebCore/accessibility/AXObjectCache.h 2017-01-04 03:07:03 UTC (rev 210265)
@@ -302,6 +302,7 @@
void postTextStateChangeNotification(Node*, const AXTextStateChangeIntent&, const VisibleSelection&);
void postTextStateChangeNotification(const Position&, const AXTextStateChangeIntent&, const VisibleSelection&);
void postLiveRegionChangeNotification(AccessibilityObject*);
+ void focusAriaModalNode();
enum AXLoadingEvent {
AXLoadingStarted,
@@ -382,6 +383,8 @@
void notificationPostTimerFired();
void liveRegionChangedNotificationPostTimerFired();
+
+ void focusAriaModalNodeTimerFired();
void postTextStateChangeNotification(AccessibilityObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
@@ -419,6 +422,7 @@
Timer m_liveRegionChangedPostTimer;
ListHashSet<RefPtr<AccessibilityObject>> m_liveRegionObjectsSet;
+ Timer m_focusAriaModalNodeTimer;
Node* m_currentAriaModalNode;
ListHashSet<Node*> m_ariaModalNodesSet;
@@ -495,6 +499,7 @@
inline void AXObjectCache::postNotification(Node*, AXNotification, PostTarget, PostType) { }
inline void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { }
inline void AXObjectCache::postLiveRegionChangeNotification(AccessibilityObject*) { }
+inline void AXObjectCache::focusAriaModalNode() { }
inline RefPtr<Range> AXObjectCache::rangeForNodeContents(Node*) { return nullptr; }
inline void AXObjectCache::remove(AXID) { }
inline void AXObjectCache::remove(RenderObject*) { }