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

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

Issue 12084028: Fix accessibility coordinates within iframes. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 10 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 "content/browser/accessibility/dump_accessibility_tree_helper.h" 5 #include "content/browser/accessibility/dump_accessibility_tree_helper.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "content/browser/accessibility/browser_accessibility_cocoa.h" 11 #include "content/browser/accessibility/browser_accessibility_cocoa.h"
12 #include "content/browser/accessibility/browser_accessibility_mac.h" 12 #include "content/browser/accessibility/browser_accessibility_mac.h"
13 #include "content/browser/accessibility/browser_accessibility_manager.h"
13 14
14 namespace content { 15 namespace content {
15 namespace { 16 namespace {
16 string16 Format(BrowserAccessibility* node, 17 string16 Format(BrowserAccessibility* node,
17 const char *prefix, 18 const char *prefix,
18 SEL selector, 19 SEL selector,
19 const char *suffix) { 20 const char *suffix) {
20 BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa(); 21 BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa();
21 id value = [cocoa_node performSelector:selector]; 22 id value = [cocoa_node performSelector:selector];
22 if (!value) 23 if (!value)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 Add(false, Format(node, "ariaLive='", @selector(ariaLive), "'")); 57 Add(false, Format(node, "ariaLive='", @selector(ariaLive), "'"));
57 Add(false, Format(node, "ariaRelevant='", @selector(ariaRelevant), "'")); 58 Add(false, Format(node, "ariaRelevant='", @selector(ariaRelevant), "'"));
58 Add(false, Format(node, "enabled='", @selector(enabled), "'")); 59 Add(false, Format(node, "enabled='", @selector(enabled), "'"));
59 Add(false, Format(node, "focused='", @selector(focused), "'")); 60 Add(false, Format(node, "focused='", @selector(focused), "'"));
60 Add(false, Format(node, "loaded='", @selector(loaded), "'")); 61 Add(false, Format(node, "loaded='", @selector(loaded), "'"));
61 Add(false, Format(node, "loadingProgress='", @selector(loadingProgress), 62 Add(false, Format(node, "loadingProgress='", @selector(loadingProgress),
62 "'")); 63 "'"));
63 Add(false, Format(node, "numberOfCharacters='", 64 Add(false, Format(node, "numberOfCharacters='",
64 @selector(numberOfCharacters), "'")); 65 @selector(numberOfCharacters), "'"));
65 Add(false, Format(node, "orientation='", @selector(orientation), "'")); 66 Add(false, Format(node, "orientation='", @selector(orientation), "'"));
66 Add(false, Format(node, "position='", @selector(position), "'"));
67 Add(false, Format(node, "required='", @selector(required), "'")); 67 Add(false, Format(node, "required='", @selector(required), "'"));
68 Add(false, Format(node, "size='", @selector(size), "'"));
69 Add(false, Format(node, "url='", @selector(url), "'")); 68 Add(false, Format(node, "url='", @selector(url), "'"));
70 Add(false, Format(node, "visibleCharacterRange='", 69 Add(false, Format(node, "visibleCharacterRange='",
71 @selector(visibleCharacterRange), "'")); 70 @selector(visibleCharacterRange), "'"));
72 Add(false, Format(node, "visited='", @selector(visited), "'")); 71 Add(false, Format(node, "visited='", @selector(visited), "'"));
72
73 // The NSAccessibility position of an ojbect is in global coordinates and
74 // based on the lower-left corner of the object. To make this easier and less
75 // confusing, convert it to local window coordinates using the top-left corner
76 // when dumping the position.
77 BrowserAccessibility* root = node->manager()->GetRoot();
78 BrowserAccessibilityCocoa* cocoa_root = root->ToBrowserAccessibilityCocoa();
79 NSPoint root_position = [[cocoa_root position] pointValue];
80 NSSize root_size = [[cocoa_root size] sizeValue];
81 int root_top = -static_cast<int>(root_position.y + root_size.height);
82 int root_left = static_cast<int>(root_position.x);
83
84 BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa();
85 NSPoint node_position = [[cocoa_node position] pointValue];
86 NSSize node_size = [[cocoa_node size] sizeValue];
87
88 NSString* position_str =
aboxhall 2013/01/29 01:52:40 It might be more readable to pull the calculation
dmazzoni 2013/01/29 16:51:50 Done.
89 [NSString stringWithFormat:@"position=(%d, %d)",
90 static_cast<int>(node_position.x - root_left),
91 static_cast<int>(
92 -node_position.y - node_size.height - root_top)];
93 Add(false, UTF8ToUTF16(
94 [position_str cStringUsingEncoding:NSUTF8StringEncoding]));
95 NSString* size_str =
96 [NSString stringWithFormat:@"size=(%d, %d)",
97 static_cast<int>(node_size.width),
98 static_cast<int>(node_size.height)];
99 Add(false, UTF8ToUTF16(
100 [size_str cStringUsingEncoding:NSUTF8StringEncoding]));
101
73 return ASCIIToUTF16(prefix) + FinishLine() + ASCIIToUTF16("\n"); 102 return ASCIIToUTF16(prefix) + FinishLine() + ASCIIToUTF16("\n");
74 } 103 }
75 104
76 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix() 105 const FilePath::StringType DumpAccessibilityTreeHelper::GetActualFileSuffix()
77 const { 106 const {
78 return FILE_PATH_LITERAL("-actual-mac.txt"); 107 return FILE_PATH_LITERAL("-actual-mac.txt");
79 } 108 }
80 109
81 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix() 110 const FilePath::StringType DumpAccessibilityTreeHelper::GetExpectedFileSuffix()
82 const { 111 const {
83 return FILE_PATH_LITERAL("-expected-mac.txt"); 112 return FILE_PATH_LITERAL("-expected-mac.txt");
84 } 113 }
85 114
86 const std::string DumpAccessibilityTreeHelper::GetAllowEmptyString() const { 115 const std::string DumpAccessibilityTreeHelper::GetAllowEmptyString() const {
87 return "@MAC-ALLOW-EMPTY:"; 116 return "@MAC-ALLOW-EMPTY:";
88 } 117 }
89 118
90 const std::string DumpAccessibilityTreeHelper::GetAllowString() const { 119 const std::string DumpAccessibilityTreeHelper::GetAllowString() const {
91 return "@MAC-ALLOW:"; 120 return "@MAC-ALLOW:";
92 } 121 }
93 122
94 const std::string DumpAccessibilityTreeHelper::GetDenyString() const { 123 const std::string DumpAccessibilityTreeHelper::GetDenyString() const {
95 return "@MAC-DENY:"; 124 return "@MAC-DENY:";
96 } 125 }
97 126
98 } // namespace content 127 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698