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

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

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008, 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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 case kSpinButtonRole: 555 case kSpinButtonRole:
556 case kTabRole: 556 case kTabRole:
557 case kTextFieldRole: 557 case kTextFieldRole:
558 case kToggleButtonRole: 558 case kToggleButtonRole:
559 return true; 559 return true;
560 default: 560 default:
561 return false; 561 return false;
562 } 562 }
563 } 563 }
564 564
565 bool AXObjectImpl::AccessibilityIsIgnored() const { 565 bool AXObjectImpl::AccessibilityIsIgnored() {
566 Node* node = GetNode();
567 if (!node) {
568 AXObjectImpl* parent = this->ParentObject();
569 while (!node && parent) {
570 node = parent->GetNode();
571 parent = parent->ParentObject();
572 }
573 }
574
575 if (node)
576 node->UpdateDistribution();
577
578 // TODO(aboxhall): Instead of this, propagate inert down through frames
579 Document* document = GetDocument();
580 while (document && document->LocalOwner()) {
581 document->LocalOwner()->UpdateDistribution();
582 document = document->LocalOwner()->ownerDocument();
583 }
584
566 UpdateCachedAttributeValuesIfNeeded(); 585 UpdateCachedAttributeValuesIfNeeded();
567 return cached_is_ignored_; 586 return cached_is_ignored_;
568 } 587 }
569 588
570 void AXObjectImpl::UpdateCachedAttributeValuesIfNeeded() const { 589 void AXObjectImpl::UpdateCachedAttributeValuesIfNeeded() const {
571 if (IsDetached()) 590 if (IsDetached())
572 return; 591 return;
573 592
574 AXObjectCacheImpl& cache = AxObjectCache(); 593 AXObjectCacheImpl& cache = AxObjectCache();
575 594
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 if (GetNode()) { 656 if (GetNode()) {
638 if (GetNode()->IsInert()) { 657 if (GetNode()->IsInert()) {
639 if (ignored_reasons) { 658 if (ignored_reasons) {
640 HTMLDialogElement* dialog = GetActiveDialogElement(GetNode()); 659 HTMLDialogElement* dialog = GetActiveDialogElement(GetNode());
641 if (dialog) { 660 if (dialog) {
642 AXObjectImpl* dialog_object = AxObjectCache().GetOrCreate(dialog); 661 AXObjectImpl* dialog_object = AxObjectCache().GetOrCreate(dialog);
643 if (dialog_object) { 662 if (dialog_object) {
644 ignored_reasons->push_back( 663 ignored_reasons->push_back(
645 IgnoredReason(kAXActiveModalDialog, dialog_object)); 664 IgnoredReason(kAXActiveModalDialog, dialog_object));
646 } else { 665 } else {
647 ignored_reasons->push_back(IgnoredReason(kAXInert)); 666 ignored_reasons->push_back(IgnoredReason(kAXInertElement));
648 } 667 }
649 } else { 668 } else {
650 // TODO(aboxhall): handle inert attribute if it eventuates 669 const AXObjectImpl* inert_root_el = InertRoot();
651 ignored_reasons->push_back(IgnoredReason(kAXInert)); 670 if (inert_root_el == this) {
671 ignored_reasons->push_back(IgnoredReason(kAXInertElement));
672 } else {
673 ignored_reasons->push_back(
674 IgnoredReason(kAXInertSubtree, inert_root_el));
675 }
652 } 676 }
653 } 677 }
654 return true; 678 return true;
655 } 679 }
656 } else { 680 } else {
657 AXObjectImpl* parent = ParentObject(); 681 AXObjectImpl* parent = ParentObject();
658 if (parent && parent->IsInertOrAriaHidden()) { 682 if (parent && parent->IsInertOrAriaHidden()) {
659 if (ignored_reasons) 683 if (ignored_reasons)
660 parent->ComputeIsInertOrAriaHidden(ignored_reasons); 684 parent->ComputeIsInertOrAriaHidden(ignored_reasons);
661 return true; 685 return true;
662 } 686 }
663 } 687 }
664 688
665 const AXObjectImpl* hidden_root = AriaHiddenRoot(); 689 const AXObjectImpl* hidden_root = AriaHiddenRoot();
666 if (hidden_root) { 690 if (hidden_root) {
667 if (ignored_reasons) { 691 if (ignored_reasons) {
668 if (hidden_root == this) { 692 if (hidden_root == this) {
669 ignored_reasons->push_back(IgnoredReason(kAXAriaHidden)); 693 ignored_reasons->push_back(IgnoredReason(kAXAriaHiddenElement));
670 } else { 694 } else {
671 ignored_reasons->push_back( 695 ignored_reasons->push_back(
672 IgnoredReason(kAXAriaHiddenRoot, hidden_root)); 696 IgnoredReason(kAXAriaHiddenSubtree, hidden_root));
673 } 697 }
674 } 698 }
675 return true; 699 return true;
676 } 700 }
677 701
678 return false; 702 return false;
679 } 703 }
680 704
681 bool AXObjectImpl::IsDescendantOfLeafNode() const { 705 bool AXObjectImpl::IsDescendantOfLeafNode() const {
682 UpdateCachedAttributeValuesIfNeeded(); 706 UpdateCachedAttributeValuesIfNeeded();
(...skipping 14 matching lines...) Expand all
697 const AXObjectImpl* AXObjectImpl::AriaHiddenRoot() const { 721 const AXObjectImpl* AXObjectImpl::AriaHiddenRoot() const {
698 for (const AXObjectImpl* object = this; object; 722 for (const AXObjectImpl* object = this; object;
699 object = object->ParentObject()) { 723 object = object->ParentObject()) {
700 if (object->AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kHidden)) 724 if (object->AOMPropertyOrARIAAttributeIsTrue(AOMBooleanProperty::kHidden))
701 return object; 725 return object;
702 } 726 }
703 727
704 return 0; 728 return 0;
705 } 729 }
706 730
731 const AXObjectImpl* AXObjectImpl::InertRoot() const {
732 const AXObjectImpl* object = this;
733 if (!RuntimeEnabledFeatures::inertAttributeEnabled())
734 return 0;
735
736 while (object && !object->IsAXNodeObject())
737 object = object->ParentObject();
738 Node* node = object->GetNode();
739 Element* element = node->IsElementNode()
740 ? ToElement(node)
741 : FlatTreeTraversal::ParentElement(*node);
742 while (element) {
743 if (element->hasAttribute(inertAttr))
744 return AxObjectCache().GetOrCreate(element);
745 element = FlatTreeTraversal::ParentElement(*element);
746 }
747
748 return 0;
749 }
750
707 bool AXObjectImpl::IsDescendantOfDisabledNode() const { 751 bool AXObjectImpl::IsDescendantOfDisabledNode() const {
708 UpdateCachedAttributeValuesIfNeeded(); 752 UpdateCachedAttributeValuesIfNeeded();
709 return cached_is_descendant_of_disabled_node_; 753 return cached_is_descendant_of_disabled_node_;
710 } 754 }
711 755
712 const AXObjectImpl* AXObjectImpl::DisabledAncestor() const { 756 const AXObjectImpl* AXObjectImpl::DisabledAncestor() const {
713 bool disabled = false; 757 bool disabled = false;
714 if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kDisabled, disabled)) { 758 if (HasAOMPropertyOrARIAAttribute(AOMBooleanProperty::kDisabled, disabled)) {
715 if (disabled) 759 if (disabled)
716 return this; 760 return this;
(...skipping 1305 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 } 2066 }
2023 2067
2024 DEFINE_TRACE(AXObjectImpl) { 2068 DEFINE_TRACE(AXObjectImpl) {
2025 visitor->Trace(children_); 2069 visitor->Trace(children_);
2026 visitor->Trace(parent_); 2070 visitor->Trace(parent_);
2027 visitor->Trace(cached_live_region_root_); 2071 visitor->Trace(cached_live_region_root_);
2028 visitor->Trace(ax_object_cache_); 2072 visitor->Trace(ax_object_cache_);
2029 } 2073 }
2030 2074
2031 } // namespace blink 2075 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698