| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/accessibility/accessibility_event_recorder.h" | 5 #include "content/browser/accessibility/accessibility_event_recorder.h" |
| 6 | 6 |
| 7 #include <oleacc.h> | 7 #include <oleacc.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 // window is frontmost or not, and "hottracked" depends on whether the | 221 // window is frontmost or not, and "hottracked" depends on whether the |
| 222 // mouse cursor happens to be over the element. | 222 // mouse cursor happens to be over the element. |
| 223 ia_state &= (~STATE_SYSTEM_OFFSCREEN & ~STATE_SYSTEM_HOTTRACKED); | 223 ia_state &= (~STATE_SYSTEM_OFFSCREEN & ~STATE_SYSTEM_HOTTRACKED); |
| 224 | 224 |
| 225 // The "readonly" state is set on almost every node and doesn't typically | 225 // The "readonly" state is set on almost every node and doesn't typically |
| 226 // change, so filter it out to keep the output less verbose. | 226 // change, so filter it out to keep the output less verbose. |
| 227 ia_state &= ~STATE_SYSTEM_READONLY; | 227 ia_state &= ~STATE_SYSTEM_READONLY; |
| 228 | 228 |
| 229 AccessibleStates ia2_state = 0; | 229 AccessibleStates ia2_state = 0; |
| 230 base::win::ScopedComPtr<IAccessible2> iaccessible2; | 230 base::win::ScopedComPtr<IAccessible2> iaccessible2; |
| 231 hr = QueryIAccessible2(iaccessible.get(), iaccessible2.Receive()); | 231 hr = QueryIAccessible2(iaccessible.Get(), iaccessible2.Receive()); |
| 232 if (SUCCEEDED(hr)) | 232 if (SUCCEEDED(hr)) |
| 233 iaccessible2->get_states(&ia2_state); | 233 iaccessible2->get_states(&ia2_state); |
| 234 | 234 |
| 235 std::string log = base::StringPrintf( | 235 std::string log = base::StringPrintf( |
| 236 "%s on role=%s", event_str.c_str(), RoleVariantToString(role).c_str()); | 236 "%s on role=%s", event_str.c_str(), RoleVariantToString(role).c_str()); |
| 237 if (name_bstr.Length() > 0) | 237 if (name_bstr.Length() > 0) |
| 238 log += base::StringPrintf(" name=\"%s\"", BstrToUTF8(name_bstr).c_str()); | 238 log += base::StringPrintf(" name=\"%s\"", BstrToUTF8(name_bstr).c_str()); |
| 239 if (value_bstr.Length() > 0) | 239 if (value_bstr.Length() > 0) |
| 240 log += base::StringPrintf(" value=\"%s\"", BstrToUTF8(value_bstr).c_str()); | 240 log += base::StringPrintf(" value=\"%s\"", BstrToUTF8(value_bstr).c_str()); |
| 241 log += " "; | 241 log += " "; |
| 242 log += base::UTF16ToUTF8(IAccessibleStateToString(ia_state)); | 242 log += base::UTF16ToUTF8(IAccessibleStateToString(ia_state)); |
| 243 log += " "; | 243 log += " "; |
| 244 log += base::UTF16ToUTF8(IAccessible2StateToString(ia2_state)); | 244 log += base::UTF16ToUTF8(IAccessible2StateToString(ia2_state)); |
| 245 | 245 |
| 246 // For TEXT_REMOVED and TEXT_INSERTED events, query the text that was | 246 // For TEXT_REMOVED and TEXT_INSERTED events, query the text that was |
| 247 // inserted or removed and include that in the log. | 247 // inserted or removed and include that in the log. |
| 248 base::win::ScopedComPtr<IAccessibleText> accessible_text; | 248 base::win::ScopedComPtr<IAccessibleText> accessible_text; |
| 249 hr = QueryIAccessibleText(iaccessible.get(), accessible_text.Receive()); | 249 hr = QueryIAccessibleText(iaccessible.Get(), accessible_text.Receive()); |
| 250 if (SUCCEEDED(hr)) { | 250 if (SUCCEEDED(hr)) { |
| 251 if (event == IA2_EVENT_TEXT_REMOVED) { | 251 if (event == IA2_EVENT_TEXT_REMOVED) { |
| 252 IA2TextSegment old_text; | 252 IA2TextSegment old_text; |
| 253 if (SUCCEEDED(accessible_text->get_oldText(&old_text))) { | 253 if (SUCCEEDED(accessible_text->get_oldText(&old_text))) { |
| 254 log += base::StringPrintf(" old_text={'%s' start=%d end=%d}", | 254 log += base::StringPrintf(" old_text={'%s' start=%d end=%d}", |
| 255 BstrToUTF8(old_text.text).c_str(), | 255 BstrToUTF8(old_text.text).c_str(), |
| 256 old_text.start, | 256 old_text.start, |
| 257 old_text.end); | 257 old_text.end); |
| 258 } | 258 } |
| 259 } | 259 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 287 if (accessibility_hwnd != hwnd) | 287 if (accessibility_hwnd != hwnd) |
| 288 return E_FAIL; | 288 return E_FAIL; |
| 289 | 289 |
| 290 IAccessible* obj = ToBrowserAccessibilityWin(manager_->GetRoot()); | 290 IAccessible* obj = ToBrowserAccessibilityWin(manager_->GetRoot()); |
| 291 obj->AddRef(); | 291 obj->AddRef(); |
| 292 *ppv_object = obj; | 292 *ppv_object = obj; |
| 293 return S_OK; | 293 return S_OK; |
| 294 } | 294 } |
| 295 | 295 |
| 296 } // namespace content | 296 } // namespace content |
| OLD | NEW |