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

Unified Diff: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp

Issue 1939303002: Enable accessible name of a control to include multiple <label> elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
diff --git a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
index c780186a855528cd7f12301a390698cbf61c3ff1..e33fd8df5f5625b48042c36ff3b7daf3386a9a05 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -51,6 +51,7 @@
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLSelectElement.h"
#include "core/html/HTMLTextAreaElement.h"
+#include "core/html/LabelsNodeList.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/layout/HitTestResult.h"
#include "core/layout/LayoutFieldset.h"
@@ -2463,12 +2464,17 @@ LayoutRect AXLayoutObject::computeElementRect() const
if (isWebArea() && obj->frame()->view())
result.setSize(LayoutSize(obj->frame()->view()->contentsSize()));
- // Checkboxes and radio buttons include their label as part of their rect.
- if (isCheckboxOrRadio()) {
- HTMLLabelElement* label = labelForElement(toElement(m_layoutObject->node()));
- if (label && label->layoutObject()) {
- LayoutRect labelRect = axObjectCache().getOrCreate(label)->elementRect();
- result.unite(labelRect);
+ // Checkboxes and radio buttons include their labels as part of their rect.
+ if (isCheckboxOrRadio() && isLabelableElement(obj->node())) {
+ LabelsNodeList* labels = toLabelableElement(obj->node())->labels();
+ if (labels) {
+ for (unsigned labelIndex = 0; labelIndex < labels->length(); ++labelIndex) {
+ AXObject* labelAXObject = axObjectCache().getOrCreate(labels->item(labelIndex));
+ if (labelAXObject) {
+ LayoutRect labelRect = labelAXObject->elementRect();
+ result.unite(labelRect);
aboxhall 2016/05/13 20:19:16 This doesn't change in this change, but it never o
dmazzoni 2016/05/13 22:22:42 Agreed, it's a bit weird.
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698