| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/browser_accessibility_win.h" | 5 #include "chrome/browser/accessibility/browser_accessibility_win.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | |
| 8 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/browser_accessibility_manager_win.h" | 9 #include "chrome/browser/accessibility/browser_accessibility_manager_win.h" |
| 11 #include "net/base/escape.h" | 10 #include "net/base/escape.h" |
| 12 | 11 |
| 13 using webkit_glue::WebAccessibility; | 12 using webkit_glue::WebAccessibility; |
| 14 | 13 |
| 15 BrowserAccessibility::BrowserAccessibility() | 14 BrowserAccessibilityWin::BrowserAccessibilityWin() |
| 16 : manager_(NULL), | 15 : manager_(NULL), |
| 17 parent_(NULL), | 16 parent_(NULL), |
| 18 child_id_(-1), | 17 child_id_(-1), |
| 19 index_in_parent_(-1), | 18 index_in_parent_(-1), |
| 20 renderer_id_(-1), | 19 renderer_id_(-1), |
| 21 instance_active_(false) { | 20 instance_active_(false) { |
| 22 } | 21 } |
| 23 | 22 |
| 24 BrowserAccessibility::~BrowserAccessibility() { | 23 BrowserAccessibilityWin::~BrowserAccessibilityWin() { |
| 25 InactivateTree(); | 24 InactivateTree(); |
| 26 } | 25 } |
| 27 | 26 |
| 28 void BrowserAccessibility::Initialize( | 27 void BrowserAccessibilityWin::Initialize( |
| 29 BrowserAccessibilityManager* manager, | 28 BrowserAccessibilityManagerWin* manager, |
| 30 BrowserAccessibility* parent, | 29 BrowserAccessibilityWin* parent, |
| 31 LONG child_id, | 30 LONG child_id, |
| 32 LONG index_in_parent, | 31 LONG index_in_parent, |
| 33 const webkit_glue::WebAccessibility& src) { | 32 const webkit_glue::WebAccessibility& src) { |
| 34 DCHECK_EQ(children_.size(), 0U); | 33 DCHECK_EQ(children_.size(), 0U); |
| 35 | 34 |
| 36 manager_ = manager; | 35 manager_ = manager; |
| 37 parent_ = parent; | 36 parent_ = parent; |
| 38 child_id_ = child_id; | 37 child_id_ = child_id; |
| 39 index_in_parent_ = index_in_parent; | 38 index_in_parent_ = index_in_parent; |
| 40 | 39 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 // If this object doesn't have a name but it does have a description, | 54 // If this object doesn't have a name but it does have a description, |
| 56 // use the description as its name - because some screen readers only | 55 // use the description as its name - because some screen readers only |
| 57 // announce the name. | 56 // announce the name. |
| 58 if (name_.empty() && HasAttribute(WebAccessibility::ATTR_DESCRIPTION)) { | 57 if (name_.empty() && HasAttribute(WebAccessibility::ATTR_DESCRIPTION)) { |
| 59 GetAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); | 58 GetAttribute(WebAccessibility::ATTR_DESCRIPTION, &name_); |
| 60 } | 59 } |
| 61 | 60 |
| 62 instance_active_ = true; | 61 instance_active_ = true; |
| 63 } | 62 } |
| 64 | 63 |
| 65 void BrowserAccessibility::AddChild(BrowserAccessibility* child) { | 64 void BrowserAccessibilityWin::AddChild(BrowserAccessibilityWin* child) { |
| 66 children_.push_back(child); | 65 children_.push_back(child); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void BrowserAccessibility::InactivateTree() { | 68 void BrowserAccessibilityWin::InactivateTree() { |
| 70 if (!instance_active_) | 69 if (!instance_active_) |
| 71 return; | 70 return; |
| 72 | 71 |
| 73 // Mark this object as inactive, so calls to all COM methods will return | 72 // Mark this object as inactive, so calls to all COM methods will return |
| 74 // failure. | 73 // failure. |
| 75 instance_active_ = false; | 74 instance_active_ = false; |
| 76 | 75 |
| 77 // Now we can safely call InactivateTree on our children and remove | 76 // Now we can safely call InactivateTree on our children and remove |
| 78 // references to them, so that as much of the tree as possible will be | 77 // references to them, so that as much of the tree as possible will be |
| 79 // destroyed now - however, nodes that still have references to them | 78 // destroyed now - however, nodes that still have references to them |
| 80 // might stick around a while until all clients have released them. | 79 // might stick around a while until all clients have released them. |
| 81 for (std::vector<BrowserAccessibility*>::iterator iter = | 80 for (std::vector<BrowserAccessibilityWin*>::iterator iter = |
| 82 children_.begin(); | 81 children_.begin(); |
| 83 iter != children_.end(); ++iter) { | 82 iter != children_.end(); ++iter) { |
| 84 (*iter)->InactivateTree(); | 83 (*iter)->InactivateTree(); |
| 85 (*iter)->Release(); | 84 (*iter)->Release(); |
| 86 } | 85 } |
| 87 children_.clear(); | 86 children_.clear(); |
| 88 manager_->Remove(child_id_); | 87 manager_->Remove(child_id_); |
| 89 } | 88 } |
| 90 | 89 |
| 91 bool BrowserAccessibility::IsDescendantOf(BrowserAccessibility* ancestor) { | 90 bool BrowserAccessibilityWin::IsDescendantOf( |
| 91 BrowserAccessibilityWin* ancestor) { |
| 92 if (this == ancestor) { | 92 if (this == ancestor) { |
| 93 return true; | 93 return true; |
| 94 } else if (parent_) { | 94 } else if (parent_) { |
| 95 return parent_->IsDescendantOf(ancestor); | 95 return parent_->IsDescendantOf(ancestor); |
| 96 } | 96 } |
| 97 | 97 |
| 98 return false; | 98 return false; |
| 99 } | 99 } |
| 100 | 100 |
| 101 BrowserAccessibility* BrowserAccessibility::GetParent() { | 101 BrowserAccessibilityWin* BrowserAccessibilityWin::GetParent() { |
| 102 return parent_; | 102 return parent_; |
| 103 } | 103 } |
| 104 | 104 |
| 105 uint32 BrowserAccessibility::GetChildCount() { | 105 uint32 BrowserAccessibilityWin::GetChildCount() { |
| 106 return children_.size(); | 106 return children_.size(); |
| 107 } | 107 } |
| 108 | 108 |
| 109 BrowserAccessibility* BrowserAccessibility::GetPreviousSibling() { | 109 BrowserAccessibilityWin* BrowserAccessibilityWin::GetPreviousSibling() { |
| 110 if (parent_ && index_in_parent_ > 0) | 110 if (parent_ && index_in_parent_ > 0) |
| 111 return parent_->children_[index_in_parent_ - 1]; | 111 return parent_->children_[index_in_parent_ - 1]; |
| 112 | 112 |
| 113 return NULL; | 113 return NULL; |
| 114 } | 114 } |
| 115 | 115 |
| 116 BrowserAccessibility* BrowserAccessibility::GetNextSibling() { | 116 BrowserAccessibilityWin* BrowserAccessibilityWin::GetNextSibling() { |
| 117 if (parent_ && | 117 if (parent_ && |
| 118 index_in_parent_ >= 0 && | 118 index_in_parent_ >= 0 && |
| 119 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { | 119 index_in_parent_ < static_cast<int>(parent_->children_.size() - 1)) { |
| 120 return parent_->children_[index_in_parent_ + 1]; | 120 return parent_->children_[index_in_parent_ + 1]; |
| 121 } | 121 } |
| 122 | 122 |
| 123 return NULL; | 123 return NULL; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void BrowserAccessibility::ReplaceChild( | 126 void BrowserAccessibilityWin::ReplaceChild( |
| 127 const BrowserAccessibility* old_acc, BrowserAccessibility* new_acc) { | 127 const BrowserAccessibilityWin* old_acc, BrowserAccessibilityWin* new_acc) { |
| 128 DCHECK_EQ(children_[old_acc->index_in_parent_], old_acc); | 128 DCHECK_EQ(children_[old_acc->index_in_parent_], old_acc); |
| 129 | 129 |
| 130 old_acc = children_[old_acc->index_in_parent_]; | 130 old_acc = children_[old_acc->index_in_parent_]; |
| 131 children_[old_acc->index_in_parent_] = new_acc; | 131 children_[old_acc->index_in_parent_] = new_acc; |
| 132 } | 132 } |
| 133 | 133 |
| 134 BrowserAccessibility* BrowserAccessibility::NewReference() { | 134 BrowserAccessibilityWin* BrowserAccessibilityWin::NewReference() { |
| 135 AddRef(); | 135 AddRef(); |
| 136 return this; | 136 return this; |
| 137 } | 137 } |
| 138 | 138 |
| 139 // | 139 // |
| 140 // IAccessible methods. | 140 // IAccessible methods. |
| 141 // | 141 // |
| 142 // Conventions: | 142 // Conventions: |
| 143 // * Always test for instance_active_ first and return E_FAIL if it's false. | 143 // * Always test for instance_active_ first and return E_FAIL if it's false. |
| 144 // * Always check for invalid arguments first, even if they're unused. | 144 // * Always check for invalid arguments first, even if they're unused. |
| 145 // * Return S_FALSE if the only output is a string argument and it's empty. | 145 // * Return S_FALSE if the only output is a string argument and it's empty. |
| 146 // | 146 // |
| 147 | 147 |
| 148 HRESULT BrowserAccessibility::accDoDefaultAction(VARIANT var_id) { | 148 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { |
| 149 if (!instance_active_) | 149 if (!instance_active_) |
| 150 return E_FAIL; | 150 return E_FAIL; |
| 151 | 151 |
| 152 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 152 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 153 if (!target) | 153 if (!target) |
| 154 return E_INVALIDARG; | 154 return E_INVALIDARG; |
| 155 | 155 |
| 156 manager_->DoDefaultAction(*target); | 156 manager_->DoDefaultAction(*target); |
| 157 return S_OK; | 157 return S_OK; |
| 158 } | 158 } |
| 159 | 159 |
| 160 STDMETHODIMP BrowserAccessibility::accHitTest(LONG x_left, LONG y_top, | 160 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, LONG y_top, |
| 161 VARIANT* child) { | 161 VARIANT* child) { |
| 162 if (!instance_active_) | 162 if (!instance_active_) |
| 163 return E_FAIL; | 163 return E_FAIL; |
| 164 | 164 |
| 165 if (!child) | 165 if (!child) |
| 166 return E_INVALIDARG; | 166 return E_INVALIDARG; |
| 167 | 167 |
| 168 return E_NOTIMPL; | 168 return E_NOTIMPL; |
| 169 } | 169 } |
| 170 | 170 |
| 171 STDMETHODIMP BrowserAccessibility::accLocation(LONG* x_left, LONG* y_top, | 171 STDMETHODIMP BrowserAccessibilityWin::accLocation(LONG* x_left, LONG* y_top, |
| 172 LONG* width, LONG* height, | 172 LONG* width, LONG* height, |
| 173 VARIANT var_id) { | 173 VARIANT var_id) { |
| 174 if (!instance_active_) | 174 if (!instance_active_) |
| 175 return E_FAIL; | 175 return E_FAIL; |
| 176 | 176 |
| 177 if (!x_left || !y_top || !width || !height) | 177 if (!x_left || !y_top || !width || !height) |
| 178 return E_INVALIDARG; | 178 return E_INVALIDARG; |
| 179 | 179 |
| 180 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 180 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 181 if (!target) | 181 if (!target) |
| 182 return E_INVALIDARG; | 182 return E_INVALIDARG; |
| 183 | 183 |
| 184 // Find the top left corner of the containing window in screen coords, and | 184 // Find the top left corner of the containing window in screen coords, and |
| 185 // adjust the output position by this amount. | 185 // adjust the output position by this amount. |
| 186 HWND parent_hwnd = manager_->GetParentHWND(); | 186 HWND parent_hwnd = manager_->GetParentWindow(); |
| 187 POINT top_left = {0, 0}; | 187 POINT top_left = {0, 0}; |
| 188 ::ClientToScreen(parent_hwnd, &top_left); | 188 ::ClientToScreen(parent_hwnd, &top_left); |
| 189 | 189 |
| 190 *x_left = target->location_.x + top_left.x; | 190 *x_left = target->location_.x + top_left.x; |
| 191 *y_top = target->location_.y + top_left.y; | 191 *y_top = target->location_.y + top_left.y; |
| 192 *width = target->location_.width; | 192 *width = target->location_.width; |
| 193 *height = target->location_.height; | 193 *height = target->location_.height; |
| 194 | 194 |
| 195 return S_OK; | 195 return S_OK; |
| 196 } | 196 } |
| 197 | 197 |
| 198 STDMETHODIMP BrowserAccessibility::accNavigate( | 198 STDMETHODIMP BrowserAccessibilityWin::accNavigate( |
| 199 LONG nav_dir, VARIANT start, VARIANT* end) { | 199 LONG nav_dir, VARIANT start, VARIANT* end) { |
| 200 BrowserAccessibility* target = GetTargetFromChildID(start); | 200 BrowserAccessibilityWin* target = GetTargetFromChildID(start); |
| 201 if (!target) | 201 if (!target) |
| 202 return E_INVALIDARG; | 202 return E_INVALIDARG; |
| 203 | 203 |
| 204 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && | 204 if ((nav_dir == NAVDIR_LASTCHILD || nav_dir == NAVDIR_FIRSTCHILD) && |
| 205 start.lVal != CHILDID_SELF) { | 205 start.lVal != CHILDID_SELF) { |
| 206 // MSAA states that navigating to first/last child can only be from self. | 206 // MSAA states that navigating to first/last child can only be from self. |
| 207 return E_INVALIDARG; | 207 return E_INVALIDARG; |
| 208 } | 208 } |
| 209 | 209 |
| 210 BrowserAccessibility* result = NULL; | 210 BrowserAccessibilityWin* result = NULL; |
| 211 switch (nav_dir) { | 211 switch (nav_dir) { |
| 212 case NAVDIR_DOWN: | 212 case NAVDIR_DOWN: |
| 213 case NAVDIR_UP: | 213 case NAVDIR_UP: |
| 214 case NAVDIR_LEFT: | 214 case NAVDIR_LEFT: |
| 215 case NAVDIR_RIGHT: | 215 case NAVDIR_RIGHT: |
| 216 // These directions are not implemented, matching Mozilla and IE. | 216 // These directions are not implemented, matching Mozilla and IE. |
| 217 return E_NOTIMPL; | 217 return E_NOTIMPL; |
| 218 case NAVDIR_FIRSTCHILD: | 218 case NAVDIR_FIRSTCHILD: |
| 219 if (target->children_.size() > 0) | 219 if (target->children_.size() > 0) |
| 220 result = target->children_[0]; | 220 result = target->children_[0]; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 234 if (!result) { | 234 if (!result) { |
| 235 end->vt = VT_EMPTY; | 235 end->vt = VT_EMPTY; |
| 236 return S_FALSE; | 236 return S_FALSE; |
| 237 } | 237 } |
| 238 | 238 |
| 239 end->vt = VT_DISPATCH; | 239 end->vt = VT_DISPATCH; |
| 240 end->pdispVal = result->NewReference(); | 240 end->pdispVal = result->NewReference(); |
| 241 return S_OK; | 241 return S_OK; |
| 242 } | 242 } |
| 243 | 243 |
| 244 STDMETHODIMP BrowserAccessibility::get_accChild(VARIANT var_child, | 244 STDMETHODIMP BrowserAccessibilityWin::get_accChild(VARIANT var_child, |
| 245 IDispatch** disp_child) { | 245 IDispatch** disp_child) { |
| 246 if (!instance_active_) | 246 if (!instance_active_) |
| 247 return E_FAIL; | 247 return E_FAIL; |
| 248 | 248 |
| 249 if (!disp_child) | 249 if (!disp_child) |
| 250 return E_INVALIDARG; | 250 return E_INVALIDARG; |
| 251 | 251 |
| 252 *disp_child = NULL; | 252 *disp_child = NULL; |
| 253 | 253 |
| 254 BrowserAccessibility* target = GetTargetFromChildID(var_child); | 254 BrowserAccessibilityWin* target = GetTargetFromChildID(var_child); |
| 255 if (!target) | 255 if (!target) |
| 256 return E_INVALIDARG; | 256 return E_INVALIDARG; |
| 257 | 257 |
| 258 (*disp_child) = target->NewReference(); | 258 (*disp_child) = target->NewReference(); |
| 259 return S_OK; | 259 return S_OK; |
| 260 } | 260 } |
| 261 | 261 |
| 262 STDMETHODIMP BrowserAccessibility::get_accChildCount(LONG* child_count) { | 262 STDMETHODIMP BrowserAccessibilityWin::get_accChildCount(LONG* child_count) { |
| 263 if (!instance_active_) | 263 if (!instance_active_) |
| 264 return E_FAIL; | 264 return E_FAIL; |
| 265 | 265 |
| 266 if (!child_count) | 266 if (!child_count) |
| 267 return E_INVALIDARG; | 267 return E_INVALIDARG; |
| 268 | 268 |
| 269 *child_count = children_.size(); | 269 *child_count = children_.size(); |
| 270 return S_OK; | 270 return S_OK; |
| 271 } | 271 } |
| 272 | 272 |
| 273 STDMETHODIMP BrowserAccessibility::get_accDefaultAction(VARIANT var_id, | 273 STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id, |
| 274 BSTR* def_action) { | 274 BSTR* def_action) { |
| 275 if (!instance_active_) | 275 if (!instance_active_) |
| 276 return E_FAIL; | 276 return E_FAIL; |
| 277 | 277 |
| 278 if (!def_action) | 278 if (!def_action) |
| 279 return E_INVALIDARG; | 279 return E_INVALIDARG; |
| 280 | 280 |
| 281 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 281 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 282 if (!target) | 282 if (!target) |
| 283 return E_INVALIDARG; | 283 return E_INVALIDARG; |
| 284 | 284 |
| 285 return target->GetAttributeAsBstr( | 285 return target->GetAttributeAsBstr( |
| 286 WebAccessibility::ATTR_SHORTCUT, def_action); | 286 WebAccessibility::ATTR_SHORTCUT, def_action); |
| 287 } | 287 } |
| 288 | 288 |
| 289 STDMETHODIMP BrowserAccessibility::get_accDescription(VARIANT var_id, | 289 STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id, |
| 290 BSTR* desc) { | 290 BSTR* desc) { |
| 291 if (!instance_active_) | 291 if (!instance_active_) |
| 292 return E_FAIL; | 292 return E_FAIL; |
| 293 | 293 |
| 294 if (!desc) | 294 if (!desc) |
| 295 return E_INVALIDARG; | 295 return E_INVALIDARG; |
| 296 | 296 |
| 297 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 297 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 298 if (!target) | 298 if (!target) |
| 299 return E_INVALIDARG; | 299 return E_INVALIDARG; |
| 300 | 300 |
| 301 return target->GetAttributeAsBstr(WebAccessibility::ATTR_DESCRIPTION, desc); | 301 return target->GetAttributeAsBstr(WebAccessibility::ATTR_DESCRIPTION, desc); |
| 302 } | 302 } |
| 303 | 303 |
| 304 STDMETHODIMP BrowserAccessibility::get_accFocus(VARIANT* focus_child) { | 304 STDMETHODIMP BrowserAccessibilityWin::get_accFocus(VARIANT* focus_child) { |
| 305 if (!instance_active_) | 305 if (!instance_active_) |
| 306 return E_FAIL; | 306 return E_FAIL; |
| 307 | 307 |
| 308 if (!focus_child) | 308 if (!focus_child) |
| 309 return E_INVALIDARG; | 309 return E_INVALIDARG; |
| 310 | 310 |
| 311 BrowserAccessibility* focus = manager_->GetFocus(this); | 311 BrowserAccessibilityWin* focus = static_cast<BrowserAccessibilityWin*>( |
| 312 manager_->GetFocus(this)); |
| 312 if (focus == this) { | 313 if (focus == this) { |
| 313 focus_child->vt = VT_I4; | 314 focus_child->vt = VT_I4; |
| 314 focus_child->lVal = CHILDID_SELF; | 315 focus_child->lVal = CHILDID_SELF; |
| 315 } else if (focus == NULL) { | 316 } else if (focus == NULL) { |
| 316 focus_child->vt = VT_EMPTY; | 317 focus_child->vt = VT_EMPTY; |
| 317 } else { | 318 } else { |
| 318 focus_child->vt = VT_DISPATCH; | 319 focus_child->vt = VT_DISPATCH; |
| 319 focus_child->pdispVal = focus->NewReference(); | 320 focus_child->pdispVal = focus->NewReference(); |
| 320 } | 321 } |
| 321 | 322 |
| 322 return S_OK; | 323 return S_OK; |
| 323 } | 324 } |
| 324 | 325 |
| 325 STDMETHODIMP BrowserAccessibility::get_accHelp(VARIANT var_id, BSTR* help) { | 326 STDMETHODIMP BrowserAccessibilityWin::get_accHelp(VARIANT var_id, BSTR* help) { |
| 326 if (!instance_active_) | 327 if (!instance_active_) |
| 327 return E_FAIL; | 328 return E_FAIL; |
| 328 | 329 |
| 329 if (!help) | 330 if (!help) |
| 330 return E_INVALIDARG; | 331 return E_INVALIDARG; |
| 331 | 332 |
| 332 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 333 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 333 if (!target) | 334 if (!target) |
| 334 return E_INVALIDARG; | 335 return E_INVALIDARG; |
| 335 | 336 |
| 336 return target->GetAttributeAsBstr(WebAccessibility::ATTR_HELP, help); | 337 return target->GetAttributeAsBstr(WebAccessibility::ATTR_HELP, help); |
| 337 } | 338 } |
| 338 | 339 |
| 339 STDMETHODIMP BrowserAccessibility::get_accKeyboardShortcut(VARIANT var_id, | 340 STDMETHODIMP BrowserAccessibilityWin::get_accKeyboardShortcut(VARIANT var_id, |
| 340 BSTR* acc_key) { | 341 BSTR* acc_key) { |
| 341 if (!instance_active_) | 342 if (!instance_active_) |
| 342 return E_FAIL; | 343 return E_FAIL; |
| 343 | 344 |
| 344 if (!acc_key) | 345 if (!acc_key) |
| 345 return E_INVALIDARG; | 346 return E_INVALIDARG; |
| 346 | 347 |
| 347 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 348 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 348 if (!target) | 349 if (!target) |
| 349 return E_INVALIDARG; | 350 return E_INVALIDARG; |
| 350 | 351 |
| 351 return target->GetAttributeAsBstr(WebAccessibility::ATTR_SHORTCUT, acc_key); | 352 return target->GetAttributeAsBstr(WebAccessibility::ATTR_SHORTCUT, acc_key); |
| 352 } | 353 } |
| 353 | 354 |
| 354 STDMETHODIMP BrowserAccessibility::get_accName(VARIANT var_id, BSTR* name) { | 355 STDMETHODIMP BrowserAccessibilityWin::get_accName(VARIANT var_id, BSTR* name) { |
| 355 if (!instance_active_) | 356 if (!instance_active_) |
| 356 return E_FAIL; | 357 return E_FAIL; |
| 357 | 358 |
| 358 if (!name) | 359 if (!name) |
| 359 return E_INVALIDARG; | 360 return E_INVALIDARG; |
| 360 | 361 |
| 361 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 362 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 362 if (!target) | 363 if (!target) |
| 363 return E_INVALIDARG; | 364 return E_INVALIDARG; |
| 364 | 365 |
| 365 if (target->name_.empty()) | 366 if (target->name_.empty()) |
| 366 return S_FALSE; | 367 return S_FALSE; |
| 367 | 368 |
| 368 *name = SysAllocString(target->name_.c_str()); | 369 *name = SysAllocString(target->name_.c_str()); |
| 369 | 370 |
| 370 DCHECK(*name); | 371 DCHECK(*name); |
| 371 return S_OK; | 372 return S_OK; |
| 372 } | 373 } |
| 373 | 374 |
| 374 STDMETHODIMP BrowserAccessibility::get_accParent(IDispatch** disp_parent) { | 375 STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { |
| 375 if (!instance_active_) | 376 if (!instance_active_) |
| 376 return E_FAIL; | 377 return E_FAIL; |
| 377 | 378 |
| 378 if (!disp_parent) | 379 if (!disp_parent) |
| 379 return E_INVALIDARG; | 380 return E_INVALIDARG; |
| 380 | 381 |
| 381 IAccessible* parent = parent_; | 382 IAccessible* parent = parent_; |
| 382 if (parent == NULL) { | 383 if (parent == NULL) { |
| 383 // This happens if we're the root of the tree; | 384 // This happens if we're the root of the tree; |
| 384 // return the IAccessible for the window. | 385 // return the IAccessible for the window. |
| 385 parent = manager_->GetParentWindowIAccessible(); | 386 parent = manager_->GetParentWindowIAccessible(); |
| 386 } | 387 } |
| 387 | 388 |
| 388 parent->AddRef(); | 389 parent->AddRef(); |
| 389 *disp_parent = parent; | 390 *disp_parent = parent; |
| 390 return S_OK; | 391 return S_OK; |
| 391 } | 392 } |
| 392 | 393 |
| 393 STDMETHODIMP BrowserAccessibility::get_accRole(VARIANT var_id, VARIANT* role) { | 394 STDMETHODIMP BrowserAccessibilityWin::get_accRole( |
| 395 VARIANT var_id, VARIANT* role) { |
| 394 if (!instance_active_) | 396 if (!instance_active_) |
| 395 return E_FAIL; | 397 return E_FAIL; |
| 396 | 398 |
| 397 if (!role) | 399 if (!role) |
| 398 return E_INVALIDARG; | 400 return E_INVALIDARG; |
| 399 | 401 |
| 400 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 402 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 401 if (!target) | 403 if (!target) |
| 402 return E_INVALIDARG; | 404 return E_INVALIDARG; |
| 403 | 405 |
| 404 if (!target->role_name_.empty()) { | 406 if (!target->role_name_.empty()) { |
| 405 role->vt = VT_BSTR; | 407 role->vt = VT_BSTR; |
| 406 role->bstrVal = SysAllocString(target->role_name_.c_str()); | 408 role->bstrVal = SysAllocString(target->role_name_.c_str()); |
| 407 } else { | 409 } else { |
| 408 role->vt = VT_I4; | 410 role->vt = VT_I4; |
| 409 role->lVal = target->role_; | 411 role->lVal = target->role_; |
| 410 } | 412 } |
| 411 return S_OK; | 413 return S_OK; |
| 412 } | 414 } |
| 413 | 415 |
| 414 STDMETHODIMP BrowserAccessibility::get_accState(VARIANT var_id, | 416 STDMETHODIMP BrowserAccessibilityWin::get_accState(VARIANT var_id, |
| 415 VARIANT* state) { | 417 VARIANT* state) { |
| 416 if (!instance_active_) | 418 if (!instance_active_) |
| 417 return E_FAIL; | 419 return E_FAIL; |
| 418 | 420 |
| 419 if (!state) | 421 if (!state) |
| 420 return E_INVALIDARG; | 422 return E_INVALIDARG; |
| 421 | 423 |
| 422 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 424 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 423 if (!target) | 425 if (!target) |
| 424 return E_INVALIDARG; | 426 return E_INVALIDARG; |
| 425 | 427 |
| 426 state->vt = VT_I4; | 428 state->vt = VT_I4; |
| 427 state->lVal = target->state_; | 429 state->lVal = target->state_; |
| 428 if (manager_->GetFocus(NULL) == this) | 430 if (manager_->GetFocus(NULL) == this) |
| 429 state->lVal |= STATE_SYSTEM_FOCUSED; | 431 state->lVal |= STATE_SYSTEM_FOCUSED; |
| 430 | 432 |
| 431 return S_OK; | 433 return S_OK; |
| 432 } | 434 } |
| 433 | 435 |
| 434 STDMETHODIMP BrowserAccessibility::get_accValue(VARIANT var_id, BSTR* value) { | 436 STDMETHODIMP BrowserAccessibilityWin::get_accValue( |
| 437 VARIANT var_id, BSTR* value) { |
| 435 if (!instance_active_) | 438 if (!instance_active_) |
| 436 return E_FAIL; | 439 return E_FAIL; |
| 437 | 440 |
| 438 if (!value) | 441 if (!value) |
| 439 return E_INVALIDARG; | 442 return E_INVALIDARG; |
| 440 | 443 |
| 441 BrowserAccessibility* target = GetTargetFromChildID(var_id); | 444 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
| 442 if (!target) | 445 if (!target) |
| 443 return E_INVALIDARG; | 446 return E_INVALIDARG; |
| 444 | 447 |
| 445 *value = SysAllocString(target->value_.c_str()); | 448 *value = SysAllocString(target->value_.c_str()); |
| 446 | 449 |
| 447 DCHECK(*value); | 450 DCHECK(*value); |
| 448 return S_OK; | 451 return S_OK; |
| 449 } | 452 } |
| 450 | 453 |
| 451 STDMETHODIMP BrowserAccessibility::get_accHelpTopic(BSTR* help_file, | 454 STDMETHODIMP BrowserAccessibilityWin::get_accHelpTopic( |
| 452 VARIANT var_id, | 455 BSTR* help_file, VARIANT var_id, LONG* topic_id) { |
| 453 LONG* topic_id) { | |
| 454 return E_NOTIMPL; | 456 return E_NOTIMPL; |
| 455 } | 457 } |
| 456 | 458 |
| 457 STDMETHODIMP BrowserAccessibility::get_accSelection(VARIANT* selected) { | 459 STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { |
| 458 if (!instance_active_) | 460 if (!instance_active_) |
| 459 return E_FAIL; | 461 return E_FAIL; |
| 460 | 462 |
| 461 return E_NOTIMPL; | 463 return E_NOTIMPL; |
| 462 } | 464 } |
| 463 | 465 |
| 464 STDMETHODIMP BrowserAccessibility::accSelect(LONG flags_sel, VARIANT var_id) { | 466 STDMETHODIMP BrowserAccessibilityWin::accSelect( |
| 467 LONG flags_sel, VARIANT var_id) { |
| 465 if (!instance_active_) | 468 if (!instance_active_) |
| 466 return E_FAIL; | 469 return E_FAIL; |
| 467 | 470 |
| 468 if (flags_sel & SELFLAG_TAKEFOCUS) { | 471 if (flags_sel & SELFLAG_TAKEFOCUS) { |
| 469 manager_->SetFocus(*this); | 472 manager_->SetFocus(*this); |
| 470 return S_OK; | 473 return S_OK; |
| 471 } | 474 } |
| 472 | 475 |
| 473 return S_FALSE; | 476 return S_FALSE; |
| 474 } | 477 } |
| 475 | 478 |
| 476 // | 479 // |
| 477 // IAccessible2 methods. | 480 // IAccessible2 methods. |
| 478 // | 481 // |
| 479 | 482 |
| 480 STDMETHODIMP BrowserAccessibility::role(LONG* role) { | 483 STDMETHODIMP BrowserAccessibilityWin::role(LONG* role) { |
| 481 if (!instance_active_) | 484 if (!instance_active_) |
| 482 return E_FAIL; | 485 return E_FAIL; |
| 483 | 486 |
| 484 if (!role) | 487 if (!role) |
| 485 return E_INVALIDARG; | 488 return E_INVALIDARG; |
| 486 | 489 |
| 487 *role = ia2_role_; | 490 *role = ia2_role_; |
| 488 | 491 |
| 489 return S_OK; | 492 return S_OK; |
| 490 } | 493 } |
| 491 | 494 |
| 492 STDMETHODIMP BrowserAccessibility::get_attributes(BSTR* attributes) { | 495 STDMETHODIMP BrowserAccessibilityWin::get_attributes(BSTR* attributes) { |
| 493 if (!instance_active_) | 496 if (!instance_active_) |
| 494 return E_FAIL; | 497 return E_FAIL; |
| 495 | 498 |
| 496 if (!attributes) | 499 if (!attributes) |
| 497 return E_INVALIDARG; | 500 return E_INVALIDARG; |
| 498 | 501 |
| 499 // Follow Firefox's convention, which is to return a set of key-value pairs | 502 // Follow Firefox's convention, which is to return a set of key-value pairs |
| 500 // separated by semicolons, with a colon between the key and the value. | 503 // separated by semicolons, with a colon between the key and the value. |
| 501 string16 str; | 504 string16 str; |
| 502 for (unsigned int i = 0; i < html_attributes_.size(); i++) { | 505 for (unsigned int i = 0; i < html_attributes_.size(); i++) { |
| 503 if (i != 0) | 506 if (i != 0) |
| 504 str += L';'; | 507 str += L';'; |
| 505 str += Escape(html_attributes_[i].first); | 508 str += Escape(html_attributes_[i].first); |
| 506 str += L':'; | 509 str += L':'; |
| 507 str += Escape(html_attributes_[i].second); | 510 str += Escape(html_attributes_[i].second); |
| 508 } | 511 } |
| 509 | 512 |
| 510 if (str.empty()) | 513 if (str.empty()) |
| 511 return S_FALSE; | 514 return S_FALSE; |
| 512 | 515 |
| 513 *attributes = SysAllocString(str.c_str()); | 516 *attributes = SysAllocString(str.c_str()); |
| 514 DCHECK(*attributes); | 517 DCHECK(*attributes); |
| 515 return S_OK; | 518 return S_OK; |
| 516 } | 519 } |
| 517 | 520 |
| 518 STDMETHODIMP BrowserAccessibility::get_states(AccessibleStates* states) { | 521 STDMETHODIMP BrowserAccessibilityWin::get_states(AccessibleStates* states) { |
| 519 if (!instance_active_) | 522 if (!instance_active_) |
| 520 return E_FAIL; | 523 return E_FAIL; |
| 521 | 524 |
| 522 if (!states) | 525 if (!states) |
| 523 return E_INVALIDARG; | 526 return E_INVALIDARG; |
| 524 | 527 |
| 525 *states = ia2_state_; | 528 *states = ia2_state_; |
| 526 | 529 |
| 527 return S_OK; | 530 return S_OK; |
| 528 } | 531 } |
| 529 | 532 |
| 530 STDMETHODIMP BrowserAccessibility::get_uniqueID(LONG* unique_id) { | 533 STDMETHODIMP BrowserAccessibilityWin::get_uniqueID(LONG* unique_id) { |
| 531 if (!instance_active_) | 534 if (!instance_active_) |
| 532 return E_FAIL; | 535 return E_FAIL; |
| 533 | 536 |
| 534 if (!unique_id) | 537 if (!unique_id) |
| 535 return E_INVALIDARG; | 538 return E_INVALIDARG; |
| 536 | 539 |
| 537 *unique_id = child_id_; | 540 *unique_id = child_id_; |
| 538 return S_OK; | 541 return S_OK; |
| 539 } | 542 } |
| 540 | 543 |
| 541 STDMETHODIMP BrowserAccessibility::get_windowHandle(HWND* window_handle) { | 544 STDMETHODIMP BrowserAccessibilityWin::get_windowHandle(HWND* window_handle) { |
| 542 if (!instance_active_) | 545 if (!instance_active_) |
| 543 return E_FAIL; | 546 return E_FAIL; |
| 544 | 547 |
| 545 if (!window_handle) | 548 if (!window_handle) |
| 546 return E_INVALIDARG; | 549 return E_INVALIDARG; |
| 547 | 550 |
| 548 *window_handle = manager_->GetParentHWND(); | 551 *window_handle = manager_->GetParentWindow(); |
| 549 return S_OK; | 552 return S_OK; |
| 550 } | 553 } |
| 551 | 554 |
| 552 STDMETHODIMP BrowserAccessibility::get_indexInParent(LONG* index_in_parent) { | 555 STDMETHODIMP BrowserAccessibilityWin::get_indexInParent(LONG* index_in_parent) { |
| 553 if (!instance_active_) | 556 if (!instance_active_) |
| 554 return E_FAIL; | 557 return E_FAIL; |
| 555 | 558 |
| 556 if (!index_in_parent) | 559 if (!index_in_parent) |
| 557 return E_INVALIDARG; | 560 return E_INVALIDARG; |
| 558 | 561 |
| 559 *index_in_parent = index_in_parent_; | 562 *index_in_parent = index_in_parent_; |
| 560 return S_OK; | 563 return S_OK; |
| 561 } | 564 } |
| 562 | 565 |
| 563 // | 566 // |
| 564 // IAccessibleImage methods. | 567 // IAccessibleImage methods. |
| 565 // | 568 // |
| 566 | 569 |
| 567 STDMETHODIMP BrowserAccessibility::get_description(BSTR* desc) { | 570 STDMETHODIMP BrowserAccessibilityWin::get_description(BSTR* desc) { |
| 568 if (!instance_active_) | 571 if (!instance_active_) |
| 569 return E_FAIL; | 572 return E_FAIL; |
| 570 | 573 |
| 571 if (!desc) | 574 if (!desc) |
| 572 return E_INVALIDARG; | 575 return E_INVALIDARG; |
| 573 | 576 |
| 574 return GetAttributeAsBstr(WebAccessibility::ATTR_DESCRIPTION, desc); | 577 return GetAttributeAsBstr(WebAccessibility::ATTR_DESCRIPTION, desc); |
| 575 } | 578 } |
| 576 | 579 |
| 577 STDMETHODIMP BrowserAccessibility::get_imagePosition( | 580 STDMETHODIMP BrowserAccessibilityWin::get_imagePosition( |
| 578 enum IA2CoordinateType coordinate_type, long* x, long* y) { | 581 enum IA2CoordinateType coordinate_type, long* x, long* y) { |
| 579 if (!instance_active_) | 582 if (!instance_active_) |
| 580 return E_FAIL; | 583 return E_FAIL; |
| 581 | 584 |
| 582 if (!x || !y) | 585 if (!x || !y) |
| 583 return E_INVALIDARG; | 586 return E_INVALIDARG; |
| 584 | 587 |
| 585 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { | 588 if (coordinate_type == IA2_COORDTYPE_SCREEN_RELATIVE) { |
| 586 HWND parent_hwnd = manager_->GetParentHWND(); | 589 HWND parent_hwnd = manager_->GetParentWindow(); |
| 587 POINT top_left = {0, 0}; | 590 POINT top_left = {0, 0}; |
| 588 ::ClientToScreen(parent_hwnd, &top_left); | 591 ::ClientToScreen(parent_hwnd, &top_left); |
| 589 *x = location_.x + top_left.x; | 592 *x = location_.x + top_left.x; |
| 590 *y = location_.y + top_left.y; | 593 *y = location_.y + top_left.y; |
| 591 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { | 594 } else if (coordinate_type == IA2_COORDTYPE_PARENT_RELATIVE) { |
| 592 *x = location_.x; | 595 *x = location_.x; |
| 593 *y = location_.y; | 596 *y = location_.y; |
| 594 if (parent_) { | 597 if (parent_) { |
| 595 *x -= parent_->location_.x; | 598 *x -= parent_->location_.x; |
| 596 *y -= parent_->location_.y; | 599 *y -= parent_->location_.y; |
| 597 } | 600 } |
| 598 } else { | 601 } else { |
| 599 return E_INVALIDARG; | 602 return E_INVALIDARG; |
| 600 } | 603 } |
| 601 | 604 |
| 602 return S_OK; | 605 return S_OK; |
| 603 } | 606 } |
| 604 | 607 |
| 605 STDMETHODIMP BrowserAccessibility::get_imageSize(long* height, long* width) { | 608 STDMETHODIMP BrowserAccessibilityWin::get_imageSize(long* height, long* width) { |
| 606 if (!instance_active_) | 609 if (!instance_active_) |
| 607 return E_FAIL; | 610 return E_FAIL; |
| 608 | 611 |
| 609 if (!height || !width) | 612 if (!height || !width) |
| 610 return E_INVALIDARG; | 613 return E_INVALIDARG; |
| 611 | 614 |
| 612 *height = location_.height; | 615 *height = location_.height; |
| 613 *width = location_.width; | 616 *width = location_.width; |
| 614 return S_OK; | 617 return S_OK; |
| 615 } | 618 } |
| 616 | 619 |
| 617 // | 620 // |
| 618 // IAccessibleText methods. | 621 // IAccessibleText methods. |
| 619 // | 622 // |
| 620 | 623 |
| 621 STDMETHODIMP BrowserAccessibility::get_nCharacters(long* n_characters) { | 624 STDMETHODIMP BrowserAccessibilityWin::get_nCharacters(long* n_characters) { |
| 622 if (!instance_active_) | 625 if (!instance_active_) |
| 623 return E_FAIL; | 626 return E_FAIL; |
| 624 | 627 |
| 625 if (!n_characters) | 628 if (!n_characters) |
| 626 return E_INVALIDARG; | 629 return E_INVALIDARG; |
| 627 | 630 |
| 628 *n_characters = name_.length(); | 631 *n_characters = name_.length(); |
| 629 return S_OK; | 632 return S_OK; |
| 630 } | 633 } |
| 631 | 634 |
| 632 STDMETHODIMP BrowserAccessibility::get_text( | 635 STDMETHODIMP BrowserAccessibilityWin::get_text( |
| 633 long start_offset, long end_offset, BSTR* text) { | 636 long start_offset, long end_offset, BSTR* text) { |
| 634 if (!instance_active_) | 637 if (!instance_active_) |
| 635 return E_FAIL; | 638 return E_FAIL; |
| 636 | 639 |
| 637 if (!text) | 640 if (!text) |
| 638 return E_INVALIDARG; | 641 return E_INVALIDARG; |
| 639 | 642 |
| 640 long len = name_.length(); | 643 long len = name_.length(); |
| 641 if (start_offset < 0) | 644 if (start_offset < 0) |
| 642 start_offset = 0; | 645 start_offset = 0; |
| 643 if (end_offset > len) | 646 if (end_offset > len) |
| 644 end_offset = len; | 647 end_offset = len; |
| 645 | 648 |
| 646 string16 substr = name_.substr(start_offset, end_offset - start_offset); | 649 string16 substr = name_.substr(start_offset, end_offset - start_offset); |
| 647 if (substr.empty()) | 650 if (substr.empty()) |
| 648 return S_FALSE; | 651 return S_FALSE; |
| 649 | 652 |
| 650 *text = SysAllocString(substr.c_str()); | 653 *text = SysAllocString(substr.c_str()); |
| 651 DCHECK(*text); | 654 DCHECK(*text); |
| 652 return S_OK; | 655 return S_OK; |
| 653 } | 656 } |
| 654 | 657 |
| 655 STDMETHODIMP BrowserAccessibility::get_caretOffset(long* offset) { | 658 STDMETHODIMP BrowserAccessibilityWin::get_caretOffset(long* offset) { |
| 656 if (!instance_active_) | 659 if (!instance_active_) |
| 657 return E_FAIL; | 660 return E_FAIL; |
| 658 | 661 |
| 659 if (!offset) | 662 if (!offset) |
| 660 return E_INVALIDARG; | 663 return E_INVALIDARG; |
| 661 | 664 |
| 662 *offset = 0; | 665 *offset = 0; |
| 663 return S_OK; | 666 return S_OK; |
| 664 } | 667 } |
| 665 | 668 |
| 666 // | 669 // |
| 667 // ISimpleDOMDocument methods. | 670 // ISimpleDOMDocument methods. |
| 668 // | 671 // |
| 669 | 672 |
| 670 STDMETHODIMP BrowserAccessibility::get_URL(BSTR* url) { | 673 STDMETHODIMP BrowserAccessibilityWin::get_URL(BSTR* url) { |
| 671 if (!instance_active_) | 674 if (!instance_active_) |
| 672 return E_FAIL; | 675 return E_FAIL; |
| 673 | 676 |
| 674 if (!url) | 677 if (!url) |
| 675 return E_INVALIDARG; | 678 return E_INVALIDARG; |
| 676 | 679 |
| 677 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_URL, url); | 680 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_URL, url); |
| 678 } | 681 } |
| 679 | 682 |
| 680 STDMETHODIMP BrowserAccessibility::get_title(BSTR* title) { | 683 STDMETHODIMP BrowserAccessibilityWin::get_title(BSTR* title) { |
| 681 if (!instance_active_) | 684 if (!instance_active_) |
| 682 return E_FAIL; | 685 return E_FAIL; |
| 683 | 686 |
| 684 if (!title) | 687 if (!title) |
| 685 return E_INVALIDARG; | 688 return E_INVALIDARG; |
| 686 | 689 |
| 687 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_TITLE, title); | 690 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_TITLE, title); |
| 688 } | 691 } |
| 689 | 692 |
| 690 STDMETHODIMP BrowserAccessibility::get_mimeType(BSTR* mime_type) { | 693 STDMETHODIMP BrowserAccessibilityWin::get_mimeType(BSTR* mime_type) { |
| 691 if (!instance_active_) | 694 if (!instance_active_) |
| 692 return E_FAIL; | 695 return E_FAIL; |
| 693 | 696 |
| 694 if (!mime_type) | 697 if (!mime_type) |
| 695 return E_INVALIDARG; | 698 return E_INVALIDARG; |
| 696 | 699 |
| 697 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_MIMETYPE, mime_type); | 700 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_MIMETYPE, mime_type); |
| 698 } | 701 } |
| 699 | 702 |
| 700 STDMETHODIMP BrowserAccessibility::get_docType(BSTR* doc_type) { | 703 STDMETHODIMP BrowserAccessibilityWin::get_docType(BSTR* doc_type) { |
| 701 if (!instance_active_) | 704 if (!instance_active_) |
| 702 return E_FAIL; | 705 return E_FAIL; |
| 703 | 706 |
| 704 if (!doc_type) | 707 if (!doc_type) |
| 705 return E_INVALIDARG; | 708 return E_INVALIDARG; |
| 706 | 709 |
| 707 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_DOCTYPE, doc_type); | 710 return GetAttributeAsBstr(WebAccessibility::ATTR_DOC_DOCTYPE, doc_type); |
| 708 } | 711 } |
| 709 | 712 |
| 710 // | 713 // |
| 711 // ISimpleDOMNode methods. | 714 // ISimpleDOMNode methods. |
| 712 // | 715 // |
| 713 | 716 |
| 714 STDMETHODIMP BrowserAccessibility::get_nodeInfo( | 717 STDMETHODIMP BrowserAccessibilityWin::get_nodeInfo( |
| 715 BSTR* node_name, | 718 BSTR* node_name, |
| 716 short* name_space_id, | 719 short* name_space_id, |
| 717 BSTR* node_value, | 720 BSTR* node_value, |
| 718 unsigned int* num_children, | 721 unsigned int* num_children, |
| 719 unsigned int* unique_id, | 722 unsigned int* unique_id, |
| 720 unsigned short* node_type) { | 723 unsigned short* node_type) { |
| 721 if (!instance_active_) | 724 if (!instance_active_) |
| 722 return E_FAIL; | 725 return E_FAIL; |
| 723 | 726 |
| 724 if (!node_name || !name_space_id || !node_value || !num_children || | 727 if (!node_name || !name_space_id || !node_value || !num_children || |
| (...skipping 17 matching lines...) Expand all Loading... |
| 742 } else if (role_ == ROLE_SYSTEM_TEXT && | 745 } else if (role_ == ROLE_SYSTEM_TEXT && |
| 743 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { | 746 ((ia2_state_ & IA2_STATE_EDITABLE) == 0)) { |
| 744 *node_type = NODETYPE_TEXT; | 747 *node_type = NODETYPE_TEXT; |
| 745 } else { | 748 } else { |
| 746 *node_type = NODETYPE_ELEMENT; | 749 *node_type = NODETYPE_ELEMENT; |
| 747 } | 750 } |
| 748 | 751 |
| 749 return S_OK; | 752 return S_OK; |
| 750 } | 753 } |
| 751 | 754 |
| 752 STDMETHODIMP BrowserAccessibility::get_attributes( | 755 STDMETHODIMP BrowserAccessibilityWin::get_attributes( |
| 753 unsigned short max_attribs, | 756 unsigned short max_attribs, |
| 754 BSTR* attrib_names, | 757 BSTR* attrib_names, |
| 755 short* name_space_id, | 758 short* name_space_id, |
| 756 BSTR* attrib_values, | 759 BSTR* attrib_values, |
| 757 unsigned short* num_attribs) { | 760 unsigned short* num_attribs) { |
| 758 if (!instance_active_) | 761 if (!instance_active_) |
| 759 return E_FAIL; | 762 return E_FAIL; |
| 760 | 763 |
| 761 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) | 764 if (!attrib_names || !name_space_id || !attrib_values || !num_attribs) |
| 762 return E_INVALIDARG; | 765 return E_INVALIDARG; |
| 763 | 766 |
| 764 *num_attribs = max_attribs; | 767 *num_attribs = max_attribs; |
| 765 if (*num_attribs > html_attributes_.size()) | 768 if (*num_attribs > html_attributes_.size()) |
| 766 *num_attribs = html_attributes_.size(); | 769 *num_attribs = html_attributes_.size(); |
| 767 | 770 |
| 768 for (unsigned short i = 0; i < *num_attribs; ++i) { | 771 for (unsigned short i = 0; i < *num_attribs; ++i) { |
| 769 attrib_names[i] = SysAllocString(html_attributes_[i].first.c_str()); | 772 attrib_names[i] = SysAllocString(html_attributes_[i].first.c_str()); |
| 770 name_space_id[i] = 0; | 773 name_space_id[i] = 0; |
| 771 attrib_values[i] = SysAllocString(html_attributes_[i].second.c_str()); | 774 attrib_values[i] = SysAllocString(html_attributes_[i].second.c_str()); |
| 772 } | 775 } |
| 773 return S_OK; | 776 return S_OK; |
| 774 } | 777 } |
| 775 | 778 |
| 776 STDMETHODIMP BrowserAccessibility::get_attributesForNames( | 779 STDMETHODIMP BrowserAccessibilityWin::get_attributesForNames( |
| 777 unsigned short num_attribs, | 780 unsigned short num_attribs, |
| 778 BSTR* attrib_names, | 781 BSTR* attrib_names, |
| 779 short* name_space_id, | 782 short* name_space_id, |
| 780 BSTR* attrib_values) { | 783 BSTR* attrib_values) { |
| 781 if (!instance_active_) | 784 if (!instance_active_) |
| 782 return E_FAIL; | 785 return E_FAIL; |
| 783 | 786 |
| 784 if (!attrib_names || !name_space_id || !attrib_values) | 787 if (!attrib_names || !name_space_id || !attrib_values) |
| 785 return E_INVALIDARG; | 788 return E_INVALIDARG; |
| 786 | 789 |
| 787 for (unsigned short i = 0; i < num_attribs; ++i) { | 790 for (unsigned short i = 0; i < num_attribs; ++i) { |
| 788 name_space_id[i] = 0; | 791 name_space_id[i] = 0; |
| 789 bool found = false; | 792 bool found = false; |
| 790 string16 name = (LPCWSTR)attrib_names[i]; | 793 string16 name = (LPCWSTR)attrib_names[i]; |
| 791 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { | 794 for (unsigned int j = 0; j < html_attributes_.size(); ++j) { |
| 792 if (html_attributes_[j].first == name) { | 795 if (html_attributes_[j].first == name) { |
| 793 attrib_values[i] = SysAllocString(html_attributes_[j].second.c_str()); | 796 attrib_values[i] = SysAllocString(html_attributes_[j].second.c_str()); |
| 794 found = true; | 797 found = true; |
| 795 break; | 798 break; |
| 796 } | 799 } |
| 797 } | 800 } |
| 798 if (!found) { | 801 if (!found) { |
| 799 attrib_values[i] = NULL; | 802 attrib_values[i] = NULL; |
| 800 } | 803 } |
| 801 } | 804 } |
| 802 return S_OK; | 805 return S_OK; |
| 803 } | 806 } |
| 804 | 807 |
| 805 STDMETHODIMP BrowserAccessibility::get_computedStyle( | 808 STDMETHODIMP BrowserAccessibilityWin::get_computedStyle( |
| 806 unsigned short max_style_properties, | 809 unsigned short max_style_properties, |
| 807 boolean use_alternate_view, | 810 boolean use_alternate_view, |
| 808 BSTR *style_properties, | 811 BSTR *style_properties, |
| 809 BSTR *style_values, | 812 BSTR *style_values, |
| 810 unsigned short *num_style_properties) { | 813 unsigned short *num_style_properties) { |
| 811 if (!instance_active_) | 814 if (!instance_active_) |
| 812 return E_FAIL; | 815 return E_FAIL; |
| 813 | 816 |
| 814 if (!style_properties || !style_values) | 817 if (!style_properties || !style_values) |
| 815 return E_INVALIDARG; | 818 return E_INVALIDARG; |
| 816 | 819 |
| 817 // We only cache a single style property for now: DISPLAY | 820 // We only cache a single style property for now: DISPLAY |
| 818 | 821 |
| 819 if (max_style_properties == 0 || | 822 if (max_style_properties == 0 || |
| 820 !HasAttribute(WebAccessibility::ATTR_DISPLAY)) { | 823 !HasAttribute(WebAccessibility::ATTR_DISPLAY)) { |
| 821 *num_style_properties = 0; | 824 *num_style_properties = 0; |
| 822 return S_OK; | 825 return S_OK; |
| 823 } | 826 } |
| 824 | 827 |
| 825 string16 display; | 828 string16 display; |
| 826 GetAttribute(WebAccessibility::ATTR_DISPLAY, &display); | 829 GetAttribute(WebAccessibility::ATTR_DISPLAY, &display); |
| 827 *num_style_properties = 1; | 830 *num_style_properties = 1; |
| 828 style_properties[0] = SysAllocString(L"display"); | 831 style_properties[0] = SysAllocString(L"display"); |
| 829 style_values[0] = SysAllocString(display.c_str()); | 832 style_values[0] = SysAllocString(display.c_str()); |
| 830 | 833 |
| 831 return S_OK; | 834 return S_OK; |
| 832 } | 835 } |
| 833 | 836 |
| 834 STDMETHODIMP BrowserAccessibility::get_computedStyleForProperties( | 837 STDMETHODIMP BrowserAccessibilityWin::get_computedStyleForProperties( |
| 835 unsigned short num_style_properties, | 838 unsigned short num_style_properties, |
| 836 boolean use_alternate_view, | 839 boolean use_alternate_view, |
| 837 BSTR* style_properties, | 840 BSTR* style_properties, |
| 838 BSTR* style_values) { | 841 BSTR* style_values) { |
| 839 if (!instance_active_) | 842 if (!instance_active_) |
| 840 return E_FAIL; | 843 return E_FAIL; |
| 841 | 844 |
| 842 if (!style_properties || !style_values) | 845 if (!style_properties || !style_values) |
| 843 return E_INVALIDARG; | 846 return E_INVALIDARG; |
| 844 | 847 |
| 845 // We only cache a single style property for now: DISPLAY | 848 // We only cache a single style property for now: DISPLAY |
| 846 | 849 |
| 847 for (unsigned short i = 0; i < num_style_properties; i++) { | 850 for (unsigned short i = 0; i < num_style_properties; i++) { |
| 848 string16 name = (LPCWSTR)style_properties[i]; | 851 string16 name = (LPCWSTR)style_properties[i]; |
| 849 StringToLowerASCII(&name); | 852 StringToLowerASCII(&name); |
| 850 if (name == L"display") { | 853 if (name == L"display") { |
| 851 string16 display; | 854 string16 display; |
| 852 GetAttribute(WebAccessibility::ATTR_DISPLAY, &display); | 855 GetAttribute(WebAccessibility::ATTR_DISPLAY, &display); |
| 853 style_values[i] = SysAllocString(display.c_str()); | 856 style_values[i] = SysAllocString(display.c_str()); |
| 854 } else { | 857 } else { |
| 855 style_values[i] = NULL; | 858 style_values[i] = NULL; |
| 856 } | 859 } |
| 857 } | 860 } |
| 858 | 861 |
| 859 return S_OK; | 862 return S_OK; |
| 860 } | 863 } |
| 861 | 864 |
| 862 STDMETHODIMP BrowserAccessibility::scrollTo(boolean placeTopLeft) { | 865 STDMETHODIMP BrowserAccessibilityWin::scrollTo(boolean placeTopLeft) { |
| 863 return E_NOTIMPL; | 866 return E_NOTIMPL; |
| 864 } | 867 } |
| 865 | 868 |
| 866 STDMETHODIMP BrowserAccessibility::get_parentNode(ISimpleDOMNode** node) { | 869 STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { |
| 867 if (!instance_active_) | 870 if (!instance_active_) |
| 868 return E_FAIL; | 871 return E_FAIL; |
| 869 | 872 |
| 870 if (!node) | 873 if (!node) |
| 871 return E_INVALIDARG; | 874 return E_INVALIDARG; |
| 872 | 875 |
| 873 *node = parent_->NewReference(); | 876 *node = parent_->NewReference(); |
| 874 return S_OK; | 877 return S_OK; |
| 875 } | 878 } |
| 876 | 879 |
| 877 STDMETHODIMP BrowserAccessibility::get_firstChild(ISimpleDOMNode** node) { | 880 STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { |
| 878 if (!instance_active_) | 881 if (!instance_active_) |
| 879 return E_FAIL; | 882 return E_FAIL; |
| 880 | 883 |
| 881 if (!node) | 884 if (!node) |
| 882 return E_INVALIDARG; | 885 return E_INVALIDARG; |
| 883 | 886 |
| 884 if (children_.size()) { | 887 if (children_.size()) { |
| 885 *node = children_[0]->NewReference(); | 888 *node = children_[0]->NewReference(); |
| 886 return S_OK; | 889 return S_OK; |
| 887 } else { | 890 } else { |
| 888 *node = NULL; | 891 *node = NULL; |
| 889 return S_FALSE; | 892 return S_FALSE; |
| 890 } | 893 } |
| 891 } | 894 } |
| 892 | 895 |
| 893 STDMETHODIMP BrowserAccessibility::get_lastChild(ISimpleDOMNode** node) { | 896 STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { |
| 894 if (!instance_active_) | 897 if (!instance_active_) |
| 895 return E_FAIL; | 898 return E_FAIL; |
| 896 | 899 |
| 897 if (!node) | 900 if (!node) |
| 898 return E_INVALIDARG; | 901 return E_INVALIDARG; |
| 899 | 902 |
| 900 if (children_.size()) { | 903 if (children_.size()) { |
| 901 *node = children_[children_.size() - 1]->NewReference(); | 904 *node = children_[children_.size() - 1]->NewReference(); |
| 902 return S_OK; | 905 return S_OK; |
| 903 } else { | 906 } else { |
| 904 *node = NULL; | 907 *node = NULL; |
| 905 return S_FALSE; | 908 return S_FALSE; |
| 906 } | 909 } |
| 907 } | 910 } |
| 908 | 911 |
| 909 STDMETHODIMP BrowserAccessibility::get_previousSibling( | 912 STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( |
| 910 ISimpleDOMNode** node) { | 913 ISimpleDOMNode** node) { |
| 911 if (!instance_active_) | 914 if (!instance_active_) |
| 912 return E_FAIL; | 915 return E_FAIL; |
| 913 | 916 |
| 914 if (!node) | 917 if (!node) |
| 915 return E_INVALIDARG; | 918 return E_INVALIDARG; |
| 916 | 919 |
| 917 if (parent_ && index_in_parent_ > 0) { | 920 if (parent_ && index_in_parent_ > 0) { |
| 918 *node = parent_->children_[index_in_parent_ - 1]->NewReference(); | 921 *node = parent_->children_[index_in_parent_ - 1]->NewReference(); |
| 919 return S_OK; | 922 return S_OK; |
| 920 } else { | 923 } else { |
| 921 *node = NULL; | 924 *node = NULL; |
| 922 return S_FALSE; | 925 return S_FALSE; |
| 923 } | 926 } |
| 924 } | 927 } |
| 925 | 928 |
| 926 STDMETHODIMP BrowserAccessibility::get_nextSibling(ISimpleDOMNode** node) { | 929 STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { |
| 927 if (!instance_active_) | 930 if (!instance_active_) |
| 928 return E_FAIL; | 931 return E_FAIL; |
| 929 | 932 |
| 930 if (!node) | 933 if (!node) |
| 931 return E_INVALIDARG; | 934 return E_INVALIDARG; |
| 932 | 935 |
| 933 if (parent_ && | 936 if (parent_ && |
| 934 index_in_parent_ >= 0 && | 937 index_in_parent_ >= 0 && |
| 935 index_in_parent_ < static_cast<int>(parent_->children_.size()) - 1) { | 938 index_in_parent_ < static_cast<int>(parent_->children_.size()) - 1) { |
| 936 *node = parent_->children_[index_in_parent_ + 1]->NewReference(); | 939 *node = parent_->children_[index_in_parent_ + 1]->NewReference(); |
| 937 return S_OK; | 940 return S_OK; |
| 938 } else { | 941 } else { |
| 939 *node = NULL; | 942 *node = NULL; |
| 940 return S_FALSE; | 943 return S_FALSE; |
| 941 } | 944 } |
| 942 } | 945 } |
| 943 | 946 |
| 944 STDMETHODIMP BrowserAccessibility::get_childAt( | 947 STDMETHODIMP BrowserAccessibilityWin::get_childAt( |
| 945 unsigned int child_index, | 948 unsigned int child_index, |
| 946 ISimpleDOMNode** node) { | 949 ISimpleDOMNode** node) { |
| 947 if (!instance_active_) | 950 if (!instance_active_) |
| 948 return E_FAIL; | 951 return E_FAIL; |
| 949 | 952 |
| 950 if (!node) | 953 if (!node) |
| 951 return E_INVALIDARG; | 954 return E_INVALIDARG; |
| 952 | 955 |
| 953 if (child_index < children_.size()) { | 956 if (child_index < children_.size()) { |
| 954 *node = children_[child_index]->NewReference(); | 957 *node = children_[child_index]->NewReference(); |
| 955 return S_OK; | 958 return S_OK; |
| 956 } else { | 959 } else { |
| 957 *node = NULL; | 960 *node = NULL; |
| 958 return S_FALSE; | 961 return S_FALSE; |
| 959 } | 962 } |
| 960 } | 963 } |
| 961 | 964 |
| 962 // | 965 // |
| 963 // ISimpleDOMText methods. | 966 // ISimpleDOMText methods. |
| 964 // | 967 // |
| 965 | 968 |
| 966 STDMETHODIMP BrowserAccessibility::get_domText(BSTR* dom_text) { | 969 STDMETHODIMP BrowserAccessibilityWin::get_domText(BSTR* dom_text) { |
| 967 if (!instance_active_) | 970 if (!instance_active_) |
| 968 return E_FAIL; | 971 return E_FAIL; |
| 969 | 972 |
| 970 if (!dom_text) | 973 if (!dom_text) |
| 971 return E_INVALIDARG; | 974 return E_INVALIDARG; |
| 972 | 975 |
| 973 if (name_.empty()) | 976 if (name_.empty()) |
| 974 return S_FALSE; | 977 return S_FALSE; |
| 975 | 978 |
| 976 *dom_text = SysAllocString(name_.c_str()); | 979 *dom_text = SysAllocString(name_.c_str()); |
| 977 DCHECK(*dom_text); | 980 DCHECK(*dom_text); |
| 978 return S_OK; | 981 return S_OK; |
| 979 } | 982 } |
| 980 | 983 |
| 981 // | 984 // |
| 982 // IServiceProvider methods. | 985 // IServiceProvider methods. |
| 983 // | 986 // |
| 984 | 987 |
| 985 STDMETHODIMP BrowserAccessibility::QueryService( | 988 STDMETHODIMP BrowserAccessibilityWin::QueryService( |
| 986 REFGUID guidService, REFIID riid, void** object) { | 989 REFGUID guidService, REFIID riid, void** object) { |
| 987 if (!instance_active_) | 990 if (!instance_active_) |
| 988 return E_FAIL; | 991 return E_FAIL; |
| 989 | 992 |
| 990 if (guidService == IID_IAccessible || | 993 if (guidService == IID_IAccessible || |
| 991 guidService == IID_IAccessible2 || | 994 guidService == IID_IAccessible2 || |
| 992 guidService == IID_IAccessibleImage || | 995 guidService == IID_IAccessibleImage || |
| 993 guidService == IID_IAccessibleText || | 996 guidService == IID_IAccessibleText || |
| 994 guidService == IID_ISimpleDOMDocument || | 997 guidService == IID_ISimpleDOMDocument || |
| 995 guidService == IID_ISimpleDOMNode || | 998 guidService == IID_ISimpleDOMNode || |
| 996 guidService == IID_ISimpleDOMText) { | 999 guidService == IID_ISimpleDOMText) { |
| 997 return QueryInterface(riid, object); | 1000 return QueryInterface(riid, object); |
| 998 } | 1001 } |
| 999 | 1002 |
| 1000 *object = NULL; | 1003 *object = NULL; |
| 1001 return E_FAIL; | 1004 return E_FAIL; |
| 1002 } | 1005 } |
| 1003 | 1006 |
| 1004 // | 1007 // |
| 1005 // CComObjectRootEx methods. | 1008 // CComObjectRootEx methods. |
| 1006 // | 1009 // |
| 1007 | 1010 |
| 1008 HRESULT WINAPI BrowserAccessibility::InternalQueryInterface( | 1011 HRESULT WINAPI BrowserAccessibilityWin::InternalQueryInterface( |
| 1009 void* this_ptr, | 1012 void* this_ptr, |
| 1010 const _ATL_INTMAP_ENTRY* entries, | 1013 const _ATL_INTMAP_ENTRY* entries, |
| 1011 REFIID iid, | 1014 REFIID iid, |
| 1012 void** object) { | 1015 void** object) { |
| 1013 if (iid == IID_IAccessibleText) { | 1016 if (iid == IID_IAccessibleText) { |
| 1014 if (role_ != ROLE_SYSTEM_LINK) { | 1017 if (role_ != ROLE_SYSTEM_LINK) { |
| 1015 *object = NULL; | 1018 *object = NULL; |
| 1016 return E_NOINTERFACE; | 1019 return E_NOINTERFACE; |
| 1017 } | 1020 } |
| 1018 } else if (iid == IID_IAccessibleImage) { | 1021 } else if (iid == IID_IAccessibleImage) { |
| 1019 if (role_ != ROLE_SYSTEM_GRAPHIC) { | 1022 if (role_ != ROLE_SYSTEM_GRAPHIC) { |
| 1020 *object = NULL; | 1023 *object = NULL; |
| 1021 return E_NOINTERFACE; | 1024 return E_NOINTERFACE; |
| 1022 } | 1025 } |
| 1023 } else if (iid == IID_ISimpleDOMDocument) { | 1026 } else if (iid == IID_ISimpleDOMDocument) { |
| 1024 if (role_ != ROLE_SYSTEM_DOCUMENT) { | 1027 if (role_ != ROLE_SYSTEM_DOCUMENT) { |
| 1025 *object = NULL; | 1028 *object = NULL; |
| 1026 return E_NOINTERFACE; | 1029 return E_NOINTERFACE; |
| 1027 } | 1030 } |
| 1028 } | 1031 } |
| 1029 | 1032 |
| 1030 return CComObjectRootBase::InternalQueryInterface( | 1033 return CComObjectRootBase::InternalQueryInterface( |
| 1031 this_ptr, entries, iid, object); | 1034 this_ptr, entries, iid, object); |
| 1032 } | 1035 } |
| 1033 | 1036 |
| 1034 // | 1037 // |
| 1035 // Private methods. | 1038 // Private methods. |
| 1036 // | 1039 // |
| 1037 | 1040 |
| 1038 BrowserAccessibility* BrowserAccessibility::GetTargetFromChildID( | 1041 BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( |
| 1039 const VARIANT& var_id) { | 1042 const VARIANT& var_id) { |
| 1040 if (var_id.vt != VT_I4) | 1043 if (var_id.vt != VT_I4) |
| 1041 return NULL; | 1044 return NULL; |
| 1042 | 1045 |
| 1043 LONG child_id = var_id.lVal; | 1046 LONG child_id = var_id.lVal; |
| 1044 if (child_id == CHILDID_SELF) | 1047 if (child_id == CHILDID_SELF) |
| 1045 return this; | 1048 return this; |
| 1046 | 1049 |
| 1047 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) | 1050 if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) |
| 1048 return children_[child_id - 1]; | 1051 return children_[child_id - 1]; |
| 1049 | 1052 |
| 1050 return manager_->GetFromChildID(child_id); | 1053 return manager_->GetFromChildID(child_id); |
| 1051 } | 1054 } |
| 1052 | 1055 |
| 1053 bool BrowserAccessibility::HasAttribute(WebAccessibility::Attribute attribute) { | 1056 bool BrowserAccessibilityWin::HasAttribute( |
| 1057 WebAccessibility::Attribute attribute) { |
| 1054 return (attributes_.find(attribute) != attributes_.end()); | 1058 return (attributes_.find(attribute) != attributes_.end()); |
| 1055 } | 1059 } |
| 1056 | 1060 |
| 1057 bool BrowserAccessibility::GetAttribute( | 1061 bool BrowserAccessibilityWin::GetAttribute( |
| 1058 WebAccessibility::Attribute attribute, string16* value) { | 1062 WebAccessibility::Attribute attribute, string16* value) { |
| 1059 std::map<int32, string16>::iterator iter = attributes_.find(attribute); | 1063 std::map<int32, string16>::iterator iter = attributes_.find(attribute); |
| 1060 if (iter != attributes_.end()) { | 1064 if (iter != attributes_.end()) { |
| 1061 *value = iter->second; | 1065 *value = iter->second; |
| 1062 return true; | 1066 return true; |
| 1063 } | 1067 } |
| 1064 | 1068 |
| 1065 return false; | 1069 return false; |
| 1066 } | 1070 } |
| 1067 | 1071 |
| 1068 HRESULT BrowserAccessibility::GetAttributeAsBstr( | 1072 HRESULT BrowserAccessibilityWin::GetAttributeAsBstr( |
| 1069 WebAccessibility::Attribute attribute, BSTR* value_bstr) { | 1073 WebAccessibility::Attribute attribute, BSTR* value_bstr) { |
| 1070 string16 str; | 1074 string16 str; |
| 1071 | 1075 |
| 1072 if (!GetAttribute(attribute, &str)) | 1076 if (!GetAttribute(attribute, &str)) |
| 1073 return S_FALSE; | 1077 return S_FALSE; |
| 1074 | 1078 |
| 1075 if (str.empty()) | 1079 if (str.empty()) |
| 1076 return S_FALSE; | 1080 return S_FALSE; |
| 1077 | 1081 |
| 1078 *value_bstr = SysAllocString(str.c_str()); | 1082 *value_bstr = SysAllocString(str.c_str()); |
| 1079 DCHECK(*value_bstr); | 1083 DCHECK(*value_bstr); |
| 1080 | 1084 |
| 1081 return S_OK; | 1085 return S_OK; |
| 1082 } | 1086 } |
| 1083 | 1087 |
| 1084 string16 BrowserAccessibility::Escape(string16 str) { | 1088 string16 BrowserAccessibilityWin::Escape(string16 str) { |
| 1085 return UTF8ToUTF16(EscapeNonASCII(UTF16ToUTF8(str))); | 1089 return UTF8ToUTF16(EscapeNonASCII(UTF16ToUTF8(str))); |
| 1086 } | 1090 } |
| 1087 | 1091 |
| 1088 void BrowserAccessibility::InitRoleAndState(LONG web_role, | 1092 void BrowserAccessibilityWin::InitRoleAndState(LONG web_role, |
| 1089 LONG web_state) { | 1093 LONG web_state) { |
| 1090 state_ = 0; | 1094 state_ = 0; |
| 1091 ia2_state_ = IA2_STATE_OPAQUE; | 1095 ia2_state_ = IA2_STATE_OPAQUE; |
| 1092 | 1096 |
| 1093 if ((web_state >> WebAccessibility::STATE_CHECKED) & 1) | 1097 if ((web_state >> WebAccessibility::STATE_CHECKED) & 1) |
| 1094 state_ |= STATE_SYSTEM_CHECKED; | 1098 state_ |= STATE_SYSTEM_CHECKED; |
| 1095 if ((web_state >> WebAccessibility::STATE_COLLAPSED) & 1) | 1099 if ((web_state >> WebAccessibility::STATE_COLLAPSED) & 1) |
| 1096 state_ |= STATE_SYSTEM_COLLAPSED; | 1100 state_ |= STATE_SYSTEM_COLLAPSED; |
| 1097 if ((web_state >> WebAccessibility::STATE_EXPANDED) & 1) | 1101 if ((web_state >> WebAccessibility::STATE_EXPANDED) & 1) |
| 1098 state_ |= STATE_SYSTEM_EXPANDED; | 1102 state_ |= STATE_SYSTEM_EXPANDED; |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 } | 1381 } |
| 1378 | 1382 |
| 1379 // The role should always be set. | 1383 // The role should always be set. |
| 1380 DCHECK(!role_name_.empty() || role_); | 1384 DCHECK(!role_name_.empty() || role_); |
| 1381 | 1385 |
| 1382 // If we didn't explicitly set the IAccessible2 role, make it the same | 1386 // If we didn't explicitly set the IAccessible2 role, make it the same |
| 1383 // as the MSAA role. | 1387 // as the MSAA role. |
| 1384 if (!ia2_role_) | 1388 if (!ia2_role_) |
| 1385 ia2_role_ = role_; | 1389 ia2_role_ = role_; |
| 1386 } | 1390 } |
| OLD | NEW |