OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/render_widget.h" | 5 #include "content/renderer/render_widget.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 #include "third_party/WebKit/public/platform/WebSize.h" | 61 #include "third_party/WebKit/public/platform/WebSize.h" |
62 #include "third_party/WebKit/public/platform/WebString.h" | 62 #include "third_party/WebKit/public/platform/WebString.h" |
63 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 63 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
64 #include "third_party/WebKit/public/web/WebNode.h" | 64 #include "third_party/WebKit/public/web/WebNode.h" |
65 #include "third_party/WebKit/public/web/WebPagePopup.h" | 65 #include "third_party/WebKit/public/web/WebPagePopup.h" |
66 #include "third_party/WebKit/public/web/WebPopupMenu.h" | 66 #include "third_party/WebKit/public/web/WebPopupMenu.h" |
67 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 67 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
68 #include "third_party/WebKit/public/web/WebRange.h" | 68 #include "third_party/WebKit/public/web/WebRange.h" |
69 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 69 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
70 #include "third_party/skia/include/core/SkShader.h" | 70 #include "third_party/skia/include/core/SkShader.h" |
71 #include "ui/accessibility/ax_enums.h" | |
71 #include "ui/base/ui_base_switches.h" | 72 #include "ui/base/ui_base_switches.h" |
72 #include "ui/gfx/frame_time.h" | 73 #include "ui/gfx/frame_time.h" |
73 #include "ui/gfx/geometry/point_conversions.h" | 74 #include "ui/gfx/geometry/point_conversions.h" |
74 #include "ui/gfx/geometry/rect_conversions.h" | 75 #include "ui/gfx/geometry/rect_conversions.h" |
75 #include "ui/gfx/geometry/size_conversions.h" | 76 #include "ui/gfx/geometry/size_conversions.h" |
76 #include "ui/gfx/skia_util.h" | 77 #include "ui/gfx/skia_util.h" |
77 #include "ui/gl/gl_switches.h" | 78 #include "ui/gl/gl_switches.h" |
78 #include "ui/surface/transport_dib.h" | 79 #include "ui/surface/transport_dib.h" |
79 | 80 |
80 #if defined(OS_ANDROID) | 81 #if defined(OS_ANDROID) |
(...skipping 2049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2130 | 2131 |
2131 UpdateCompositionInfo(true); | 2132 UpdateCompositionInfo(true); |
2132 } | 2133 } |
2133 | 2134 |
2134 #if defined(OS_ANDROID) | 2135 #if defined(OS_ANDROID) |
2135 void RenderWidget::showUnhandledTapUIIfNeeded( | 2136 void RenderWidget::showUnhandledTapUIIfNeeded( |
2136 const WebPoint& tapped_position, | 2137 const WebPoint& tapped_position, |
2137 const WebNode& tapped_node, | 2138 const WebNode& tapped_node, |
2138 bool page_changed) { | 2139 bool page_changed) { |
2139 DCHECK(handling_input_event_); | 2140 DCHECK(handling_input_event_); |
2141 WebCursor::CursorInfo cursor_info; | |
2142 current_cursor_.GetCursorInfo(&cursor_info); | |
dmazzoni
2015/01/23 17:39:56
I haven't used current_cursor_ before - are we sur
Donn Denman
2015/01/29 22:42:39
I couldn't figure out the cursor stuff, so decided
| |
2143 bool has_pointer_cursor = cursor_info.type == WebCursorInfo::TypeHand; | |
2144 bool has_wai_aria_role = hasAriaRole(tapped_node); | |
2140 bool should_trigger = !page_changed && tapped_node.isTextNode() && | 2145 bool should_trigger = !page_changed && tapped_node.isTextNode() && |
2141 !tapped_node.isContentEditable(); | 2146 !tapped_node.isContentEditable() && |
2147 !has_wai_aria_role && !tapped_node.isFocusable() && | |
dmazzoni
2015/01/23 17:39:56
I think you need to search up the ancestor chain t
Donn Denman
2015/01/29 22:42:39
Done -- Now checking all ancestors for focusabilit
| |
2148 !has_pointer_cursor; | |
2142 if (should_trigger) { | 2149 if (should_trigger) { |
2143 Send(new ViewHostMsg_ShowUnhandledTapUIIfNeeded(routing_id_, | 2150 Send(new ViewHostMsg_ShowUnhandledTapUIIfNeeded(routing_id_, |
2144 tapped_position.x, tapped_position.y)); | 2151 tapped_position.x, tapped_position.y)); |
2145 } | 2152 } |
2146 } | 2153 } |
2154 | |
2155 bool RenderWidget::hasAriaRole(const WebNode& node) { | |
dmazzoni
2015/01/23 17:39:56
This should probably be named hasWidgetAriaRole or
Donn Denman
2015/01/29 22:42:39
Moved this logic into Blink.
| |
2156 // From http://www.w3.org/TR/wai-aria/roles#widget_roles | |
2157 const ui::AXRole widget_and_composite_roles[] = { | |
2158 ui::AX_ROLE_ALERT, | |
dmazzoni
2015/01/23 17:39:56
ui::AXRole is not a list of ARIA roles, it's a lis
Donn Denman
2015/01/29 22:42:39
Thanks for explaining this. Moved to WebAXObject.
| |
2159 ui::AX_ROLE_ALERT_DIALOG, | |
2160 ui::AX_ROLE_BUTTON, | |
2161 ui::AX_ROLE_CHECK_BOX, | |
2162 ui::AX_ROLE_DIALOG, | |
2163 // TODO(donnd): add these missing role definitions! | |
2164 // ui::AX_ROLE_GRID_CELL, | |
2165 ui::AX_ROLE_LINK, | |
2166 ui::AX_ROLE_MARQUEE, | |
2167 ui::AX_ROLE_MENU_ITEM, | |
2168 ui::AX_ROLE_MENU_ITEM_CHECK_BOX, | |
2169 ui::AX_ROLE_MENU_ITEM_RADIO, | |
2170 // ui::AX_ROLE_OPTION, | |
2171 // ui::AX_ROLE_PROGRESS_BAR, | |
2172 // ui::AX_ROLE_RADIO, | |
2173 ui::AX_ROLE_SCROLL_BAR, | |
2174 ui::AX_ROLE_SLIDER, | |
2175 ui::AX_ROLE_SPIN_BUTTON, | |
2176 ui::AX_ROLE_STATUS, | |
2177 ui::AX_ROLE_TAB, | |
2178 ui::AX_ROLE_TAB_PANEL, | |
2179 // ui::AX_ROLE_TEXT_BOX, | |
2180 ui::AX_ROLE_TIMER, | |
2181 ui::AX_ROLE_TOOLTIP, | |
2182 ui::AX_ROLE_TREE_ITEM, | |
2183 // Composite roles. | |
2184 ui::AX_ROLE_COMBO_BOX, | |
2185 ui::AX_ROLE_GRID, | |
2186 ui::AX_ROLE_LIST_BOX, | |
2187 ui::AX_ROLE_MENU, | |
2188 ui::AX_ROLE_MENU_BAR, | |
2189 ui::AX_ROLE_RADIO_GROUP, | |
2190 ui::AX_ROLE_TAB_LIST, | |
2191 ui::AX_ROLE_TREE, | |
2192 ui::AX_ROLE_TREE_GRID}; | |
2193 WebNode curNode = node; | |
2194 do { | |
2195 if (curNode.isElementNode()) { | |
2196 const blink::WebElement& element = curNode.toConst<blink::WebElement>(); | |
2197 VLOG(0) << "ctxs markup: " << element.createMarkup().utf8().data(); | |
2198 std::string role = element.getAttribute("role").utf8().data(); | |
dmazzoni
2015/01/23 17:39:56
The role attribute is actually allowed to be a spa
Donn Denman
2015/01/29 22:42:39
Done in the Blink CL. Thanks for pointing this ou
| |
2199 if (role.length() > 0) { | |
2200 VLOG(0) << "ctxs role: " << role; | |
2201 for (unsigned i = 0; | |
dmazzoni
2015/01/23 17:39:56
I'd use a hash_set for this - even if we don't thi
Donn Denman
2015/01/29 22:42:39
Done.
| |
2202 i < sizeof(widget_and_composite_roles) / sizeof(roles[0]); i++) { | |
2203 if (ui::ToString(widget_and_composite_roles[i]) == role) | |
dmazzoni
2015/01/23 17:39:56
This should be case-insensitive. I'd convert the a
Donn Denman
2015/01/29 22:42:39
Done in the Blink CL. Thanks for pointing this ou
| |
2204 return true; | |
2205 } | |
2206 } | |
2207 } | |
2208 curNode = curNode.parentNode(); | |
2209 } while (!curNode.isNull()); | |
2210 return false; | |
2211 } | |
2147 #endif | 2212 #endif |
2148 | 2213 |
2149 void RenderWidget::didHandleGestureEvent( | 2214 void RenderWidget::didHandleGestureEvent( |
2150 const WebGestureEvent& event, | 2215 const WebGestureEvent& event, |
2151 bool event_cancelled) { | 2216 bool event_cancelled) { |
2152 #if defined(OS_ANDROID) || defined(USE_AURA) | 2217 #if defined(OS_ANDROID) || defined(USE_AURA) |
2153 if (event_cancelled) | 2218 if (event_cancelled) |
2154 return; | 2219 return; |
2155 if (event.type == WebInputEvent::GestureTap) { | 2220 if (event.type == WebInputEvent::GestureTap) { |
2156 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); | 2221 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2373 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2438 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2374 video_hole_frames_.AddObserver(frame); | 2439 video_hole_frames_.AddObserver(frame); |
2375 } | 2440 } |
2376 | 2441 |
2377 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2442 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2378 video_hole_frames_.RemoveObserver(frame); | 2443 video_hole_frames_.RemoveObserver(frame); |
2379 } | 2444 } |
2380 #endif // defined(VIDEO_HOLE) | 2445 #endif // defined(VIDEO_HOLE) |
2381 | 2446 |
2382 } // namespace content | 2447 } // namespace content |
OLD | NEW |