| 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/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" |
| (...skipping 2088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2099 BrowserAccessibilityManager* manager = | 2099 BrowserAccessibilityManager* manager = |
| 2100 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2100 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2101 | 2101 |
| 2102 // Contents specifies document view of RenderWidgetHostViewCocoa provided by | 2102 // Contents specifies document view of RenderWidgetHostViewCocoa provided by |
| 2103 // BrowserAccessibilityManager. Children includes all subviews in addition to | 2103 // BrowserAccessibilityManager. Children includes all subviews in addition to |
| 2104 // contents. Currently we do not have subviews besides the document view. | 2104 // contents. Currently we do not have subviews besides the document view. |
| 2105 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || | 2105 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || |
| 2106 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && | 2106 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && |
| 2107 manager) { | 2107 manager) { |
| 2108 return [NSArray arrayWithObjects:manager-> | 2108 return [NSArray arrayWithObjects:manager-> |
| 2109 GetRoot()->ToBrowserAccessibilityCocoa(), nil]; | 2109 GetRoot()->toBrowserAccessibilityCocoa(), nil]; |
| 2110 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { | 2110 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { |
| 2111 return NSAccessibilityScrollAreaRole; | 2111 return NSAccessibilityScrollAreaRole; |
| 2112 } | 2112 } |
| 2113 id ret = [super accessibilityAttributeValue:attribute]; | 2113 id ret = [super accessibilityAttributeValue:attribute]; |
| 2114 return ret; | 2114 return ret; |
| 2115 } | 2115 } |
| 2116 | 2116 |
| 2117 - (NSArray*)accessibilityAttributeNames { | 2117 - (NSArray*)accessibilityAttributeNames { |
| 2118 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 2118 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 2119 [ret addObject:NSAccessibilityContentsAttribute]; | 2119 [ret addObject:NSAccessibilityContentsAttribute]; |
| 2120 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; | 2120 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; |
| 2121 return ret; | 2121 return ret; |
| 2122 } | 2122 } |
| 2123 | 2123 |
| 2124 - (id)accessibilityHitTest:(NSPoint)point { | 2124 - (id)accessibilityHitTest:(NSPoint)point { |
| 2125 if (!renderWidgetHostView_->GetBrowserAccessibilityManager()) | 2125 if (!renderWidgetHostView_->GetBrowserAccessibilityManager()) |
| 2126 return self; | 2126 return self; |
| 2127 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; | 2127 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; |
| 2128 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; | 2128 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; |
| 2129 localPoint.y = NSHeight([self bounds]) - localPoint.y; | 2129 localPoint.y = NSHeight([self bounds]) - localPoint.y; |
| 2130 BrowserAccessibilityCocoa* root = renderWidgetHostView_-> | 2130 BrowserAccessibilityCocoa* root = renderWidgetHostView_-> |
| 2131 GetBrowserAccessibilityManager()-> | 2131 GetBrowserAccessibilityManager()-> |
| 2132 GetRoot()->ToBrowserAccessibilityCocoa(); | 2132 GetRoot()->toBrowserAccessibilityCocoa(); |
| 2133 id obj = [root accessibilityHitTest:localPoint]; | 2133 id obj = [root accessibilityHitTest:localPoint]; |
| 2134 return obj; | 2134 return obj; |
| 2135 } | 2135 } |
| 2136 | 2136 |
| 2137 - (BOOL)accessibilityIsIgnored { | 2137 - (BOOL)accessibilityIsIgnored { |
| 2138 return !renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2138 return !renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2139 } | 2139 } |
| 2140 | 2140 |
| 2141 - (NSUInteger)accessibilityGetIndexOf:(id)child { | 2141 - (NSUInteger)accessibilityGetIndexOf:(id)child { |
| 2142 BrowserAccessibilityManager* manager = | 2142 BrowserAccessibilityManager* manager = |
| 2143 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2143 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2144 // Only child is root. | 2144 // Only child is root. |
| 2145 if (manager && | 2145 if (manager && |
| 2146 manager->GetRoot()->ToBrowserAccessibilityCocoa() == child) { | 2146 manager->GetRoot()->toBrowserAccessibilityCocoa() == child) { |
| 2147 return 0; | 2147 return 0; |
| 2148 } else { | 2148 } else { |
| 2149 return NSNotFound; | 2149 return NSNotFound; |
| 2150 } | 2150 } |
| 2151 } | 2151 } |
| 2152 | 2152 |
| 2153 - (id)accessibilityFocusedUIElement { | 2153 - (id)accessibilityFocusedUIElement { |
| 2154 BrowserAccessibilityManager* manager = | 2154 BrowserAccessibilityManager* manager = |
| 2155 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2155 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2156 if (manager) { | 2156 if (manager) { |
| 2157 BrowserAccessibility* focused_item = manager->GetFocus(NULL); | 2157 BrowserAccessibility* focused_item = manager->GetFocus(NULL); |
| 2158 DCHECK(focused_item); | 2158 DCHECK(focused_item); |
| 2159 if (focused_item) { | 2159 if (focused_item) { |
| 2160 BrowserAccessibilityCocoa* focused_item_cocoa = | 2160 BrowserAccessibilityCocoa* focused_item_cocoa = |
| 2161 focused_item->ToBrowserAccessibilityCocoa(); | 2161 focused_item->toBrowserAccessibilityCocoa(); |
| 2162 DCHECK(focused_item_cocoa); | 2162 DCHECK(focused_item_cocoa); |
| 2163 if (focused_item_cocoa) | 2163 if (focused_item_cocoa) |
| 2164 return focused_item_cocoa; | 2164 return focused_item_cocoa; |
| 2165 } | 2165 } |
| 2166 } | 2166 } |
| 2167 return [super accessibilityFocusedUIElement]; | 2167 return [super accessibilityFocusedUIElement]; |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 - (void)doDefaultAction:(int32)accessibilityObjectId { | 2170 - (void)doDefaultAction:(int32)accessibilityObjectId { |
| 2171 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; | 2171 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 if (!string) return NO; | 2897 if (!string) return NO; |
| 2898 | 2898 |
| 2899 // If the user is currently using an IME, confirm the IME input, | 2899 // 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. | 2900 // and then insert the text from the service, the same as TextEdit and Safari. |
| 2901 [self confirmComposition]; | 2901 [self confirmComposition]; |
| 2902 [self insertText:string]; | 2902 [self insertText:string]; |
| 2903 return YES; | 2903 return YES; |
| 2904 } | 2904 } |
| 2905 | 2905 |
| 2906 @end | 2906 @end |
| OLD | NEW |