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

Side by Side Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 849143003: Fix focus and bounds calculations for guest frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
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 <execinfo.h> 5 #include <execinfo.h>
6 6
7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 7 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
8 8
9 #include <map> 9 #include <map>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "base/strings/sys_string_conversions.h" 13 #include "base/strings/sys_string_conversions.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "content/app/strings/grit/content_strings.h" 15 #include "content/app/strings/grit/content_strings.h"
16 #include "content/browser/accessibility/browser_accessibility_manager.h" 16 #include "content/browser/accessibility/browser_accessibility_manager.h"
17 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 17 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
18 #include "content/public/common/content_client.h" 18 #include "content/public/common/content_client.h"
19 #import "ui/accessibility/platform/ax_platform_node_mac.h" 19 #import "ui/accessibility/platform/ax_platform_node_mac.h"
20 20
21 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, 21 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5,
22 // 10.6, and 10.7. It allows accessibility clients to observe events posted on 22 // 10.6, and 10.7. It allows accessibility clients to observe events posted on
23 // this object. 23 // this object.
24 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element); 24 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element);
25 25
26 using ui::AXNodeData; 26 using ui::AXNodeData;
27 using content::BrowserAccessibility; 27 using content::BrowserAccessibility;
28 using content::BrowserAccessibilityDelegate;
28 using content::BrowserAccessibilityManager; 29 using content::BrowserAccessibilityManager;
29 using content::BrowserAccessibilityManagerMac; 30 using content::BrowserAccessibilityManagerMac;
30 using content::ContentClient; 31 using content::ContentClient;
31 typedef ui::AXStringAttribute StringAttribute; 32 typedef ui::AXStringAttribute StringAttribute;
32 33
33 namespace { 34 namespace {
34 35
35 // Returns an autoreleased copy of the AXNodeData's attribute. 36 // Returns an autoreleased copy of the AXNodeData's attribute.
36 NSString* NSStringForStringAttribute( 37 NSString* NSStringForStringAttribute(
37 BrowserAccessibility* browserAccessibility, 38 BrowserAccessibility* browserAccessibility,
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 return browserAccessibility_->manager() ? 502 return browserAccessibility_->manager() ?
502 browserAccessibility_->manager()->delegate() : 503 browserAccessibility_->manager()->delegate() :
503 nil; 504 nil;
504 } 505 }
505 506
506 - (NSPoint)pointInScreen:(NSPoint)origin 507 - (NSPoint)pointInScreen:(NSPoint)origin
507 size:(NSSize)size { 508 size:(NSSize)size {
508 if (!browserAccessibility_) 509 if (!browserAccessibility_)
509 return NSZeroPoint; 510 return NSZeroPoint;
510 511
512 // Get the delegate for the topmost BrowserAccessibilityManager, because
513 // that's the only one that can convert points to their origin in the screen.
514 BrowserAccessibilityManager* manager = browserAccessibility_->manager();
515 BrowserAccessibility* root = manager->GetRoot();
516 while (root->GetParent())
517 root = root->GetParent()->manager()->GetRoot();
aboxhall 2015/01/15 05:08:25 That's an impressive method chain! Any chance of a
dmazzoni 2015/01/15 21:02:33 Great question! * root->GetParent() can't be NULL
518 manager = root->manager();
519 BrowserAccessibilityDelegate* delegate = manager->delegate();
520
511 gfx::Rect bounds(origin.x, origin.y, size.width, size.height); 521 gfx::Rect bounds(origin.x, origin.y, size.width, size.height);
512 gfx::Point point = [self delegate]->AccessibilityOriginInScreen(bounds); 522 gfx::Point point = delegate->AccessibilityOriginInScreen(bounds);
513 return NSMakePoint(point.x(), point.y()); 523 return NSMakePoint(point.x(), point.y());
514 } 524 }
515 525
516 // Returns a string indicating the NSAccessibility role of this object. 526 // Returns a string indicating the NSAccessibility role of this object.
517 - (NSString*)role { 527 - (NSString*)role {
518 ui::AXRole role = [self internalRole]; 528 ui::AXRole role = [self internalRole];
519 if (role == ui::AX_ROLE_CANVAS && 529 if (role == ui::AX_ROLE_CANVAS &&
520 browserAccessibility_->GetBoolAttribute( 530 browserAccessibility_->GetBoolAttribute(
521 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { 531 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) {
522 return NSAccessibilityGroupRole; 532 return NSAccessibilityGroupRole;
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 return [super hash]; 1528 return [super hash];
1519 return browserAccessibility_->GetId(); 1529 return browserAccessibility_->GetId();
1520 } 1530 }
1521 1531
1522 - (BOOL)accessibilityShouldUseUniqueId { 1532 - (BOOL)accessibilityShouldUseUniqueId {
1523 return YES; 1533 return YES;
1524 } 1534 }
1525 1535
1526 @end 1536 @end
1527 1537
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698