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

Side by Side Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 2883203002: Revert of Rename AXObject to AXObjectImpl in modules/ and web/ (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 if (layout_object_) 320 if (layout_object_)
321 layout_object_->SetHasAXObject(false); 321 layout_object_->SetHasAXObject(false);
322 #endif 322 #endif
323 layout_object_ = 0; 323 layout_object_ = 0;
324 } 324 }
325 325
326 // 326 //
327 // Check object role or purpose. 327 // Check object role or purpose.
328 // 328 //
329 329
330 static bool IsLinkable(const AXObjectImpl& object) { 330 static bool IsLinkable(const AXObject& object) {
331 if (!object.GetLayoutObject()) 331 if (!object.GetLayoutObject())
332 return false; 332 return false;
333 333
334 // See https://wiki.mozilla.org/Accessibility/AT-Windows-API for the elements 334 // See https://wiki.mozilla.org/Accessibility/AT-Windows-API for the elements
335 // Mozilla considers linkable. 335 // Mozilla considers linkable.
336 return object.IsLink() || object.IsImage() || 336 return object.IsLink() || object.IsImage() ||
337 object.GetLayoutObject()->IsText(); 337 object.GetLayoutObject()->IsText();
338 } 338 }
339 339
340 // Requires layoutObject to be present because it relies on style 340 // Requires layoutObject to be present because it relies on style
341 // user-modify. Don't move this logic to AXNodeObject. 341 // user-modify. Don't move this logic to AXNodeObject.
342 bool AXLayoutObject::IsEditable() const { 342 bool AXLayoutObject::IsEditable() const {
343 if (GetLayoutObject() && GetLayoutObject()->IsTextControl()) 343 if (GetLayoutObject() && GetLayoutObject()->IsTextControl())
344 return true; 344 return true;
345 345
346 if (GetNode() && HasEditableStyle(*GetNode())) 346 if (GetNode() && HasEditableStyle(*GetNode()))
347 return true; 347 return true;
348 348
349 if (IsWebArea()) { 349 if (IsWebArea()) {
350 Document& document = GetLayoutObject()->GetDocument(); 350 Document& document = GetLayoutObject()->GetDocument();
351 HTMLElement* body = document.body(); 351 HTMLElement* body = document.body();
352 if (body && HasEditableStyle(*body)) { 352 if (body && HasEditableStyle(*body)) {
353 AXObjectImpl* ax_body = AxObjectCache().GetOrCreate(body); 353 AXObject* ax_body = AxObjectCache().GetOrCreate(body);
354 return ax_body && ax_body != ax_body->AriaHiddenRoot(); 354 return ax_body && ax_body != ax_body->AriaHiddenRoot();
355 } 355 }
356 356
357 return HasEditableStyle(document); 357 return HasEditableStyle(document);
358 } 358 }
359 359
360 return AXNodeObject::IsEditable(); 360 return AXNodeObject::IsEditable();
361 } 361 }
362 362
363 // Requires layoutObject to be present because it relies on style 363 // Requires layoutObject to be present because it relies on style
364 // user-modify. Don't move this logic to AXNodeObject. 364 // user-modify. Don't move this logic to AXNodeObject.
365 bool AXLayoutObject::IsRichlyEditable() const { 365 bool AXLayoutObject::IsRichlyEditable() const {
366 if (GetNode() && HasRichlyEditableStyle(*GetNode())) 366 if (GetNode() && HasRichlyEditableStyle(*GetNode()))
367 return true; 367 return true;
368 368
369 if (IsWebArea()) { 369 if (IsWebArea()) {
370 Document& document = layout_object_->GetDocument(); 370 Document& document = layout_object_->GetDocument();
371 HTMLElement* body = document.body(); 371 HTMLElement* body = document.body();
372 if (body && HasRichlyEditableStyle(*body)) { 372 if (body && HasRichlyEditableStyle(*body)) {
373 AXObjectImpl* ax_body = AxObjectCache().GetOrCreate(body); 373 AXObject* ax_body = AxObjectCache().GetOrCreate(body);
374 return ax_body && ax_body != ax_body->AriaHiddenRoot(); 374 return ax_body && ax_body != ax_body->AriaHiddenRoot();
375 } 375 }
376 376
377 return HasRichlyEditableStyle(document); 377 return HasRichlyEditableStyle(document);
378 } 378 }
379 379
380 return AXNodeObject::IsRichlyEditable(); 380 return AXNodeObject::IsRichlyEditable();
381 } 381 }
382 382
383 bool AXLayoutObject::IsLinked() const { 383 bool AXLayoutObject::IsLinked() const {
(...skipping 21 matching lines...) Expand all
405 return view_rect.IsEmpty(); 405 return view_rect.IsEmpty();
406 } 406 }
407 407
408 bool AXLayoutObject::IsReadOnly() const { 408 bool AXLayoutObject::IsReadOnly() const {
409 DCHECK(layout_object_); 409 DCHECK(layout_object_);
410 410
411 if (IsWebArea()) { 411 if (IsWebArea()) {
412 Document& document = layout_object_->GetDocument(); 412 Document& document = layout_object_->GetDocument();
413 HTMLElement* body = document.body(); 413 HTMLElement* body = document.body();
414 if (body && HasEditableStyle(*body)) { 414 if (body && HasEditableStyle(*body)) {
415 AXObjectImpl* ax_body = AxObjectCache().GetOrCreate(body); 415 AXObject* ax_body = AxObjectCache().GetOrCreate(body);
416 return !ax_body || ax_body == ax_body->AriaHiddenRoot(); 416 return !ax_body || ax_body == ax_body->AriaHiddenRoot();
417 } 417 }
418 418
419 return !HasEditableStyle(document); 419 return !HasEditableStyle(document);
420 } 420 }
421 421
422 return AXNodeObject::IsReadOnly(); 422 return AXNodeObject::IsReadOnly();
423 } 423 }
424 424
425 bool AXLayoutObject::IsVisited() const { 425 bool AXLayoutObject::IsVisited() const {
426 // FIXME: Is it a privacy violation to expose visited information to 426 // FIXME: Is it a privacy violation to expose visited information to
427 // accessibility APIs? 427 // accessibility APIs?
428 return layout_object_->Style()->IsLink() && 428 return layout_object_->Style()->IsLink() &&
429 layout_object_->Style()->InsideLink() == 429 layout_object_->Style()->InsideLink() ==
430 EInsideLink::kInsideVisitedLink; 430 EInsideLink::kInsideVisitedLink;
431 } 431 }
432 432
433 // 433 //
434 // Check object state. 434 // Check object state.
435 // 435 //
436 436
437 bool AXLayoutObject::IsFocused() const { 437 bool AXLayoutObject::IsFocused() const {
438 if (!GetDocument()) 438 if (!GetDocument())
439 return false; 439 return false;
440 440
441 Element* focused_element = GetDocument()->FocusedElement(); 441 Element* focused_element = GetDocument()->FocusedElement();
442 if (!focused_element) 442 if (!focused_element)
443 return false; 443 return false;
444 AXObjectImpl* focused_object = AxObjectCache().GetOrCreate(focused_element); 444 AXObject* focused_object = AxObjectCache().GetOrCreate(focused_element);
445 if (!focused_object || !focused_object->IsAXLayoutObject()) 445 if (!focused_object || !focused_object->IsAXLayoutObject())
446 return false; 446 return false;
447 447
448 // A web area is represented by the Document node in the DOM tree, which isn't 448 // A web area is represented by the Document node in the DOM tree, which isn't
449 // focusable. Check instead if the frame's selection controller is focused 449 // focusable. Check instead if the frame's selection controller is focused
450 if (focused_object == this || 450 if (focused_object == this ||
451 (RoleValue() == kWebAreaRole && 451 (RoleValue() == kWebAreaRole &&
452 GetDocument()->GetFrame()->Selection().IsFocusedAndActive())) 452 GetDocument()->GetFrame()->Selection().IsFocusedAndActive()))
453 return true; 453 return true;
454 454
455 return false; 455 return false;
456 } 456 }
457 457
458 bool AXLayoutObject::IsSelected() const { 458 bool AXLayoutObject::IsSelected() const {
459 if (!GetLayoutObject() || !GetNode()) 459 if (!GetLayoutObject() || !GetNode())
460 return false; 460 return false;
461 461
462 const AtomicString& aria_selected = GetAttribute(aria_selectedAttr); 462 const AtomicString& aria_selected = GetAttribute(aria_selectedAttr);
463 if (EqualIgnoringASCIICase(aria_selected, "true")) 463 if (EqualIgnoringASCIICase(aria_selected, "true"))
464 return true; 464 return true;
465 465
466 AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); 466 AXObject* focused_object = AxObjectCache().FocusedObject();
467 if (AriaRoleAttribute() == kListBoxOptionRole && focused_object && 467 if (AriaRoleAttribute() == kListBoxOptionRole && focused_object &&
468 focused_object->ActiveDescendant() == this) { 468 focused_object->ActiveDescendant() == this) {
469 return true; 469 return true;
470 } 470 }
471 471
472 if (IsTabItem() && IsTabItemSelected()) 472 if (IsTabItem() && IsTabItemSelected())
473 return true; 473 return true;
474 474
475 return false; 475 return false;
476 } 476 }
(...skipping 17 matching lines...) Expand all
494 // aria-hidden is meant to override visibility as the determinant in AX 494 // aria-hidden is meant to override visibility as the determinant in AX
495 // hierarchy inclusion. 495 // hierarchy inclusion.
496 if (EqualIgnoringASCIICase(GetAttribute(aria_hiddenAttr), "false")) 496 if (EqualIgnoringASCIICase(GetAttribute(aria_hiddenAttr), "false"))
497 return kDefaultBehavior; 497 return kDefaultBehavior;
498 498
499 if (ignored_reasons) 499 if (ignored_reasons)
500 ignored_reasons->push_back(IgnoredReason(kAXNotVisible)); 500 ignored_reasons->push_back(IgnoredReason(kAXNotVisible));
501 return kIgnoreObject; 501 return kIgnoreObject;
502 } 502 }
503 503
504 return AXObjectImpl::DefaultObjectInclusion(ignored_reasons); 504 return AXObject::DefaultObjectInclusion(ignored_reasons);
505 } 505 }
506 506
507 bool AXLayoutObject::ComputeAccessibilityIsIgnored( 507 bool AXLayoutObject::ComputeAccessibilityIsIgnored(
508 IgnoredReasons* ignored_reasons) const { 508 IgnoredReasons* ignored_reasons) const {
509 #if DCHECK_IS_ON() 509 #if DCHECK_IS_ON()
510 DCHECK(initialized_); 510 DCHECK(initialized_);
511 #endif 511 #endif
512 512
513 if (!layout_object_) 513 if (!layout_object_)
514 return true; 514 return true;
(...skipping 20 matching lines...) Expand all
535 } 535 }
536 536
537 if (RoleValue() == kIgnoredRole) { 537 if (RoleValue() == kIgnoredRole) {
538 if (ignored_reasons) 538 if (ignored_reasons)
539 ignored_reasons->push_back(IgnoredReason(kAXUninteresting)); 539 ignored_reasons->push_back(IgnoredReason(kAXUninteresting));
540 return true; 540 return true;
541 } 541 }
542 542
543 if (HasInheritedPresentationalRole()) { 543 if (HasInheritedPresentationalRole()) {
544 if (ignored_reasons) { 544 if (ignored_reasons) {
545 const AXObjectImpl* inherits_from = InheritsPresentationalRoleFrom(); 545 const AXObject* inherits_from = InheritsPresentationalRoleFrom();
546 if (inherits_from == this) 546 if (inherits_from == this)
547 ignored_reasons->push_back(IgnoredReason(kAXPresentationalRole)); 547 ignored_reasons->push_back(IgnoredReason(kAXPresentationalRole));
548 else 548 else
549 ignored_reasons->push_back( 549 ignored_reasons->push_back(
550 IgnoredReason(kAXInheritsPresentation, inherits_from)); 550 IgnoredReason(kAXInheritsPresentation, inherits_from));
551 } 551 }
552 return true; 552 return true;
553 } 553 }
554 554
555 // An ARIA tree can only have tree items and static text as children. 555 // An ARIA tree can only have tree items and static text as children.
556 if (AXObjectImpl* tree_ancestor = TreeAncestorDisallowingChild()) { 556 if (AXObject* tree_ancestor = TreeAncestorDisallowingChild()) {
557 if (ignored_reasons) 557 if (ignored_reasons)
558 ignored_reasons->push_back( 558 ignored_reasons->push_back(
559 IgnoredReason(kAXAncestorDisallowsChild, tree_ancestor)); 559 IgnoredReason(kAXAncestorDisallowsChild, tree_ancestor));
560 return true; 560 return true;
561 } 561 }
562 562
563 // A LayoutPart is an iframe element or embedded object element or something 563 // A LayoutPart is an iframe element or embedded object element or something
564 // like that. We don't want to ignore those. 564 // like that. We don't want to ignore those.
565 if (layout_object_->IsLayoutPart()) 565 if (layout_object_->IsLayoutPart())
566 return false; 566 return false;
567 567
568 // Make sure renderers with layers stay in the tree. 568 // Make sure renderers with layers stay in the tree.
569 if (GetLayoutObject() && GetLayoutObject()->HasLayer() && GetNode() && 569 if (GetLayoutObject() && GetLayoutObject()->HasLayer() && GetNode() &&
570 GetNode()->hasChildren()) 570 GetNode()->hasChildren())
571 return false; 571 return false;
572 572
573 // Find out if this element is inside of a label element. If so, it may be 573 // Find out if this element is inside of a label element. If so, it may be
574 // ignored because it's the label for a checkbox or radio button. 574 // ignored because it's the label for a checkbox or radio button.
575 AXObjectImpl* control_object = CorrespondingControlForLabelElement(); 575 AXObject* control_object = CorrespondingControlForLabelElement();
576 if (control_object && control_object->IsCheckboxOrRadio() && 576 if (control_object && control_object->IsCheckboxOrRadio() &&
577 control_object->NameFromLabelElement()) { 577 control_object->NameFromLabelElement()) {
578 if (ignored_reasons) { 578 if (ignored_reasons) {
579 HTMLLabelElement* label = LabelElementContainer(); 579 HTMLLabelElement* label = LabelElementContainer();
580 if (label && label != GetNode()) { 580 if (label && label != GetNode()) {
581 AXObjectImpl* label_ax_object = AxObjectCache().GetOrCreate(label); 581 AXObject* label_ax_object = AxObjectCache().GetOrCreate(label);
582 ignored_reasons->push_back( 582 ignored_reasons->push_back(
583 IgnoredReason(kAXLabelContainer, label_ax_object)); 583 IgnoredReason(kAXLabelContainer, label_ax_object));
584 } 584 }
585 585
586 ignored_reasons->push_back(IgnoredReason(kAXLabelFor, control_object)); 586 ignored_reasons->push_back(IgnoredReason(kAXLabelFor, control_object));
587 } 587 }
588 return true; 588 return true;
589 } 589 }
590 590
591 if (layout_object_->IsBR()) 591 if (layout_object_->IsBR())
592 return false; 592 return false;
593 593
594 if (IsLink()) 594 if (IsLink())
595 return false; 595 return false;
596 596
597 if (IsInPageLinkTarget()) 597 if (IsInPageLinkTarget())
598 return false; 598 return false;
599 599
600 if (layout_object_->IsText()) { 600 if (layout_object_->IsText()) {
601 // Static text beneath MenuItems and MenuButtons are just reported along 601 // Static text beneath MenuItems and MenuButtons are just reported along
602 // with the menu item, so it's ignored on an individual level. 602 // with the menu item, so it's ignored on an individual level.
603 AXObjectImpl* parent = ParentObjectUnignored(); 603 AXObject* parent = ParentObjectUnignored();
604 if (parent && (parent->AriaRoleAttribute() == kMenuItemRole || 604 if (parent && (parent->AriaRoleAttribute() == kMenuItemRole ||
605 parent->AriaRoleAttribute() == kMenuButtonRole)) { 605 parent->AriaRoleAttribute() == kMenuButtonRole)) {
606 if (ignored_reasons) 606 if (ignored_reasons)
607 ignored_reasons->push_back( 607 ignored_reasons->push_back(
608 IgnoredReason(kAXStaticTextUsedAsNameFor, parent)); 608 IgnoredReason(kAXStaticTextUsedAsNameFor, parent));
609 return true; 609 return true;
610 } 610 }
611 LayoutText* layout_text = ToLayoutText(layout_object_); 611 LayoutText* layout_text = ToLayoutText(layout_object_);
612 if (!layout_text->HasTextBoxes()) { 612 if (!layout_text->HasTextBoxes()) {
613 if (ignored_reasons) 613 if (ignored_reasons)
614 ignored_reasons->push_back(IgnoredReason(kAXEmptyText)); 614 ignored_reasons->push_back(IgnoredReason(kAXEmptyText));
615 return true; 615 return true;
616 } 616 }
617 617
618 // Don't ignore static text in editable text controls. 618 // Don't ignore static text in editable text controls.
619 for (AXObjectImpl* parent = ParentObject(); parent; 619 for (AXObject* parent = ParentObject(); parent;
620 parent = parent->ParentObject()) { 620 parent = parent->ParentObject()) {
621 if (parent->RoleValue() == kTextFieldRole) 621 if (parent->RoleValue() == kTextFieldRole)
622 return false; 622 return false;
623 } 623 }
624 624
625 // Text elements that are just empty whitespace should not be returned. 625 // Text elements that are just empty whitespace should not be returned.
626 // FIXME(dmazzoni): we probably shouldn't ignore this if the style is 'pre', 626 // FIXME(dmazzoni): we probably shouldn't ignore this if the style is 'pre',
627 // or similar... 627 // or similar...
628 if (layout_text->GetText().Impl()->ContainsOnlyWhitespace()) { 628 if (layout_text->GetText().Impl()->ContainsOnlyWhitespace()) {
629 if (ignored_reasons) 629 if (ignored_reasons)
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 802 }
803 803
804 RGBA32 AXLayoutObject::ComputeBackgroundColor() const { 804 RGBA32 AXLayoutObject::ComputeBackgroundColor() const {
805 if (!GetLayoutObject()) 805 if (!GetLayoutObject())
806 return AXNodeObject::BackgroundColor(); 806 return AXNodeObject::BackgroundColor();
807 807
808 Color blended_color = Color::kTransparent; 808 Color blended_color = Color::kTransparent;
809 // Color::blend should be called like this: background.blend(foreground). 809 // Color::blend should be called like this: background.blend(foreground).
810 for (LayoutObject* layout_object = GetLayoutObject(); layout_object; 810 for (LayoutObject* layout_object = GetLayoutObject(); layout_object;
811 layout_object = layout_object->Parent()) { 811 layout_object = layout_object->Parent()) {
812 const AXObjectImpl* ax_parent = AxObjectCache().GetOrCreate(layout_object); 812 const AXObject* ax_parent = AxObjectCache().GetOrCreate(layout_object);
813 if (ax_parent && ax_parent != this) { 813 if (ax_parent && ax_parent != this) {
814 Color parent_color = ax_parent->BackgroundColor(); 814 Color parent_color = ax_parent->BackgroundColor();
815 blended_color = parent_color.Blend(blended_color); 815 blended_color = parent_color.Blend(blended_color);
816 return blended_color.Rgb(); 816 return blended_color.Rgb();
817 } 817 }
818 818
819 const ComputedStyle* style = layout_object->Style(); 819 const ComputedStyle* style = layout_object->Style();
820 if (!style || !style->HasBackground()) 820 if (!style || !style->HasBackground())
821 continue; 821 continue;
822 822
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 ClearChildren(); 1073 ClearChildren();
1074 AddInlineTextBoxChildren(true); 1074 AddInlineTextBoxChildren(true);
1075 return; 1075 return;
1076 } 1076 }
1077 1077
1078 for (const auto& child : children_) { 1078 for (const auto& child : children_) {
1079 child->LoadInlineTextBoxes(); 1079 child->LoadInlineTextBoxes();
1080 } 1080 }
1081 } 1081 }
1082 1082
1083 AXObjectImpl* AXLayoutObject::NextOnLine() const { 1083 AXObject* AXLayoutObject::NextOnLine() const {
1084 if (!GetLayoutObject()) 1084 if (!GetLayoutObject())
1085 return nullptr; 1085 return nullptr;
1086 1086
1087 AXObjectImpl* result = nullptr; 1087 AXObject* result = nullptr;
1088 if (GetLayoutObject()->IsListMarker()) { 1088 if (GetLayoutObject()->IsListMarker()) {
1089 AXObjectImpl* next_sibling = RawNextSibling(); 1089 AXObject* next_sibling = RawNextSibling();
1090 if (!next_sibling || !next_sibling->Children().size()) 1090 if (!next_sibling || !next_sibling->Children().size())
1091 return nullptr; 1091 return nullptr;
1092 result = next_sibling->Children()[0].Get(); 1092 result = next_sibling->Children()[0].Get();
1093 } else { 1093 } else {
1094 InlineBox* inline_box = nullptr; 1094 InlineBox* inline_box = nullptr;
1095 if (GetLayoutObject()->IsLayoutInline()) 1095 if (GetLayoutObject()->IsLayoutInline())
1096 inline_box = ToLayoutInline(GetLayoutObject())->LastLineBox(); 1096 inline_box = ToLayoutInline(GetLayoutObject())->LastLineBox();
1097 else if (GetLayoutObject()->IsText()) 1097 else if (GetLayoutObject()->IsText())
1098 inline_box = ToLayoutText(GetLayoutObject())->LastTextBox(); 1098 inline_box = ToLayoutText(GetLayoutObject())->LastTextBox();
1099 1099
(...skipping 12 matching lines...) Expand all
1112 1112
1113 // A static text node might span multiple lines. Try to return the first 1113 // A static text node might span multiple lines. Try to return the first
1114 // inline text box within that static text if possible. 1114 // inline text box within that static text if possible.
1115 if (result && result->RoleValue() == kStaticTextRole && 1115 if (result && result->RoleValue() == kStaticTextRole &&
1116 result->Children().size()) 1116 result->Children().size())
1117 result = result->Children()[0].Get(); 1117 result = result->Children()[0].Get();
1118 1118
1119 return result; 1119 return result;
1120 } 1120 }
1121 1121
1122 AXObjectImpl* AXLayoutObject::PreviousOnLine() const { 1122 AXObject* AXLayoutObject::PreviousOnLine() const {
1123 if (!GetLayoutObject()) 1123 if (!GetLayoutObject())
1124 return nullptr; 1124 return nullptr;
1125 1125
1126 InlineBox* inline_box = nullptr; 1126 InlineBox* inline_box = nullptr;
1127 if (GetLayoutObject()->IsLayoutInline()) 1127 if (GetLayoutObject()->IsLayoutInline())
1128 inline_box = ToLayoutInline(GetLayoutObject())->FirstLineBox(); 1128 inline_box = ToLayoutInline(GetLayoutObject())->FirstLineBox();
1129 else if (GetLayoutObject()->IsText()) 1129 else if (GetLayoutObject()->IsText())
1130 inline_box = ToLayoutText(GetLayoutObject())->FirstTextBox(); 1130 inline_box = ToLayoutText(GetLayoutObject())->FirstTextBox();
1131 1131
1132 if (!inline_box) 1132 if (!inline_box)
1133 return nullptr; 1133 return nullptr;
1134 1134
1135 AXObjectImpl* result = nullptr; 1135 AXObject* result = nullptr;
1136 for (InlineBox* prev = inline_box->PrevOnLine(); prev; 1136 for (InlineBox* prev = inline_box->PrevOnLine(); prev;
1137 prev = prev->PrevOnLine()) { 1137 prev = prev->PrevOnLine()) {
1138 LayoutObject* layout_object = 1138 LayoutObject* layout_object =
1139 LineLayoutAPIShim::LayoutObjectFrom(prev->GetLineLayoutItem()); 1139 LineLayoutAPIShim::LayoutObjectFrom(prev->GetLineLayoutItem());
1140 result = AxObjectCache().GetOrCreate(layout_object); 1140 result = AxObjectCache().GetOrCreate(layout_object);
1141 if (result) 1141 if (result)
1142 break; 1142 break;
1143 } 1143 }
1144 1144
1145 // A static text node might span multiple lines. Try to return the last inline 1145 // A static text node might span multiple lines. Try to return the last inline
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
1284 case kImageRole: 1284 case kImageRole:
1285 case kProgressIndicatorRole: 1285 case kProgressIndicatorRole:
1286 case kSpinButtonRole: 1286 case kSpinButtonRole:
1287 // case SeparatorRole: 1287 // case SeparatorRole:
1288 return true; 1288 return true;
1289 default: 1289 default:
1290 return false; 1290 return false;
1291 } 1291 }
1292 } 1292 }
1293 1293
1294 AXObjectImpl* AXLayoutObject::AncestorForWhichThisIsAPresentationalChild() 1294 AXObject* AXLayoutObject::AncestorForWhichThisIsAPresentationalChild() const {
1295 const {
1296 // Walk the parent chain looking for a parent that has presentational children 1295 // Walk the parent chain looking for a parent that has presentational children
1297 AXObjectImpl* parent = ParentObjectIfExists(); 1296 AXObject* parent = ParentObjectIfExists();
1298 while (parent) { 1297 while (parent) {
1299 if (parent->AriaRoleHasPresentationalChildren()) 1298 if (parent->AriaRoleHasPresentationalChildren())
1300 break; 1299 break;
1301 1300
1302 // The descendants of a AXMenuList that are AXLayoutObjects are all 1301 // The descendants of a AXMenuList that are AXLayoutObjects are all
1303 // presentational. (The real descendants are an AXMenuListPopup and 1302 // presentational. (The real descendants are an AXMenuListPopup and
1304 // AXMenuListOptions, which are not AXLayoutObjects.) 1303 // AXMenuListOptions, which are not AXLayoutObjects.)
1305 if (parent->IsMenuList()) 1304 if (parent->IsMenuList())
1306 break; 1305 break;
1307 1306
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1390 }
1392 1391
1393 bool AXLayoutObject::LiveRegionBusy() const { 1392 bool AXLayoutObject::LiveRegionBusy() const {
1394 return ElementAttributeValue(aria_busyAttr); 1393 return ElementAttributeValue(aria_busyAttr);
1395 } 1394 }
1396 1395
1397 // 1396 //
1398 // Hit testing. 1397 // Hit testing.
1399 // 1398 //
1400 1399
1401 AXObjectImpl* AXLayoutObject::AccessibilityHitTest( 1400 AXObject* AXLayoutObject::AccessibilityHitTest(const IntPoint& point) const {
1402 const IntPoint& point) const {
1403 if (!layout_object_ || !layout_object_->HasLayer()) 1401 if (!layout_object_ || !layout_object_->HasLayer())
1404 return nullptr; 1402 return nullptr;
1405 1403
1406 PaintLayer* layer = ToLayoutBox(layout_object_)->Layer(); 1404 PaintLayer* layer = ToLayoutBox(layout_object_)->Layer();
1407 1405
1408 HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); 1406 HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive);
1409 HitTestResult hit_test_result = HitTestResult(request, point); 1407 HitTestResult hit_test_result = HitTestResult(request, point);
1410 layer->HitTest(hit_test_result); 1408 layer->HitTest(hit_test_result);
1411 1409
1412 Node* node = hit_test_result.InnerNode(); 1410 Node* node = hit_test_result.InnerNode();
1413 if (!node) 1411 if (!node)
1414 return nullptr; 1412 return nullptr;
1415 1413
1416 if (isHTMLAreaElement(node)) 1414 if (isHTMLAreaElement(node))
1417 return AccessibilityImageMapHitTest(toHTMLAreaElement(node), point); 1415 return AccessibilityImageMapHitTest(toHTMLAreaElement(node), point);
1418 1416
1419 if (isHTMLOptionElement(node)) { 1417 if (isHTMLOptionElement(node)) {
1420 node = toHTMLOptionElement(*node).OwnerSelectElement(); 1418 node = toHTMLOptionElement(*node).OwnerSelectElement();
1421 if (!node) 1419 if (!node)
1422 return nullptr; 1420 return nullptr;
1423 } 1421 }
1424 1422
1425 LayoutObject* obj = node->GetLayoutObject(); 1423 LayoutObject* obj = node->GetLayoutObject();
1426 if (!obj) 1424 if (!obj)
1427 return nullptr; 1425 return nullptr;
1428 1426
1429 AXObjectImpl* result = AxObjectCache().GetOrCreate(obj); 1427 AXObject* result = AxObjectCache().GetOrCreate(obj);
1430 result->UpdateChildrenIfNecessary(); 1428 result->UpdateChildrenIfNecessary();
1431 1429
1432 // Allow the element to perform any hit-testing it might need to do to reach 1430 // Allow the element to perform any hit-testing it might need to do to reach
1433 // non-layout children. 1431 // non-layout children.
1434 result = result->ElementAccessibilityHitTest(point); 1432 result = result->ElementAccessibilityHitTest(point);
1435 if (result && result->AccessibilityIsIgnored()) { 1433 if (result && result->AccessibilityIsIgnored()) {
1436 // If this element is the label of a control, a hit test should return the 1434 // If this element is the label of a control, a hit test should return the
1437 // control. 1435 // control.
1438 if (result->IsAXLayoutObject()) { 1436 if (result->IsAXLayoutObject()) {
1439 AXObjectImpl* control_object = 1437 AXObject* control_object =
1440 ToAXLayoutObject(result)->CorrespondingControlForLabelElement(); 1438 ToAXLayoutObject(result)->CorrespondingControlForLabelElement();
1441 if (control_object && control_object->NameFromLabelElement()) 1439 if (control_object && control_object->NameFromLabelElement())
1442 return control_object; 1440 return control_object;
1443 } 1441 }
1444 1442
1445 result = result->ParentObjectUnignored(); 1443 result = result->ParentObjectUnignored();
1446 } 1444 }
1447 1445
1448 return result; 1446 return result;
1449 } 1447 }
1450 1448
1451 AXObjectImpl* AXLayoutObject::ElementAccessibilityHitTest( 1449 AXObject* AXLayoutObject::ElementAccessibilityHitTest(
1452 const IntPoint& point) const { 1450 const IntPoint& point) const {
1453 if (IsSVGImage()) 1451 if (IsSVGImage())
1454 return RemoteSVGElementHitTest(point); 1452 return RemoteSVGElementHitTest(point);
1455 1453
1456 return AXObjectImpl::ElementAccessibilityHitTest(point); 1454 return AXObject::ElementAccessibilityHitTest(point);
1457 } 1455 }
1458 1456
1459 // 1457 //
1460 // High-level accessibility tree access. 1458 // High-level accessibility tree access.
1461 // 1459 //
1462 1460
1463 AXObjectImpl* AXLayoutObject::ComputeParent() const { 1461 AXObject* AXLayoutObject::ComputeParent() const {
1464 DCHECK(!IsDetached()); 1462 DCHECK(!IsDetached());
1465 if (!layout_object_) 1463 if (!layout_object_)
1466 return 0; 1464 return 0;
1467 1465
1468 if (AriaRoleAttribute() == kMenuBarRole) 1466 if (AriaRoleAttribute() == kMenuBarRole)
1469 return AxObjectCache().GetOrCreate(layout_object_->Parent()); 1467 return AxObjectCache().GetOrCreate(layout_object_->Parent());
1470 1468
1471 // menuButton and its corresponding menu are DOM siblings, but Accessibility 1469 // menuButton and its corresponding menu are DOM siblings, but Accessibility
1472 // needs them to be parent/child. 1470 // needs them to be parent/child.
1473 if (AriaRoleAttribute() == kMenuRole) { 1471 if (AriaRoleAttribute() == kMenuRole) {
1474 AXObjectImpl* parent = MenuButtonForMenu(); 1472 AXObject* parent = MenuButtonForMenu();
1475 if (parent) 1473 if (parent)
1476 return parent; 1474 return parent;
1477 } 1475 }
1478 1476
1479 LayoutObject* parent_obj = LayoutParentObject(); 1477 LayoutObject* parent_obj = LayoutParentObject();
1480 if (parent_obj) 1478 if (parent_obj)
1481 return AxObjectCache().GetOrCreate(parent_obj); 1479 return AxObjectCache().GetOrCreate(parent_obj);
1482 1480
1483 // A WebArea's parent should be the page popup owner, if any, otherwise null. 1481 // A WebArea's parent should be the page popup owner, if any, otherwise null.
1484 if (IsWebArea()) { 1482 if (IsWebArea()) {
1485 LocalFrame* frame = layout_object_->GetFrame(); 1483 LocalFrame* frame = layout_object_->GetFrame();
1486 return AxObjectCache().GetOrCreate(frame->PagePopupOwner()); 1484 return AxObjectCache().GetOrCreate(frame->PagePopupOwner());
1487 } 1485 }
1488 1486
1489 return 0; 1487 return 0;
1490 } 1488 }
1491 1489
1492 AXObjectImpl* AXLayoutObject::ComputeParentIfExists() const { 1490 AXObject* AXLayoutObject::ComputeParentIfExists() const {
1493 if (!layout_object_) 1491 if (!layout_object_)
1494 return 0; 1492 return 0;
1495 1493
1496 if (AriaRoleAttribute() == kMenuBarRole) 1494 if (AriaRoleAttribute() == kMenuBarRole)
1497 return AxObjectCache().Get(layout_object_->Parent()); 1495 return AxObjectCache().Get(layout_object_->Parent());
1498 1496
1499 // menuButton and its corresponding menu are DOM siblings, but Accessibility 1497 // menuButton and its corresponding menu are DOM siblings, but Accessibility
1500 // needs them to be parent/child. 1498 // needs them to be parent/child.
1501 if (AriaRoleAttribute() == kMenuRole) { 1499 if (AriaRoleAttribute() == kMenuRole) {
1502 AXObjectImpl* parent = MenuButtonForMenu(); 1500 AXObject* parent = MenuButtonForMenu();
1503 if (parent) 1501 if (parent)
1504 return parent; 1502 return parent;
1505 } 1503 }
1506 1504
1507 LayoutObject* parent_obj = LayoutParentObject(); 1505 LayoutObject* parent_obj = LayoutParentObject();
1508 if (parent_obj) 1506 if (parent_obj)
1509 return AxObjectCache().Get(parent_obj); 1507 return AxObjectCache().Get(parent_obj);
1510 1508
1511 // A WebArea's parent should be the page popup owner, if any, otherwise null. 1509 // A WebArea's parent should be the page popup owner, if any, otherwise null.
1512 if (IsWebArea()) { 1510 if (IsWebArea()) {
1513 LocalFrame* frame = layout_object_->GetFrame(); 1511 LocalFrame* frame = layout_object_->GetFrame();
1514 return AxObjectCache().Get(frame->PagePopupOwner()); 1512 return AxObjectCache().Get(frame->PagePopupOwner());
1515 } 1513 }
1516 1514
1517 return 0; 1515 return 0;
1518 } 1516 }
1519 1517
1520 // 1518 //
1521 // Low-level accessibility tree exploration, only for use within the 1519 // Low-level accessibility tree exploration, only for use within the
1522 // accessibility module. 1520 // accessibility module.
1523 // 1521 //
1524 1522
1525 AXObjectImpl* AXLayoutObject::RawFirstChild() const { 1523 AXObject* AXLayoutObject::RawFirstChild() const {
1526 if (!layout_object_) 1524 if (!layout_object_)
1527 return 0; 1525 return 0;
1528 1526
1529 LayoutObject* first_child = FirstChildConsideringContinuation(layout_object_); 1527 LayoutObject* first_child = FirstChildConsideringContinuation(layout_object_);
1530 1528
1531 if (!first_child) 1529 if (!first_child)
1532 return 0; 1530 return 0;
1533 1531
1534 return AxObjectCache().GetOrCreate(first_child); 1532 return AxObjectCache().GetOrCreate(first_child);
1535 } 1533 }
1536 1534
1537 AXObjectImpl* AXLayoutObject::RawNextSibling() const { 1535 AXObject* AXLayoutObject::RawNextSibling() const {
1538 if (!layout_object_) 1536 if (!layout_object_)
1539 return 0; 1537 return 0;
1540 1538
1541 LayoutObject* next_sibling = 0; 1539 LayoutObject* next_sibling = 0;
1542 1540
1543 LayoutInline* inline_continuation = 1541 LayoutInline* inline_continuation =
1544 layout_object_->IsLayoutBlockFlow() 1542 layout_object_->IsLayoutBlockFlow()
1545 ? ToLayoutBlockFlow(layout_object_)->InlineElementContinuation() 1543 ? ToLayoutBlockFlow(layout_object_)->InlineElementContinuation()
1546 : nullptr; 1544 : nullptr;
1547 if (inline_continuation) { 1545 if (inline_continuation) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 // If the need to add more children in addition to existing children arises, 1593 // If the need to add more children in addition to existing children arises,
1596 // childrenChanged should have been called, leaving the object with no 1594 // childrenChanged should have been called, leaving the object with no
1597 // children. 1595 // children.
1598 DCHECK(!have_children_); 1596 DCHECK(!have_children_);
1599 1597
1600 have_children_ = true; 1598 have_children_ = true;
1601 1599
1602 if (!CanHaveChildren()) 1600 if (!CanHaveChildren())
1603 return; 1601 return;
1604 1602
1605 HeapVector<Member<AXObjectImpl>> owned_children; 1603 HeapVector<Member<AXObject>> owned_children;
1606 ComputeAriaOwnsChildren(owned_children); 1604 ComputeAriaOwnsChildren(owned_children);
1607 1605
1608 for (AXObjectImpl* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) { 1606 for (AXObject* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) {
1609 if (!AxObjectCache().IsAriaOwned(obj)) { 1607 if (!AxObjectCache().IsAriaOwned(obj)) {
1610 obj->SetParent(this); 1608 obj->SetParent(this);
1611 AddChild(obj); 1609 AddChild(obj);
1612 } 1610 }
1613 } 1611 }
1614 1612
1615 AddHiddenChildren(); 1613 AddHiddenChildren();
1616 AddPopupChildren(); 1614 AddPopupChildren();
1617 AddImageMapChildren(); 1615 AddImageMapChildren();
1618 AddTextFieldChildren(); 1616 AddTextFieldChildren();
(...skipping 14 matching lines...) Expand all
1633 if (!layout_object_) 1631 if (!layout_object_)
1634 return false; 1632 return false;
1635 1633
1636 return AXNodeObject::CanHaveChildren(); 1634 return AXNodeObject::CanHaveChildren();
1637 } 1635 }
1638 1636
1639 void AXLayoutObject::UpdateChildrenIfNecessary() { 1637 void AXLayoutObject::UpdateChildrenIfNecessary() {
1640 if (NeedsToUpdateChildren()) 1638 if (NeedsToUpdateChildren())
1641 ClearChildren(); 1639 ClearChildren();
1642 1640
1643 AXObjectImpl::UpdateChildrenIfNecessary(); 1641 AXObject::UpdateChildrenIfNecessary();
1644 } 1642 }
1645 1643
1646 void AXLayoutObject::ClearChildren() { 1644 void AXLayoutObject::ClearChildren() {
1647 AXObjectImpl::ClearChildren(); 1645 AXObject::ClearChildren();
1648 children_dirty_ = false; 1646 children_dirty_ = false;
1649 } 1647 }
1650 1648
1651 // 1649 //
1652 // Properties of the object's owning document or page. 1650 // Properties of the object's owning document or page.
1653 // 1651 //
1654 1652
1655 double AXLayoutObject::EstimatedLoadingProgress() const { 1653 double AXLayoutObject::EstimatedLoadingProgress() const {
1656 if (!layout_object_) 1654 if (!layout_object_)
1657 return 0; 1655 return 0;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 return ToElement(&runner); 1722 return ToElement(&runner);
1725 } 1723 }
1726 1724
1727 return 0; 1725 return 0;
1728 } 1726 }
1729 1727
1730 // 1728 //
1731 // Functions that retrieve the current selection. 1729 // Functions that retrieve the current selection.
1732 // 1730 //
1733 1731
1734 AXObjectImpl::AXRange AXLayoutObject::Selection() const { 1732 AXObject::AXRange AXLayoutObject::Selection() const {
1735 AXRange text_selection = TextControlSelection(); 1733 AXRange text_selection = TextControlSelection();
1736 if (text_selection.IsValid()) 1734 if (text_selection.IsValid())
1737 return text_selection; 1735 return text_selection;
1738 1736
1739 if (!GetLayoutObject() || !GetLayoutObject()->GetFrame()) 1737 if (!GetLayoutObject() || !GetLayoutObject()->GetFrame())
1740 return AXRange(); 1738 return AXRange();
1741 1739
1742 VisibleSelection selection = 1740 VisibleSelection selection =
1743 GetLayoutObject() 1741 GetLayoutObject()
1744 ->GetFrame() 1742 ->GetFrame()
1745 ->Selection() 1743 ->Selection()
1746 .ComputeVisibleSelectionInDOMTreeDeprecated(); 1744 .ComputeVisibleSelectionInDOMTreeDeprecated();
1747 if (selection.IsNone()) 1745 if (selection.IsNone())
1748 return AXRange(); 1746 return AXRange();
1749 1747
1750 VisiblePosition visible_start = selection.VisibleStart(); 1748 VisiblePosition visible_start = selection.VisibleStart();
1751 Position start = visible_start.ToParentAnchoredPosition(); 1749 Position start = visible_start.ToParentAnchoredPosition();
1752 TextAffinity start_affinity = visible_start.Affinity(); 1750 TextAffinity start_affinity = visible_start.Affinity();
1753 VisiblePosition visible_end = selection.VisibleEnd(); 1751 VisiblePosition visible_end = selection.VisibleEnd();
1754 Position end = visible_end.ToParentAnchoredPosition(); 1752 Position end = visible_end.ToParentAnchoredPosition();
1755 TextAffinity end_affinity = visible_end.Affinity(); 1753 TextAffinity end_affinity = visible_end.Affinity();
1756 1754
1757 Node* anchor_node = start.AnchorNode(); 1755 Node* anchor_node = start.AnchorNode();
1758 DCHECK(anchor_node); 1756 DCHECK(anchor_node);
1759 1757
1760 AXLayoutObject* anchor_object = nullptr; 1758 AXLayoutObject* anchor_object = nullptr;
1761 // Find the closest node that has a corresponding AXObjectImpl. 1759 // Find the closest node that has a corresponding AXObject.
1762 // This is because some nodes may be aria hidden or might not even have 1760 // This is because some nodes may be aria hidden or might not even have
1763 // a layout object if they are part of the shadow DOM. 1761 // a layout object if they are part of the shadow DOM.
1764 while (anchor_node) { 1762 while (anchor_node) {
1765 anchor_object = GetUnignoredObjectFromNode(*anchor_node); 1763 anchor_object = GetUnignoredObjectFromNode(*anchor_node);
1766 if (anchor_object) 1764 if (anchor_object)
1767 break; 1765 break;
1768 1766
1769 if (anchor_node->nextSibling()) 1767 if (anchor_node->nextSibling())
1770 anchor_node = anchor_node->nextSibling(); 1768 anchor_node = anchor_node->nextSibling();
1771 else 1769 else
(...skipping 22 matching lines...) Expand all
1794 DCHECK_GE(anchor_offset, 0); 1792 DCHECK_GE(anchor_offset, 0);
1795 int focus_offset = focus_object->IndexForVisiblePosition(visible_end); 1793 int focus_offset = focus_object->IndexForVisiblePosition(visible_end);
1796 DCHECK_GE(focus_offset, 0); 1794 DCHECK_GE(focus_offset, 0);
1797 return AXRange(anchor_object, anchor_offset, start_affinity, focus_object, 1795 return AXRange(anchor_object, anchor_offset, start_affinity, focus_object,
1798 focus_offset, end_affinity); 1796 focus_offset, end_affinity);
1799 } 1797 }
1800 1798
1801 // Gets only the start and end offsets of the selection computed using the 1799 // Gets only the start and end offsets of the selection computed using the
1802 // current object as the starting point. Returns a null selection if there is 1800 // current object as the starting point. Returns a null selection if there is
1803 // no selection in the subtree rooted at this object. 1801 // no selection in the subtree rooted at this object.
1804 AXObjectImpl::AXRange AXLayoutObject::SelectionUnderObject() const { 1802 AXObject::AXRange AXLayoutObject::SelectionUnderObject() const {
1805 AXRange text_selection = TextControlSelection(); 1803 AXRange text_selection = TextControlSelection();
1806 if (text_selection.IsValid()) 1804 if (text_selection.IsValid())
1807 return text_selection; 1805 return text_selection;
1808 1806
1809 if (!GetNode() || !GetLayoutObject()->GetFrame()) 1807 if (!GetNode() || !GetLayoutObject()->GetFrame())
1810 return AXRange(); 1808 return AXRange();
1811 1809
1812 VisibleSelection selection = 1810 VisibleSelection selection =
1813 GetLayoutObject() 1811 GetLayoutObject()
1814 ->GetFrame() 1812 ->GetFrame()
(...skipping 13 matching lines...) Expand all
1828 } 1826 }
1829 1827
1830 int start = IndexForVisiblePosition(selection.VisibleStart()); 1828 int start = IndexForVisiblePosition(selection.VisibleStart());
1831 DCHECK_GE(start, 0); 1829 DCHECK_GE(start, 0);
1832 int end = IndexForVisiblePosition(selection.VisibleEnd()); 1830 int end = IndexForVisiblePosition(selection.VisibleEnd());
1833 DCHECK_GE(end, 0); 1831 DCHECK_GE(end, 0);
1834 1832
1835 return AXRange(start, end); 1833 return AXRange(start, end);
1836 } 1834 }
1837 1835
1838 AXObjectImpl::AXRange AXLayoutObject::TextControlSelection() const { 1836 AXObject::AXRange AXLayoutObject::TextControlSelection() const {
1839 if (!GetLayoutObject()) 1837 if (!GetLayoutObject())
1840 return AXRange(); 1838 return AXRange();
1841 1839
1842 LayoutObject* layout = nullptr; 1840 LayoutObject* layout = nullptr;
1843 if (GetLayoutObject()->IsTextControl()) { 1841 if (GetLayoutObject()->IsTextControl()) {
1844 layout = GetLayoutObject(); 1842 layout = GetLayoutObject();
1845 } else { 1843 } else {
1846 Element* focused_element = GetDocument()->FocusedElement(); 1844 Element* focused_element = GetDocument()->FocusedElement();
1847 if (focused_element && focused_element->GetLayoutObject() && 1845 if (focused_element && focused_element->GetLayoutObject() &&
1848 focused_element->GetLayoutObject()->IsTextControl()) 1846 focused_element->GetLayoutObject()->IsTextControl())
1849 layout = focused_element->GetLayoutObject(); 1847 layout = focused_element->GetLayoutObject();
1850 } 1848 }
1851 1849
1852 if (!layout) 1850 if (!layout)
1853 return AXRange(); 1851 return AXRange();
1854 1852
1855 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(layout); 1853 AXObject* ax_object = AxObjectCache().GetOrCreate(layout);
1856 if (!ax_object || !ax_object->IsAXLayoutObject()) 1854 if (!ax_object || !ax_object->IsAXLayoutObject())
1857 return AXRange(); 1855 return AXRange();
1858 1856
1859 VisibleSelection selection = 1857 VisibleSelection selection =
1860 layout->GetFrame() 1858 layout->GetFrame()
1861 ->Selection() 1859 ->Selection()
1862 .ComputeVisibleSelectionInDOMTreeDeprecated(); 1860 .ComputeVisibleSelectionInDOMTreeDeprecated();
1863 TextControlElement* text_control = 1861 TextControlElement* text_control =
1864 ToLayoutTextControl(layout)->GetTextControlElement(); 1862 ToLayoutTextControl(layout)->GetTextControlElement();
1865 DCHECK(text_control); 1863 DCHECK(text_control);
(...skipping 24 matching lines...) Expand all
1890 range->setEnd(index_position, IGNORE_EXCEPTION_FOR_TESTING); 1888 range->setEnd(index_position, IGNORE_EXCEPTION_FOR_TESTING);
1891 1889
1892 return TextIterator::RangeLength(range->StartPosition(), 1890 return TextIterator::RangeLength(range->StartPosition(),
1893 range->EndPosition()); 1891 range->EndPosition());
1894 } 1892 }
1895 1893
1896 AXLayoutObject* AXLayoutObject::GetUnignoredObjectFromNode(Node& node) const { 1894 AXLayoutObject* AXLayoutObject::GetUnignoredObjectFromNode(Node& node) const {
1897 if (IsDetached()) 1895 if (IsDetached())
1898 return nullptr; 1896 return nullptr;
1899 1897
1900 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(&node); 1898 AXObject* ax_object = AxObjectCache().GetOrCreate(&node);
1901 if (!ax_object) 1899 if (!ax_object)
1902 return nullptr; 1900 return nullptr;
1903 1901
1904 if (ax_object->IsAXLayoutObject() && !ax_object->AccessibilityIsIgnored()) 1902 if (ax_object->IsAXLayoutObject() && !ax_object->AccessibilityIsIgnored())
1905 return ToAXLayoutObject(ax_object); 1903 return ToAXLayoutObject(ax_object);
1906 1904
1907 return nullptr; 1905 return nullptr;
1908 } 1906 }
1909 1907
1910 // 1908 //
1911 // Modify or take an action on an object. 1909 // Modify or take an action on an object.
1912 // 1910 //
1913 1911
1914 // Convert from an accessible object and offset to a VisiblePosition. 1912 // Convert from an accessible object and offset to a VisiblePosition.
1915 static VisiblePosition ToVisiblePosition(AXObjectImpl* obj, int offset) { 1913 static VisiblePosition ToVisiblePosition(AXObject* obj, int offset) {
1916 if (!obj->GetNode()) 1914 if (!obj->GetNode())
1917 return VisiblePosition(); 1915 return VisiblePosition();
1918 1916
1919 Node* node = obj->GetNode(); 1917 Node* node = obj->GetNode();
1920 if (!node->IsTextNode()) { 1918 if (!node->IsTextNode()) {
1921 int child_count = obj->Children().size(); 1919 int child_count = obj->Children().size();
1922 1920
1923 // Place position immediately before the container node, if there was no 1921 // Place position immediately before the container node, if there was no
1924 // children. 1922 // children.
1925 if (child_count == 0) { 1923 if (child_count == 0) {
1926 if (!obj->ParentObject()) 1924 if (!obj->ParentObject())
1927 return VisiblePosition(); 1925 return VisiblePosition();
1928 return ToVisiblePosition(obj->ParentObject(), obj->IndexInParent()); 1926 return ToVisiblePosition(obj->ParentObject(), obj->IndexInParent());
1929 } 1927 }
1930 1928
1931 // The offsets are child offsets over the AX tree. Note that we allow 1929 // The offsets are child offsets over the AX tree. Note that we allow
1932 // for the offset to equal the number of children as |Range| does. 1930 // for the offset to equal the number of children as |Range| does.
1933 if (offset < 0 || offset > child_count) 1931 if (offset < 0 || offset > child_count)
1934 return VisiblePosition(); 1932 return VisiblePosition();
1935 1933
1936 // Clamp to between 0 and child count - 1. 1934 // Clamp to between 0 and child count - 1.
1937 int clamped_offset = 1935 int clamped_offset =
1938 static_cast<unsigned>(offset) > (obj->Children().size() - 1) 1936 static_cast<unsigned>(offset) > (obj->Children().size() - 1)
1939 ? offset - 1 1937 ? offset - 1
1940 : offset; 1938 : offset;
1941 AXObjectImpl* child_obj = obj->Children()[clamped_offset]; 1939 AXObject* child_obj = obj->Children()[clamped_offset];
1942 Node* child_node = child_obj->GetNode(); 1940 Node* child_node = child_obj->GetNode();
1943 if (!child_node || !child_node->parentNode()) 1941 if (!child_node || !child_node->parentNode())
1944 return VisiblePosition(); 1942 return VisiblePosition();
1945 1943
1946 // The index in parent. 1944 // The index in parent.
1947 int adjusted_offset = child_node->NodeIndex(); 1945 int adjusted_offset = child_node->NodeIndex();
1948 1946
1949 // If we had to clamp the offset above, the client wants to select the 1947 // If we had to clamp the offset above, the client wants to select the
1950 // end of the node. 1948 // end of the node.
1951 if (clamped_offset != offset) 1949 if (clamped_offset != offset)
(...skipping 12 matching lines...) Expand all
1964 1962
1965 VisiblePosition node_position = blink::VisiblePositionBeforeNode(*node); 1963 VisiblePosition node_position = blink::VisiblePositionBeforeNode(*node);
1966 int node_index = blink::IndexForVisiblePosition(node_position, parent); 1964 int node_index = blink::IndexForVisiblePosition(node_position, parent);
1967 return blink::VisiblePositionForIndex(node_index + offset, parent); 1965 return blink::VisiblePositionForIndex(node_index + offset, parent);
1968 } 1966 }
1969 1967
1970 void AXLayoutObject::SetSelection(const AXRange& selection) { 1968 void AXLayoutObject::SetSelection(const AXRange& selection) {
1971 if (!GetLayoutObject() || !selection.IsValid()) 1969 if (!GetLayoutObject() || !selection.IsValid())
1972 return; 1970 return;
1973 1971
1974 AXObjectImpl* anchor_object = 1972 AXObject* anchor_object =
1975 selection.anchor_object ? selection.anchor_object.Get() : this; 1973 selection.anchor_object ? selection.anchor_object.Get() : this;
1976 AXObjectImpl* focus_object = 1974 AXObject* focus_object =
1977 selection.focus_object ? selection.focus_object.Get() : this; 1975 selection.focus_object ? selection.focus_object.Get() : this;
1978 1976
1979 if (!IsValidSelectionBound(anchor_object) || 1977 if (!IsValidSelectionBound(anchor_object) ||
1980 !IsValidSelectionBound(focus_object)) { 1978 !IsValidSelectionBound(focus_object)) {
1981 return; 1979 return;
1982 } 1980 }
1983 1981
1984 // The selection offsets are offsets into the accessible value. 1982 // The selection offsets are offsets into the accessible value.
1985 if (anchor_object == focus_object && 1983 if (anchor_object == focus_object &&
1986 anchor_object->GetLayoutObject()->IsTextControl()) { 1984 anchor_object->GetLayoutObject()->IsTextControl()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2018 if (anchor_visible_position.IsNull() || focus_visible_position.IsNull()) 2016 if (anchor_visible_position.IsNull() || focus_visible_position.IsNull())
2019 return; 2017 return;
2020 2018
2021 frame->Selection().SetSelection( 2019 frame->Selection().SetSelection(
2022 SelectionInDOMTree::Builder() 2020 SelectionInDOMTree::Builder()
2023 .Collapse(anchor_visible_position.ToPositionWithAffinity()) 2021 .Collapse(anchor_visible_position.ToPositionWithAffinity())
2024 .Extend(focus_visible_position.DeepEquivalent()) 2022 .Extend(focus_visible_position.DeepEquivalent())
2025 .Build()); 2023 .Build());
2026 } 2024 }
2027 2025
2028 bool AXLayoutObject::IsValidSelectionBound( 2026 bool AXLayoutObject::IsValidSelectionBound(const AXObject* bound_object) const {
2029 const AXObjectImpl* bound_object) const {
2030 return GetLayoutObject() && bound_object && !bound_object->IsDetached() && 2027 return GetLayoutObject() && bound_object && !bound_object->IsDetached() &&
2031 bound_object->IsAXLayoutObject() && bound_object->GetLayoutObject() && 2028 bound_object->IsAXLayoutObject() && bound_object->GetLayoutObject() &&
2032 bound_object->GetLayoutObject()->GetFrame() == 2029 bound_object->GetLayoutObject()->GetFrame() ==
2033 GetLayoutObject()->GetFrame() && 2030 GetLayoutObject()->GetFrame() &&
2034 &bound_object->AxObjectCache() == &AxObjectCache(); 2031 &bound_object->AxObjectCache() == &AxObjectCache();
2035 } 2032 }
2036 2033
2037 void AXLayoutObject::SetValue(const String& string) { 2034 void AXLayoutObject::SetValue(const String& string) {
2038 if (!GetNode() || !GetNode()->IsElementNode()) 2035 if (!GetNode() || !GetNode()->IsElementNode())
2039 return; 2036 return;
(...skipping 10 matching lines...) Expand all
2050 } 2047 }
2051 2048
2052 // 2049 //
2053 // Notifications that this object may have changed. 2050 // Notifications that this object may have changed.
2054 // 2051 //
2055 2052
2056 void AXLayoutObject::HandleActiveDescendantChanged() { 2053 void AXLayoutObject::HandleActiveDescendantChanged() {
2057 if (!GetLayoutObject()) 2054 if (!GetLayoutObject())
2058 return; 2055 return;
2059 2056
2060 AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); 2057 AXObject* focused_object = AxObjectCache().FocusedObject();
2061 if (focused_object == this && SupportsActiveDescendant()) { 2058 if (focused_object == this && SupportsActiveDescendant()) {
2062 AxObjectCache().PostNotification( 2059 AxObjectCache().PostNotification(
2063 GetLayoutObject(), AXObjectCacheImpl::kAXActiveDescendantChanged); 2060 GetLayoutObject(), AXObjectCacheImpl::kAXActiveDescendantChanged);
2064 } 2061 }
2065 } 2062 }
2066 2063
2067 void AXLayoutObject::HandleAriaExpandedChanged() { 2064 void AXLayoutObject::HandleAriaExpandedChanged() {
2068 // Find if a parent of this object should handle aria-expanded changes. 2065 // Find if a parent of this object should handle aria-expanded changes.
2069 AXObjectImpl* container_parent = this->ParentObject(); 2066 AXObject* container_parent = this->ParentObject();
2070 while (container_parent) { 2067 while (container_parent) {
2071 bool found_parent = false; 2068 bool found_parent = false;
2072 2069
2073 switch (container_parent->RoleValue()) { 2070 switch (container_parent->RoleValue()) {
2074 case kTreeRole: 2071 case kTreeRole:
2075 case kTreeGridRole: 2072 case kTreeGridRole:
2076 case kGridRole: 2073 case kGridRole:
2077 case kTableRole: 2074 case kTableRole:
2078 found_parent = true; 2075 found_parent = true;
2079 break; 2076 break;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2179 // If a LayoutText needs layout, its inline text boxes are either 2176 // If a LayoutText needs layout, its inline text boxes are either
2180 // nonexistent or invalid, so defer until the layout happens and 2177 // nonexistent or invalid, so defer until the layout happens and
2181 // the layoutObject calls AXObjectCacheImpl::inlineTextBoxesUpdated. 2178 // the layoutObject calls AXObjectCacheImpl::inlineTextBoxesUpdated.
2182 return; 2179 return;
2183 } 2180 }
2184 2181
2185 LayoutText* layout_text = ToLayoutText(GetLayoutObject()); 2182 LayoutText* layout_text = ToLayoutText(GetLayoutObject());
2186 for (RefPtr<AbstractInlineTextBox> box = 2183 for (RefPtr<AbstractInlineTextBox> box =
2187 layout_text->FirstAbstractInlineTextBox(); 2184 layout_text->FirstAbstractInlineTextBox();
2188 box.Get(); box = box->NextInlineTextBox()) { 2185 box.Get(); box = box->NextInlineTextBox()) {
2189 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(box.Get()); 2186 AXObject* ax_object = AxObjectCache().GetOrCreate(box.Get());
2190 if (!ax_object->AccessibilityIsIgnored()) 2187 if (!ax_object->AccessibilityIsIgnored())
2191 children_.push_back(ax_object); 2188 children_.push_back(ax_object);
2192 } 2189 }
2193 } 2190 }
2194 2191
2195 void AXLayoutObject::LineBreaks(Vector<int>& line_breaks) const { 2192 void AXLayoutObject::LineBreaks(Vector<int>& line_breaks) const {
2196 if (!IsTextControl()) 2193 if (!IsTextControl())
2197 return; 2194 return;
2198 2195
2199 VisiblePosition visible_pos = VisiblePositionForIndex(0); 2196 VisiblePosition visible_pos = VisiblePositionForIndex(0);
(...skipping 12 matching lines...) Expand all
2212 if (visible_pos.DeepEquivalent().CompareTo( 2209 if (visible_pos.DeepEquivalent().CompareTo(
2213 prev_visible_pos.DeepEquivalent()) < 0) 2210 prev_visible_pos.DeepEquivalent()) < 0)
2214 break; 2211 break;
2215 } 2212 }
2216 } 2213 }
2217 2214
2218 // 2215 //
2219 // Private. 2216 // Private.
2220 // 2217 //
2221 2218
2222 AXObjectImpl* AXLayoutObject::TreeAncestorDisallowingChild() const { 2219 AXObject* AXLayoutObject::TreeAncestorDisallowingChild() const {
2223 // Determine if this is in a tree. If so, we apply special behavior to make it 2220 // Determine if this is in a tree. If so, we apply special behavior to make it
2224 // work like an AXOutline. 2221 // work like an AXOutline.
2225 AXObjectImpl* ax_obj = ParentObject(); 2222 AXObject* ax_obj = ParentObject();
2226 AXObjectImpl* tree_ancestor = 0; 2223 AXObject* tree_ancestor = 0;
2227 while (ax_obj) { 2224 while (ax_obj) {
2228 if (ax_obj->IsTree()) { 2225 if (ax_obj->IsTree()) {
2229 tree_ancestor = ax_obj; 2226 tree_ancestor = ax_obj;
2230 break; 2227 break;
2231 } 2228 }
2232 ax_obj = ax_obj->ParentObject(); 2229 ax_obj = ax_obj->ParentObject();
2233 } 2230 }
2234 2231
2235 // If the object is in a tree, only tree items should be exposed (and the 2232 // If the object is in a tree, only tree items should be exposed (and the
2236 // children of tree items). 2233 // children of tree items).
2237 if (tree_ancestor) { 2234 if (tree_ancestor) {
2238 AccessibilityRole role = RoleValue(); 2235 AccessibilityRole role = RoleValue();
2239 if (role != kTreeItemRole && role != kStaticTextRole) 2236 if (role != kTreeItemRole && role != kStaticTextRole)
2240 return tree_ancestor; 2237 return tree_ancestor;
2241 } 2238 }
2242 return 0; 2239 return 0;
2243 } 2240 }
2244 2241
2245 bool AXLayoutObject::IsTabItemSelected() const { 2242 bool AXLayoutObject::IsTabItemSelected() const {
2246 if (!IsTabItem() || !GetLayoutObject()) 2243 if (!IsTabItem() || !GetLayoutObject())
2247 return false; 2244 return false;
2248 2245
2249 Node* node = GetNode(); 2246 Node* node = GetNode();
2250 if (!node || !node->IsElementNode()) 2247 if (!node || !node->IsElementNode())
2251 return false; 2248 return false;
2252 2249
2253 // The ARIA spec says a tab item can also be selected if it is aria-labeled by 2250 // The ARIA spec says a tab item can also be selected if it is aria-labeled by
2254 // a tabpanel that has keyboard focus inside of it, or if a tabpanel in its 2251 // a tabpanel that has keyboard focus inside of it, or if a tabpanel in its
2255 // aria-controls list has KB focus inside of it. 2252 // aria-controls list has KB focus inside of it.
2256 AXObjectImpl* focused_element = AxObjectCache().FocusedObject(); 2253 AXObject* focused_element = AxObjectCache().FocusedObject();
2257 if (!focused_element) 2254 if (!focused_element)
2258 return false; 2255 return false;
2259 2256
2260 HeapVector<Member<Element>> elements; 2257 HeapVector<Member<Element>> elements;
2261 ElementsFromAttribute(elements, aria_controlsAttr); 2258 ElementsFromAttribute(elements, aria_controlsAttr);
2262 2259
2263 for (const auto& element : elements) { 2260 for (const auto& element : elements) {
2264 AXObjectImpl* tab_panel = AxObjectCache().GetOrCreate(element); 2261 AXObject* tab_panel = AxObjectCache().GetOrCreate(element);
2265 2262
2266 // A tab item should only control tab panels. 2263 // A tab item should only control tab panels.
2267 if (!tab_panel || tab_panel->RoleValue() != kTabPanelRole) 2264 if (!tab_panel || tab_panel->RoleValue() != kTabPanelRole)
2268 continue; 2265 continue;
2269 2266
2270 AXObjectImpl* check_focus_element = focused_element; 2267 AXObject* check_focus_element = focused_element;
2271 // Check if the focused element is a descendant of the element controlled by 2268 // Check if the focused element is a descendant of the element controlled by
2272 // the tab item. 2269 // the tab item.
2273 while (check_focus_element) { 2270 while (check_focus_element) {
2274 if (tab_panel == check_focus_element) 2271 if (tab_panel == check_focus_element)
2275 return true; 2272 return true;
2276 check_focus_element = check_focus_element->ParentObject(); 2273 check_focus_element = check_focus_element->ParentObject();
2277 } 2274 }
2278 } 2275 }
2279 2276
2280 return false; 2277 return false;
2281 } 2278 }
2282 2279
2283 AXObjectImpl* AXLayoutObject::AccessibilityImageMapHitTest( 2280 AXObject* AXLayoutObject::AccessibilityImageMapHitTest(
2284 HTMLAreaElement* area, 2281 HTMLAreaElement* area,
2285 const IntPoint& point) const { 2282 const IntPoint& point) const {
2286 if (!area) 2283 if (!area)
2287 return 0; 2284 return 0;
2288 2285
2289 AXObjectImpl* parent = AxObjectCache().GetOrCreate(area->ImageElement()); 2286 AXObject* parent = AxObjectCache().GetOrCreate(area->ImageElement());
2290 if (!parent) 2287 if (!parent)
2291 return 0; 2288 return 0;
2292 2289
2293 for (const auto& child : parent->Children()) { 2290 for (const auto& child : parent->Children()) {
2294 if (child->GetBoundsInFrameCoordinates().Contains(point)) 2291 if (child->GetBoundsInFrameCoordinates().Contains(point))
2295 return child.Get(); 2292 return child.Get();
2296 } 2293 }
2297 2294
2298 return 0; 2295 return 0;
2299 } 2296 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2357 root->SetParent(0); 2354 root->SetParent(0);
2358 } 2355 }
2359 2356
2360 AXSVGRoot* AXLayoutObject::RemoteSVGRootElement() const { 2357 AXSVGRoot* AXLayoutObject::RemoteSVGRootElement() const {
2361 // FIXME(dmazzoni): none of this code properly handled multiple references to 2358 // FIXME(dmazzoni): none of this code properly handled multiple references to
2362 // the same remote SVG document. I'm disabling this support until it can be 2359 // the same remote SVG document. I'm disabling this support until it can be
2363 // fixed properly. 2360 // fixed properly.
2364 return 0; 2361 return 0;
2365 } 2362 }
2366 2363
2367 AXObjectImpl* AXLayoutObject::RemoteSVGElementHitTest( 2364 AXObject* AXLayoutObject::RemoteSVGElementHitTest(const IntPoint& point) const {
2368 const IntPoint& point) const { 2365 AXObject* remote = RemoteSVGRootElement();
2369 AXObjectImpl* remote = RemoteSVGRootElement();
2370 if (!remote) 2366 if (!remote)
2371 return 0; 2367 return 0;
2372 2368
2373 IntSize offset = 2369 IntSize offset =
2374 point - RoundedIntPoint(GetBoundsInFrameCoordinates().Location()); 2370 point - RoundedIntPoint(GetBoundsInFrameCoordinates().Location());
2375 return remote->AccessibilityHitTest(IntPoint(offset)); 2371 return remote->AccessibilityHitTest(IntPoint(offset));
2376 } 2372 }
2377 2373
2378 // The boundingBox for elements within the remote SVG element needs to be offset 2374 // The boundingBox for elements within the remote SVG element needs to be offset
2379 // by its position within the parent page, otherwise they are in relative 2375 // by its position within the parent page, otherwise they are in relative
2380 // coordinates only. 2376 // coordinates only.
2381 void AXLayoutObject::OffsetBoundingBoxForRemoteSVGElement( 2377 void AXLayoutObject::OffsetBoundingBoxForRemoteSVGElement(
2382 LayoutRect& rect) const { 2378 LayoutRect& rect) const {
2383 for (AXObjectImpl* parent = ParentObject(); parent; 2379 for (AXObject* parent = ParentObject(); parent;
2384 parent = parent->ParentObject()) { 2380 parent = parent->ParentObject()) {
2385 if (parent->IsAXSVGRoot()) { 2381 if (parent->IsAXSVGRoot()) {
2386 rect.MoveBy( 2382 rect.MoveBy(
2387 parent->ParentObject()->GetBoundsInFrameCoordinates().Location()); 2383 parent->ParentObject()->GetBoundsInFrameCoordinates().Location());
2388 break; 2384 break;
2389 } 2385 }
2390 } 2386 }
2391 } 2387 }
2392 2388
2393 // Hidden children are those that are not laid out or visible, but are 2389 // Hidden children are those that are not laid out or visible, but are
(...skipping 18 matching lines...) Expand all
2412 if (!should_insert_hidden_nodes) 2408 if (!should_insert_hidden_nodes)
2413 return; 2409 return;
2414 2410
2415 // Iterate through all of the children, including those that may have already 2411 // Iterate through all of the children, including those that may have already
2416 // been added, and try to insert hidden nodes in the correct place in the DOM 2412 // been added, and try to insert hidden nodes in the correct place in the DOM
2417 // order. 2413 // order.
2418 unsigned insertion_index = 0; 2414 unsigned insertion_index = 0;
2419 for (Node& child : NodeTraversal::ChildrenOf(*node)) { 2415 for (Node& child : NodeTraversal::ChildrenOf(*node)) {
2420 if (child.GetLayoutObject()) { 2416 if (child.GetLayoutObject()) {
2421 // Find out where the last layout sibling is located within m_children. 2417 // Find out where the last layout sibling is located within m_children.
2422 if (AXObjectImpl* child_object = 2418 if (AXObject* child_object =
2423 AxObjectCache().Get(child.GetLayoutObject())) { 2419 AxObjectCache().Get(child.GetLayoutObject())) {
2424 if (child_object->AccessibilityIsIgnored()) { 2420 if (child_object->AccessibilityIsIgnored()) {
2425 const auto& children = child_object->Children(); 2421 const auto& children = child_object->Children();
2426 child_object = children.size() ? children.back().Get() : 0; 2422 child_object = children.size() ? children.back().Get() : 0;
2427 } 2423 }
2428 if (child_object) 2424 if (child_object)
2429 insertion_index = children_.Find(child_object) + 1; 2425 insertion_index = children_.Find(child_object) + 1;
2430 continue; 2426 continue;
2431 } 2427 }
2432 } 2428 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2467 if (!css_box || !css_box->IsLayoutImage()) 2463 if (!css_box || !css_box->IsLayoutImage())
2468 return; 2464 return;
2469 2465
2470 HTMLMapElement* map = ToLayoutImage(css_box)->ImageMap(); 2466 HTMLMapElement* map = ToLayoutImage(css_box)->ImageMap();
2471 if (!map) 2467 if (!map)
2472 return; 2468 return;
2473 2469
2474 for (HTMLAreaElement& area : 2470 for (HTMLAreaElement& area :
2475 Traversal<HTMLAreaElement>::DescendantsOf(*map)) { 2471 Traversal<HTMLAreaElement>::DescendantsOf(*map)) {
2476 // add an <area> element for this child if it has a link 2472 // add an <area> element for this child if it has a link
2477 AXObjectImpl* obj = AxObjectCache().GetOrCreate(&area); 2473 AXObject* obj = AxObjectCache().GetOrCreate(&area);
2478 if (obj) { 2474 if (obj) {
2479 AXImageMapLink* area_object = ToAXImageMapLink(obj); 2475 AXImageMapLink* area_object = ToAXImageMapLink(obj);
2480 area_object->SetParent(this); 2476 area_object->SetParent(this);
2481 DCHECK(area_object->AxObjectID() != 0); 2477 DCHECK(area_object->AxObjectID() != 0);
2482 if (!area_object->AccessibilityIsIgnored()) 2478 if (!area_object->AccessibilityIsIgnored())
2483 children_.push_back(area_object); 2479 children_.push_back(area_object);
2484 else 2480 else
2485 AxObjectCache().Remove(area_object->AxObjectID()); 2481 AxObjectCache().Remove(area_object->AxObjectID());
2486 } 2482 }
2487 } 2483 }
2488 } 2484 }
2489 2485
2490 void AXLayoutObject::AddCanvasChildren() { 2486 void AXLayoutObject::AddCanvasChildren() {
2491 if (!isHTMLCanvasElement(GetNode())) 2487 if (!isHTMLCanvasElement(GetNode()))
2492 return; 2488 return;
2493 2489
2494 // If it's a canvas, it won't have laid out children, but it might have 2490 // If it's a canvas, it won't have laid out children, but it might have
2495 // accessible fallback content. Clear m_haveChildren because 2491 // accessible fallback content. Clear m_haveChildren because
2496 // AXNodeObject::addChildren will expect it to be false. 2492 // AXNodeObject::addChildren will expect it to be false.
2497 DCHECK(!children_.size()); 2493 DCHECK(!children_.size());
2498 have_children_ = false; 2494 have_children_ = false;
2499 AXNodeObject::AddChildren(); 2495 AXNodeObject::AddChildren();
2500 } 2496 }
2501 2497
2502 void AXLayoutObject::AddPopupChildren() { 2498 void AXLayoutObject::AddPopupChildren() {
2503 if (!isHTMLInputElement(GetNode())) 2499 if (!isHTMLInputElement(GetNode()))
2504 return; 2500 return;
2505 if (AXObjectImpl* ax_popup = 2501 if (AXObject* ax_popup = toHTMLInputElement(GetNode())->PopupRootAXObject())
2506 toHTMLInputElement(GetNode())->PopupRootAXObject())
2507 children_.push_back(ax_popup); 2502 children_.push_back(ax_popup);
2508 } 2503 }
2509 2504
2510 void AXLayoutObject::AddRemoteSVGChildren() { 2505 void AXLayoutObject::AddRemoteSVGChildren() {
2511 AXSVGRoot* root = RemoteSVGRootElement(); 2506 AXSVGRoot* root = RemoteSVGRootElement();
2512 if (!root) 2507 if (!root)
2513 return; 2508 return;
2514 2509
2515 root->SetParent(this); 2510 root->SetParent(this);
2516 2511
2517 if (root->AccessibilityIsIgnored()) { 2512 if (root->AccessibilityIsIgnored()) {
2518 for (const auto& child : root->Children()) 2513 for (const auto& child : root->Children())
2519 children_.push_back(child); 2514 children_.push_back(child);
2520 } else { 2515 } else {
2521 children_.push_back(root); 2516 children_.push_back(root);
2522 } 2517 }
2523 } 2518 }
2524 2519
2525 bool AXLayoutObject::ElementAttributeValue( 2520 bool AXLayoutObject::ElementAttributeValue(
2526 const QualifiedName& attribute_name) const { 2521 const QualifiedName& attribute_name) const {
2527 if (!layout_object_) 2522 if (!layout_object_)
2528 return false; 2523 return false;
2529 2524
2530 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true"); 2525 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true");
2531 } 2526 }
2532 2527
2533 } // namespace blink 2528 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698