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

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

Issue 2088453002: Implement the inert attribute (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move flat tree checks up to the top of isInert Created 3 years, 10 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 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (getNode()) { 529 if (getNode()) {
530 if (getNode()->isInert()) { 530 if (getNode()->isInert()) {
531 if (ignoredReasons) { 531 if (ignoredReasons) {
532 HTMLDialogElement* dialog = getActiveDialogElement(getNode()); 532 HTMLDialogElement* dialog = getActiveDialogElement(getNode());
533 if (dialog) { 533 if (dialog) {
534 AXObject* dialogObject = axObjectCache().getOrCreate(dialog); 534 AXObject* dialogObject = axObjectCache().getOrCreate(dialog);
535 if (dialogObject) 535 if (dialogObject)
536 ignoredReasons->push_back( 536 ignoredReasons->push_back(
537 IgnoredReason(AXActiveModalDialog, dialogObject)); 537 IgnoredReason(AXActiveModalDialog, dialogObject));
538 else 538 else
539 ignoredReasons->push_back(IgnoredReason(AXInert)); 539 ignoredReasons->push_back(IgnoredReason(AXInertElement));
540 } else { 540 } else {
541 // TODO(aboxhall): handle inert attribute if it eventuates 541 const AXObject* inertRoot = this->inertRoot();
542 ignoredReasons->push_back(IgnoredReason(AXInert)); 542 if (inertRoot == this) {
543 ignoredReasons->push_back(IgnoredReason(AXInertElement));
544 } else {
545 ignoredReasons->push_back(IgnoredReason(AXInertSubtree, inertRoot));
546 }
543 } 547 }
544 } 548 }
545 return true; 549 return true;
546 } 550 }
547 } else { 551 } else {
548 AXObject* parent = parentObject(); 552 AXObject* parent = parentObject();
549 if (parent && parent->isInertOrAriaHidden()) { 553 if (parent && parent->isInertOrAriaHidden()) {
550 if (ignoredReasons) 554 if (ignoredReasons)
551 parent->computeIsInertOrAriaHidden(ignoredReasons); 555 parent->computeIsInertOrAriaHidden(ignoredReasons);
552 return true; 556 return true;
553 } 557 }
554 } 558 }
555 559
556 const AXObject* hiddenRoot = ariaHiddenRoot(); 560 const AXObject* hiddenRoot = ariaHiddenRoot();
557 if (hiddenRoot) { 561 if (hiddenRoot) {
558 if (ignoredReasons) { 562 if (ignoredReasons) {
559 if (hiddenRoot == this) 563 if (hiddenRoot == this) {
560 ignoredReasons->push_back(IgnoredReason(AXAriaHidden)); 564 ignoredReasons->push_back(IgnoredReason(AXAriaHiddenElement));
561 else 565 } else {
562 ignoredReasons->push_back(IgnoredReason(AXAriaHiddenRoot, hiddenRoot)); 566 ignoredReasons->push_back(
567 IgnoredReason(AXAriaHiddenSubtree, hiddenRoot));
568 }
563 } 569 }
564 return true; 570 return true;
565 } 571 }
566 572
567 return false; 573 return false;
568 } 574 }
569 575
570 bool AXObject::isDescendantOfLeafNode() const { 576 bool AXObject::isDescendantOfLeafNode() const {
571 updateCachedAttributeValuesIfNeeded(); 577 updateCachedAttributeValuesIfNeeded();
572 return m_cachedIsDescendantOfLeafNode; 578 return m_cachedIsDescendantOfLeafNode;
(...skipping 12 matching lines...) Expand all
585 591
586 const AXObject* AXObject::ariaHiddenRoot() const { 592 const AXObject* AXObject::ariaHiddenRoot() const {
587 for (const AXObject* object = this; object; object = object->parentObject()) { 593 for (const AXObject* object = this; object; object = object->parentObject()) {
588 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) 594 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true"))
589 return object; 595 return object;
590 } 596 }
591 597
592 return 0; 598 return 0;
593 } 599 }
594 600
601 const AXObject* AXObject::inertRoot() const {
602 const AXObject* object = this;
603 if (!RuntimeEnabledFeatures::inertAttributeEnabled())
604 return nullptr;
605
606 while (object && !object->isAXNodeObject())
607 object = object->parentObject();
608 Node* node = object->getNode();
609 node->updateDistribution();
esprehn 2017/02/16 06:28:12 updateDistribution can actually cause a detach(),
610 Element* element = node->isElementNode()
611 ? toElement(node)
612 : FlatTreeTraversal::parentElement(*node);
613 while (element) {
614 if (element->hasAttribute(inertAttr))
615 return axObjectCache().getOrCreate(element);
616 element = FlatTreeTraversal::parentElement(*element);
617 }
618
619 return nullptr;
620 }
621
595 bool AXObject::isDescendantOfDisabledNode() const { 622 bool AXObject::isDescendantOfDisabledNode() const {
596 updateCachedAttributeValuesIfNeeded(); 623 updateCachedAttributeValuesIfNeeded();
597 return m_cachedIsDescendantOfDisabledNode; 624 return m_cachedIsDescendantOfDisabledNode;
598 } 625 }
599 626
600 const AXObject* AXObject::disabledAncestor() const { 627 const AXObject* AXObject::disabledAncestor() const {
601 const AtomicString& disabled = getAttribute(aria_disabledAttr); 628 const AtomicString& disabled = getAttribute(aria_disabledAttr);
602 if (equalIgnoringCase(disabled, "true")) 629 if (equalIgnoringCase(disabled, "true"))
603 return this; 630 return this;
604 if (equalIgnoringCase(disabled, "false")) 631 if (equalIgnoringCase(disabled, "false"))
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1762 } 1789 }
1763 1790
1764 DEFINE_TRACE(AXObject) { 1791 DEFINE_TRACE(AXObject) {
1765 visitor->trace(m_children); 1792 visitor->trace(m_children);
1766 visitor->trace(m_parent); 1793 visitor->trace(m_parent);
1767 visitor->trace(m_cachedLiveRegionRoot); 1794 visitor->trace(m_cachedLiveRegionRoot);
1768 visitor->trace(m_axObjectCache); 1795 visitor->trace(m_axObjectCache);
1769 } 1796 }
1770 1797
1771 } // namespace blink 1798 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698