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

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: Update layout tests Created 3 years, 11 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 526
527 bool AXObject::computeIsInertOrAriaHidden( 527 bool AXObject::computeIsInertOrAriaHidden(
528 IgnoredReasons* ignoredReasons) const { 528 IgnoredReasons* ignoredReasons) const {
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->append(
537 IgnoredReason(AXActiveModalDialog, dialogObject)); 537 IgnoredReason(AXActiveModalDialog, dialogObject));
538 else 538 else
539 ignoredReasons->push_back(IgnoredReason(AXInert)); 539 ignoredReasons->append(IgnoredReason(AXInertElement));
540 } else { 540 } else {
541 // TODO(aboxhall): handle inert attribute if it eventuates 541 const AXObject* inertRootEl = inertRoot();
542 ignoredReasons->push_back(IgnoredReason(AXInert)); 542 if (inertRootEl == this)
543 ignoredReasons->append(IgnoredReason(AXInertElement));
544 else
545 ignoredReasons->append(IgnoredReason(AXInertSubtree, inertRootEl));
543 } 546 }
544 } 547 }
545 return true; 548 return true;
546 } 549 }
547 } else { 550 } else {
548 AXObject* parent = parentObject(); 551 AXObject* parent = parentObject();
549 if (parent && parent->isInertOrAriaHidden()) { 552 if (parent && parent->isInertOrAriaHidden()) {
550 if (ignoredReasons) 553 if (ignoredReasons)
551 parent->computeIsInertOrAriaHidden(ignoredReasons); 554 parent->computeIsInertOrAriaHidden(ignoredReasons);
552 return true; 555 return true;
553 } 556 }
554 } 557 }
555 558
556 const AXObject* hiddenRoot = ariaHiddenRoot(); 559 const AXObject* hiddenRoot = ariaHiddenRoot();
557 if (hiddenRoot) { 560 if (hiddenRoot) {
558 if (ignoredReasons) { 561 if (ignoredReasons) {
559 if (hiddenRoot == this) 562 if (hiddenRoot == this) {
560 ignoredReasons->push_back(IgnoredReason(AXAriaHidden)); 563 ignoredReasons->push_back(IgnoredReason(AXAriaHiddenElement));
561 else 564 } else {
562 ignoredReasons->push_back(IgnoredReason(AXAriaHiddenRoot, hiddenRoot)); 565 ignoredReasons->push_back(
566 IgnoredReason(AXAriaHiddenSubtree, hiddenRoot));
567 }
563 } 568 }
564 return true; 569 return true;
565 } 570 }
566 571
567 return false; 572 return false;
568 } 573 }
569 574
570 bool AXObject::isDescendantOfLeafNode() const { 575 bool AXObject::isDescendantOfLeafNode() const {
571 updateCachedAttributeValuesIfNeeded(); 576 updateCachedAttributeValuesIfNeeded();
572 return m_cachedIsDescendantOfLeafNode; 577 return m_cachedIsDescendantOfLeafNode;
(...skipping 12 matching lines...) Expand all
585 590
586 const AXObject* AXObject::ariaHiddenRoot() const { 591 const AXObject* AXObject::ariaHiddenRoot() const {
587 for (const AXObject* object = this; object; object = object->parentObject()) { 592 for (const AXObject* object = this; object; object = object->parentObject()) {
588 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true")) 593 if (equalIgnoringCase(object->getAttribute(aria_hiddenAttr), "true"))
589 return object; 594 return object;
590 } 595 }
591 596
592 return 0; 597 return 0;
593 } 598 }
594 599
600 const AXObject* AXObject::inertRoot() const {
601 const AXObject* object = this;
602 while (object && !object->isAXNodeObject())
603 object = object->parentObject();
604 for (Node* node = object->getNode(); node; node = node->parentNode()) {
dmazzoni 2017/01/18 16:38:54 I'm assuming this should also be parentOrShadowHos
aboxhall 2017/01/19 02:44:26 Ah yep, good catch, thanks.
605 if (!node->isElementNode())
606 continue;
607 if (toElement(node)->hasAttribute(inertAttr))
dmazzoni 2017/01/18 16:38:54 Need to check RuntimeEnabledFeatures here too
aboxhall 2017/01/19 02:44:26 Hm - probably doesn't matter in practice, since th
608 return axObjectCache().getOrCreate(node);
609 }
610
611 return 0;
612 }
613
595 bool AXObject::isDescendantOfDisabledNode() const { 614 bool AXObject::isDescendantOfDisabledNode() const {
596 updateCachedAttributeValuesIfNeeded(); 615 updateCachedAttributeValuesIfNeeded();
597 return m_cachedIsDescendantOfDisabledNode; 616 return m_cachedIsDescendantOfDisabledNode;
598 } 617 }
599 618
600 const AXObject* AXObject::disabledAncestor() const { 619 const AXObject* AXObject::disabledAncestor() const {
601 const AtomicString& disabled = getAttribute(aria_disabledAttr); 620 const AtomicString& disabled = getAttribute(aria_disabledAttr);
602 if (equalIgnoringCase(disabled, "true")) 621 if (equalIgnoringCase(disabled, "true"))
603 return this; 622 return this;
604 if (equalIgnoringCase(disabled, "false")) 623 if (equalIgnoringCase(disabled, "false"))
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1746 } 1765 }
1747 1766
1748 DEFINE_TRACE(AXObject) { 1767 DEFINE_TRACE(AXObject) {
1749 visitor->trace(m_children); 1768 visitor->trace(m_children);
1750 visitor->trace(m_parent); 1769 visitor->trace(m_parent);
1751 visitor->trace(m_cachedLiveRegionRoot); 1770 visitor->trace(m_cachedLiveRegionRoot);
1752 visitor->trace(m_axObjectCache); 1771 visitor->trace(m_axObjectCache);
1753 } 1772 }
1754 1773
1755 } // namespace blink 1774 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698