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