Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 10381010: Add initial GTK web accessibility framework (new with valgrind fix). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/render_widget_host_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/mac/closure_blocks_leopard_compat.h" 12 #include "base/mac/closure_blocks_leopard_compat.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #include "base/mac/scoped_cftyperef.h" 14 #include "base/mac/scoped_cftyperef.h"
15 #import "base/mac/scoped_nsautorelease_pool.h" 15 #import "base/mac/scoped_nsautorelease_pool.h"
16 #import "base/memory/scoped_nsobject.h" 16 #import "base/memory/scoped_nsobject.h"
17 #include "base/metrics/histogram.h" 17 #include "base/metrics/histogram.h"
18 #include "base/string_util.h" 18 #include "base/string_util.h"
19 #include "base/sys_info.h" 19 #include "base/sys_info.h"
20 #include "base/sys_string_conversions.h" 20 #include "base/sys_string_conversions.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 22 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
23 #import "content/browser/accessibility/browser_accessibility_mac.h"
23 #include "content/browser/accessibility/browser_accessibility_manager.h" 24 #include "content/browser/accessibility/browser_accessibility_manager.h"
24 #include "content/browser/plugin_process_host.h" 25 #include "content/browser/plugin_process_host.h"
25 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" 26 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h"
26 #include "content/browser/renderer_host/backing_store_mac.h" 27 #include "content/browser/renderer_host/backing_store_mac.h"
27 #include "content/browser/renderer_host/backing_store_manager.h" 28 #include "content/browser/renderer_host/backing_store_manager.h"
28 #include "content/browser/renderer_host/compositing_iosurface_mac.h" 29 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
29 #include "content/browser/renderer_host/render_process_host_impl.h" 30 #include "content/browser/renderer_host/render_process_host_impl.h"
30 #include "content/browser/renderer_host/render_view_host_impl.h" 31 #include "content/browser/renderer_host/render_view_host_impl.h"
31 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 32 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
32 #import "content/browser/renderer_host/text_input_client_mac.h" 33 #import "content/browser/renderer_host/text_input_client_mac.h"
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 BrowserAccessibilityManager* manager = 2100 BrowserAccessibilityManager* manager =
2100 renderWidgetHostView_->GetBrowserAccessibilityManager(); 2101 renderWidgetHostView_->GetBrowserAccessibilityManager();
2101 2102
2102 // Contents specifies document view of RenderWidgetHostViewCocoa provided by 2103 // Contents specifies document view of RenderWidgetHostViewCocoa provided by
2103 // BrowserAccessibilityManager. Children includes all subviews in addition to 2104 // BrowserAccessibilityManager. Children includes all subviews in addition to
2104 // contents. Currently we do not have subviews besides the document view. 2105 // contents. Currently we do not have subviews besides the document view.
2105 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || 2106 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] ||
2106 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && 2107 [attribute isEqualToString:NSAccessibilityContentsAttribute]) &&
2107 manager) { 2108 manager) {
2108 return [NSArray arrayWithObjects:manager-> 2109 return [NSArray arrayWithObjects:manager->
2109 GetRoot()->toBrowserAccessibilityCocoa(), nil]; 2110 GetRoot()->ToBrowserAccessibilityMac()->native_view(), nil];
2110 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { 2111 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
2111 return NSAccessibilityScrollAreaRole; 2112 return NSAccessibilityScrollAreaRole;
2112 } 2113 }
2113 id ret = [super accessibilityAttributeValue:attribute]; 2114 id ret = [super accessibilityAttributeValue:attribute];
2114 return ret; 2115 return ret;
2115 } 2116 }
2116 2117
2117 - (NSArray*)accessibilityAttributeNames { 2118 - (NSArray*)accessibilityAttributeNames {
2118 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 2119 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
2119 [ret addObject:NSAccessibilityContentsAttribute]; 2120 [ret addObject:NSAccessibilityContentsAttribute];
2120 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; 2121 [ret addObjectsFromArray:[super accessibilityAttributeNames]];
2121 return ret; 2122 return ret;
2122 } 2123 }
2123 2124
2124 - (id)accessibilityHitTest:(NSPoint)point { 2125 - (id)accessibilityHitTest:(NSPoint)point {
2125 if (!renderWidgetHostView_->GetBrowserAccessibilityManager()) 2126 if (!renderWidgetHostView_->GetBrowserAccessibilityManager())
2126 return self; 2127 return self;
2127 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; 2128 NSPoint pointInWindow = [[self window] convertScreenToBase:point];
2128 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; 2129 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil];
2129 localPoint.y = NSHeight([self bounds]) - localPoint.y; 2130 localPoint.y = NSHeight([self bounds]) - localPoint.y;
2130 BrowserAccessibilityCocoa* root = renderWidgetHostView_-> 2131 BrowserAccessibilityCocoa* root = renderWidgetHostView_->
2131 GetBrowserAccessibilityManager()-> 2132 GetBrowserAccessibilityManager()->
2132 GetRoot()->toBrowserAccessibilityCocoa(); 2133 GetRoot()->ToBrowserAccessibilityMac()->native_view();
2133 id obj = [root accessibilityHitTest:localPoint]; 2134 id obj = [root accessibilityHitTest:localPoint];
2134 return obj; 2135 return obj;
2135 } 2136 }
2136 2137
2137 - (BOOL)accessibilityIsIgnored { 2138 - (BOOL)accessibilityIsIgnored {
2138 return !renderWidgetHostView_->GetBrowserAccessibilityManager(); 2139 return !renderWidgetHostView_->GetBrowserAccessibilityManager();
2139 } 2140 }
2140 2141
2141 - (NSUInteger)accessibilityGetIndexOf:(id)child { 2142 - (NSUInteger)accessibilityGetIndexOf:(id)child {
2142 BrowserAccessibilityManager* manager = 2143 BrowserAccessibilityManager* manager =
2143 renderWidgetHostView_->GetBrowserAccessibilityManager(); 2144 renderWidgetHostView_->GetBrowserAccessibilityManager();
2144 // Only child is root. 2145 // Only child is root.
2145 if (manager && 2146 if (manager &&
2146 manager->GetRoot()->toBrowserAccessibilityCocoa() == child) { 2147 manager->GetRoot()->ToBrowserAccessibilityMac()->native_view() == child) {
2147 return 0; 2148 return 0;
2148 } else { 2149 } else {
2149 return NSNotFound; 2150 return NSNotFound;
2150 } 2151 }
2151 } 2152 }
2152 2153
2153 - (id)accessibilityFocusedUIElement { 2154 - (id)accessibilityFocusedUIElement {
2154 BrowserAccessibilityManager* manager = 2155 BrowserAccessibilityManager* manager =
2155 renderWidgetHostView_->GetBrowserAccessibilityManager(); 2156 renderWidgetHostView_->GetBrowserAccessibilityManager();
2156 if (manager) { 2157 if (manager) {
2157 BrowserAccessibility* focused_item = manager->GetFocus(NULL); 2158 BrowserAccessibility* focused_item = manager->GetFocus(NULL);
2158 DCHECK(focused_item); 2159 DCHECK(focused_item);
2159 if (focused_item) { 2160 if (focused_item) {
2160 BrowserAccessibilityCocoa* focused_item_cocoa = 2161 BrowserAccessibilityCocoa* focused_item_cocoa =
2161 focused_item->toBrowserAccessibilityCocoa(); 2162 focused_item->ToBrowserAccessibilityMac()->native_view();
2162 DCHECK(focused_item_cocoa); 2163 DCHECK(focused_item_cocoa);
2163 if (focused_item_cocoa) 2164 if (focused_item_cocoa)
2164 return focused_item_cocoa; 2165 return focused_item_cocoa;
2165 } 2166 }
2166 } 2167 }
2167 return [super accessibilityFocusedUIElement]; 2168 return [super accessibilityFocusedUIElement];
2168 } 2169 }
2169 2170
2170 - (void)doDefaultAction:(int32)accessibilityObjectId { 2171 - (void)doDefaultAction:(int32)accessibilityObjectId {
2171 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; 2172 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_;
(...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 if (!string) return NO; 2898 if (!string) return NO;
2898 2899
2899 // If the user is currently using an IME, confirm the IME input, 2900 // If the user is currently using an IME, confirm the IME input,
2900 // and then insert the text from the service, the same as TextEdit and Safari. 2901 // and then insert the text from the service, the same as TextEdit and Safari.
2901 [self confirmComposition]; 2902 [self confirmComposition];
2902 [self insertText:string]; 2903 [self insertText:string];
2903 return YES; 2904 return YES;
2904 } 2905 }
2905 2906
2906 @end 2907 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698