| OLD | NEW |
| 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 Loading... |
| 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 AXObject& object) { | 330 static bool IsLinkable(const AXObjectImpl& 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 AXObject* ax_body = AxObjectCache().GetOrCreate(body); | 353 AXObjectImpl* 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 AXObject* ax_body = AxObjectCache().GetOrCreate(body); | 373 AXObjectImpl* 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 Loading... |
| 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 AXObject* ax_body = AxObjectCache().GetOrCreate(body); | 415 AXObjectImpl* 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 AXObject* focused_object = AxObjectCache().GetOrCreate(focused_element); | 444 AXObjectImpl* 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 AXObject* focused_object = AxObjectCache().FocusedObject(); | 466 AXObjectImpl* 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 Loading... |
| 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 AXObject::DefaultObjectInclusion(ignored_reasons); | 504 return AXObjectImpl::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 Loading... |
| 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 AXObject* inherits_from = InheritsPresentationalRoleFrom(); | 545 const AXObjectImpl* 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 (AXObject* tree_ancestor = TreeAncestorDisallowingChild()) { | 556 if (AXObjectImpl* 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 AXObject* control_object = CorrespondingControlForLabelElement(); | 575 AXObjectImpl* 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 AXObject* label_ax_object = AxObjectCache().GetOrCreate(label); | 581 AXObjectImpl* 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 AXObject* parent = ParentObjectUnignored(); | 603 AXObjectImpl* 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 (AXObject* parent = ParentObject(); parent; | 619 for (AXObjectImpl* 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 Loading... |
| 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 AXObject* ax_parent = AxObjectCache().GetOrCreate(layout_object); | 812 const AXObjectImpl* 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 Loading... |
| 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 AXObject* AXLayoutObject::NextOnLine() const { | 1083 AXObjectImpl* AXLayoutObject::NextOnLine() const { |
| 1084 if (!GetLayoutObject()) | 1084 if (!GetLayoutObject()) |
| 1085 return nullptr; | 1085 return nullptr; |
| 1086 | 1086 |
| 1087 AXObject* result = nullptr; | 1087 AXObjectImpl* result = nullptr; |
| 1088 if (GetLayoutObject()->IsListMarker()) { | 1088 if (GetLayoutObject()->IsListMarker()) { |
| 1089 AXObject* next_sibling = RawNextSibling(); | 1089 AXObjectImpl* 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 Loading... |
| 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 AXObject* AXLayoutObject::PreviousOnLine() const { | 1122 AXObjectImpl* 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 AXObject* result = nullptr; | 1135 AXObjectImpl* 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 Loading... |
| 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 AXObject* AXLayoutObject::AncestorForWhichThisIsAPresentationalChild() const { | 1294 AXObjectImpl* AXLayoutObject::AncestorForWhichThisIsAPresentationalChild() |
| 1295 const { |
| 1295 // Walk the parent chain looking for a parent that has presentational children | 1296 // Walk the parent chain looking for a parent that has presentational children |
| 1296 AXObject* parent = ParentObjectIfExists(); | 1297 AXObjectImpl* parent = ParentObjectIfExists(); |
| 1297 while (parent) { | 1298 while (parent) { |
| 1298 if (parent->AriaRoleHasPresentationalChildren()) | 1299 if (parent->AriaRoleHasPresentationalChildren()) |
| 1299 break; | 1300 break; |
| 1300 | 1301 |
| 1301 // The descendants of a AXMenuList that are AXLayoutObjects are all | 1302 // The descendants of a AXMenuList that are AXLayoutObjects are all |
| 1302 // presentational. (The real descendants are an AXMenuListPopup and | 1303 // presentational. (The real descendants are an AXMenuListPopup and |
| 1303 // AXMenuListOptions, which are not AXLayoutObjects.) | 1304 // AXMenuListOptions, which are not AXLayoutObjects.) |
| 1304 if (parent->IsMenuList()) | 1305 if (parent->IsMenuList()) |
| 1305 break; | 1306 break; |
| 1306 | 1307 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 } | 1391 } |
| 1391 | 1392 |
| 1392 bool AXLayoutObject::LiveRegionBusy() const { | 1393 bool AXLayoutObject::LiveRegionBusy() const { |
| 1393 return ElementAttributeValue(aria_busyAttr); | 1394 return ElementAttributeValue(aria_busyAttr); |
| 1394 } | 1395 } |
| 1395 | 1396 |
| 1396 // | 1397 // |
| 1397 // Hit testing. | 1398 // Hit testing. |
| 1398 // | 1399 // |
| 1399 | 1400 |
| 1400 AXObject* AXLayoutObject::AccessibilityHitTest(const IntPoint& point) const { | 1401 AXObjectImpl* AXLayoutObject::AccessibilityHitTest( |
| 1402 const IntPoint& point) const { |
| 1401 if (!layout_object_ || !layout_object_->HasLayer()) | 1403 if (!layout_object_ || !layout_object_->HasLayer()) |
| 1402 return nullptr; | 1404 return nullptr; |
| 1403 | 1405 |
| 1404 PaintLayer* layer = ToLayoutBox(layout_object_)->Layer(); | 1406 PaintLayer* layer = ToLayoutBox(layout_object_)->Layer(); |
| 1405 | 1407 |
| 1406 HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); | 1408 HitTestRequest request(HitTestRequest::kReadOnly | HitTestRequest::kActive); |
| 1407 HitTestResult hit_test_result = HitTestResult(request, point); | 1409 HitTestResult hit_test_result = HitTestResult(request, point); |
| 1408 layer->HitTest(hit_test_result); | 1410 layer->HitTest(hit_test_result); |
| 1409 | 1411 |
| 1410 Node* node = hit_test_result.InnerNode(); | 1412 Node* node = hit_test_result.InnerNode(); |
| 1411 if (!node) | 1413 if (!node) |
| 1412 return nullptr; | 1414 return nullptr; |
| 1413 | 1415 |
| 1414 if (isHTMLAreaElement(node)) | 1416 if (isHTMLAreaElement(node)) |
| 1415 return AccessibilityImageMapHitTest(toHTMLAreaElement(node), point); | 1417 return AccessibilityImageMapHitTest(toHTMLAreaElement(node), point); |
| 1416 | 1418 |
| 1417 if (isHTMLOptionElement(node)) { | 1419 if (isHTMLOptionElement(node)) { |
| 1418 node = toHTMLOptionElement(*node).OwnerSelectElement(); | 1420 node = toHTMLOptionElement(*node).OwnerSelectElement(); |
| 1419 if (!node) | 1421 if (!node) |
| 1420 return nullptr; | 1422 return nullptr; |
| 1421 } | 1423 } |
| 1422 | 1424 |
| 1423 LayoutObject* obj = node->GetLayoutObject(); | 1425 LayoutObject* obj = node->GetLayoutObject(); |
| 1424 if (!obj) | 1426 if (!obj) |
| 1425 return nullptr; | 1427 return nullptr; |
| 1426 | 1428 |
| 1427 AXObject* result = AxObjectCache().GetOrCreate(obj); | 1429 AXObjectImpl* result = AxObjectCache().GetOrCreate(obj); |
| 1428 result->UpdateChildrenIfNecessary(); | 1430 result->UpdateChildrenIfNecessary(); |
| 1429 | 1431 |
| 1430 // Allow the element to perform any hit-testing it might need to do to reach | 1432 // Allow the element to perform any hit-testing it might need to do to reach |
| 1431 // non-layout children. | 1433 // non-layout children. |
| 1432 result = result->ElementAccessibilityHitTest(point); | 1434 result = result->ElementAccessibilityHitTest(point); |
| 1433 if (result && result->AccessibilityIsIgnored()) { | 1435 if (result && result->AccessibilityIsIgnored()) { |
| 1434 // If this element is the label of a control, a hit test should return the | 1436 // If this element is the label of a control, a hit test should return the |
| 1435 // control. | 1437 // control. |
| 1436 if (result->IsAXLayoutObject()) { | 1438 if (result->IsAXLayoutObject()) { |
| 1437 AXObject* control_object = | 1439 AXObjectImpl* control_object = |
| 1438 ToAXLayoutObject(result)->CorrespondingControlForLabelElement(); | 1440 ToAXLayoutObject(result)->CorrespondingControlForLabelElement(); |
| 1439 if (control_object && control_object->NameFromLabelElement()) | 1441 if (control_object && control_object->NameFromLabelElement()) |
| 1440 return control_object; | 1442 return control_object; |
| 1441 } | 1443 } |
| 1442 | 1444 |
| 1443 result = result->ParentObjectUnignored(); | 1445 result = result->ParentObjectUnignored(); |
| 1444 } | 1446 } |
| 1445 | 1447 |
| 1446 return result; | 1448 return result; |
| 1447 } | 1449 } |
| 1448 | 1450 |
| 1449 AXObject* AXLayoutObject::ElementAccessibilityHitTest( | 1451 AXObjectImpl* AXLayoutObject::ElementAccessibilityHitTest( |
| 1450 const IntPoint& point) const { | 1452 const IntPoint& point) const { |
| 1451 if (IsSVGImage()) | 1453 if (IsSVGImage()) |
| 1452 return RemoteSVGElementHitTest(point); | 1454 return RemoteSVGElementHitTest(point); |
| 1453 | 1455 |
| 1454 return AXObject::ElementAccessibilityHitTest(point); | 1456 return AXObjectImpl::ElementAccessibilityHitTest(point); |
| 1455 } | 1457 } |
| 1456 | 1458 |
| 1457 // | 1459 // |
| 1458 // High-level accessibility tree access. | 1460 // High-level accessibility tree access. |
| 1459 // | 1461 // |
| 1460 | 1462 |
| 1461 AXObject* AXLayoutObject::ComputeParent() const { | 1463 AXObjectImpl* AXLayoutObject::ComputeParent() const { |
| 1462 DCHECK(!IsDetached()); | 1464 DCHECK(!IsDetached()); |
| 1463 if (!layout_object_) | 1465 if (!layout_object_) |
| 1464 return 0; | 1466 return 0; |
| 1465 | 1467 |
| 1466 if (AriaRoleAttribute() == kMenuBarRole) | 1468 if (AriaRoleAttribute() == kMenuBarRole) |
| 1467 return AxObjectCache().GetOrCreate(layout_object_->Parent()); | 1469 return AxObjectCache().GetOrCreate(layout_object_->Parent()); |
| 1468 | 1470 |
| 1469 // menuButton and its corresponding menu are DOM siblings, but Accessibility | 1471 // menuButton and its corresponding menu are DOM siblings, but Accessibility |
| 1470 // needs them to be parent/child. | 1472 // needs them to be parent/child. |
| 1471 if (AriaRoleAttribute() == kMenuRole) { | 1473 if (AriaRoleAttribute() == kMenuRole) { |
| 1472 AXObject* parent = MenuButtonForMenu(); | 1474 AXObjectImpl* parent = MenuButtonForMenu(); |
| 1473 if (parent) | 1475 if (parent) |
| 1474 return parent; | 1476 return parent; |
| 1475 } | 1477 } |
| 1476 | 1478 |
| 1477 LayoutObject* parent_obj = LayoutParentObject(); | 1479 LayoutObject* parent_obj = LayoutParentObject(); |
| 1478 if (parent_obj) | 1480 if (parent_obj) |
| 1479 return AxObjectCache().GetOrCreate(parent_obj); | 1481 return AxObjectCache().GetOrCreate(parent_obj); |
| 1480 | 1482 |
| 1481 // A WebArea's parent should be the page popup owner, if any, otherwise null. | 1483 // A WebArea's parent should be the page popup owner, if any, otherwise null. |
| 1482 if (IsWebArea()) { | 1484 if (IsWebArea()) { |
| 1483 LocalFrame* frame = layout_object_->GetFrame(); | 1485 LocalFrame* frame = layout_object_->GetFrame(); |
| 1484 return AxObjectCache().GetOrCreate(frame->PagePopupOwner()); | 1486 return AxObjectCache().GetOrCreate(frame->PagePopupOwner()); |
| 1485 } | 1487 } |
| 1486 | 1488 |
| 1487 return 0; | 1489 return 0; |
| 1488 } | 1490 } |
| 1489 | 1491 |
| 1490 AXObject* AXLayoutObject::ComputeParentIfExists() const { | 1492 AXObjectImpl* AXLayoutObject::ComputeParentIfExists() const { |
| 1491 if (!layout_object_) | 1493 if (!layout_object_) |
| 1492 return 0; | 1494 return 0; |
| 1493 | 1495 |
| 1494 if (AriaRoleAttribute() == kMenuBarRole) | 1496 if (AriaRoleAttribute() == kMenuBarRole) |
| 1495 return AxObjectCache().Get(layout_object_->Parent()); | 1497 return AxObjectCache().Get(layout_object_->Parent()); |
| 1496 | 1498 |
| 1497 // menuButton and its corresponding menu are DOM siblings, but Accessibility | 1499 // menuButton and its corresponding menu are DOM siblings, but Accessibility |
| 1498 // needs them to be parent/child. | 1500 // needs them to be parent/child. |
| 1499 if (AriaRoleAttribute() == kMenuRole) { | 1501 if (AriaRoleAttribute() == kMenuRole) { |
| 1500 AXObject* parent = MenuButtonForMenu(); | 1502 AXObjectImpl* parent = MenuButtonForMenu(); |
| 1501 if (parent) | 1503 if (parent) |
| 1502 return parent; | 1504 return parent; |
| 1503 } | 1505 } |
| 1504 | 1506 |
| 1505 LayoutObject* parent_obj = LayoutParentObject(); | 1507 LayoutObject* parent_obj = LayoutParentObject(); |
| 1506 if (parent_obj) | 1508 if (parent_obj) |
| 1507 return AxObjectCache().Get(parent_obj); | 1509 return AxObjectCache().Get(parent_obj); |
| 1508 | 1510 |
| 1509 // A WebArea's parent should be the page popup owner, if any, otherwise null. | 1511 // A WebArea's parent should be the page popup owner, if any, otherwise null. |
| 1510 if (IsWebArea()) { | 1512 if (IsWebArea()) { |
| 1511 LocalFrame* frame = layout_object_->GetFrame(); | 1513 LocalFrame* frame = layout_object_->GetFrame(); |
| 1512 return AxObjectCache().Get(frame->PagePopupOwner()); | 1514 return AxObjectCache().Get(frame->PagePopupOwner()); |
| 1513 } | 1515 } |
| 1514 | 1516 |
| 1515 return 0; | 1517 return 0; |
| 1516 } | 1518 } |
| 1517 | 1519 |
| 1518 // | 1520 // |
| 1519 // Low-level accessibility tree exploration, only for use within the | 1521 // Low-level accessibility tree exploration, only for use within the |
| 1520 // accessibility module. | 1522 // accessibility module. |
| 1521 // | 1523 // |
| 1522 | 1524 |
| 1523 AXObject* AXLayoutObject::RawFirstChild() const { | 1525 AXObjectImpl* AXLayoutObject::RawFirstChild() const { |
| 1524 if (!layout_object_) | 1526 if (!layout_object_) |
| 1525 return 0; | 1527 return 0; |
| 1526 | 1528 |
| 1527 LayoutObject* first_child = FirstChildConsideringContinuation(layout_object_); | 1529 LayoutObject* first_child = FirstChildConsideringContinuation(layout_object_); |
| 1528 | 1530 |
| 1529 if (!first_child) | 1531 if (!first_child) |
| 1530 return 0; | 1532 return 0; |
| 1531 | 1533 |
| 1532 return AxObjectCache().GetOrCreate(first_child); | 1534 return AxObjectCache().GetOrCreate(first_child); |
| 1533 } | 1535 } |
| 1534 | 1536 |
| 1535 AXObject* AXLayoutObject::RawNextSibling() const { | 1537 AXObjectImpl* AXLayoutObject::RawNextSibling() const { |
| 1536 if (!layout_object_) | 1538 if (!layout_object_) |
| 1537 return 0; | 1539 return 0; |
| 1538 | 1540 |
| 1539 LayoutObject* next_sibling = 0; | 1541 LayoutObject* next_sibling = 0; |
| 1540 | 1542 |
| 1541 LayoutInline* inline_continuation = | 1543 LayoutInline* inline_continuation = |
| 1542 layout_object_->IsLayoutBlockFlow() | 1544 layout_object_->IsLayoutBlockFlow() |
| 1543 ? ToLayoutBlockFlow(layout_object_)->InlineElementContinuation() | 1545 ? ToLayoutBlockFlow(layout_object_)->InlineElementContinuation() |
| 1544 : nullptr; | 1546 : nullptr; |
| 1545 if (inline_continuation) { | 1547 if (inline_continuation) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1593 // If the need to add more children in addition to existing children arises, | 1595 // If the need to add more children in addition to existing children arises, |
| 1594 // childrenChanged should have been called, leaving the object with no | 1596 // childrenChanged should have been called, leaving the object with no |
| 1595 // children. | 1597 // children. |
| 1596 DCHECK(!have_children_); | 1598 DCHECK(!have_children_); |
| 1597 | 1599 |
| 1598 have_children_ = true; | 1600 have_children_ = true; |
| 1599 | 1601 |
| 1600 if (!CanHaveChildren()) | 1602 if (!CanHaveChildren()) |
| 1601 return; | 1603 return; |
| 1602 | 1604 |
| 1603 HeapVector<Member<AXObject>> owned_children; | 1605 HeapVector<Member<AXObjectImpl>> owned_children; |
| 1604 ComputeAriaOwnsChildren(owned_children); | 1606 ComputeAriaOwnsChildren(owned_children); |
| 1605 | 1607 |
| 1606 for (AXObject* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) { | 1608 for (AXObjectImpl* obj = RawFirstChild(); obj; obj = obj->RawNextSibling()) { |
| 1607 if (!AxObjectCache().IsAriaOwned(obj)) { | 1609 if (!AxObjectCache().IsAriaOwned(obj)) { |
| 1608 obj->SetParent(this); | 1610 obj->SetParent(this); |
| 1609 AddChild(obj); | 1611 AddChild(obj); |
| 1610 } | 1612 } |
| 1611 } | 1613 } |
| 1612 | 1614 |
| 1613 AddHiddenChildren(); | 1615 AddHiddenChildren(); |
| 1614 AddPopupChildren(); | 1616 AddPopupChildren(); |
| 1615 AddImageMapChildren(); | 1617 AddImageMapChildren(); |
| 1616 AddTextFieldChildren(); | 1618 AddTextFieldChildren(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1631 if (!layout_object_) | 1633 if (!layout_object_) |
| 1632 return false; | 1634 return false; |
| 1633 | 1635 |
| 1634 return AXNodeObject::CanHaveChildren(); | 1636 return AXNodeObject::CanHaveChildren(); |
| 1635 } | 1637 } |
| 1636 | 1638 |
| 1637 void AXLayoutObject::UpdateChildrenIfNecessary() { | 1639 void AXLayoutObject::UpdateChildrenIfNecessary() { |
| 1638 if (NeedsToUpdateChildren()) | 1640 if (NeedsToUpdateChildren()) |
| 1639 ClearChildren(); | 1641 ClearChildren(); |
| 1640 | 1642 |
| 1641 AXObject::UpdateChildrenIfNecessary(); | 1643 AXObjectImpl::UpdateChildrenIfNecessary(); |
| 1642 } | 1644 } |
| 1643 | 1645 |
| 1644 void AXLayoutObject::ClearChildren() { | 1646 void AXLayoutObject::ClearChildren() { |
| 1645 AXObject::ClearChildren(); | 1647 AXObjectImpl::ClearChildren(); |
| 1646 children_dirty_ = false; | 1648 children_dirty_ = false; |
| 1647 } | 1649 } |
| 1648 | 1650 |
| 1649 // | 1651 // |
| 1650 // Properties of the object's owning document or page. | 1652 // Properties of the object's owning document or page. |
| 1651 // | 1653 // |
| 1652 | 1654 |
| 1653 double AXLayoutObject::EstimatedLoadingProgress() const { | 1655 double AXLayoutObject::EstimatedLoadingProgress() const { |
| 1654 if (!layout_object_) | 1656 if (!layout_object_) |
| 1655 return 0; | 1657 return 0; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1722 return ToElement(&runner); | 1724 return ToElement(&runner); |
| 1723 } | 1725 } |
| 1724 | 1726 |
| 1725 return 0; | 1727 return 0; |
| 1726 } | 1728 } |
| 1727 | 1729 |
| 1728 // | 1730 // |
| 1729 // Functions that retrieve the current selection. | 1731 // Functions that retrieve the current selection. |
| 1730 // | 1732 // |
| 1731 | 1733 |
| 1732 AXObject::AXRange AXLayoutObject::Selection() const { | 1734 AXObjectImpl::AXRange AXLayoutObject::Selection() const { |
| 1733 AXRange text_selection = TextControlSelection(); | 1735 AXRange text_selection = TextControlSelection(); |
| 1734 if (text_selection.IsValid()) | 1736 if (text_selection.IsValid()) |
| 1735 return text_selection; | 1737 return text_selection; |
| 1736 | 1738 |
| 1737 if (!GetLayoutObject() || !GetLayoutObject()->GetFrame()) | 1739 if (!GetLayoutObject() || !GetLayoutObject()->GetFrame()) |
| 1738 return AXRange(); | 1740 return AXRange(); |
| 1739 | 1741 |
| 1740 VisibleSelection selection = | 1742 VisibleSelection selection = |
| 1741 GetLayoutObject() | 1743 GetLayoutObject() |
| 1742 ->GetFrame() | 1744 ->GetFrame() |
| 1743 ->Selection() | 1745 ->Selection() |
| 1744 .ComputeVisibleSelectionInDOMTreeDeprecated(); | 1746 .ComputeVisibleSelectionInDOMTreeDeprecated(); |
| 1745 if (selection.IsNone()) | 1747 if (selection.IsNone()) |
| 1746 return AXRange(); | 1748 return AXRange(); |
| 1747 | 1749 |
| 1748 VisiblePosition visible_start = selection.VisibleStart(); | 1750 VisiblePosition visible_start = selection.VisibleStart(); |
| 1749 Position start = visible_start.ToParentAnchoredPosition(); | 1751 Position start = visible_start.ToParentAnchoredPosition(); |
| 1750 TextAffinity start_affinity = visible_start.Affinity(); | 1752 TextAffinity start_affinity = visible_start.Affinity(); |
| 1751 VisiblePosition visible_end = selection.VisibleEnd(); | 1753 VisiblePosition visible_end = selection.VisibleEnd(); |
| 1752 Position end = visible_end.ToParentAnchoredPosition(); | 1754 Position end = visible_end.ToParentAnchoredPosition(); |
| 1753 TextAffinity end_affinity = visible_end.Affinity(); | 1755 TextAffinity end_affinity = visible_end.Affinity(); |
| 1754 | 1756 |
| 1755 Node* anchor_node = start.AnchorNode(); | 1757 Node* anchor_node = start.AnchorNode(); |
| 1756 DCHECK(anchor_node); | 1758 DCHECK(anchor_node); |
| 1757 | 1759 |
| 1758 AXLayoutObject* anchor_object = nullptr; | 1760 AXLayoutObject* anchor_object = nullptr; |
| 1759 // Find the closest node that has a corresponding AXObject. | 1761 // Find the closest node that has a corresponding AXObjectImpl. |
| 1760 // This is because some nodes may be aria hidden or might not even have | 1762 // This is because some nodes may be aria hidden or might not even have |
| 1761 // a layout object if they are part of the shadow DOM. | 1763 // a layout object if they are part of the shadow DOM. |
| 1762 while (anchor_node) { | 1764 while (anchor_node) { |
| 1763 anchor_object = GetUnignoredObjectFromNode(*anchor_node); | 1765 anchor_object = GetUnignoredObjectFromNode(*anchor_node); |
| 1764 if (anchor_object) | 1766 if (anchor_object) |
| 1765 break; | 1767 break; |
| 1766 | 1768 |
| 1767 if (anchor_node->nextSibling()) | 1769 if (anchor_node->nextSibling()) |
| 1768 anchor_node = anchor_node->nextSibling(); | 1770 anchor_node = anchor_node->nextSibling(); |
| 1769 else | 1771 else |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1792 DCHECK_GE(anchor_offset, 0); | 1794 DCHECK_GE(anchor_offset, 0); |
| 1793 int focus_offset = focus_object->IndexForVisiblePosition(visible_end); | 1795 int focus_offset = focus_object->IndexForVisiblePosition(visible_end); |
| 1794 DCHECK_GE(focus_offset, 0); | 1796 DCHECK_GE(focus_offset, 0); |
| 1795 return AXRange(anchor_object, anchor_offset, start_affinity, focus_object, | 1797 return AXRange(anchor_object, anchor_offset, start_affinity, focus_object, |
| 1796 focus_offset, end_affinity); | 1798 focus_offset, end_affinity); |
| 1797 } | 1799 } |
| 1798 | 1800 |
| 1799 // Gets only the start and end offsets of the selection computed using the | 1801 // Gets only the start and end offsets of the selection computed using the |
| 1800 // current object as the starting point. Returns a null selection if there is | 1802 // current object as the starting point. Returns a null selection if there is |
| 1801 // no selection in the subtree rooted at this object. | 1803 // no selection in the subtree rooted at this object. |
| 1802 AXObject::AXRange AXLayoutObject::SelectionUnderObject() const { | 1804 AXObjectImpl::AXRange AXLayoutObject::SelectionUnderObject() const { |
| 1803 AXRange text_selection = TextControlSelection(); | 1805 AXRange text_selection = TextControlSelection(); |
| 1804 if (text_selection.IsValid()) | 1806 if (text_selection.IsValid()) |
| 1805 return text_selection; | 1807 return text_selection; |
| 1806 | 1808 |
| 1807 if (!GetNode() || !GetLayoutObject()->GetFrame()) | 1809 if (!GetNode() || !GetLayoutObject()->GetFrame()) |
| 1808 return AXRange(); | 1810 return AXRange(); |
| 1809 | 1811 |
| 1810 VisibleSelection selection = | 1812 VisibleSelection selection = |
| 1811 GetLayoutObject() | 1813 GetLayoutObject() |
| 1812 ->GetFrame() | 1814 ->GetFrame() |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1826 } | 1828 } |
| 1827 | 1829 |
| 1828 int start = IndexForVisiblePosition(selection.VisibleStart()); | 1830 int start = IndexForVisiblePosition(selection.VisibleStart()); |
| 1829 DCHECK_GE(start, 0); | 1831 DCHECK_GE(start, 0); |
| 1830 int end = IndexForVisiblePosition(selection.VisibleEnd()); | 1832 int end = IndexForVisiblePosition(selection.VisibleEnd()); |
| 1831 DCHECK_GE(end, 0); | 1833 DCHECK_GE(end, 0); |
| 1832 | 1834 |
| 1833 return AXRange(start, end); | 1835 return AXRange(start, end); |
| 1834 } | 1836 } |
| 1835 | 1837 |
| 1836 AXObject::AXRange AXLayoutObject::TextControlSelection() const { | 1838 AXObjectImpl::AXRange AXLayoutObject::TextControlSelection() const { |
| 1837 if (!GetLayoutObject()) | 1839 if (!GetLayoutObject()) |
| 1838 return AXRange(); | 1840 return AXRange(); |
| 1839 | 1841 |
| 1840 LayoutObject* layout = nullptr; | 1842 LayoutObject* layout = nullptr; |
| 1841 if (GetLayoutObject()->IsTextControl()) { | 1843 if (GetLayoutObject()->IsTextControl()) { |
| 1842 layout = GetLayoutObject(); | 1844 layout = GetLayoutObject(); |
| 1843 } else { | 1845 } else { |
| 1844 Element* focused_element = GetDocument()->FocusedElement(); | 1846 Element* focused_element = GetDocument()->FocusedElement(); |
| 1845 if (focused_element && focused_element->GetLayoutObject() && | 1847 if (focused_element && focused_element->GetLayoutObject() && |
| 1846 focused_element->GetLayoutObject()->IsTextControl()) | 1848 focused_element->GetLayoutObject()->IsTextControl()) |
| 1847 layout = focused_element->GetLayoutObject(); | 1849 layout = focused_element->GetLayoutObject(); |
| 1848 } | 1850 } |
| 1849 | 1851 |
| 1850 if (!layout) | 1852 if (!layout) |
| 1851 return AXRange(); | 1853 return AXRange(); |
| 1852 | 1854 |
| 1853 AXObject* ax_object = AxObjectCache().GetOrCreate(layout); | 1855 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(layout); |
| 1854 if (!ax_object || !ax_object->IsAXLayoutObject()) | 1856 if (!ax_object || !ax_object->IsAXLayoutObject()) |
| 1855 return AXRange(); | 1857 return AXRange(); |
| 1856 | 1858 |
| 1857 VisibleSelection selection = | 1859 VisibleSelection selection = |
| 1858 layout->GetFrame() | 1860 layout->GetFrame() |
| 1859 ->Selection() | 1861 ->Selection() |
| 1860 .ComputeVisibleSelectionInDOMTreeDeprecated(); | 1862 .ComputeVisibleSelectionInDOMTreeDeprecated(); |
| 1861 TextControlElement* text_control = | 1863 TextControlElement* text_control = |
| 1862 ToLayoutTextControl(layout)->GetTextControlElement(); | 1864 ToLayoutTextControl(layout)->GetTextControlElement(); |
| 1863 DCHECK(text_control); | 1865 DCHECK(text_control); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1888 range->setEnd(index_position, IGNORE_EXCEPTION_FOR_TESTING); | 1890 range->setEnd(index_position, IGNORE_EXCEPTION_FOR_TESTING); |
| 1889 | 1891 |
| 1890 return TextIterator::RangeLength(range->StartPosition(), | 1892 return TextIterator::RangeLength(range->StartPosition(), |
| 1891 range->EndPosition()); | 1893 range->EndPosition()); |
| 1892 } | 1894 } |
| 1893 | 1895 |
| 1894 AXLayoutObject* AXLayoutObject::GetUnignoredObjectFromNode(Node& node) const { | 1896 AXLayoutObject* AXLayoutObject::GetUnignoredObjectFromNode(Node& node) const { |
| 1895 if (IsDetached()) | 1897 if (IsDetached()) |
| 1896 return nullptr; | 1898 return nullptr; |
| 1897 | 1899 |
| 1898 AXObject* ax_object = AxObjectCache().GetOrCreate(&node); | 1900 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(&node); |
| 1899 if (!ax_object) | 1901 if (!ax_object) |
| 1900 return nullptr; | 1902 return nullptr; |
| 1901 | 1903 |
| 1902 if (ax_object->IsAXLayoutObject() && !ax_object->AccessibilityIsIgnored()) | 1904 if (ax_object->IsAXLayoutObject() && !ax_object->AccessibilityIsIgnored()) |
| 1903 return ToAXLayoutObject(ax_object); | 1905 return ToAXLayoutObject(ax_object); |
| 1904 | 1906 |
| 1905 return nullptr; | 1907 return nullptr; |
| 1906 } | 1908 } |
| 1907 | 1909 |
| 1908 // | 1910 // |
| 1909 // Modify or take an action on an object. | 1911 // Modify or take an action on an object. |
| 1910 // | 1912 // |
| 1911 | 1913 |
| 1912 // Convert from an accessible object and offset to a VisiblePosition. | 1914 // Convert from an accessible object and offset to a VisiblePosition. |
| 1913 static VisiblePosition ToVisiblePosition(AXObject* obj, int offset) { | 1915 static VisiblePosition ToVisiblePosition(AXObjectImpl* obj, int offset) { |
| 1914 if (!obj->GetNode()) | 1916 if (!obj->GetNode()) |
| 1915 return VisiblePosition(); | 1917 return VisiblePosition(); |
| 1916 | 1918 |
| 1917 Node* node = obj->GetNode(); | 1919 Node* node = obj->GetNode(); |
| 1918 if (!node->IsTextNode()) { | 1920 if (!node->IsTextNode()) { |
| 1919 int child_count = obj->Children().size(); | 1921 int child_count = obj->Children().size(); |
| 1920 | 1922 |
| 1921 // Place position immediately before the container node, if there was no | 1923 // Place position immediately before the container node, if there was no |
| 1922 // children. | 1924 // children. |
| 1923 if (child_count == 0) { | 1925 if (child_count == 0) { |
| 1924 if (!obj->ParentObject()) | 1926 if (!obj->ParentObject()) |
| 1925 return VisiblePosition(); | 1927 return VisiblePosition(); |
| 1926 return ToVisiblePosition(obj->ParentObject(), obj->IndexInParent()); | 1928 return ToVisiblePosition(obj->ParentObject(), obj->IndexInParent()); |
| 1927 } | 1929 } |
| 1928 | 1930 |
| 1929 // The offsets are child offsets over the AX tree. Note that we allow | 1931 // The offsets are child offsets over the AX tree. Note that we allow |
| 1930 // for the offset to equal the number of children as |Range| does. | 1932 // for the offset to equal the number of children as |Range| does. |
| 1931 if (offset < 0 || offset > child_count) | 1933 if (offset < 0 || offset > child_count) |
| 1932 return VisiblePosition(); | 1934 return VisiblePosition(); |
| 1933 | 1935 |
| 1934 // Clamp to between 0 and child count - 1. | 1936 // Clamp to between 0 and child count - 1. |
| 1935 int clamped_offset = | 1937 int clamped_offset = |
| 1936 static_cast<unsigned>(offset) > (obj->Children().size() - 1) | 1938 static_cast<unsigned>(offset) > (obj->Children().size() - 1) |
| 1937 ? offset - 1 | 1939 ? offset - 1 |
| 1938 : offset; | 1940 : offset; |
| 1939 AXObject* child_obj = obj->Children()[clamped_offset]; | 1941 AXObjectImpl* child_obj = obj->Children()[clamped_offset]; |
| 1940 Node* child_node = child_obj->GetNode(); | 1942 Node* child_node = child_obj->GetNode(); |
| 1941 if (!child_node || !child_node->parentNode()) | 1943 if (!child_node || !child_node->parentNode()) |
| 1942 return VisiblePosition(); | 1944 return VisiblePosition(); |
| 1943 | 1945 |
| 1944 // The index in parent. | 1946 // The index in parent. |
| 1945 int adjusted_offset = child_node->NodeIndex(); | 1947 int adjusted_offset = child_node->NodeIndex(); |
| 1946 | 1948 |
| 1947 // If we had to clamp the offset above, the client wants to select the | 1949 // If we had to clamp the offset above, the client wants to select the |
| 1948 // end of the node. | 1950 // end of the node. |
| 1949 if (clamped_offset != offset) | 1951 if (clamped_offset != offset) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1962 | 1964 |
| 1963 VisiblePosition node_position = blink::VisiblePositionBeforeNode(*node); | 1965 VisiblePosition node_position = blink::VisiblePositionBeforeNode(*node); |
| 1964 int node_index = blink::IndexForVisiblePosition(node_position, parent); | 1966 int node_index = blink::IndexForVisiblePosition(node_position, parent); |
| 1965 return blink::VisiblePositionForIndex(node_index + offset, parent); | 1967 return blink::VisiblePositionForIndex(node_index + offset, parent); |
| 1966 } | 1968 } |
| 1967 | 1969 |
| 1968 void AXLayoutObject::SetSelection(const AXRange& selection) { | 1970 void AXLayoutObject::SetSelection(const AXRange& selection) { |
| 1969 if (!GetLayoutObject() || !selection.IsValid()) | 1971 if (!GetLayoutObject() || !selection.IsValid()) |
| 1970 return; | 1972 return; |
| 1971 | 1973 |
| 1972 AXObject* anchor_object = | 1974 AXObjectImpl* anchor_object = |
| 1973 selection.anchor_object ? selection.anchor_object.Get() : this; | 1975 selection.anchor_object ? selection.anchor_object.Get() : this; |
| 1974 AXObject* focus_object = | 1976 AXObjectImpl* focus_object = |
| 1975 selection.focus_object ? selection.focus_object.Get() : this; | 1977 selection.focus_object ? selection.focus_object.Get() : this; |
| 1976 | 1978 |
| 1977 if (!IsValidSelectionBound(anchor_object) || | 1979 if (!IsValidSelectionBound(anchor_object) || |
| 1978 !IsValidSelectionBound(focus_object)) { | 1980 !IsValidSelectionBound(focus_object)) { |
| 1979 return; | 1981 return; |
| 1980 } | 1982 } |
| 1981 | 1983 |
| 1982 // The selection offsets are offsets into the accessible value. | 1984 // The selection offsets are offsets into the accessible value. |
| 1983 if (anchor_object == focus_object && | 1985 if (anchor_object == focus_object && |
| 1984 anchor_object->GetLayoutObject()->IsTextControl()) { | 1986 anchor_object->GetLayoutObject()->IsTextControl()) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2016 if (anchor_visible_position.IsNull() || focus_visible_position.IsNull()) | 2018 if (anchor_visible_position.IsNull() || focus_visible_position.IsNull()) |
| 2017 return; | 2019 return; |
| 2018 | 2020 |
| 2019 frame->Selection().SetSelection( | 2021 frame->Selection().SetSelection( |
| 2020 SelectionInDOMTree::Builder() | 2022 SelectionInDOMTree::Builder() |
| 2021 .Collapse(anchor_visible_position.ToPositionWithAffinity()) | 2023 .Collapse(anchor_visible_position.ToPositionWithAffinity()) |
| 2022 .Extend(focus_visible_position.DeepEquivalent()) | 2024 .Extend(focus_visible_position.DeepEquivalent()) |
| 2023 .Build()); | 2025 .Build()); |
| 2024 } | 2026 } |
| 2025 | 2027 |
| 2026 bool AXLayoutObject::IsValidSelectionBound(const AXObject* bound_object) const { | 2028 bool AXLayoutObject::IsValidSelectionBound( |
| 2029 const AXObjectImpl* bound_object) const { |
| 2027 return GetLayoutObject() && bound_object && !bound_object->IsDetached() && | 2030 return GetLayoutObject() && bound_object && !bound_object->IsDetached() && |
| 2028 bound_object->IsAXLayoutObject() && bound_object->GetLayoutObject() && | 2031 bound_object->IsAXLayoutObject() && bound_object->GetLayoutObject() && |
| 2029 bound_object->GetLayoutObject()->GetFrame() == | 2032 bound_object->GetLayoutObject()->GetFrame() == |
| 2030 GetLayoutObject()->GetFrame() && | 2033 GetLayoutObject()->GetFrame() && |
| 2031 &bound_object->AxObjectCache() == &AxObjectCache(); | 2034 &bound_object->AxObjectCache() == &AxObjectCache(); |
| 2032 } | 2035 } |
| 2033 | 2036 |
| 2034 void AXLayoutObject::SetValue(const String& string) { | 2037 void AXLayoutObject::SetValue(const String& string) { |
| 2035 if (!GetNode() || !GetNode()->IsElementNode()) | 2038 if (!GetNode() || !GetNode()->IsElementNode()) |
| 2036 return; | 2039 return; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 2047 } | 2050 } |
| 2048 | 2051 |
| 2049 // | 2052 // |
| 2050 // Notifications that this object may have changed. | 2053 // Notifications that this object may have changed. |
| 2051 // | 2054 // |
| 2052 | 2055 |
| 2053 void AXLayoutObject::HandleActiveDescendantChanged() { | 2056 void AXLayoutObject::HandleActiveDescendantChanged() { |
| 2054 if (!GetLayoutObject()) | 2057 if (!GetLayoutObject()) |
| 2055 return; | 2058 return; |
| 2056 | 2059 |
| 2057 AXObject* focused_object = AxObjectCache().FocusedObject(); | 2060 AXObjectImpl* focused_object = AxObjectCache().FocusedObject(); |
| 2058 if (focused_object == this && SupportsActiveDescendant()) { | 2061 if (focused_object == this && SupportsActiveDescendant()) { |
| 2059 AxObjectCache().PostNotification( | 2062 AxObjectCache().PostNotification( |
| 2060 GetLayoutObject(), AXObjectCacheImpl::kAXActiveDescendantChanged); | 2063 GetLayoutObject(), AXObjectCacheImpl::kAXActiveDescendantChanged); |
| 2061 } | 2064 } |
| 2062 } | 2065 } |
| 2063 | 2066 |
| 2064 void AXLayoutObject::HandleAriaExpandedChanged() { | 2067 void AXLayoutObject::HandleAriaExpandedChanged() { |
| 2065 // Find if a parent of this object should handle aria-expanded changes. | 2068 // Find if a parent of this object should handle aria-expanded changes. |
| 2066 AXObject* container_parent = this->ParentObject(); | 2069 AXObjectImpl* container_parent = this->ParentObject(); |
| 2067 while (container_parent) { | 2070 while (container_parent) { |
| 2068 bool found_parent = false; | 2071 bool found_parent = false; |
| 2069 | 2072 |
| 2070 switch (container_parent->RoleValue()) { | 2073 switch (container_parent->RoleValue()) { |
| 2071 case kTreeRole: | 2074 case kTreeRole: |
| 2072 case kTreeGridRole: | 2075 case kTreeGridRole: |
| 2073 case kGridRole: | 2076 case kGridRole: |
| 2074 case kTableRole: | 2077 case kTableRole: |
| 2075 found_parent = true; | 2078 found_parent = true; |
| 2076 break; | 2079 break; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 // If a LayoutText needs layout, its inline text boxes are either | 2179 // If a LayoutText needs layout, its inline text boxes are either |
| 2177 // nonexistent or invalid, so defer until the layout happens and | 2180 // nonexistent or invalid, so defer until the layout happens and |
| 2178 // the layoutObject calls AXObjectCacheImpl::inlineTextBoxesUpdated. | 2181 // the layoutObject calls AXObjectCacheImpl::inlineTextBoxesUpdated. |
| 2179 return; | 2182 return; |
| 2180 } | 2183 } |
| 2181 | 2184 |
| 2182 LayoutText* layout_text = ToLayoutText(GetLayoutObject()); | 2185 LayoutText* layout_text = ToLayoutText(GetLayoutObject()); |
| 2183 for (RefPtr<AbstractInlineTextBox> box = | 2186 for (RefPtr<AbstractInlineTextBox> box = |
| 2184 layout_text->FirstAbstractInlineTextBox(); | 2187 layout_text->FirstAbstractInlineTextBox(); |
| 2185 box.Get(); box = box->NextInlineTextBox()) { | 2188 box.Get(); box = box->NextInlineTextBox()) { |
| 2186 AXObject* ax_object = AxObjectCache().GetOrCreate(box.Get()); | 2189 AXObjectImpl* ax_object = AxObjectCache().GetOrCreate(box.Get()); |
| 2187 if (!ax_object->AccessibilityIsIgnored()) | 2190 if (!ax_object->AccessibilityIsIgnored()) |
| 2188 children_.push_back(ax_object); | 2191 children_.push_back(ax_object); |
| 2189 } | 2192 } |
| 2190 } | 2193 } |
| 2191 | 2194 |
| 2192 void AXLayoutObject::LineBreaks(Vector<int>& line_breaks) const { | 2195 void AXLayoutObject::LineBreaks(Vector<int>& line_breaks) const { |
| 2193 if (!IsTextControl()) | 2196 if (!IsTextControl()) |
| 2194 return; | 2197 return; |
| 2195 | 2198 |
| 2196 VisiblePosition visible_pos = VisiblePositionForIndex(0); | 2199 VisiblePosition visible_pos = VisiblePositionForIndex(0); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2209 if (visible_pos.DeepEquivalent().CompareTo( | 2212 if (visible_pos.DeepEquivalent().CompareTo( |
| 2210 prev_visible_pos.DeepEquivalent()) < 0) | 2213 prev_visible_pos.DeepEquivalent()) < 0) |
| 2211 break; | 2214 break; |
| 2212 } | 2215 } |
| 2213 } | 2216 } |
| 2214 | 2217 |
| 2215 // | 2218 // |
| 2216 // Private. | 2219 // Private. |
| 2217 // | 2220 // |
| 2218 | 2221 |
| 2219 AXObject* AXLayoutObject::TreeAncestorDisallowingChild() const { | 2222 AXObjectImpl* AXLayoutObject::TreeAncestorDisallowingChild() const { |
| 2220 // Determine if this is in a tree. If so, we apply special behavior to make it | 2223 // Determine if this is in a tree. If so, we apply special behavior to make it |
| 2221 // work like an AXOutline. | 2224 // work like an AXOutline. |
| 2222 AXObject* ax_obj = ParentObject(); | 2225 AXObjectImpl* ax_obj = ParentObject(); |
| 2223 AXObject* tree_ancestor = 0; | 2226 AXObjectImpl* tree_ancestor = 0; |
| 2224 while (ax_obj) { | 2227 while (ax_obj) { |
| 2225 if (ax_obj->IsTree()) { | 2228 if (ax_obj->IsTree()) { |
| 2226 tree_ancestor = ax_obj; | 2229 tree_ancestor = ax_obj; |
| 2227 break; | 2230 break; |
| 2228 } | 2231 } |
| 2229 ax_obj = ax_obj->ParentObject(); | 2232 ax_obj = ax_obj->ParentObject(); |
| 2230 } | 2233 } |
| 2231 | 2234 |
| 2232 // If the object is in a tree, only tree items should be exposed (and the | 2235 // If the object is in a tree, only tree items should be exposed (and the |
| 2233 // children of tree items). | 2236 // children of tree items). |
| 2234 if (tree_ancestor) { | 2237 if (tree_ancestor) { |
| 2235 AccessibilityRole role = RoleValue(); | 2238 AccessibilityRole role = RoleValue(); |
| 2236 if (role != kTreeItemRole && role != kStaticTextRole) | 2239 if (role != kTreeItemRole && role != kStaticTextRole) |
| 2237 return tree_ancestor; | 2240 return tree_ancestor; |
| 2238 } | 2241 } |
| 2239 return 0; | 2242 return 0; |
| 2240 } | 2243 } |
| 2241 | 2244 |
| 2242 bool AXLayoutObject::IsTabItemSelected() const { | 2245 bool AXLayoutObject::IsTabItemSelected() const { |
| 2243 if (!IsTabItem() || !GetLayoutObject()) | 2246 if (!IsTabItem() || !GetLayoutObject()) |
| 2244 return false; | 2247 return false; |
| 2245 | 2248 |
| 2246 Node* node = GetNode(); | 2249 Node* node = GetNode(); |
| 2247 if (!node || !node->IsElementNode()) | 2250 if (!node || !node->IsElementNode()) |
| 2248 return false; | 2251 return false; |
| 2249 | 2252 |
| 2250 // The ARIA spec says a tab item can also be selected if it is aria-labeled by | 2253 // The ARIA spec says a tab item can also be selected if it is aria-labeled by |
| 2251 // a tabpanel that has keyboard focus inside of it, or if a tabpanel in its | 2254 // a tabpanel that has keyboard focus inside of it, or if a tabpanel in its |
| 2252 // aria-controls list has KB focus inside of it. | 2255 // aria-controls list has KB focus inside of it. |
| 2253 AXObject* focused_element = AxObjectCache().FocusedObject(); | 2256 AXObjectImpl* focused_element = AxObjectCache().FocusedObject(); |
| 2254 if (!focused_element) | 2257 if (!focused_element) |
| 2255 return false; | 2258 return false; |
| 2256 | 2259 |
| 2257 HeapVector<Member<Element>> elements; | 2260 HeapVector<Member<Element>> elements; |
| 2258 ElementsFromAttribute(elements, aria_controlsAttr); | 2261 ElementsFromAttribute(elements, aria_controlsAttr); |
| 2259 | 2262 |
| 2260 for (const auto& element : elements) { | 2263 for (const auto& element : elements) { |
| 2261 AXObject* tab_panel = AxObjectCache().GetOrCreate(element); | 2264 AXObjectImpl* tab_panel = AxObjectCache().GetOrCreate(element); |
| 2262 | 2265 |
| 2263 // A tab item should only control tab panels. | 2266 // A tab item should only control tab panels. |
| 2264 if (!tab_panel || tab_panel->RoleValue() != kTabPanelRole) | 2267 if (!tab_panel || tab_panel->RoleValue() != kTabPanelRole) |
| 2265 continue; | 2268 continue; |
| 2266 | 2269 |
| 2267 AXObject* check_focus_element = focused_element; | 2270 AXObjectImpl* check_focus_element = focused_element; |
| 2268 // Check if the focused element is a descendant of the element controlled by | 2271 // Check if the focused element is a descendant of the element controlled by |
| 2269 // the tab item. | 2272 // the tab item. |
| 2270 while (check_focus_element) { | 2273 while (check_focus_element) { |
| 2271 if (tab_panel == check_focus_element) | 2274 if (tab_panel == check_focus_element) |
| 2272 return true; | 2275 return true; |
| 2273 check_focus_element = check_focus_element->ParentObject(); | 2276 check_focus_element = check_focus_element->ParentObject(); |
| 2274 } | 2277 } |
| 2275 } | 2278 } |
| 2276 | 2279 |
| 2277 return false; | 2280 return false; |
| 2278 } | 2281 } |
| 2279 | 2282 |
| 2280 AXObject* AXLayoutObject::AccessibilityImageMapHitTest( | 2283 AXObjectImpl* AXLayoutObject::AccessibilityImageMapHitTest( |
| 2281 HTMLAreaElement* area, | 2284 HTMLAreaElement* area, |
| 2282 const IntPoint& point) const { | 2285 const IntPoint& point) const { |
| 2283 if (!area) | 2286 if (!area) |
| 2284 return 0; | 2287 return 0; |
| 2285 | 2288 |
| 2286 AXObject* parent = AxObjectCache().GetOrCreate(area->ImageElement()); | 2289 AXObjectImpl* parent = AxObjectCache().GetOrCreate(area->ImageElement()); |
| 2287 if (!parent) | 2290 if (!parent) |
| 2288 return 0; | 2291 return 0; |
| 2289 | 2292 |
| 2290 for (const auto& child : parent->Children()) { | 2293 for (const auto& child : parent->Children()) { |
| 2291 if (child->GetBoundsInFrameCoordinates().Contains(point)) | 2294 if (child->GetBoundsInFrameCoordinates().Contains(point)) |
| 2292 return child.Get(); | 2295 return child.Get(); |
| 2293 } | 2296 } |
| 2294 | 2297 |
| 2295 return 0; | 2298 return 0; |
| 2296 } | 2299 } |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 root->SetParent(0); | 2357 root->SetParent(0); |
| 2355 } | 2358 } |
| 2356 | 2359 |
| 2357 AXSVGRoot* AXLayoutObject::RemoteSVGRootElement() const { | 2360 AXSVGRoot* AXLayoutObject::RemoteSVGRootElement() const { |
| 2358 // FIXME(dmazzoni): none of this code properly handled multiple references to | 2361 // FIXME(dmazzoni): none of this code properly handled multiple references to |
| 2359 // the same remote SVG document. I'm disabling this support until it can be | 2362 // the same remote SVG document. I'm disabling this support until it can be |
| 2360 // fixed properly. | 2363 // fixed properly. |
| 2361 return 0; | 2364 return 0; |
| 2362 } | 2365 } |
| 2363 | 2366 |
| 2364 AXObject* AXLayoutObject::RemoteSVGElementHitTest(const IntPoint& point) const { | 2367 AXObjectImpl* AXLayoutObject::RemoteSVGElementHitTest( |
| 2365 AXObject* remote = RemoteSVGRootElement(); | 2368 const IntPoint& point) const { |
| 2369 AXObjectImpl* remote = RemoteSVGRootElement(); |
| 2366 if (!remote) | 2370 if (!remote) |
| 2367 return 0; | 2371 return 0; |
| 2368 | 2372 |
| 2369 IntSize offset = | 2373 IntSize offset = |
| 2370 point - RoundedIntPoint(GetBoundsInFrameCoordinates().Location()); | 2374 point - RoundedIntPoint(GetBoundsInFrameCoordinates().Location()); |
| 2371 return remote->AccessibilityHitTest(IntPoint(offset)); | 2375 return remote->AccessibilityHitTest(IntPoint(offset)); |
| 2372 } | 2376 } |
| 2373 | 2377 |
| 2374 // The boundingBox for elements within the remote SVG element needs to be offset | 2378 // The boundingBox for elements within the remote SVG element needs to be offset |
| 2375 // by its position within the parent page, otherwise they are in relative | 2379 // by its position within the parent page, otherwise they are in relative |
| 2376 // coordinates only. | 2380 // coordinates only. |
| 2377 void AXLayoutObject::OffsetBoundingBoxForRemoteSVGElement( | 2381 void AXLayoutObject::OffsetBoundingBoxForRemoteSVGElement( |
| 2378 LayoutRect& rect) const { | 2382 LayoutRect& rect) const { |
| 2379 for (AXObject* parent = ParentObject(); parent; | 2383 for (AXObjectImpl* parent = ParentObject(); parent; |
| 2380 parent = parent->ParentObject()) { | 2384 parent = parent->ParentObject()) { |
| 2381 if (parent->IsAXSVGRoot()) { | 2385 if (parent->IsAXSVGRoot()) { |
| 2382 rect.MoveBy( | 2386 rect.MoveBy( |
| 2383 parent->ParentObject()->GetBoundsInFrameCoordinates().Location()); | 2387 parent->ParentObject()->GetBoundsInFrameCoordinates().Location()); |
| 2384 break; | 2388 break; |
| 2385 } | 2389 } |
| 2386 } | 2390 } |
| 2387 } | 2391 } |
| 2388 | 2392 |
| 2389 // Hidden children are those that are not laid out or visible, but are | 2393 // Hidden children are those that are not laid out or visible, but are |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2408 if (!should_insert_hidden_nodes) | 2412 if (!should_insert_hidden_nodes) |
| 2409 return; | 2413 return; |
| 2410 | 2414 |
| 2411 // Iterate through all of the children, including those that may have already | 2415 // Iterate through all of the children, including those that may have already |
| 2412 // been added, and try to insert hidden nodes in the correct place in the DOM | 2416 // been added, and try to insert hidden nodes in the correct place in the DOM |
| 2413 // order. | 2417 // order. |
| 2414 unsigned insertion_index = 0; | 2418 unsigned insertion_index = 0; |
| 2415 for (Node& child : NodeTraversal::ChildrenOf(*node)) { | 2419 for (Node& child : NodeTraversal::ChildrenOf(*node)) { |
| 2416 if (child.GetLayoutObject()) { | 2420 if (child.GetLayoutObject()) { |
| 2417 // Find out where the last layout sibling is located within m_children. | 2421 // Find out where the last layout sibling is located within m_children. |
| 2418 if (AXObject* child_object = | 2422 if (AXObjectImpl* child_object = |
| 2419 AxObjectCache().Get(child.GetLayoutObject())) { | 2423 AxObjectCache().Get(child.GetLayoutObject())) { |
| 2420 if (child_object->AccessibilityIsIgnored()) { | 2424 if (child_object->AccessibilityIsIgnored()) { |
| 2421 const auto& children = child_object->Children(); | 2425 const auto& children = child_object->Children(); |
| 2422 child_object = children.size() ? children.back().Get() : 0; | 2426 child_object = children.size() ? children.back().Get() : 0; |
| 2423 } | 2427 } |
| 2424 if (child_object) | 2428 if (child_object) |
| 2425 insertion_index = children_.Find(child_object) + 1; | 2429 insertion_index = children_.Find(child_object) + 1; |
| 2426 continue; | 2430 continue; |
| 2427 } | 2431 } |
| 2428 } | 2432 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2463 if (!css_box || !css_box->IsLayoutImage()) | 2467 if (!css_box || !css_box->IsLayoutImage()) |
| 2464 return; | 2468 return; |
| 2465 | 2469 |
| 2466 HTMLMapElement* map = ToLayoutImage(css_box)->ImageMap(); | 2470 HTMLMapElement* map = ToLayoutImage(css_box)->ImageMap(); |
| 2467 if (!map) | 2471 if (!map) |
| 2468 return; | 2472 return; |
| 2469 | 2473 |
| 2470 for (HTMLAreaElement& area : | 2474 for (HTMLAreaElement& area : |
| 2471 Traversal<HTMLAreaElement>::DescendantsOf(*map)) { | 2475 Traversal<HTMLAreaElement>::DescendantsOf(*map)) { |
| 2472 // add an <area> element for this child if it has a link | 2476 // add an <area> element for this child if it has a link |
| 2473 AXObject* obj = AxObjectCache().GetOrCreate(&area); | 2477 AXObjectImpl* obj = AxObjectCache().GetOrCreate(&area); |
| 2474 if (obj) { | 2478 if (obj) { |
| 2475 AXImageMapLink* area_object = ToAXImageMapLink(obj); | 2479 AXImageMapLink* area_object = ToAXImageMapLink(obj); |
| 2476 area_object->SetParent(this); | 2480 area_object->SetParent(this); |
| 2477 DCHECK(area_object->AxObjectID() != 0); | 2481 DCHECK(area_object->AxObjectID() != 0); |
| 2478 if (!area_object->AccessibilityIsIgnored()) | 2482 if (!area_object->AccessibilityIsIgnored()) |
| 2479 children_.push_back(area_object); | 2483 children_.push_back(area_object); |
| 2480 else | 2484 else |
| 2481 AxObjectCache().Remove(area_object->AxObjectID()); | 2485 AxObjectCache().Remove(area_object->AxObjectID()); |
| 2482 } | 2486 } |
| 2483 } | 2487 } |
| 2484 } | 2488 } |
| 2485 | 2489 |
| 2486 void AXLayoutObject::AddCanvasChildren() { | 2490 void AXLayoutObject::AddCanvasChildren() { |
| 2487 if (!isHTMLCanvasElement(GetNode())) | 2491 if (!isHTMLCanvasElement(GetNode())) |
| 2488 return; | 2492 return; |
| 2489 | 2493 |
| 2490 // If it's a canvas, it won't have laid out children, but it might have | 2494 // If it's a canvas, it won't have laid out children, but it might have |
| 2491 // accessible fallback content. Clear m_haveChildren because | 2495 // accessible fallback content. Clear m_haveChildren because |
| 2492 // AXNodeObject::addChildren will expect it to be false. | 2496 // AXNodeObject::addChildren will expect it to be false. |
| 2493 DCHECK(!children_.size()); | 2497 DCHECK(!children_.size()); |
| 2494 have_children_ = false; | 2498 have_children_ = false; |
| 2495 AXNodeObject::AddChildren(); | 2499 AXNodeObject::AddChildren(); |
| 2496 } | 2500 } |
| 2497 | 2501 |
| 2498 void AXLayoutObject::AddPopupChildren() { | 2502 void AXLayoutObject::AddPopupChildren() { |
| 2499 if (!isHTMLInputElement(GetNode())) | 2503 if (!isHTMLInputElement(GetNode())) |
| 2500 return; | 2504 return; |
| 2501 if (AXObject* ax_popup = toHTMLInputElement(GetNode())->PopupRootAXObject()) | 2505 if (AXObjectImpl* ax_popup = |
| 2506 toHTMLInputElement(GetNode())->PopupRootAXObject()) |
| 2502 children_.push_back(ax_popup); | 2507 children_.push_back(ax_popup); |
| 2503 } | 2508 } |
| 2504 | 2509 |
| 2505 void AXLayoutObject::AddRemoteSVGChildren() { | 2510 void AXLayoutObject::AddRemoteSVGChildren() { |
| 2506 AXSVGRoot* root = RemoteSVGRootElement(); | 2511 AXSVGRoot* root = RemoteSVGRootElement(); |
| 2507 if (!root) | 2512 if (!root) |
| 2508 return; | 2513 return; |
| 2509 | 2514 |
| 2510 root->SetParent(this); | 2515 root->SetParent(this); |
| 2511 | 2516 |
| 2512 if (root->AccessibilityIsIgnored()) { | 2517 if (root->AccessibilityIsIgnored()) { |
| 2513 for (const auto& child : root->Children()) | 2518 for (const auto& child : root->Children()) |
| 2514 children_.push_back(child); | 2519 children_.push_back(child); |
| 2515 } else { | 2520 } else { |
| 2516 children_.push_back(root); | 2521 children_.push_back(root); |
| 2517 } | 2522 } |
| 2518 } | 2523 } |
| 2519 | 2524 |
| 2520 bool AXLayoutObject::ElementAttributeValue( | 2525 bool AXLayoutObject::ElementAttributeValue( |
| 2521 const QualifiedName& attribute_name) const { | 2526 const QualifiedName& attribute_name) const { |
| 2522 if (!layout_object_) | 2527 if (!layout_object_) |
| 2523 return false; | 2528 return false; |
| 2524 | 2529 |
| 2525 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true"); | 2530 return EqualIgnoringASCIICase(GetAttribute(attribute_name), "true"); |
| 2526 } | 2531 } |
| 2527 | 2532 |
| 2528 } // namespace blink | 2533 } // namespace blink |
| OLD | NEW |