Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/glue/webaccessibility.h" | 5 #include "webkit/glue/webaccessibility.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache .h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityCache .h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObjec t.h" |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityRole. h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityRole. h" |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebAttribute.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocumentType.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocumentType.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement .h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
| 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNamedNodeMap.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNamedNodeMap.h" |
| 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" | 23 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
| 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" | 24 #include "third_party/WebKit/Source/WebKit/chromium/public/WebRect.h" |
| 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" | 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
| 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" | 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebVector.h" |
| 28 | 28 |
| 29 using base::DoubleToString; | |
| 30 using base::IntToString; | |
| 29 using WebKit::WebAccessibilityCache; | 31 using WebKit::WebAccessibilityCache; |
| 30 using WebKit::WebAccessibilityRole; | 32 using WebKit::WebAccessibilityRole; |
| 31 using WebKit::WebAccessibilityObject; | 33 using WebKit::WebAccessibilityObject; |
| 32 | 34 |
| 33 namespace webkit_glue { | 35 namespace webkit_glue { |
| 34 | 36 |
| 37 static std::string BoolToString(bool b) { | |
| 38 return b? "true": "false"; | |
|
tony
2011/08/27 00:05:47
Nit: Space between b and ?
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 39 } | |
| 40 | |
| 35 // Provides a conversion between the WebKit::WebAccessibilityRole and a role | 41 // Provides a conversion between the WebKit::WebAccessibilityRole and a role |
| 36 // supported on the Browser side. Listed alphabetically by the | 42 // supported on the Browser side. Listed alphabetically by the |
| 37 // WebAccessibilityRole (except for default role). | 43 // WebAccessibilityRole (except for default role). |
| 38 WebAccessibility::Role ConvertRole(WebKit::WebAccessibilityRole role) { | 44 WebAccessibility::Role ConvertRole(WebKit::WebAccessibilityRole role) { |
| 39 switch (role) { | 45 switch (role) { |
| 40 case WebKit::WebAccessibilityRoleAnnotation: | 46 case WebKit::WebAccessibilityRoleAnnotation: |
| 41 return WebAccessibility::ROLE_ANNOTATION; | 47 return WebAccessibility::ROLE_ANNOTATION; |
| 42 case WebKit::WebAccessibilityRoleApplication: | 48 case WebKit::WebAccessibilityRoleApplication: |
| 43 return WebAccessibility::ROLE_APPLICATION; | 49 return WebAccessibility::ROLE_APPLICATION; |
| 44 case WebKit::WebAccessibilityRoleApplicationAlert: | 50 case WebKit::WebAccessibilityRoleApplicationAlert: |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 238 | 244 |
| 239 if (o.isCollapsed()) | 245 if (o.isCollapsed()) |
| 240 state |= (1 << WebAccessibility::STATE_COLLAPSED); | 246 state |= (1 << WebAccessibility::STATE_COLLAPSED); |
| 241 | 247 |
| 242 if (o.canSetFocusAttribute()) | 248 if (o.canSetFocusAttribute()) |
| 243 state |= (1 << WebAccessibility::STATE_FOCUSABLE); | 249 state |= (1 << WebAccessibility::STATE_FOCUSABLE); |
| 244 | 250 |
| 245 if (o.isFocused()) | 251 if (o.isFocused()) |
| 246 state |= (1 << WebAccessibility::STATE_FOCUSED); | 252 state |= (1 << WebAccessibility::STATE_FOCUSED); |
| 247 | 253 |
| 248 if (o.roleValue() == WebKit::WebAccessibilityRolePopUpButton) { | 254 if (o.roleValue() == WebKit::WebAccessibilityRolePopUpButton || |
| 255 o.ariaHasPopup()) { | |
| 249 state |= (1 << WebAccessibility::STATE_HASPOPUP); | 256 state |= (1 << WebAccessibility::STATE_HASPOPUP); |
| 250 | |
| 251 if (!o.isCollapsed()) | 257 if (!o.isCollapsed()) |
| 252 state |= (1 << WebAccessibility::STATE_EXPANDED); | 258 state |= (1 << WebAccessibility::STATE_EXPANDED); |
| 253 } | 259 } |
| 254 | 260 |
| 255 if (o.isHovered()) | 261 if (o.isHovered()) |
| 256 state |= (1 << WebAccessibility::STATE_HOTTRACKED); | 262 state |= (1 << WebAccessibility::STATE_HOTTRACKED); |
| 257 | 263 |
| 258 if (o.isIndeterminate()) | 264 if (o.isIndeterminate()) |
| 259 state |= (1 << WebAccessibility::STATE_INDETERMINATE); | 265 state |= (1 << WebAccessibility::STATE_INDETERMINATE); |
| 260 | 266 |
| 261 if (!o.isVisible()) | 267 if (!o.isVisible()) |
| 262 state |= (1 << WebAccessibility::STATE_INVISIBLE); | 268 state |= (1 << WebAccessibility::STATE_INVISIBLE); |
| 263 | 269 |
| 264 if (o.isLinked()) | 270 if (o.isLinked()) |
| 265 state |= (1 << WebAccessibility::STATE_LINKED); | 271 state |= (1 << WebAccessibility::STATE_LINKED); |
| 266 | 272 |
| 267 if (o.isMultiSelectable()) | 273 if (o.isMultiSelectable()) |
| 268 state |= (1 << WebAccessibility::STATE_MULTISELECTABLE); | 274 state |= (1 << WebAccessibility::STATE_MULTISELECTABLE); |
| 269 | 275 |
| 270 if (o.isOffScreen()) | 276 if (o.isOffScreen()) |
| 271 state |= (1 << WebAccessibility::STATE_OFFSCREEN); | 277 state |= (1 << WebAccessibility::STATE_OFFSCREEN); |
| 272 | 278 |
| 273 if (o.isPressed()) | 279 if (o.isPressed()) |
| 274 state |= (1 << WebAccessibility::STATE_PRESSED); | 280 state |= (1 << WebAccessibility::STATE_PRESSED); |
| 275 | 281 |
| 276 if (o.isPasswordField()) | 282 if (o.isPasswordField()) |
| 277 state |= (1 << WebAccessibility::STATE_PROTECTED); | 283 state |= (1 << WebAccessibility::STATE_PROTECTED); |
| 278 | 284 |
| 279 if (o.isReadOnly()) | 285 if (o.isAriaReadOnly()) |
| 280 state |= (1 << WebAccessibility::STATE_READONLY); | 286 state |= (1 << WebAccessibility::STATE_READONLY); |
| 281 | 287 |
| 288 if (o.isRequired()) | |
| 289 state |= (1 << WebAccessibility::STATE_REQUIRED); | |
| 290 | |
| 282 if (o.canSetSelectedAttribute()) | 291 if (o.canSetSelectedAttribute()) |
| 283 state |= (1 << WebAccessibility::STATE_SELECTABLE); | 292 state |= (1 << WebAccessibility::STATE_SELECTABLE); |
| 284 | 293 |
| 285 if (o.isSelected()) | 294 if (o.isSelected()) |
| 286 state |= (1 << WebAccessibility::STATE_SELECTED); | 295 state |= (1 << WebAccessibility::STATE_SELECTED); |
| 287 | 296 |
| 288 if (o.isVisited()) | 297 if (o.isVisited()) |
| 289 state |= (1 << WebAccessibility::STATE_TRAVERSED); | 298 state |= (1 << WebAccessibility::STATE_TRAVERSED); |
| 290 | 299 |
| 291 if (!o.isEnabled()) | 300 if (!o.isEnabled()) |
| 292 state |= (1 << WebAccessibility::STATE_UNAVAILABLE); | 301 state |= (1 << WebAccessibility::STATE_UNAVAILABLE); |
| 293 | 302 |
| 303 if (o.isVertical()) | |
| 304 state |= (1 << WebAccessibility::STATE_VERTICAL); | |
| 305 | |
| 306 if (o.isVisited()) | |
| 307 state |= (1 << WebAccessibility::STATE_VISITED); | |
| 308 | |
| 294 return state; | 309 return state; |
| 295 } | 310 } |
| 296 | 311 |
| 297 WebAccessibility::WebAccessibility() | 312 WebAccessibility::WebAccessibility() |
| 298 : id(-1), | 313 : id(-1), |
| 299 role(ROLE_NONE), | 314 role(ROLE_NONE), |
| 300 state(-1) { | 315 state(-1) { |
| 301 } | 316 } |
| 302 | 317 |
| 303 WebAccessibility::WebAccessibility(const WebKit::WebAccessibilityObject& src, | 318 WebAccessibility::WebAccessibility(const WebKit::WebAccessibilityObject& src, |
| 304 WebKit::WebAccessibilityCache* cache, | 319 WebKit::WebAccessibilityCache* cache, |
| 305 bool include_children) { | 320 bool include_children) { |
| 306 Init(src, cache, include_children); | 321 Init(src, cache, include_children); |
| 307 } | 322 } |
| 308 | 323 |
| 309 WebAccessibility::~WebAccessibility() { | 324 WebAccessibility::~WebAccessibility() { |
| 310 } | 325 } |
| 311 | 326 |
| 327 std::string WebAccessibility::DebugString(bool recursive) { | |
| 328 std::string result; | |
| 329 static int indent = 0; | |
| 330 | |
| 331 for (int i = 0; i < indent; i++) | |
| 332 result += " "; | |
| 333 | |
| 334 result += "id=" + IntToString(id); | |
| 335 | |
| 336 switch(role) { | |
| 337 case ROLE_ALERT: result += " ALERT"; break; | |
| 338 case ROLE_ALERT_DIALOG: result += " ALERT_DIALOG"; break; | |
| 339 case ROLE_ANNOTATION: result += " ANNOTATION"; break; | |
| 340 case ROLE_APPLICATION: result += " APPLICATION"; break; | |
| 341 case ROLE_ARTICLE: result += " ARTICLE"; break; | |
| 342 case ROLE_BROWSER: result += " BROWSER"; break; | |
| 343 case ROLE_BUSY_INDICATOR: result += " BUSY_INDICATOR"; break; | |
| 344 case ROLE_BUTTON: result += " BUTTON"; break; | |
| 345 case ROLE_CELL: result += " CELL"; break; | |
| 346 case ROLE_CHECKBOX: result += " CHECKBOX"; break; | |
| 347 case ROLE_COLOR_WELL: result += " COLOR_WELL"; break; | |
| 348 case ROLE_COLUMN: result += " COLUMN"; break; | |
| 349 case ROLE_COLUMN_HEADER: result += " COLUMN_HEADER"; break; | |
| 350 case ROLE_COMBO_BOX: result += " COMBO_BOX"; break; | |
| 351 case ROLE_DEFINITION_LIST_DEFINITION: result += " DL_DEFINITION"; break; | |
| 352 case ROLE_DEFINITION_LIST_TERM: result += " DL_TERM"; break; | |
| 353 case ROLE_DIALOG: result += " DIALOG"; break; | |
| 354 case ROLE_DIRECTORY: result += " DIRECTORY"; break; | |
| 355 case ROLE_DISCLOSURE_TRIANGLE: result += " DISCLOSURE_TRIANGLE"; break; | |
| 356 case ROLE_DOCUMENT: result += " DOCUMENT"; break; | |
| 357 case ROLE_DRAWER: result += " DRAWER"; break; | |
| 358 case ROLE_EDITABLE_TEXT: result += " EDITABLE_TEXT"; break; | |
| 359 case ROLE_GRID: result += " GRID"; break; | |
| 360 case ROLE_GROUP: result += " GROUP"; break; | |
| 361 case ROLE_GROW_AREA: result += " GROW_AREA"; break; | |
| 362 case ROLE_HEADING: result += " HEADING"; break; | |
| 363 case ROLE_HELP_TAG: result += " HELP_TAG"; break; | |
| 364 case ROLE_IGNORED: result += " IGNORED"; break; | |
| 365 case ROLE_IMAGE: result += " IMAGE"; break; | |
| 366 case ROLE_IMAGE_MAP: result += " IMAGE_MAP"; break; | |
| 367 case ROLE_IMAGE_MAP_LINK: result += " IMAGE_MAP_LINK"; break; | |
| 368 case ROLE_INCREMENTOR: result += " INCREMENTOR"; break; | |
| 369 case ROLE_LANDMARK_APPLICATION: result += " L_APPLICATION"; break; | |
| 370 case ROLE_LANDMARK_BANNER: result += " L_BANNER"; break; | |
| 371 case ROLE_LANDMARK_COMPLEMENTARY: result += " L_COMPLEMENTARY"; break; | |
| 372 case ROLE_LANDMARK_CONTENTINFO: result += " L_CONTENTINFO"; break; | |
| 373 case ROLE_LANDMARK_MAIN: result += " L_MAIN"; break; | |
| 374 case ROLE_LANDMARK_NAVIGATION: result += " L_NAVIGATION"; break; | |
| 375 case ROLE_LANDMARK_SEARCH: result += " L_SEARCH"; break; | |
| 376 case ROLE_LINK: result += " LINK"; break; | |
| 377 case ROLE_LIST: result += " LIST"; break; | |
| 378 case ROLE_LISTBOX: result += " LISTBOX"; break; | |
| 379 case ROLE_LISTBOX_OPTION: result += " LISTBOX_OPTION"; break; | |
| 380 case ROLE_LIST_ITEM: result += " LIST_ITEM"; break; | |
| 381 case ROLE_LIST_MARKER: result += " LIST_MARKER"; break; | |
| 382 case ROLE_LOG: result += " LOG"; break; | |
| 383 case ROLE_MARQUEE: result += " MARQUEE"; break; | |
| 384 case ROLE_MATH: result += " MATH"; break; | |
| 385 case ROLE_MATTE: result += " MATTE"; break; | |
| 386 case ROLE_MENU: result += " MENU"; break; | |
| 387 case ROLE_MENU_BAR: result += " MENU_BAR"; break; | |
| 388 case ROLE_MENU_BUTTON: result += " MENU_BUTTON"; break; | |
| 389 case ROLE_MENU_ITEM: result += " MENU_ITEM"; break; | |
| 390 case ROLE_MENU_LIST_OPTION: result += " MENU_LIST_OPTION"; break; | |
| 391 case ROLE_MENU_LIST_POPUP: result += " MENU_LIST_POPUP"; break; | |
| 392 case ROLE_NOTE: result += " NOTE"; break; | |
| 393 case ROLE_OUTLINE: result += " OUTLINE"; break; | |
| 394 case ROLE_POPUP_BUTTON: result += " POPUP_BUTTON"; break; | |
| 395 case ROLE_PROGRESS_INDICATOR: result += " PROGRESS_INDICATOR"; break; | |
| 396 case ROLE_RADIO_BUTTON: result += " RADIO_BUTTON"; break; | |
| 397 case ROLE_RADIO_GROUP: result += " RADIO_GROUP"; break; | |
| 398 case ROLE_REGION: result += " REGION"; break; | |
| 399 case ROLE_ROW: result += " ROW"; break; | |
| 400 case ROLE_ROW_HEADER: result += " ROW_HEADER"; break; | |
| 401 case ROLE_RULER: result += " RULER"; break; | |
| 402 case ROLE_RULER_MARKER: result += " RULER_MARKER"; break; | |
| 403 case ROLE_SCROLLAREA: result += " SCROLLAREA"; break; | |
| 404 case ROLE_SCROLLBAR: result += " SCROLLBAR"; break; | |
| 405 case ROLE_SHEET: result += " SHEET"; break; | |
| 406 case ROLE_SLIDER: result += " SLIDER"; break; | |
| 407 case ROLE_SLIDER_THUMB: result += " SLIDER_THUMB"; break; | |
| 408 case ROLE_SPLITTER: result += " SPLITTER"; break; | |
| 409 case ROLE_SPLIT_GROUP: result += " SPLIT_GROUP"; break; | |
| 410 case ROLE_STATIC_TEXT: result += " STATIC_TEXT"; break; | |
| 411 case ROLE_STATUS: result += " STATUS"; break; | |
| 412 case ROLE_SYSTEM_WIDE: result += " SYSTEM_WIDE"; break; | |
| 413 case ROLE_TAB: result += " TAB"; break; | |
| 414 case ROLE_TABLE: result += " TABLE"; break; | |
| 415 case ROLE_TABLE_HEADER_CONTAINER: result += " TABLE_HDR_CONTAINER"; break; | |
| 416 case ROLE_TAB_GROUP: result += " TAB_GROUP"; break; | |
| 417 case ROLE_TAB_LIST: result += " TAB_LIST"; break; | |
| 418 case ROLE_TAB_PANEL: result += " TAB_PANEL"; break; | |
| 419 case ROLE_TEXTAREA: result += " TEXTAREA"; break; | |
| 420 case ROLE_TEXT_FIELD: result += " TEXT_FIELD"; break; | |
| 421 case ROLE_TIMER: result += " TIMER"; break; | |
| 422 case ROLE_TOOLBAR: result += " TOOLBAR"; break; | |
| 423 case ROLE_TOOLTIP: result += " TOOLTIP"; break; | |
| 424 case ROLE_TREE: result += " TREE"; break; | |
| 425 case ROLE_TREE_GRID: result += " TREE_GRID"; break; | |
| 426 case ROLE_TREE_ITEM: result += " TREE_ITEM"; break; | |
| 427 case ROLE_UNKNOWN: result += " UNKNOWN"; break; | |
| 428 case ROLE_VALUE_INDICATOR: result += " VALUE_INDICATOR"; break; | |
| 429 case ROLE_WEBCORE_LINK: result += " WEBCORE_LINK"; break; | |
| 430 case ROLE_WEB_AREA: result += " WEB_AREA"; break; | |
| 431 case ROLE_WINDOW: result += " WINDOW"; break; | |
| 432 } | |
| 433 | |
| 434 if (state & (1 << STATE_BUSY)) | |
| 435 result += " BUSY"; | |
| 436 if (state & (1 << STATE_CHECKED)) | |
| 437 result += " CHECKED"; | |
| 438 if (state & (1 << STATE_COLLAPSED)) | |
| 439 result += " COLLAPSED"; | |
| 440 if (state & (1 << STATE_EXPANDED)) | |
| 441 result += " EXPANDED"; | |
| 442 if (state & (1 << STATE_FOCUSABLE)) | |
| 443 result += " FOCUSABLE"; | |
| 444 if (state & (1 << STATE_FOCUSED)) | |
| 445 result += " FOCUSED"; | |
| 446 if (state & (1 << STATE_HASPOPUP)) | |
| 447 result += " HASPOPUP"; | |
| 448 if (state & (1 << STATE_HOTTRACKED)) | |
| 449 result += " HOTTRACKED"; | |
| 450 if (state & (1 << STATE_INDETERMINATE)) | |
| 451 result += " INDETERMINATE"; | |
| 452 if (state & (1 << STATE_INVISIBLE)) | |
| 453 result += " INVISIBLE"; | |
| 454 if (state & (1 << STATE_LINKED)) | |
| 455 result += " LINKED"; | |
| 456 if (state & (1 << STATE_MULTISELECTABLE)) | |
| 457 result += " MULTISELECTABLE"; | |
| 458 if (state & (1 << STATE_OFFSCREEN)) | |
| 459 result += " OFFSCREEN"; | |
| 460 if (state & (1 << STATE_PRESSED)) | |
| 461 result += " PRESSED"; | |
| 462 if (state & (1 << STATE_PROTECTED)) | |
| 463 result += " PROTECTED"; | |
| 464 if (state & (1 << STATE_READONLY)) | |
| 465 result += " READONLY"; | |
| 466 if (state & (1 << STATE_REQUIRED)) | |
| 467 result += " REQUIRED"; | |
| 468 if (state & (1 << STATE_SELECTABLE)) | |
| 469 result += " SELECTABLE"; | |
| 470 if (state & (1 << STATE_SELECTED)) | |
| 471 result += " SELECTED"; | |
| 472 if (state & (1 << STATE_TRAVERSED)) | |
| 473 result += " TRAVERSED"; | |
| 474 if (state & (1 << STATE_UNAVAILABLE)) | |
| 475 result += " UNAVAILABLE"; | |
| 476 if (state & (1 << STATE_VERTICAL)) | |
| 477 result += " VERTICAL"; | |
| 478 if (state & (1 << STATE_VISITED)) | |
| 479 result += " VISITED"; | |
| 480 | |
| 481 std::string tmp = UTF16ToUTF8(name); | |
| 482 RemoveChars(tmp, "\n", &tmp); | |
| 483 if (!tmp.empty()) | |
| 484 result += " name=" + tmp; | |
| 485 | |
| 486 tmp = UTF16ToUTF8(value); | |
| 487 RemoveChars(tmp, "\n", &tmp); | |
| 488 if (!tmp.empty()) | |
| 489 result += " value=" + tmp; | |
| 490 | |
| 491 result += " (" + IntToString(location.x()) + ", " + | |
| 492 IntToString(location.y()) + ")-(" + | |
| 493 IntToString(location.width()) + ", " + | |
| 494 IntToString(location.height()) + ")"; | |
| 495 | |
| 496 std::map<IntAttribute, int32>& iattrs = int_attributes; | |
| 497 if (iattrs.find(ATTR_DOC_SCROLLX) != iattrs.end()) | |
|
tony
2011/08/27 00:05:47
It would be faster to iterate over the map and swi
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 498 result += " scrollx=" + IntToString(iattrs[ATTR_DOC_SCROLLX]); | |
| 499 if (iattrs.find(ATTR_DOC_SCROLLY) != iattrs.end()) | |
| 500 result += " scrolly=" + IntToString(iattrs[ATTR_DOC_SCROLLY]); | |
| 501 if (iattrs.find(ATTR_TEXT_SEL_START) != iattrs.end()) | |
| 502 result += " sel_start=" + IntToString(iattrs[ATTR_TEXT_SEL_START]); | |
| 503 if (iattrs.find(ATTR_TEXT_SEL_END) != iattrs.end()) | |
| 504 result += " sel_end=" + IntToString(iattrs[ATTR_TEXT_SEL_END]); | |
| 505 if (iattrs.find(ATTR_TABLE_ROW_COUNT) != iattrs.end()) | |
| 506 result += " rows=" + IntToString(iattrs[ATTR_TABLE_ROW_COUNT]); | |
| 507 if (iattrs.find(ATTR_TABLE_COLUMN_COUNT) != iattrs.end()) | |
| 508 result += " cols=" + IntToString(iattrs[ATTR_TABLE_COLUMN_COUNT]); | |
| 509 if (iattrs.find(ATTR_TABLE_CELL_COLUMN_INDEX) != iattrs.end()) | |
| 510 result += " col=" + IntToString(iattrs[ATTR_TABLE_CELL_COLUMN_INDEX]); | |
| 511 if (iattrs.find(ATTR_TABLE_CELL_ROW_INDEX) != iattrs.end()) | |
| 512 result += " row=" + IntToString(iattrs[ATTR_TABLE_CELL_ROW_INDEX]); | |
| 513 if (iattrs.find(ATTR_TABLE_CELL_COLUMN_SPAN) != iattrs.end()) | |
| 514 result += " colspan=" + IntToString(iattrs[ATTR_TABLE_CELL_COLUMN_SPAN]); | |
| 515 if (iattrs.find(ATTR_TABLE_CELL_ROW_SPAN) != iattrs.end()) | |
| 516 result += " rowspan=" + IntToString(iattrs[ATTR_TABLE_CELL_ROW_SPAN]); | |
| 517 | |
| 518 std::map<StringAttribute, string16>& sattrs = string_attributes; | |
| 519 if (sattrs.find(ATTR_DOC_URL) != sattrs.end()) | |
|
tony
2011/08/27 00:05:47
Same as above.
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 520 result += " doc_url=" + UTF16ToUTF8(sattrs[ATTR_DOC_URL]); | |
| 521 if (sattrs.find(ATTR_DOC_TITLE) != sattrs.end()) | |
| 522 result += " doc_title=" + UTF16ToUTF8(sattrs[ATTR_DOC_TITLE]); | |
| 523 if (sattrs.find(ATTR_DOC_MIMETYPE) != sattrs.end()) | |
| 524 result += " doc_mimetype=" + UTF16ToUTF8(sattrs[ATTR_DOC_MIMETYPE]); | |
| 525 if (sattrs.find(ATTR_DOC_DOCTYPE) != sattrs.end()) | |
| 526 result += " doc_doctype=" + UTF16ToUTF8(sattrs[ATTR_DOC_DOCTYPE]); | |
| 527 if (sattrs.find(ATTR_ACCESS_KEY) != sattrs.end()) | |
| 528 result += " access_key=" + UTF16ToUTF8(sattrs[ATTR_ACCESS_KEY]); | |
| 529 if (sattrs.find(ATTR_ACTION) != sattrs.end()) | |
| 530 result += " action=" + UTF16ToUTF8(sattrs[ATTR_ACTION]); | |
| 531 if (sattrs.find(ATTR_DESCRIPTION) != sattrs.end()) | |
| 532 result += " description=" + UTF16ToUTF8(sattrs[ATTR_DESCRIPTION]); | |
| 533 if (sattrs.find(ATTR_DISPLAY) != sattrs.end()) | |
| 534 result += " display=" + UTF16ToUTF8(sattrs[ATTR_DISPLAY]); | |
| 535 if (sattrs.find(ATTR_HELP) != sattrs.end()) | |
| 536 result += " help=" + UTF16ToUTF8(sattrs[ATTR_HELP]); | |
| 537 if (sattrs.find(ATTR_HTML_TAG) != sattrs.end()) | |
| 538 result += " html_tag=" + UTF16ToUTF8(sattrs[ATTR_HTML_TAG]); | |
| 539 if (sattrs.find(ATTR_LIVE_RELEVANT) != sattrs.end()) | |
| 540 result += " relevant=" + UTF16ToUTF8(sattrs[ATTR_LIVE_RELEVANT]); | |
| 541 if (sattrs.find(ATTR_LIVE_STATUS) != sattrs.end()) | |
| 542 result += " live=" + UTF16ToUTF8(sattrs[ATTR_LIVE_STATUS]); | |
| 543 if (sattrs.find(ATTR_CONTAINER_LIVE_RELEVANT) != sattrs.end()) { | |
| 544 result += " container_relevant=" + | |
| 545 UTF16ToUTF8(sattrs[ATTR_CONTAINER_LIVE_RELEVANT]); | |
| 546 } | |
| 547 if (sattrs.find(ATTR_CONTAINER_LIVE_STATUS) != sattrs.end()) { | |
| 548 result += " container_live=" + | |
| 549 UTF16ToUTF8(sattrs[ATTR_CONTAINER_LIVE_STATUS]); | |
| 550 } | |
| 551 if (sattrs.find(ATTR_ROLE) != sattrs.end()) | |
| 552 result += " role=" + UTF16ToUTF8(sattrs[ATTR_ROLE]); | |
| 553 if (sattrs.find(ATTR_SHORTCUT) != sattrs.end()) | |
| 554 result += " shortcut=" + UTF16ToUTF8(sattrs[ATTR_SHORTCUT]); | |
| 555 if (sattrs.find(ATTR_URL) != sattrs.end()) | |
| 556 result += " url=" + UTF16ToUTF8(sattrs[ATTR_URL]); | |
| 557 | |
| 558 std::map<FloatAttribute, float>& fattrs = float_attributes; | |
| 559 if (fattrs.find(ATTR_DOC_LOADING_PROGRESS) != fattrs.end()) { | |
| 560 result += " doc_progress=" + | |
| 561 DoubleToString(fattrs[ATTR_DOC_LOADING_PROGRESS]); | |
| 562 } | |
| 563 if (fattrs.find(ATTR_VALUE_FOR_RANGE) != fattrs.end()) { | |
| 564 result += " value_for_range=" + | |
| 565 DoubleToString(fattrs[ATTR_VALUE_FOR_RANGE]); | |
| 566 } | |
| 567 if (fattrs.find(ATTR_MAX_VALUE_FOR_RANGE) != fattrs.end()) { | |
| 568 result += " max_value=" + | |
| 569 DoubleToString(fattrs[ATTR_MAX_VALUE_FOR_RANGE]); | |
| 570 } | |
| 571 if (fattrs.find(ATTR_MIN_VALUE_FOR_RANGE) != fattrs.end()) { | |
| 572 result += " min_value=" + | |
| 573 DoubleToString(fattrs[ATTR_MIN_VALUE_FOR_RANGE]); | |
| 574 } | |
| 575 | |
| 576 std::map<BoolAttribute, bool>& battrs = bool_attributes; | |
| 577 if (battrs.find(ATTR_DOC_LOADED) != battrs.end()) | |
| 578 result += " doc_loaded=" + BoolToString(battrs[ATTR_DOC_LOADED]); | |
| 579 if (battrs.find(ATTR_BUTTON_MIXED) != battrs.end()) | |
| 580 result += " mixed=" + BoolToString(battrs[ATTR_BUTTON_MIXED]); | |
| 581 if (battrs.find(ATTR_LIVE_ATOMIC) != battrs.end()) | |
| 582 result += " atomic=" + BoolToString(battrs[ATTR_LIVE_ATOMIC]); | |
| 583 if (battrs.find(ATTR_LIVE_BUSY) != battrs.end()) | |
| 584 result += " busy=" + BoolToString(battrs[ATTR_LIVE_BUSY]); | |
| 585 if (battrs.find(ATTR_CONTAINER_LIVE_ATOMIC) != battrs.end()) { | |
| 586 result += " container_atomic=" + | |
| 587 BoolToString(battrs[ATTR_CONTAINER_LIVE_ATOMIC]); | |
| 588 } | |
| 589 if (battrs.find(ATTR_CONTAINER_LIVE_BUSY) != battrs.end()) { | |
| 590 result += " container_busy=" + | |
| 591 BoolToString(battrs[ATTR_CONTAINER_LIVE_BUSY]); | |
| 592 } | |
| 593 | |
| 594 if (children.size() > 0) | |
|
tony
2011/08/27 00:05:47
Nit: !children.empty()
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 595 result += " children=" + IntToString(children.size()); | |
| 596 | |
| 597 if (indirect_child_ids.size() > 0) { | |
|
tony
2011/08/27 00:05:47
Nit: !empty()
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 598 result += " indirect_child_ids="; | |
| 599 for (size_t i = 0; i < indirect_child_ids.size(); i++) { | |
|
tony
2011/08/27 00:05:47
Nit: ++i
dmazzoni
2011/08/29 18:08:51
Fixed throughout.
| |
| 600 if (i > 0) | |
| 601 result += ","; | |
| 602 result += IntToString(indirect_child_ids[i]); | |
| 603 } | |
| 604 } | |
| 605 | |
| 606 if (line_breaks.size() > 0) { | |
|
tony
2011/08/27 00:05:47
Please make a helper function for printing a vecto
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 607 result += " line_breaks="; | |
| 608 for (size_t i = 0; i < line_breaks.size(); i++) { | |
| 609 if (i > 0) | |
| 610 result += ","; | |
| 611 result += IntToString(line_breaks[i]); | |
| 612 } | |
| 613 } | |
| 614 | |
| 615 if (cell_ids.size() > 0) { | |
|
tony
2011/08/27 00:05:47
Nit: !empty()
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 616 result += " cell_ids="; | |
| 617 for (size_t i = 0; i < cell_ids.size(); i++) { | |
|
tony
2011/08/27 00:05:47
Nit: ++i
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 618 if (i > 0) | |
| 619 result += ","; | |
| 620 result += IntToString(cell_ids[i]); | |
| 621 } | |
| 622 } | |
| 623 | |
| 624 if (recursive) { | |
| 625 result += "\n"; | |
| 626 indent++; | |
|
tony
2011/08/27 00:05:47
Nit: ++indent
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 627 for (size_t i = 0; i < children.size(); i++) | |
| 628 result += children[i].DebugString(true); | |
| 629 indent--; | |
|
tony
2011/08/27 00:05:47
Nit: --indent
dmazzoni
2011/08/29 18:08:51
Done.
| |
| 630 } | |
| 631 | |
| 632 return result; | |
| 633 } | |
| 634 | |
| 312 void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src, | 635 void WebAccessibility::Init(const WebKit::WebAccessibilityObject& src, |
| 313 WebKit::WebAccessibilityCache* cache, | 636 WebKit::WebAccessibilityCache* cache, |
| 314 bool include_children) { | 637 bool include_children) { |
| 315 name = src.title(); | 638 name = src.title(); |
| 316 value = src.stringValue(); | |
| 317 role = ConvertRole(src.roleValue()); | 639 role = ConvertRole(src.roleValue()); |
| 318 state = ConvertState(src); | 640 state = ConvertState(src); |
| 319 location = src.boundingBoxRect(); | 641 location = src.boundingBoxRect(); |
| 320 | 642 |
| 643 if (src.valueDescription().length()) | |
|
tony
2011/08/27 00:05:47
Nit: !.empty()
dmazzoni
2011/08/29 18:08:51
Actually this one is a WebString, which doesn't ha
| |
| 644 value = src.valueDescription(); | |
| 645 else | |
| 646 value = src.stringValue(); | |
| 647 | |
| 648 if (src.accessKey().length()) | |
| 649 string_attributes[ATTR_ACCESS_KEY] = src.accessKey(); | |
| 321 if (src.actionVerb().length()) | 650 if (src.actionVerb().length()) |
| 322 string_attributes[ATTR_ACTION] = src.actionVerb(); | 651 string_attributes[ATTR_ACTION] = src.actionVerb(); |
| 652 if (src.isButtonStateMixed()) | |
| 653 bool_attributes[ATTR_BUTTON_MIXED] = true; | |
| 323 if (src.accessibilityDescription().length()) | 654 if (src.accessibilityDescription().length()) |
| 324 string_attributes[ATTR_DESCRIPTION] = src.accessibilityDescription(); | 655 string_attributes[ATTR_DESCRIPTION] = src.accessibilityDescription(); |
| 656 if (src.hasComputedStyle()) | |
| 657 string_attributes[ATTR_DISPLAY] = src.computedStyleDisplay(); | |
| 325 if (src.helpText().length()) | 658 if (src.helpText().length()) |
| 326 string_attributes[ATTR_HELP] = src.helpText(); | 659 string_attributes[ATTR_HELP] = src.helpText(); |
| 327 if (src.keyboardShortcut().length()) | 660 if (src.keyboardShortcut().length()) |
| 328 string_attributes[ATTR_SHORTCUT] = src.keyboardShortcut(); | 661 string_attributes[ATTR_SHORTCUT] = src.keyboardShortcut(); |
| 329 if (src.hasComputedStyle()) | |
| 330 string_attributes[ATTR_DISPLAY] = src.computedStyleDisplay(); | |
| 331 if (!src.url().isEmpty()) | 662 if (!src.url().isEmpty()) |
| 332 string_attributes[ATTR_URL] = src.url().spec().utf16(); | 663 string_attributes[ATTR_URL] = src.url().spec().utf16(); |
| 333 | 664 |
| 665 if (role == ROLE_TREE_ITEM) | |
| 666 int_attributes[ATTR_HIERARCHICAL_LEVEL] = src.hierarchicalLevel(); | |
| 667 | |
| 668 if (role == ROLE_SLIDER) | |
| 669 include_children = false; | |
| 670 | |
| 334 WebKit::WebNode node = src.node(); | 671 WebKit::WebNode node = src.node(); |
| 335 bool is_iframe = false; | 672 bool is_iframe = false; |
| 336 | 673 |
| 337 if (!node.isNull() && node.isElementNode()) { | 674 if (!node.isNull() && node.isElementNode()) { |
| 338 WebKit::WebElement element = node.to<WebKit::WebElement>(); | 675 WebKit::WebElement element = node.to<WebKit::WebElement>(); |
| 339 is_iframe = (element.tagName() == ASCIIToUTF16("IFRAME")); | 676 is_iframe = (element.tagName() == ASCIIToUTF16("IFRAME")); |
| 340 | 677 |
| 341 // TODO(ctguil): The tagName in WebKit is lower cased but | 678 // TODO(ctguil): The tagName in WebKit is lower cased but |
| 342 // HTMLElement::nodeName calls localNameUpper. Consider adding | 679 // HTMLElement::nodeName calls localNameUpper. Consider adding |
| 343 // a WebElement method that returns the original lower cased tagName. | 680 // a WebElement method that returns the original lower cased tagName. |
| 344 string_attributes[ATTR_HTML_TAG] = | 681 string_attributes[ATTR_HTML_TAG] = |
| 345 StringToLowerASCII(string16(element.tagName())); | 682 StringToLowerASCII(string16(element.tagName())); |
| 346 for (unsigned i = 0; i < element.attributes().length(); i++) { | 683 for (unsigned i = 0; i < element.attributes().length(); i++) { |
| 347 html_attributes.push_back( | 684 string16 name = StringToLowerASCII(string16( |
| 348 std::pair<string16, string16>( | 685 element.attributes().attributeItem(i).localName())); |
| 349 element.attributes().attributeItem(i).localName(), | 686 string16 value = element.attributes().attributeItem(i).value(); |
| 350 element.attributes().attributeItem(i).value())); | 687 html_attributes.push_back(std::pair<string16, string16>(name, value)); |
| 351 } | 688 } |
| 352 | 689 |
| 353 if (element.isFormControlElement()) { | 690 if (element.isFormControlElement()) { |
| 354 WebKit::WebFormControlElement form_element = | 691 WebKit::WebFormControlElement form_element = |
| 355 element.to<WebKit::WebFormControlElement>(); | 692 element.to<WebKit::WebFormControlElement>(); |
| 356 if (form_element.formControlType() == ASCIIToUTF16("text") || | 693 if (form_element.formControlType() == ASCIIToUTF16("text") || |
| 357 form_element.formControlType() == ASCIIToUTF16("textarea")) { | 694 form_element.formControlType() == ASCIIToUTF16("textarea")) { |
| 358 // Jaws gets confused by children of text fields, so we ignore them. | 695 // Jaws gets confused by children of text fields, so we ignore them. |
| 359 include_children = false; | 696 include_children = false; |
| 360 | 697 |
| 361 int_attributes[ATTR_TEXT_SEL_START] = src.selectionStart(); | 698 int_attributes[ATTR_TEXT_SEL_START] = src.selectionStart(); |
| 362 int_attributes[ATTR_TEXT_SEL_END] = src.selectionEnd(); | 699 int_attributes[ATTR_TEXT_SEL_END] = src.selectionEnd(); |
| 363 WebKit::WebVector<int> src_line_breaks; | 700 WebKit::WebVector<int> src_line_breaks; |
| 364 src.lineBreaks(src_line_breaks); | 701 src.lineBreaks(src_line_breaks); |
| 365 line_breaks.reserve(src_line_breaks.size()); | 702 line_breaks.reserve(src_line_breaks.size()); |
| 366 for (size_t i = 0; i < src_line_breaks.size(); i++) | 703 for (size_t i = 0; i < src_line_breaks.size(); i++) |
| 367 line_breaks.push_back(src_line_breaks[i]); | 704 line_breaks.push_back(src_line_breaks[i]); |
| 368 } | 705 } |
| 369 } | 706 } |
| 707 | |
| 708 // ARIA role. | |
| 709 if (element.hasAttribute("role")) { | |
| 710 string_attributes[ATTR_ROLE] = element.getAttribute("role"); | |
| 711 } | |
| 712 | |
| 713 // Live region attributes | |
| 714 if (element.hasAttribute("aria-atomic")) { | |
| 715 bool_attributes[ATTR_LIVE_ATOMIC] = | |
| 716 LowerCaseEqualsASCII(element.getAttribute("aria-atomic"), "true"); | |
| 717 } | |
| 718 if (element.hasAttribute("aria-busy")) { | |
| 719 bool_attributes[ATTR_LIVE_BUSY] = | |
| 720 LowerCaseEqualsASCII(element.getAttribute("aria-busy"), "true"); | |
| 721 } | |
| 722 if (element.hasAttribute("aria-live")) { | |
| 723 string_attributes[ATTR_LIVE_STATUS] = element.getAttribute("aria-live"); | |
| 724 } | |
| 725 if (element.hasAttribute("aria-relevant")) { | |
| 726 string_attributes[ATTR_LIVE_RELEVANT] = | |
| 727 element.getAttribute("aria-relevant"); | |
| 728 } | |
| 729 } | |
| 730 | |
| 731 // Walk up the parent chain to set live region attributes of containers | |
| 732 | |
| 733 WebKit::WebAccessibilityObject container_accessible = src; | |
| 734 while (!container_accessible.isNull()) { | |
| 735 WebKit::WebNode container_node = container_accessible.node(); | |
| 736 if (!container_node.isNull() && container_node.isElementNode()) { | |
| 737 WebKit::WebElement container_elem = | |
| 738 container_node.to<WebKit::WebElement>(); | |
| 739 if (container_elem.hasAttribute("aria-atomic") && | |
| 740 bool_attributes.find(ATTR_CONTAINER_LIVE_ATOMIC) == | |
| 741 bool_attributes.end()) { | |
| 742 bool_attributes[ATTR_CONTAINER_LIVE_ATOMIC] = | |
| 743 LowerCaseEqualsASCII(container_elem.getAttribute("aria-atomic"), | |
| 744 "true"); | |
| 745 } | |
| 746 if (container_elem.hasAttribute("aria-busy") && | |
| 747 bool_attributes.find(ATTR_CONTAINER_LIVE_BUSY) == | |
| 748 bool_attributes.end()) { | |
| 749 bool_attributes[ATTR_CONTAINER_LIVE_BUSY] = | |
| 750 LowerCaseEqualsASCII(container_elem.getAttribute("aria-busy"), | |
| 751 "true"); | |
| 752 } | |
| 753 if (container_elem.hasAttribute("aria-live") && | |
| 754 string_attributes.find(ATTR_CONTAINER_LIVE_STATUS) == | |
| 755 string_attributes.end()) { | |
| 756 string_attributes[ATTR_CONTAINER_LIVE_STATUS] = | |
| 757 container_elem.getAttribute("aria-live"); | |
| 758 } | |
| 759 if (container_elem.hasAttribute("aria-relevant") && | |
| 760 string_attributes.find(ATTR_CONTAINER_LIVE_RELEVANT) == | |
| 761 string_attributes.end()) { | |
| 762 string_attributes[ATTR_CONTAINER_LIVE_RELEVANT] = | |
| 763 container_elem.getAttribute("aria-relevant"); | |
| 764 } | |
| 765 } | |
| 766 container_accessible = container_accessible.parentObject(); | |
| 767 } | |
| 768 | |
| 769 if (role == WebAccessibility::ROLE_PROGRESS_INDICATOR || | |
| 770 role == WebAccessibility::ROLE_SCROLLBAR || | |
| 771 role == WebAccessibility::ROLE_SLIDER) { | |
| 772 float_attributes[ATTR_VALUE_FOR_RANGE] = src.valueForRange(); | |
| 773 float_attributes[ATTR_MAX_VALUE_FOR_RANGE] = src.minValueForRange(); | |
| 774 float_attributes[ATTR_MIN_VALUE_FOR_RANGE] = src.maxValueForRange(); | |
| 370 } | 775 } |
| 371 | 776 |
| 372 if (role == WebAccessibility::ROLE_DOCUMENT || | 777 if (role == WebAccessibility::ROLE_DOCUMENT || |
| 373 role == WebAccessibility::ROLE_WEB_AREA) { | 778 role == WebAccessibility::ROLE_WEB_AREA) { |
| 374 const WebKit::WebDocument& document = src.document(); | 779 const WebKit::WebDocument& document = src.document(); |
| 375 if (name.empty()) | 780 if (name.empty()) |
| 376 name = document.title(); | 781 name = document.title(); |
| 377 string_attributes[ATTR_DOC_TITLE] = document.title(); | 782 string_attributes[ATTR_DOC_TITLE] = document.title(); |
| 378 string_attributes[ATTR_DOC_URL] = document.url().spec().utf16(); | 783 string_attributes[ATTR_DOC_URL] = document.url().spec().utf16(); |
| 379 if (document.isXHTMLDocument()) | 784 if (document.isXHTMLDocument()) |
| 380 string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml"); | 785 string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/xhtml"); |
| 381 else | 786 else |
| 382 string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html"); | 787 string_attributes[ATTR_DOC_MIMETYPE] = WebKit::WebString("text/html"); |
| 788 bool_attributes[ATTR_DOC_LOADED] = src.isLoaded(); | |
| 789 float_attributes[ATTR_DOC_LOADING_PROGRESS] = | |
| 790 src.estimatedLoadingProgress(); | |
| 383 | 791 |
| 384 const WebKit::WebDocumentType& doctype = document.doctype(); | 792 const WebKit::WebDocumentType& doctype = document.doctype(); |
| 385 if (!doctype.isNull()) | 793 if (!doctype.isNull()) |
| 386 string_attributes[ATTR_DOC_DOCTYPE] = doctype.name(); | 794 string_attributes[ATTR_DOC_DOCTYPE] = doctype.name(); |
| 387 | 795 |
| 388 const gfx::Size& scroll_offset = document.frame()->scrollOffset(); | 796 const gfx::Size& scroll_offset = document.frame()->scrollOffset(); |
| 389 int_attributes[ATTR_DOC_SCROLLX] = scroll_offset.width(); | 797 int_attributes[ATTR_DOC_SCROLLX] = scroll_offset.width(); |
| 390 int_attributes[ATTR_DOC_SCROLLY] = scroll_offset.height(); | 798 int_attributes[ATTR_DOC_SCROLLY] = scroll_offset.height(); |
| 391 } | 799 } |
| 392 | 800 |
| 393 if (role == WebAccessibility::ROLE_TABLE) { | 801 if (role == WebAccessibility::ROLE_TABLE) { |
| 394 int column_count = src.columnCount(); | 802 int column_count = src.columnCount(); |
| 395 int row_count = src.rowCount(); | 803 int row_count = src.rowCount(); |
| 396 if (column_count > 0 && row_count > 0) { | 804 if (column_count > 0 && row_count > 0) { |
| 805 std::set<int> unique_cell_id_set; | |
| 397 int_attributes[ATTR_TABLE_COLUMN_COUNT] = column_count; | 806 int_attributes[ATTR_TABLE_COLUMN_COUNT] = column_count; |
| 398 int_attributes[ATTR_TABLE_ROW_COUNT] = row_count; | 807 int_attributes[ATTR_TABLE_ROW_COUNT] = row_count; |
| 399 for (int i = 0; i < column_count * row_count; i++) { | 808 for (int i = 0; i < column_count * row_count; i++) { |
| 400 WebAccessibilityObject cell = src.cellForColumnAndRow( | 809 WebAccessibilityObject cell = src.cellForColumnAndRow( |
| 401 i % column_count, i / column_count); | 810 i % column_count, i / column_count); |
| 402 int cell_id = -1; | 811 int cell_id = -1; |
| 403 if (!cell.isNull()) | 812 if (!cell.isNull()) { |
| 404 cell_id = cache->addOrGetId(cell); | 813 cell_id = cache->addOrGetId(cell); |
| 814 if (unique_cell_id_set.find(cell_id) == unique_cell_id_set.end()) { | |
|
David Tseng
2011/08/29 19:05:34
NIT: IS THIS NECESSSARY?
| |
| 815 unique_cell_id_set.insert(cell_id); | |
| 816 unique_cell_ids.push_back(cell_id); | |
| 817 } | |
| 818 } | |
| 405 cell_ids.push_back(cell_id); | 819 cell_ids.push_back(cell_id); |
| 406 } | 820 } |
| 407 } | 821 } |
| 408 } | 822 } |
| 409 | 823 |
| 410 if (role == WebAccessibility::ROLE_CELL || | 824 if (role == WebAccessibility::ROLE_CELL || |
| 411 role == WebAccessibility::ROLE_ROW_HEADER || | 825 role == WebAccessibility::ROLE_ROW_HEADER || |
| 412 role == WebAccessibility::ROLE_COLUMN_HEADER) { | 826 role == WebAccessibility::ROLE_COLUMN_HEADER) { |
| 413 int_attributes[ATTR_TABLE_CELL_COLUMN_INDEX] = src.cellColumnIndex(); | 827 int_attributes[ATTR_TABLE_CELL_COLUMN_INDEX] = src.cellColumnIndex(); |
| 414 int_attributes[ATTR_TABLE_CELL_COLUMN_SPAN] = src.cellColumnSpan(); | 828 int_attributes[ATTR_TABLE_CELL_COLUMN_SPAN] = src.cellColumnSpan(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 bool WebAccessibility::IsParentUnignoredOf( | 875 bool WebAccessibility::IsParentUnignoredOf( |
| 462 const WebKit::WebAccessibilityObject& ancestor, | 876 const WebKit::WebAccessibilityObject& ancestor, |
| 463 const WebKit::WebAccessibilityObject& child) { | 877 const WebKit::WebAccessibilityObject& child) { |
| 464 WebKit::WebAccessibilityObject parent = child.parentObject(); | 878 WebKit::WebAccessibilityObject parent = child.parentObject(); |
| 465 while (!parent.isNull() && parent.accessibilityIsIgnored()) | 879 while (!parent.isNull() && parent.accessibilityIsIgnored()) |
| 466 parent = parent.parentObject(); | 880 parent = parent.parentObject(); |
| 467 return parent.equals(ancestor); | 881 return parent.equals(ancestor); |
| 468 } | 882 } |
| 469 | 883 |
| 470 } // namespace webkit_glue | 884 } // namespace webkit_glue |
| OLD | NEW |