| 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" |
| 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" | |
| 24 #include "content/browser/accessibility/browser_accessibility_manager.h" | 23 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 25 #include "content/browser/plugin_process_host.h" | 24 #include "content/browser/plugin_process_host.h" |
| 26 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" | 25 #import "content/browser/renderer_host/accelerated_plugin_view_mac.h" |
| 27 #include "content/browser/renderer_host/backing_store_mac.h" | 26 #include "content/browser/renderer_host/backing_store_mac.h" |
| 28 #include "content/browser/renderer_host/backing_store_manager.h" | 27 #include "content/browser/renderer_host/backing_store_manager.h" |
| 29 #include "content/browser/renderer_host/compositing_iosurface_mac.h" | 28 #include "content/browser/renderer_host/compositing_iosurface_mac.h" |
| 30 #include "content/browser/renderer_host/render_process_host_impl.h" | 29 #include "content/browser/renderer_host/render_process_host_impl.h" |
| 31 #include "content/browser/renderer_host/render_view_host_impl.h" | 30 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 32 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" | 31 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h
elper.h" |
| 33 #import "content/browser/renderer_host/text_input_client_mac.h" | 32 #import "content/browser/renderer_host/text_input_client_mac.h" |
| (...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2100 BrowserAccessibilityManager* manager = | 2099 BrowserAccessibilityManager* manager = |
| 2101 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2100 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2102 | 2101 |
| 2103 // Contents specifies document view of RenderWidgetHostViewCocoa provided by | 2102 // Contents specifies document view of RenderWidgetHostViewCocoa provided by |
| 2104 // BrowserAccessibilityManager. Children includes all subviews in addition to | 2103 // BrowserAccessibilityManager. Children includes all subviews in addition to |
| 2105 // contents. Currently we do not have subviews besides the document view. | 2104 // contents. Currently we do not have subviews besides the document view. |
| 2106 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || | 2105 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || |
| 2107 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && | 2106 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && |
| 2108 manager) { | 2107 manager) { |
| 2109 return [NSArray arrayWithObjects:manager-> | 2108 return [NSArray arrayWithObjects:manager-> |
| 2110 GetRoot()->ToBrowserAccessibilityMac()->native_view(), nil]; | 2109 GetRoot()->toBrowserAccessibilityCocoa(), nil]; |
| 2111 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { | 2110 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { |
| 2112 return NSAccessibilityScrollAreaRole; | 2111 return NSAccessibilityScrollAreaRole; |
| 2113 } | 2112 } |
| 2114 id ret = [super accessibilityAttributeValue:attribute]; | 2113 id ret = [super accessibilityAttributeValue:attribute]; |
| 2115 return ret; | 2114 return ret; |
| 2116 } | 2115 } |
| 2117 | 2116 |
| 2118 - (NSArray*)accessibilityAttributeNames { | 2117 - (NSArray*)accessibilityAttributeNames { |
| 2119 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 2118 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 2120 [ret addObject:NSAccessibilityContentsAttribute]; | 2119 [ret addObject:NSAccessibilityContentsAttribute]; |
| 2121 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; | 2120 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; |
| 2122 return ret; | 2121 return ret; |
| 2123 } | 2122 } |
| 2124 | 2123 |
| 2125 - (id)accessibilityHitTest:(NSPoint)point { | 2124 - (id)accessibilityHitTest:(NSPoint)point { |
| 2126 if (!renderWidgetHostView_->GetBrowserAccessibilityManager()) | 2125 if (!renderWidgetHostView_->GetBrowserAccessibilityManager()) |
| 2127 return self; | 2126 return self; |
| 2128 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; | 2127 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; |
| 2129 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; | 2128 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; |
| 2130 localPoint.y = NSHeight([self bounds]) - localPoint.y; | 2129 localPoint.y = NSHeight([self bounds]) - localPoint.y; |
| 2131 BrowserAccessibilityCocoa* root = renderWidgetHostView_-> | 2130 BrowserAccessibilityCocoa* root = renderWidgetHostView_-> |
| 2132 GetBrowserAccessibilityManager()-> | 2131 GetBrowserAccessibilityManager()-> |
| 2133 GetRoot()->ToBrowserAccessibilityMac()->native_view(); | 2132 GetRoot()->toBrowserAccessibilityCocoa(); |
| 2134 id obj = [root accessibilityHitTest:localPoint]; | 2133 id obj = [root accessibilityHitTest:localPoint]; |
| 2135 return obj; | 2134 return obj; |
| 2136 } | 2135 } |
| 2137 | 2136 |
| 2138 - (BOOL)accessibilityIsIgnored { | 2137 - (BOOL)accessibilityIsIgnored { |
| 2139 return !renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2138 return !renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2140 } | 2139 } |
| 2141 | 2140 |
| 2142 - (NSUInteger)accessibilityGetIndexOf:(id)child { | 2141 - (NSUInteger)accessibilityGetIndexOf:(id)child { |
| 2143 BrowserAccessibilityManager* manager = | 2142 BrowserAccessibilityManager* manager = |
| 2144 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2143 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2145 // Only child is root. | 2144 // Only child is root. |
| 2146 if (manager && | 2145 if (manager && |
| 2147 manager->GetRoot()->ToBrowserAccessibilityMac()->native_view() == child) { | 2146 manager->GetRoot()->toBrowserAccessibilityCocoa() == child) { |
| 2148 return 0; | 2147 return 0; |
| 2149 } else { | 2148 } else { |
| 2150 return NSNotFound; | 2149 return NSNotFound; |
| 2151 } | 2150 } |
| 2152 } | 2151 } |
| 2153 | 2152 |
| 2154 - (id)accessibilityFocusedUIElement { | 2153 - (id)accessibilityFocusedUIElement { |
| 2155 BrowserAccessibilityManager* manager = | 2154 BrowserAccessibilityManager* manager = |
| 2156 renderWidgetHostView_->GetBrowserAccessibilityManager(); | 2155 renderWidgetHostView_->GetBrowserAccessibilityManager(); |
| 2157 if (manager) { | 2156 if (manager) { |
| 2158 BrowserAccessibility* focused_item = manager->GetFocus(NULL); | 2157 BrowserAccessibility* focused_item = manager->GetFocus(NULL); |
| 2159 DCHECK(focused_item); | 2158 DCHECK(focused_item); |
| 2160 if (focused_item) { | 2159 if (focused_item) { |
| 2161 BrowserAccessibilityCocoa* focused_item_cocoa = | 2160 BrowserAccessibilityCocoa* focused_item_cocoa = |
| 2162 focused_item->ToBrowserAccessibilityMac()->native_view(); | 2161 focused_item->toBrowserAccessibilityCocoa(); |
| 2163 DCHECK(focused_item_cocoa); | 2162 DCHECK(focused_item_cocoa); |
| 2164 if (focused_item_cocoa) | 2163 if (focused_item_cocoa) |
| 2165 return focused_item_cocoa; | 2164 return focused_item_cocoa; |
| 2166 } | 2165 } |
| 2167 } | 2166 } |
| 2168 return [super accessibilityFocusedUIElement]; | 2167 return [super accessibilityFocusedUIElement]; |
| 2169 } | 2168 } |
| 2170 | 2169 |
| 2171 - (void)doDefaultAction:(int32)accessibilityObjectId { | 2170 - (void)doDefaultAction:(int32)accessibilityObjectId { |
| 2172 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... |
| 2898 if (!string) return NO; | 2897 if (!string) return NO; |
| 2899 | 2898 |
| 2900 // 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, |
| 2901 // 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. |
| 2902 [self confirmComposition]; | 2901 [self confirmComposition]; |
| 2903 [self insertText:string]; | 2902 [self insertText:string]; |
| 2904 return YES; | 2903 return YES; |
| 2905 } | 2904 } |
| 2906 | 2905 |
| 2907 @end | 2906 @end |
| OLD | NEW |