<!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>[179024] trunk/Tools</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/179024">179024</a></dd>
<dt>Author</dt> <dd>bfulgham@apple.com</dd>
<dt>Date</dt> <dd>2015-01-23 13:31:34 -0800 (Fri, 23 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[Win] Update DRT Accessibility implementation to better match Mac.
https://bugs.webkit.org/show_bug.cgi?id=140830

Reviewed by Dean Jackson.

* DumpRenderTree/win/AccessibilityUIElementWin.cpp:
(AccessibilityUIElement::titleUIElement):
(AccessibilityUIElement::parentElement):
(convertToDRTLabel):
(AccessibilityUIElement::role):
(AccessibilityUIElement::title):
(AccessibilityUIElement::description):
(AccessibilityUIElement::stringValue):
(AccessibilityUIElement::helpText):
(AccessibilityUIElement::isFocused):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsDumpRenderTreewinAccessibilityUIElementWincpp">trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (179023 => 179024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-01-23 20:53:41 UTC (rev 179023)
+++ trunk/Tools/ChangeLog        2015-01-23 21:31:34 UTC (rev 179024)
</span><span class="lines">@@ -1,3 +1,21 @@
</span><ins>+2015-01-23  Brent Fulgham  &lt;bfulgham@apple.com&gt;
+
+        [Win] Update DRT Accessibility implementation to better match Mac.
+        https://bugs.webkit.org/show_bug.cgi?id=140830
+
+        Reviewed by Dean Jackson.
+
+        * DumpRenderTree/win/AccessibilityUIElementWin.cpp:
+        (AccessibilityUIElement::titleUIElement):
+        (AccessibilityUIElement::parentElement):
+        (convertToDRTLabel):
+        (AccessibilityUIElement::role):
+        (AccessibilityUIElement::title):
+        (AccessibilityUIElement::description):
+        (AccessibilityUIElement::stringValue):
+        (AccessibilityUIElement::helpText):
+        (AccessibilityUIElement::isFocused):
+
</ins><span class="cx"> 2015-01-23  Sergio Villar Senin  &lt;svillar@igalia.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION: run-perf-tests --profiler= seems to have broken
</span></span></pre></div>
<a id="trunkToolsDumpRenderTreewinAccessibilityUIElementWincpp"></a>
<div class="modfile"><h4>Modified: trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp (179023 => 179024)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp        2015-01-23 20:53:41 UTC (rev 179023)
+++ trunk/Tools/DumpRenderTree/win/AccessibilityUIElementWin.cpp        2015-01-23 21:31:34 UTC (rev 179024)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2008, 2013, 2014 Apple Inc. All Rights Reserved.
</del><ins>+ * Copyright (C) 2008, 2013, 2014-2015 Apple Inc. All Rights Reserved.
</ins><span class="cx">  *
</span><span class="cx">  * Redistribution and use in source and binary forms, with or without
</span><span class="cx">  * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx"> AccessibilityUIElement AccessibilityUIElement::parentElement()
</span><span class="cx"> {
</span><span class="cx">     if (!m_element)
</span><del>-        return 0;
</del><ins>+        return nullptr;
</ins><span class="cx"> 
</span><span class="cx">     COMPtr&lt;IDispatch&gt; parent;
</span><span class="cx">     m_element-&gt;get_accParent(&amp;parent);
</span><span class="lines">@@ -240,18 +240,64 @@
</span><span class="cx">     return vSelf;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+static _bstr_t convertToDRTLabel(const _bstr_t roleName)
+{
+    if (!wcscmp(roleName, L&quot;cell&quot;))
+        return _bstr_t(L&quot;AXCell&quot;);
+    if (!wcscmp(roleName, L&quot;check box&quot;))
+        return _bstr_t(L&quot;AXCheckBox&quot;);
+    if (!wcscmp(roleName, L&quot;client&quot;))
+        return _bstr_t(L&quot;AXWebArea&quot;);
+    if (!wcscmp(roleName, L&quot;column&quot;))
+        return _bstr_t(L&quot;AXColumn&quot;);
+    if (!wcscmp(roleName, L&quot;combo box&quot;))
+        return _bstr_t(L&quot;AXComboBox&quot;);
+    if (!wcscmp(roleName, L&quot;grouping&quot;))
+        return _bstr_t(L&quot;AXGroup&quot;);
+    if (!wcscmp(roleName, L&quot;editable text&quot;))
+        return _bstr_t(L&quot;AXStaticText&quot;); // Might be AXTextField, too.
+    if (!wcscmp(roleName, L&quot;graphic&quot;))
+        return _bstr_t(L&quot;AXImage&quot;);
+    if (!wcscmp(roleName, L&quot;link&quot;))
+        return _bstr_t(L&quot;AXLink&quot;);
+    if (!wcscmp(roleName, L&quot;list item&quot;))
+        return _bstr_t(L&quot;AXTab&quot;);
+    if (!wcscmp(roleName, L&quot;list&quot;))
+        return _bstr_t(L&quot;AXList&quot;);
+    if (!wcscmp(roleName, L&quot;menu bar&quot;))
+        return _bstr_t(L&quot;AXMenuBar&quot;);
+    if (!wcscmp(roleName, L&quot;page tab list&quot;))
+        return _bstr_t(L&quot;AXTabGroup&quot;);
+    if (!wcscmp(roleName, L&quot;page tab&quot;))
+        return _bstr_t(L&quot;AXTab&quot;);
+    if (!wcscmp(roleName, L&quot;push button&quot;))
+        return _bstr_t(L&quot;AXButton&quot;);
+    if (!wcscmp(roleName, L&quot;progress bar&quot;))
+        return _bstr_t(L&quot;AXProgressIndicator&quot;);
+    if (!wcscmp(roleName, L&quot;radio button&quot;))
+        return _bstr_t(L&quot;AXRadioButton&quot;);
+    if (!wcscmp(roleName, L&quot;row&quot;))
+        return _bstr_t(L&quot;AXRow&quot;);
+    if (!wcscmp(roleName, L&quot;table&quot;))
+        return _bstr_t(L&quot;AXTable&quot;);
+    if (!wcscmp(roleName, L&quot;text&quot;))
+        return _bstr_t(L&quot;AXStaticText&quot;);
+
+    return roleName;
+}
+
</ins><span class="cx"> JSStringRef AccessibilityUIElement::role()
</span><span class="cx"> {
</span><span class="cx">     if (!m_element)
</span><del>-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXRole: &quot;));
</ins><span class="cx"> 
</span><span class="cx">     _variant_t vRole;
</span><span class="cx">     if (FAILED(m_element-&gt;get_accRole(self(), &amp;vRole.GetVARIANT())))
</span><del>-        return JSStringCreateWithCharacters(nullptr, 0);
</del><ins>+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXRole: &quot;));
</ins><span class="cx"> 
</span><span class="cx">     ASSERT(V_VT(&amp;vRole) == VT_I4 || V_VT(&amp;vRole) == VT_BSTR);
</span><span class="cx"> 
</span><del>-    wstring result;
</del><ins>+    _bstr_t result;
</ins><span class="cx">     if (V_VT(&amp;vRole) == VT_I4) {
</span><span class="cx">         unsigned roleTextLength = ::GetRoleText(V_I4(&amp;vRole), nullptr, 0) + 1;
</span><span class="cx"> 
</span><span class="lines">@@ -261,9 +307,9 @@
</span><span class="cx"> 
</span><span class="cx">         result = roleText.data();
</span><span class="cx">     } else if (V_VT(&amp;vRole) == VT_BSTR)
</span><del>-        result = wstring(V_BSTR(&amp;vRole), ::SysStringLen(V_BSTR(&amp;vRole)));
</del><ins>+        result = V_BSTR(&amp;vRole);
</ins><span class="cx"> 
</span><del>-    return JSStringCreateWithCharacters(result.data(), result.length());
</del><ins>+    return JSStringCreateWithBSTR(_bstr_t(L&quot;AXRole: &quot;) + convertToDRTLabel(result));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSStringRef AccessibilityUIElement::subrole()
</span><span class="lines">@@ -284,29 +330,46 @@
</span><span class="cx"> JSStringRef AccessibilityUIElement::title()
</span><span class="cx"> {
</span><span class="cx">     if (!m_element)
</span><del>-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXTitle: &quot;));
</ins><span class="cx"> 
</span><span class="cx">     _bstr_t titleBSTR;
</span><del>-    if (FAILED(m_element-&gt;get_accName(self(), &amp;titleBSTR.GetBSTR())) || !titleBSTR.length())
-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+    if (FAILED(m_element-&gt;get_accName(self(), &amp;titleBSTR.GetBSTR())))
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXTitle: &quot;));
</ins><span class="cx"> 
</span><del>-    return JSStringCreateWithBSTR(titleBSTR);
</del><ins>+    return JSStringCreateWithBSTR(_bstr_t(L&quot;AXTitle: &quot;) + titleBSTR);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSStringRef AccessibilityUIElement::description()
</span><span class="cx"> {
</span><span class="cx">     if (!m_element)
</span><del>-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXDescription: &quot;));
</ins><span class="cx"> 
</span><span class="cx">     _bstr_t descriptionBSTR;
</span><del>-    if (FAILED(m_element-&gt;get_accDescription(self(), &amp;descriptionBSTR.GetBSTR())) || !descriptionBSTR.length())
-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+    if (FAILED(m_element-&gt;get_accDescription(self(), &amp;descriptionBSTR.GetBSTR())))
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXDescription: &quot;));
+
+    if (!descriptionBSTR.length())
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXDescription: &quot;));
+
+    if (wcsstr(static_cast&lt;wchar_t*&gt;(descriptionBSTR), L&quot;Description: &quot;) == static_cast&lt;wchar_t*&gt;(descriptionBSTR)) {
+        // The Mozilla MSAA implementation requires that the string returned to us be prefixed with &quot;Description: &quot;
+        // To match the Mac test results, we will just prefix with AX -&gt; AXDescription:
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AX&quot;) + descriptionBSTR);
+    }
+
</ins><span class="cx">     return JSStringCreateWithBSTR(descriptionBSTR);
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSStringRef AccessibilityUIElement::stringValue()
</span><span class="cx"> {
</span><del>-    return JSStringCreateWithCharacters(0, 0);
</del><ins>+    if (!m_element)
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXValue: &quot;));
+
+    _bstr_t valueBSTR;
+    if (FAILED(m_element-&gt;get_accValue(self(), &amp;valueBSTR.GetBSTR())))
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXValue: &quot;));
+
+    return JSStringCreateWithBSTR(_bstr_t(L&quot;AXValue: &quot;) + valueBSTR);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> JSStringRef AccessibilityUIElement::language()
</span><span class="lines">@@ -317,12 +380,13 @@
</span><span class="cx"> JSStringRef AccessibilityUIElement::helpText() const
</span><span class="cx"> {
</span><span class="cx">     if (!m_element)
</span><del>-        return JSStringCreateWithCharacters(0, 0);
</del><ins>+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXHelp: &quot;));
</ins><span class="cx"> 
</span><span class="cx">     _bstr_t helpTextBSTR;
</span><del>-    if (FAILED(m_element-&gt;get_accHelp(self(), &amp;helpTextBSTR.GetBSTR())) || !helpTextBSTR.length())
-        return JSStringCreateWithCharacters(0, 0);
-    return JSStringCreateWithBSTR(helpTextBSTR);
</del><ins>+    if (FAILED(m_element-&gt;get_accHelp(self(), &amp;helpTextBSTR.GetBSTR())))
+        return JSStringCreateWithBSTR(_bstr_t(L&quot;AXHelp: &quot;));
+
+    return JSStringCreateWithBSTR(_bstr_t(L&quot;AXHelp: &quot;) + helpTextBSTR);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> double AccessibilityUIElement::x()
</span><span class="lines">@@ -399,8 +463,8 @@
</span><span class="cx"> 
</span><span class="cx"> bool AccessibilityUIElement::isFocused() const
</span><span class="cx"> {
</span><del>-    // FIXME: implement
-    return false;
</del><ins>+    DWORD state = accessibilityState(m_element);
+    return (state &amp; STATE_SYSTEM_FOCUSED) == STATE_SYSTEM_FOCUSED;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool AccessibilityUIElement::isSelected() const
</span></span></pre>
</div>
</div>

</body>
</html>