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

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

Issue 1467423002: Implement nameFromLabelElement to see if a control is associated with a label. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@axlayoutobj_null
Patch Set: Created 5 years 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/AXNodeObject.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 } 588 }
589 589
590 // TODO: we should refactor this - but right now this is necessary to make 590 // TODO: we should refactor this - but right now this is necessary to make
591 // sure scroll areas stay in the tree. 591 // sure scroll areas stay in the tree.
592 if (isAttachment()) 592 if (isAttachment())
593 return false; 593 return false;
594 594
595 // find out if this element is inside of a label element. 595 // find out if this element is inside of a label element.
596 // if so, it may be ignored because it's the label for a checkbox or radio b utton 596 // if so, it may be ignored because it's the label for a checkbox or radio b utton
597 AXObject* controlObject = correspondingControlForLabelElement(); 597 AXObject* controlObject = correspondingControlForLabelElement();
598 if (controlObject && controlObject->isCheckboxOrRadio()) { 598 if (controlObject && controlObject->isCheckboxOrRadio() && controlObject->na meFromLabelElement()) {
599 AXNameFrom controlNameFrom; 599 if (ignoredReasons) {
600 AXObject::AXObjectVector controlNameObjects; 600 HTMLLabelElement* label = labelElementContainer();
601 controlObject->name(controlNameFrom, &controlNameObjects); 601 if (label && !label->isSameNode(node())) {
602 if (controlNameFrom == AXNameFromRelatedElement) { 602 AXObject* labelAXObject = axObjectCache().getOrCreate(label);
603 if (ignoredReasons) { 603 ignoredReasons->append(IgnoredReason(AXLabelContainer, labelAXOb ject));
604 HTMLLabelElement* label = labelElementContainer(); 604 }
605 if (label && !label->isSameNode(node())) {
606 AXObject* labelAXObject = axObjectCache().getOrCreate(label) ;
607 ignoredReasons->append(IgnoredReason(AXLabelContainer, label AXObject));
608 }
609 605
610 ignoredReasons->append(IgnoredReason(AXLabelFor, controlObject)) ; 606 ignoredReasons->append(IgnoredReason(AXLabelFor, controlObject));
611 }
612 return true;
613 } 607 }
608 return true;
614 } 609 }
615 610
616 if (m_layoutObject->isBR()) 611 if (m_layoutObject->isBR())
617 return false; 612 return false;
618 613
619 if (m_layoutObject->isText()) { 614 if (m_layoutObject->isText()) {
620 // static text beneath MenuItems and MenuButtons are just reported along with the menu item, so it's ignored on an individual level 615 // static text beneath MenuItems and MenuButtons are just reported along with the menu item, so it's ignored on an individual level
621 AXObject* parent = parentObjectUnignored(); 616 AXObject* parent = parentObjectUnignored();
622 if (parent && (parent->ariaRoleAttribute() == MenuItemRole || parent->ar iaRoleAttribute() == MenuButtonRole)) { 617 if (parent && (parent->ariaRoleAttribute() == MenuItemRole || parent->ar iaRoleAttribute() == MenuButtonRole)) {
623 if (ignoredReasons) 618 if (ignoredReasons)
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 1489
1495 AXObject* result = axObjectCache().getOrCreate(obj); 1490 AXObject* result = axObjectCache().getOrCreate(obj);
1496 result->updateChildrenIfNecessary(); 1491 result->updateChildrenIfNecessary();
1497 1492
1498 // Allow the element to perform any hit-testing it might need to do to reach non-layout children. 1493 // Allow the element to perform any hit-testing it might need to do to reach non-layout children.
1499 result = result->elementAccessibilityHitTest(point); 1494 result = result->elementAccessibilityHitTest(point);
1500 if (result && result->accessibilityIsIgnored()) { 1495 if (result && result->accessibilityIsIgnored()) {
1501 // If this element is the label of a control, a hit test should return t he control. 1496 // If this element is the label of a control, a hit test should return t he control.
1502 if (result->isAXLayoutObject()) { 1497 if (result->isAXLayoutObject()) {
1503 AXObject* controlObject = toAXLayoutObject(result)->correspondingCon trolForLabelElement(); 1498 AXObject* controlObject = toAXLayoutObject(result)->correspondingCon trolForLabelElement();
1504 if (controlObject) { 1499 if (controlObject && controlObject->nameFromLabelElement())
1505 AXNameFrom controlNameFrom; 1500 return controlObject;
1506 AXObject::AXObjectVector controlNameObjects;
1507 controlObject->name(controlNameFrom, &controlNameObjects);
1508 if (controlObject && controlNameFrom == AXNameFromRelatedElement )
1509 return controlObject;
1510 }
1511 } 1501 }
1512 1502
1513 result = result->parentObjectUnignored(); 1503 result = result->parentObjectUnignored();
1514 } 1504 }
1515 1505
1516 return result; 1506 return result;
1517 } 1507 }
1518 1508
1519 AXObject* AXLayoutObject::elementAccessibilityHitTest(const IntPoint& point) con st 1509 AXObject* AXLayoutObject::elementAccessibilityHitTest(const IntPoint& point) con st
1520 { 1510 {
(...skipping 1037 matching lines...) Expand 10 before | Expand all | Expand 10 after
2558 if (label && label->layoutObject()) { 2548 if (label && label->layoutObject()) {
2559 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct(); 2549 LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRe ct();
2560 result.unite(labelRect); 2550 result.unite(labelRect);
2561 } 2551 }
2562 } 2552 }
2563 2553
2564 return result; 2554 return result;
2565 } 2555 }
2566 2556
2567 } // namespace blink 2557 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/accessibility/AXNodeObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698