1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <vector>
#include "webkit/tools/test_shell/accessibility_controller.h"
#include "base/logging.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/tools/test_shell/test_shell.h"
using WebKit::WebAccessibilityCache;
using WebKit::WebAccessibilityObject;
using WebKit::WebFrame;
AccessibilityController::AccessibilityController(TestShell* shell)
: shell_(shell) {
BindMethod("logFocusEvents",
&AccessibilityController::LogFocusEventsCallback);
BindMethod("logScrollingStartEvents",
&AccessibilityController::LogScrollingStartEventsCallback);
BindProperty("focusedElement",
&AccessibilityController::FocusedElementGetterCallback);
BindProperty("rootElement",
&AccessibilityController::RootElementGetterCallback);
BindFallbackMethod(&AccessibilityController::FallbackCallback);
}
void AccessibilityController::BindToJavascript(
WebFrame* frame, const std::wstring& classname) {
WebAccessibilityCache::enableAccessibility();
CppBoundClass::BindToJavascript(frame, classname);
}
void AccessibilityController::Reset() {
root_element_ = WebAccessibilityObject();
focused_element_ = WebAccessibilityObject();
elements_.Clear();
}
void AccessibilityController::SetFocusedElement(
const WebAccessibilityObject& focused_element) {
focused_element_ = focused_element;
}
AccessibilityUIElement* AccessibilityController::GetFocusedElement() {
if (focused_element_.isNull())
focused_element_ = shell_->webView()->accessibilityObject();
return elements_.Create(focused_element_);
}
AccessibilityUIElement* AccessibilityController::GetRootElement() {
if (root_element_.isNull())
root_element_ = shell_->webView()->accessibilityObject();
return elements_.CreateRoot(root_element_);
}
void AccessibilityController::LogFocusEventsCallback(
const CppArgumentList &args,
CppVariant *result) {
// As of r49031, this is not being used upstream.
result->SetNull();
}
void AccessibilityController::LogScrollingStartEventsCallback(
const CppArgumentList &args,
CppVariant *result) {
// As of r49031, this is not being used upstream.
result->SetNull();
}
void AccessibilityController::FocusedElementGetterCallback(CppVariant* result) {
result->Set(*(GetFocusedElement()->GetAsCppVariant()));
}
void AccessibilityController::RootElementGetterCallback(CppVariant *result) {
result->Set(*(GetRootElement()->GetAsCppVariant()));
}
void AccessibilityController::FallbackCallback(const CppArgumentList &args,
CppVariant *result) {
std::wstring message(
L"JavaScript ERROR: unknown method called on AccessibilityController");
if (!shell_->layout_test_mode()) {
logging::LogMessage("CONSOLE:", 0).stream() << message;
} else {
printf("CONSOLE MESSAGE: %S\n", message.c_str());
}
result->SetNull();
}
|