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

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

Issue 407493002: Revert of Migrate accessibility from RenderView to RenderFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 #import <objc/runtime.h> 7 #import <objc/runtime.h>
8 #include <OpenGL/gl.h> 8 #include <OpenGL/gl.h>
9 #include <QuartzCore/QuartzCore.h> 9 #include <QuartzCore/QuartzCore.h>
10 10
(...skipping 2047 matching lines...) Expand 10 before | Expand all | Expand 10 after
2058 RenderWidgetHostViewMacDictionaryHelper helper(this); 2058 RenderWidgetHostViewMacDictionaryHelper helper(this);
2059 helper.ShowDefinitionForSelection(); 2059 helper.ShowDefinitionForSelection();
2060 } 2060 }
2061 2061
2062 void RenderWidgetHostViewMac::SetBackgroundOpaque(bool opaque) { 2062 void RenderWidgetHostViewMac::SetBackgroundOpaque(bool opaque) {
2063 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); 2063 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque);
2064 if (render_widget_host_) 2064 if (render_widget_host_)
2065 render_widget_host_->SetBackgroundOpaque(opaque); 2065 render_widget_host_->SetBackgroundOpaque(opaque);
2066 } 2066 }
2067 2067
2068 BrowserAccessibilityManager* 2068 void RenderWidgetHostViewMac::CreateBrowserAccessibilityManagerIfNeeded() {
2069 RenderWidgetHostViewMac::CreateBrowserAccessibilityManager( 2069 if (!GetBrowserAccessibilityManager()) {
2070 BrowserAccessibilityDelegate* delegate) { 2070 SetBrowserAccessibilityManager(
2071 return new BrowserAccessibilityManagerMac( 2071 new BrowserAccessibilityManagerMac(
2072 cocoa_view_, 2072 cocoa_view_,
2073 BrowserAccessibilityManagerMac::GetEmptyDocument(), 2073 BrowserAccessibilityManagerMac::GetEmptyDocument(),
2074 delegate); 2074 render_widget_host_));
2075 }
2075 } 2076 }
2076 2077
2077 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen( 2078 gfx::Point RenderWidgetHostViewMac::AccessibilityOriginInScreen(
2078 const gfx::Rect& bounds) { 2079 const gfx::Rect& bounds) {
2079 NSPoint origin = NSMakePoint(bounds.x(), bounds.y()); 2080 NSPoint origin = NSMakePoint(bounds.x(), bounds.y());
2080 NSSize size = NSMakeSize(bounds.width(), bounds.height()); 2081 NSSize size = NSMakeSize(bounds.width(), bounds.height());
2081 origin.y = NSHeight([cocoa_view_ bounds]) - origin.y; 2082 origin.y = NSHeight([cocoa_view_ bounds]) - origin.y;
2082 NSPoint originInWindow = [cocoa_view_ convertPoint:origin toView:nil]; 2083 NSPoint originInWindow = [cocoa_view_ convertPoint:origin toView:nil];
2083 NSPoint originInScreen = 2084 NSPoint originInScreen =
2084 [[cocoa_view_ window] convertBaseToScreen:originInWindow]; 2085 [[cocoa_view_ window] convertBaseToScreen:originInWindow];
2085 originInScreen.y = originInScreen.y - size.height; 2086 originInScreen.y = originInScreen.y - size.height;
2086 return gfx::Point(originInScreen.x, originInScreen.y); 2087 return gfx::Point(originInScreen.x, originInScreen.y);
2087 } 2088 }
2088 2089
2089 void RenderWidgetHostViewMac::AccessibilityShowMenu(const gfx::Point& point) { 2090 void RenderWidgetHostViewMac::OnAccessibilitySetFocus(int accObjId) {
2090 NSPoint location = NSMakePoint(point.x(), point.y()); 2091 // Immediately set the focused item even though we have not officially set
2092 // focus on it as VoiceOver expects to get the focused item after this
2093 // method returns.
2094 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
2095 if (manager)
2096 manager->SetFocus(manager->GetFromID(accObjId), false);
2097 }
2098
2099 void RenderWidgetHostViewMac::AccessibilityShowMenu(int accObjId) {
2100 BrowserAccessibilityManager* manager = GetBrowserAccessibilityManager();
2101 if (!manager)
2102 return;
2103 BrowserAccessibilityCocoa* obj =
2104 manager->GetFromID(accObjId)->ToBrowserAccessibilityCocoa();
2105
2106 // Performs a right click copying WebKit's
2107 // accessibilityPerformShowMenuAction.
2108 NSPoint objOrigin = [obj origin];
2109 NSSize size = [[obj size] sizeValue];
2110 gfx::Point origin = AccessibilityOriginInScreen(
2111 gfx::Rect(objOrigin.x, objOrigin.y, size.width, size.height));
2112 NSPoint location = NSMakePoint(origin.x(), origin.y());
2091 location = [[cocoa_view_ window] convertScreenToBase:location]; 2113 location = [[cocoa_view_ window] convertScreenToBase:location];
2114 location.x += size.width/2;
2115 location.y += size.height/2;
2116
2092 NSEvent* fakeRightClick = [NSEvent 2117 NSEvent* fakeRightClick = [NSEvent
2093 mouseEventWithType:NSRightMouseDown 2118 mouseEventWithType:NSRightMouseDown
2094 location:location 2119 location:location
2095 modifierFlags:0 2120 modifierFlags:0
2096 timestamp:0 2121 timestamp:0
2097 windowNumber:[[cocoa_view_ window] windowNumber] 2122 windowNumber:[[cocoa_view_ window] windowNumber]
2098 context:[NSGraphicsContext currentContext] 2123 context:[NSGraphicsContext currentContext]
2099 eventNumber:0 2124 eventNumber:0
2100 clickCount:1 2125 clickCount:1
2101 pressure:0]; 2126 pressure:0];
2102 2127
2103 [cocoa_view_ mouseEvent:fakeRightClick]; 2128 [cocoa_view_ mouseEvent:fakeRightClick];
2104 } 2129 }
2105 2130
2131
2132
2106 void RenderWidgetHostViewMac::SetTextInputActive(bool active) { 2133 void RenderWidgetHostViewMac::SetTextInputActive(bool active) {
2107 if (active) { 2134 if (active) {
2108 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) 2135 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD)
2109 EnablePasswordInput(); 2136 EnablePasswordInput();
2110 else 2137 else
2111 DisablePasswordInput(); 2138 DisablePasswordInput();
2112 } else { 2139 } else {
2113 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD) 2140 if (text_input_type_ == ui::TEXT_INPUT_TYPE_PASSWORD)
2114 DisablePasswordInput(); 2141 DisablePasswordInput();
2115 } 2142 }
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
3143 return [fullArray subarrayWithRange:NSMakeRange(index, length)]; 3170 return [fullArray subarrayWithRange:NSMakeRange(index, length)];
3144 } 3171 }
3145 3172
3146 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute { 3173 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute {
3147 NSArray* fullArray = [self accessibilityAttributeValue:attribute]; 3174 NSArray* fullArray = [self accessibilityAttributeValue:attribute];
3148 return [fullArray count]; 3175 return [fullArray count];
3149 } 3176 }
3150 3177
3151 - (id)accessibilityAttributeValue:(NSString *)attribute { 3178 - (id)accessibilityAttributeValue:(NSString *)attribute {
3152 BrowserAccessibilityManager* manager = 3179 BrowserAccessibilityManager* manager =
3153 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 3180 renderWidgetHostView_->GetBrowserAccessibilityManager();
3154 3181
3155 // Contents specifies document view of RenderWidgetHostViewCocoa provided by 3182 // Contents specifies document view of RenderWidgetHostViewCocoa provided by
3156 // BrowserAccessibilityManager. Children includes all subviews in addition to 3183 // BrowserAccessibilityManager. Children includes all subviews in addition to
3157 // contents. Currently we do not have subviews besides the document view. 3184 // contents. Currently we do not have subviews besides the document view.
3158 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || 3185 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] ||
3159 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && 3186 [attribute isEqualToString:NSAccessibilityContentsAttribute]) &&
3160 manager) { 3187 manager) {
3161 return [NSArray arrayWithObjects:manager-> 3188 return [NSArray arrayWithObjects:manager->
3162 GetRoot()->ToBrowserAccessibilityCocoa(), nil]; 3189 GetRoot()->ToBrowserAccessibilityCocoa(), nil];
3163 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { 3190 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
3164 return NSAccessibilityScrollAreaRole; 3191 return NSAccessibilityScrollAreaRole;
3165 } 3192 }
3166 id ret = [super accessibilityAttributeValue:attribute]; 3193 id ret = [super accessibilityAttributeValue:attribute];
3167 return ret; 3194 return ret;
3168 } 3195 }
3169 3196
3170 - (NSArray*)accessibilityAttributeNames { 3197 - (NSArray*)accessibilityAttributeNames {
3171 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 3198 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
3172 [ret addObject:NSAccessibilityContentsAttribute]; 3199 [ret addObject:NSAccessibilityContentsAttribute];
3173 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; 3200 [ret addObjectsFromArray:[super accessibilityAttributeNames]];
3174 return ret; 3201 return ret;
3175 } 3202 }
3176 3203
3177 - (id)accessibilityHitTest:(NSPoint)point { 3204 - (id)accessibilityHitTest:(NSPoint)point {
3178 BrowserAccessibilityManager* manager = 3205 if (!renderWidgetHostView_->GetBrowserAccessibilityManager())
3179 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager();
3180 if (!manager)
3181 return self; 3206 return self;
3182 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; 3207 NSPoint pointInWindow = [[self window] convertScreenToBase:point];
3183 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; 3208 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil];
3184 localPoint.y = NSHeight([self bounds]) - localPoint.y; 3209 localPoint.y = NSHeight([self bounds]) - localPoint.y;
3185 BrowserAccessibilityCocoa* root = 3210 BrowserAccessibilityCocoa* root = renderWidgetHostView_->
3186 manager->GetRoot()->ToBrowserAccessibilityCocoa(); 3211 GetBrowserAccessibilityManager()->
3212 GetRoot()->ToBrowserAccessibilityCocoa();
3187 id obj = [root accessibilityHitTest:localPoint]; 3213 id obj = [root accessibilityHitTest:localPoint];
3188 return obj; 3214 return obj;
3189 } 3215 }
3190 3216
3191 - (BOOL)accessibilityIsIgnored { 3217 - (BOOL)accessibilityIsIgnored {
3192 BrowserAccessibilityManager* manager = 3218 return !renderWidgetHostView_->GetBrowserAccessibilityManager();
3193 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager();
3194 return !manager;
3195 } 3219 }
3196 3220
3197 - (NSUInteger)accessibilityGetIndexOf:(id)child { 3221 - (NSUInteger)accessibilityGetIndexOf:(id)child {
3198 BrowserAccessibilityManager* manager = 3222 BrowserAccessibilityManager* manager =
3199 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 3223 renderWidgetHostView_->GetBrowserAccessibilityManager();
3200 // Only child is root. 3224 // Only child is root.
3201 if (manager && 3225 if (manager &&
3202 manager->GetRoot()->ToBrowserAccessibilityCocoa() == child) { 3226 manager->GetRoot()->ToBrowserAccessibilityCocoa() == child) {
3203 return 0; 3227 return 0;
3204 } else { 3228 } else {
3205 return NSNotFound; 3229 return NSNotFound;
3206 } 3230 }
3207 } 3231 }
3208 3232
3209 - (id)accessibilityFocusedUIElement { 3233 - (id)accessibilityFocusedUIElement {
3210 BrowserAccessibilityManager* manager = 3234 BrowserAccessibilityManager* manager =
3211 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 3235 renderWidgetHostView_->GetBrowserAccessibilityManager();
3212 if (manager) { 3236 if (manager) {
3213 BrowserAccessibility* focused_item = manager->GetFocus(NULL); 3237 BrowserAccessibility* focused_item = manager->GetFocus(NULL);
3214 DCHECK(focused_item); 3238 DCHECK(focused_item);
3215 if (focused_item) { 3239 if (focused_item) {
3216 BrowserAccessibilityCocoa* focused_item_cocoa = 3240 BrowserAccessibilityCocoa* focused_item_cocoa =
3217 focused_item->ToBrowserAccessibilityCocoa(); 3241 focused_item->ToBrowserAccessibilityCocoa();
3218 DCHECK(focused_item_cocoa); 3242 DCHECK(focused_item_cocoa);
3219 if (focused_item_cocoa) 3243 if (focused_item_cocoa)
3220 return focused_item_cocoa; 3244 return focused_item_cocoa;
3221 } 3245 }
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after
3958 3982
3959 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3983 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3960 // regions that are not draggable. (See ControlRegionView in 3984 // regions that are not draggable. (See ControlRegionView in
3961 // native_app_window_cocoa.mm). This requires the render host view to be 3985 // native_app_window_cocoa.mm). This requires the render host view to be
3962 // draggable by default. 3986 // draggable by default.
3963 - (BOOL)mouseDownCanMoveWindow { 3987 - (BOOL)mouseDownCanMoveWindow {
3964 return YES; 3988 return YES;
3965 } 3989 }
3966 3990
3967 @end 3991 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698