OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2008, 2009, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 case kSpinButtonRole: | 526 case kSpinButtonRole: |
527 case kTabRole: | 527 case kTabRole: |
528 case kTextFieldRole: | 528 case kTextFieldRole: |
529 case kToggleButtonRole: | 529 case kToggleButtonRole: |
530 return true; | 530 return true; |
531 default: | 531 default: |
532 return false; | 532 return false; |
533 } | 533 } |
534 } | 534 } |
535 | 535 |
536 bool AXObject::AccessibilityIsIgnored() const { | 536 bool AXObject::AccessibilityIsIgnored() { |
537 Node* node = GetNode(); | |
538 if (!node) { | |
539 AXObject* parent = this->ParentObject(); | |
540 while (!node && parent) { | |
541 node = parent->GetNode(); | |
542 parent = parent->ParentObject(); | |
543 } | |
544 } | |
545 | |
546 if (node) | |
547 node->UpdateDistribution(); | |
548 | |
549 // TODO(aboxhall): Instead of this, propagate inert down through frames | |
550 Document* document = GetDocument(); | |
551 if (document && document->LocalOwner()) | |
552 document->LocalOwner()->UpdateDistribution(); | |
esprehn
2017/05/12 21:16:54
Why are you updating the distribution of the paren
aboxhall
2017/05/18 01:30:49
It crashes (DCHECK fails) without this in certain
| |
553 | |
537 UpdateCachedAttributeValuesIfNeeded(); | 554 UpdateCachedAttributeValuesIfNeeded(); |
538 return cached_is_ignored_; | 555 return cached_is_ignored_; |
539 } | 556 } |
540 | 557 |
541 void AXObject::UpdateCachedAttributeValuesIfNeeded() const { | 558 void AXObject::UpdateCachedAttributeValuesIfNeeded() const { |
542 if (IsDetached()) | 559 if (IsDetached()) |
543 return; | 560 return; |
544 | 561 |
545 AXObjectCacheImpl& cache = AxObjectCache(); | 562 AXObjectCacheImpl& cache = AxObjectCache(); |
546 | 563 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
608 if (GetNode()) { | 625 if (GetNode()) { |
609 if (GetNode()->IsInert()) { | 626 if (GetNode()->IsInert()) { |
610 if (ignored_reasons) { | 627 if (ignored_reasons) { |
611 HTMLDialogElement* dialog = GetActiveDialogElement(GetNode()); | 628 HTMLDialogElement* dialog = GetActiveDialogElement(GetNode()); |
612 if (dialog) { | 629 if (dialog) { |
613 AXObject* dialog_object = AxObjectCache().GetOrCreate(dialog); | 630 AXObject* dialog_object = AxObjectCache().GetOrCreate(dialog); |
614 if (dialog_object) | 631 if (dialog_object) |
615 ignored_reasons->push_back( | 632 ignored_reasons->push_back( |
616 IgnoredReason(kAXActiveModalDialog, dialog_object)); | 633 IgnoredReason(kAXActiveModalDialog, dialog_object)); |
617 else | 634 else |
618 ignored_reasons->push_back(IgnoredReason(kAXInert)); | 635 ignored_reasons->push_back(IgnoredReason(kAXInertElement)); |
619 } else { | 636 } else { |
620 // TODO(aboxhall): handle inert attribute if it eventuates | 637 const AXObject* inert_root_el = InertRoot(); |
621 ignored_reasons->push_back(IgnoredReason(kAXInert)); | 638 if (inert_root_el == this) { |
639 ignored_reasons->push_back(IgnoredReason(kAXInertElement)); | |
640 } else { | |
641 ignored_reasons->push_back( | |
642 IgnoredReason(kAXInertSubtree, inert_root_el)); | |
643 } | |
622 } | 644 } |
623 } | 645 } |
624 return true; | 646 return true; |
625 } | 647 } |
626 } else { | 648 } else { |
627 AXObject* parent = ParentObject(); | 649 AXObject* parent = ParentObject(); |
628 if (parent && parent->IsInertOrAriaHidden()) { | 650 if (parent && parent->IsInertOrAriaHidden()) { |
629 if (ignored_reasons) | 651 if (ignored_reasons) |
630 parent->ComputeIsInertOrAriaHidden(ignored_reasons); | 652 parent->ComputeIsInertOrAriaHidden(ignored_reasons); |
631 return true; | 653 return true; |
632 } | 654 } |
633 } | 655 } |
634 | 656 |
635 const AXObject* hidden_root = AriaHiddenRoot(); | 657 const AXObject* hidden_root = AriaHiddenRoot(); |
636 if (hidden_root) { | 658 if (hidden_root) { |
637 if (ignored_reasons) { | 659 if (ignored_reasons) { |
638 if (hidden_root == this) | 660 if (hidden_root == this) { |
639 ignored_reasons->push_back(IgnoredReason(kAXAriaHidden)); | 661 ignored_reasons->push_back(IgnoredReason(kAXAriaHiddenElement)); |
640 else | 662 } else { |
641 ignored_reasons->push_back( | 663 ignored_reasons->push_back( |
642 IgnoredReason(kAXAriaHiddenRoot, hidden_root)); | 664 IgnoredReason(kAXAriaHiddenSubtree, hidden_root)); |
665 } | |
643 } | 666 } |
644 return true; | 667 return true; |
645 } | 668 } |
646 | 669 |
647 return false; | 670 return false; |
648 } | 671 } |
649 | 672 |
650 bool AXObject::IsDescendantOfLeafNode() const { | 673 bool AXObject::IsDescendantOfLeafNode() const { |
651 UpdateCachedAttributeValuesIfNeeded(); | 674 UpdateCachedAttributeValuesIfNeeded(); |
652 return cached_is_descendant_of_leaf_node_; | 675 return cached_is_descendant_of_leaf_node_; |
(...skipping 12 matching lines...) Expand all Loading... | |
665 | 688 |
666 const AXObject* AXObject::AriaHiddenRoot() const { | 689 const AXObject* AXObject::AriaHiddenRoot() const { |
667 for (const AXObject* object = this; object; object = object->ParentObject()) { | 690 for (const AXObject* object = this; object; object = object->ParentObject()) { |
668 if (EqualIgnoringASCIICase(object->GetAttribute(aria_hiddenAttr), "true")) | 691 if (EqualIgnoringASCIICase(object->GetAttribute(aria_hiddenAttr), "true")) |
669 return object; | 692 return object; |
670 } | 693 } |
671 | 694 |
672 return 0; | 695 return 0; |
673 } | 696 } |
674 | 697 |
698 const AXObject* AXObject::InertRoot() const { | |
699 const AXObject* object = this; | |
700 if (!RuntimeEnabledFeatures::inertAttributeEnabled()) | |
701 return 0; | |
702 | |
703 while (object && !object->IsAXNodeObject()) | |
704 object = object->ParentObject(); | |
705 Node* node = object->GetNode(); | |
706 Element* element = node->IsElementNode() | |
707 ? ToElement(node) | |
708 : FlatTreeTraversal::ParentElement(*node); | |
esprehn
2017/05/12 21:16:54
You could add FlatTreeTraversal::ParentElementOrSe
aboxhall
2017/05/18 01:30:49
This actually doesn't seem to be a super common ca
| |
709 while (element) { | |
710 if (element->hasAttribute(inertAttr)) | |
711 return AxObjectCache().GetOrCreate(element); | |
712 element = FlatTreeTraversal::ParentElement(*element); | |
713 } | |
714 | |
715 return 0; | |
716 } | |
717 | |
675 bool AXObject::IsDescendantOfDisabledNode() const { | 718 bool AXObject::IsDescendantOfDisabledNode() const { |
676 UpdateCachedAttributeValuesIfNeeded(); | 719 UpdateCachedAttributeValuesIfNeeded(); |
677 return cached_is_descendant_of_disabled_node_; | 720 return cached_is_descendant_of_disabled_node_; |
678 } | 721 } |
679 | 722 |
680 const AXObject* AXObject::DisabledAncestor() const { | 723 const AXObject* AXObject::DisabledAncestor() const { |
681 const AtomicString& disabled = GetAttribute(aria_disabledAttr); | 724 const AtomicString& disabled = GetAttribute(aria_disabledAttr); |
682 if (EqualIgnoringASCIICase(disabled, "true")) | 725 if (EqualIgnoringASCIICase(disabled, "true")) |
683 return this; | 726 return this; |
684 if (EqualIgnoringASCIICase(disabled, "false")) | 727 if (EqualIgnoringASCIICase(disabled, "false")) |
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1209 void AXObject::ClearChildren() { | 1252 void AXObject::ClearChildren() { |
1210 // Detach all weak pointers from objects to their parents. | 1253 // Detach all weak pointers from objects to their parents. |
1211 for (const auto& child : children_) | 1254 for (const auto& child : children_) |
1212 child->DetachFromParent(); | 1255 child->DetachFromParent(); |
1213 | 1256 |
1214 children_.clear(); | 1257 children_.clear(); |
1215 have_children_ = false; | 1258 have_children_ = false; |
1216 } | 1259 } |
1217 | 1260 |
1218 Document* AXObject::GetDocument() const { | 1261 Document* AXObject::GetDocument() const { |
1219 FrameView* frame_view = DocumentFrameView(); | 1262 return &(AxObjectCache().GetDocument()); |
1220 if (!frame_view) | |
1221 return 0; | |
1222 | |
1223 return frame_view->GetFrame().GetDocument(); | |
1224 } | 1263 } |
1225 | 1264 |
1226 FrameView* AXObject::DocumentFrameView() const { | 1265 FrameView* AXObject::DocumentFrameView() const { |
1227 const AXObject* object = this; | 1266 const AXObject* object = this; |
1228 while (object && !object->IsAXLayoutObject()) | 1267 while (object && !object->IsAXLayoutObject()) |
1229 object = object->ParentObject(); | 1268 object = object->ParentObject(); |
1230 | 1269 |
1231 if (!object) | 1270 if (!object) |
1232 return 0; | 1271 return 0; |
1233 | 1272 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1862 } | 1901 } |
1863 | 1902 |
1864 DEFINE_TRACE(AXObject) { | 1903 DEFINE_TRACE(AXObject) { |
1865 visitor->Trace(children_); | 1904 visitor->Trace(children_); |
1866 visitor->Trace(parent_); | 1905 visitor->Trace(parent_); |
1867 visitor->Trace(cached_live_region_root_); | 1906 visitor->Trace(cached_live_region_root_); |
1868 visitor->Trace(ax_object_cache_); | 1907 visitor->Trace(ax_object_cache_); |
1869 } | 1908 } |
1870 | 1909 |
1871 } // namespace blink | 1910 } // namespace blink |
OLD | NEW |