diff --git a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp index a80f014f78e..6b6527ea28d 100755 --- a/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp +++ b/nvdaHelper/vbufBackends/gecko_ia2/gecko_ia2.cpp @@ -901,10 +901,6 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf( } } - //If the name isn't being rendered as the content, then add the name as a field attribute. - if (!nameIsContent && name) - parentNode->addAttribute(L"name", name); - if(nameIsContent) { // We may render an accessible name for this node if it has been explicitly set or it has no useful content. parentNode->alwaysRerenderDescendants=true; @@ -1149,18 +1145,26 @@ VBufStorage_fieldNode_t* GeckoVBufBackend_t::fillVBuf( } } - auto labelId = getLabelIDCached(); - if (labelId) { - auto labelControlFieldNode = buffer->getControlFieldNodeWithIdentifier(docHandle, labelId.value()); - if (labelControlFieldNode) { - bool isDescendant = buffer->isDescendantNode(parentNode, labelControlFieldNode); - if (isDescendant) { - parentNode->addAttribute(L"labelledByContent", L"true"); + //If the name isn't being rendered as the content, then add the name as a field attribute. + if (!nameIsContent && name) { + parentNode->addAttribute(L"name", name); + // Determine whether this node is labelled by its content. We only need to do + // this if the node has a name and the name is explicit, since this is what + // browsers expose in this case. + if (nameIsExplicit) { + auto labelId = getLabelIDCached(); + if (labelId) { + auto labelControlFieldNode = buffer->getControlFieldNodeWithIdentifier(docHandle, labelId.value()); + if (labelControlFieldNode) { + bool isDescendant = buffer->isDescendantNode(parentNode, labelControlFieldNode); + if (isDescendant) { + parentNode->addAttribute(L"labelledByContent", L"true"); + } + } } } } - // Clean up. if(name) SysFreeString(name);