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

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: Don't modify visited set when computing aria-labelledby Created 4 years, 6 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 42cdc55a52f5ab4aa4dad3334dbbf5b6c9762e88..1d124aab0e27085b4698bfe0d321f07fc8ca6a96 100644
--- a/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
+++ b/third_party/WebKit/Source/modules/accessibility/AXLayoutObject.cpp
@@ -52,6 +52,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/LayoutFileUploadControl.h"
@@ -2468,12 +2469,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);
+ }
+ }
}
}

Powered by Google App Engine
This is Rietveld 408576698