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 "ui/views/accessibility/ax_view_obj_wrapper.h" | 5 #include "ui/views/accessibility/ax_view_obj_wrapper.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "content/public/browser/render_process_host.h" | |
dmazzoni
2014/10/29 06:53:30
Yeah, you can't include these from here.
I think
| |
9 #include "content/public/browser/web_contents.h" | |
10 #include "content/public/browser/render_frame_host.h" | |
8 #include "ui/accessibility/ax_node_data.h" | 11 #include "ui/accessibility/ax_node_data.h" |
9 #include "ui/accessibility/ax_view_state.h" | 12 #include "ui/accessibility/ax_view_state.h" |
10 #include "ui/views/accessibility/ax_aura_obj_cache.h" | 13 #include "ui/views/accessibility/ax_aura_obj_cache.h" |
14 #include "ui/views/controls/webview/webview.h" | |
11 #include "ui/views/view.h" | 15 #include "ui/views/view.h" |
12 #include "ui/views/widget/widget.h" | 16 #include "ui/views/widget/widget.h" |
13 | 17 |
14 namespace views { | 18 namespace views { |
15 | 19 |
16 AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) { | 20 AXViewObjWrapper::AXViewObjWrapper(View* view) : view_(view) { |
17 DCHECK(view->GetWidget()); | 21 DCHECK(view->GetWidget()); |
18 if (view->GetWidget()) | 22 if (view->GetWidget()) |
19 AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget()); | 23 AXAuraObjCache::GetInstance()->GetOrCreate(view->GetWidget()); |
20 } | 24 } |
(...skipping 14 matching lines...) Expand all Loading... | |
35 for (int i = 0; i < view_->child_count(); ++i) { | 39 for (int i = 0; i < view_->child_count(); ++i) { |
36 AXAuraObjWrapper* child = | 40 AXAuraObjWrapper* child = |
37 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); | 41 AXAuraObjCache::GetInstance()->GetOrCreate(view_->child_at(i)); |
38 out_children->push_back(child); | 42 out_children->push_back(child); |
39 } | 43 } |
40 } | 44 } |
41 | 45 |
42 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { | 46 void AXViewObjWrapper::Serialize(ui::AXNodeData* out_node_data) { |
43 ui::AXViewState view_data; | 47 ui::AXViewState view_data; |
44 view_->GetAccessibleState(&view_data); | 48 view_->GetAccessibleState(&view_data); |
49 | |
50 // WebView views are considered groups; remap here temporarily. | |
51 if (view_->GetClassName() == WebView::kViewClassName) { | |
52 view_data.role = ui::AX_ROLE_WEB_AREA; | |
dmazzoni
2014/10/29 00:14:11
Why not just fix this in WebView?
Is the WebView
aboxhall
2014/10/29 19:29:11
Further to that - if we consider a WebView a host
David Tseng
2014/10/29 20:35:30
I'm not sure I entirely understand this. We need t
aboxhall
2014/10/29 20:53:29
I think my other comment now merges into this one,
| |
53 content::WebContents* contents = | |
54 static_cast<WebView*>(view_)->GetWebContents(); | |
55 content::RenderFrameHost* rfh = contents->GetMainFrame(); | |
56 if (rfh) { | |
57 int process_id = rfh->GetProcess()->GetID(); | |
58 int routing_id = rfh->GetRoutingID(); | |
59 out_node_data->AddIntAttribute(ui::AX_ATTR_PROCESS_ID, process_id); | |
60 out_node_data->AddIntAttribute(ui::AX_ATTR_ROUTING_ID, routing_id); | |
61 } | |
62 } | |
63 | |
45 out_node_data->id = GetID(); | 64 out_node_data->id = GetID(); |
46 out_node_data->role = view_data.role; | 65 out_node_data->role = view_data.role; |
47 | 66 |
48 out_node_data->state = view_data.state(); | 67 out_node_data->state = view_data.state(); |
49 if (view_->HasFocus()) | 68 if (view_->HasFocus()) |
50 out_node_data->state |= 1 << ui::AX_STATE_FOCUSED; | 69 out_node_data->state |= 1 << ui::AX_STATE_FOCUSED; |
51 if (view_->IsFocusable()) | 70 if (view_->IsFocusable()) |
52 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE; | 71 out_node_data->state |= 1 << ui::AX_STATE_FOCUSABLE; |
53 | 72 |
54 out_node_data->location = view_->GetBoundsInScreen(); | 73 out_node_data->location = view_->GetBoundsInScreen(); |
55 | 74 |
56 out_node_data->AddStringAttribute( | 75 out_node_data->AddStringAttribute( |
57 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name)); | 76 ui::AX_ATTR_NAME, base::UTF16ToUTF8(view_data.name)); |
58 out_node_data->AddStringAttribute( | 77 out_node_data->AddStringAttribute( |
59 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value)); | 78 ui::AX_ATTR_VALUE, base::UTF16ToUTF8(view_data.value)); |
60 | 79 |
61 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, | 80 if (view_data.selection_start > -1 && |
62 view_data.selection_start); | 81 view_data.selection_end > -1) { |
63 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, | 82 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_START, |
64 view_data.selection_end); | 83 view_data.selection_start); |
84 | |
85 out_node_data->AddIntAttribute(ui::AX_ATTR_TEXT_SEL_END, | |
86 view_data.selection_end); | |
87 } | |
65 } | 88 } |
66 | 89 |
67 int32 AXViewObjWrapper::GetID() { | 90 int32 AXViewObjWrapper::GetID() { |
68 return AXAuraObjCache::GetInstance()->GetID(view_); | 91 return AXAuraObjCache::GetInstance()->GetID(view_); |
69 } | 92 } |
70 | 93 |
71 void AXViewObjWrapper::DoDefault() { | 94 void AXViewObjWrapper::DoDefault() { |
72 gfx::Rect rect = view_->GetBoundsInScreen(); | 95 gfx::Rect rect = view_->GetBoundsInScreen(); |
73 gfx::Point center = rect.CenterPoint(); | 96 gfx::Point center = rect.CenterPoint(); |
74 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, | 97 view_->OnMousePressed(ui::MouseEvent(ui::ET_MOUSE_PRESSED, center, center, |
75 ui::EF_LEFT_MOUSE_BUTTON, | 98 ui::EF_LEFT_MOUSE_BUTTON, |
76 ui::EF_LEFT_MOUSE_BUTTON)); | 99 ui::EF_LEFT_MOUSE_BUTTON)); |
77 } | 100 } |
78 | 101 |
79 void AXViewObjWrapper::Focus() { | 102 void AXViewObjWrapper::Focus() { |
80 view_->RequestFocus(); | 103 view_->RequestFocus(); |
81 } | 104 } |
82 | 105 |
83 void AXViewObjWrapper::MakeVisible() { | 106 void AXViewObjWrapper::MakeVisible() { |
84 // TODO(dtseng): Implement. | 107 // TODO(dtseng): Implement. |
85 } | 108 } |
86 | 109 |
87 void AXViewObjWrapper::SetSelection(int32 start, int32 end) { | 110 void AXViewObjWrapper::SetSelection(int32 start, int32 end) { |
88 // TODO(dtseng): Implement. | 111 // TODO(dtseng): Implement. |
89 } | 112 } |
90 | 113 |
91 } // namespace views | 114 } // namespace views |
OLD | NEW |