<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210265] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210265">210265</a></dd>
<dt>Author</dt> <dd>n_wang@apple.com</dd>
<dt>Date</dt> <dd>2017-01-03 19:07:03 -0800 (Tue, 03 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>AX: Focus should jump into modal dialogs when one appears
https://bugs.webkit.org/show_bug.cgi?id=166670
Reviewed by Chris Fleizach.
Source/WebCore:
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):
LayoutTests:
* accessibility/mac/aria-modal-auto-focus-expected.txt: Added.
* accessibility/mac/aria-modal-auto-focus.html: Added.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCachecpp">trunk/Source/WebCore/accessibility/AXObjectCache.cpp</a></li>
<li><a href="#trunkSourceWebCoreaccessibilityAXObjectCacheh">trunk/Source/WebCore/accessibility/AXObjectCache.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsaccessibilitymacariamodalautofocusexpectedtxt">trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus-expected.txt</a></li>
<li><a href="#trunkLayoutTestsaccessibilitymacariamodalautofocushtml">trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus.html</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (210264 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-01-04 02:10:55 UTC (rev 210264)
+++ trunk/LayoutTests/ChangeLog        2017-01-04 03:07:03 UTC (rev 210265)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2017-01-03 Nan Wang <n_wang@apple.com>
+
+ 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.
+
</ins><span class="cx"> 2017-01-03 Brian Burg <bburg@apple.com>
</span><span class="cx">
</span><span class="cx"> Web Inspector: WrappedPromise constructor should behave like the Promise constructor
</span></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacariamodalautofocusexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus-expected.txt (0 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,19 @@
</span><ins>+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
</ins></span></pre></div>
<a id="trunkLayoutTestsaccessibilitymacariamodalautofocushtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/accessibility/mac/aria-modal-auto-focus.html (0 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,95 @@
</span><ins>+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+
+<style>
+.box-hidden {
+ display: none;
+}
+</style>
+
+<body id="body">
+
+<div id="bg">
+<p id="bgContent">Other page content with <a href="#">a 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="../../resources/js-test-post.js"></script>
+</body>
+</html>
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (210264 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2017-01-03 Nan Wang <n_wang@apple.com>
+
+ 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):
+
</ins><span class="cx"> 2017-01-03 Andy Estes <aestes@apple.com>
</span><span class="cx">
</span><span class="cx"> Rename SharedBufferMac.mm to SharedBufferCocoa.mm
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.cpp (210264 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -112,6 +112,7 @@
</span><span class="cx"> // Post value change notifications for password fields or elements contained in password fields at a 40hz interval to thwart analysis of typing cadence
</span><span class="cx"> static double AccessibilityPasswordValueChangeNotificationInterval = 0.025;
</span><span class="cx"> static double AccessibilityLiveRegionChangedNotificationInterval = 0.020;
</span><ins>+static double AccessibilityFocusAriaModalNodeNotificationInterval = 0.050;
</ins><span class="cx">
</span><span class="cx"> AccessibilityObjectInclusion AXComputedObjectAttributeCache::getIgnored(AXID id) const
</span><span class="cx"> {
</span><span class="lines">@@ -187,6 +188,7 @@
</span><span class="cx"> , m_notificationPostTimer(*this, &AXObjectCache::notificationPostTimerFired)
</span><span class="cx"> , m_passwordNotificationPostTimer(*this, &AXObjectCache::passwordNotificationPostTimerFired)
</span><span class="cx"> , m_liveRegionChangedPostTimer(*this, &AXObjectCache::liveRegionChangedNotificationPostTimerFired)
</span><ins>+ , m_focusAriaModalNodeTimer(*this, &AXObjectCache::focusAriaModalNodeTimerFired)
</ins><span class="cx"> , m_currentAriaModalNode(nullptr)
</span><span class="cx"> {
</span><span class="cx"> findAriaModalNodes();
</span><span class="lines">@@ -196,6 +198,7 @@
</span><span class="cx"> {
</span><span class="cx"> m_notificationPostTimer.stop();
</span><span class="cx"> m_liveRegionChangedPostTimer.stop();
</span><ins>+ m_focusAriaModalNodeTimer.stop();
</ins><span class="cx">
</span><span class="cx"> for (const auto& object : m_objects.values()) {
</span><span class="cx"> detachWrapper(object.get(), CacheDestroyed);
</span><span class="lines">@@ -1350,6 +1353,44 @@
</span><span class="cx"> m_liveRegionObjectsSet.clear();
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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);
+ }
+}
+
</ins><span class="cx"> void AXObjectCache::handleScrollbarUpdate(ScrollView* view)
</span><span class="cx"> {
</span><span class="cx"> if (!view)
</span><span class="lines">@@ -1439,6 +1480,9 @@
</span><span class="cx"> m_ariaModalNodesSet.remove(node);
</span><span class="cx"> updateCurrentAriaModalNode();
</span><span class="cx"> }
</span><ins>+ if (m_currentAriaModalNode)
+ focusAriaModalNode();
+
</ins><span class="cx"> startCachingComputedObjectAttributesUntilTreeMutates();
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceWebCoreaccessibilityAXObjectCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/accessibility/AXObjectCache.h (210264 => 210265)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -302,6 +302,7 @@
</span><span class="cx"> void postTextStateChangeNotification(Node*, const AXTextStateChangeIntent&, const VisibleSelection&);
</span><span class="cx"> void postTextStateChangeNotification(const Position&, const AXTextStateChangeIntent&, const VisibleSelection&);
</span><span class="cx"> void postLiveRegionChangeNotification(AccessibilityObject*);
</span><ins>+ void focusAriaModalNode();
</ins><span class="cx">
</span><span class="cx"> enum AXLoadingEvent {
</span><span class="cx"> AXLoadingStarted,
</span><span class="lines">@@ -382,6 +383,8 @@
</span><span class="cx"> void notificationPostTimerFired();
</span><span class="cx">
</span><span class="cx"> void liveRegionChangedNotificationPostTimerFired();
</span><ins>+
+ void focusAriaModalNodeTimerFired();
</ins><span class="cx">
</span><span class="cx"> void postTextStateChangeNotification(AccessibilityObject*, const AXTextStateChangeIntent&, const VisibleSelection&);
</span><span class="cx">
</span><span class="lines">@@ -419,6 +422,7 @@
</span><span class="cx"> Timer m_liveRegionChangedPostTimer;
</span><span class="cx"> ListHashSet<RefPtr<AccessibilityObject>> m_liveRegionObjectsSet;
</span><span class="cx">
</span><ins>+ Timer m_focusAriaModalNodeTimer;
</ins><span class="cx"> Node* m_currentAriaModalNode;
</span><span class="cx"> ListHashSet<Node*> m_ariaModalNodesSet;
</span><span class="cx">
</span><span class="lines">@@ -495,6 +499,7 @@
</span><span class="cx"> inline void AXObjectCache::postNotification(Node*, AXNotification, PostTarget, PostType) { }
</span><span class="cx"> inline void AXObjectCache::postPlatformNotification(AccessibilityObject*, AXNotification) { }
</span><span class="cx"> inline void AXObjectCache::postLiveRegionChangeNotification(AccessibilityObject*) { }
</span><ins>+inline void AXObjectCache::focusAriaModalNode() { }
</ins><span class="cx"> inline RefPtr<Range> AXObjectCache::rangeForNodeContents(Node*) { return nullptr; }
</span><span class="cx"> inline void AXObjectCache::remove(AXID) { }
</span><span class="cx"> inline void AXObjectCache::remove(RenderObject*) { }
</span></span></pre>
</div>
</div>
</body>
</html>