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

Unified Diff: Source/modules/accessibility/AXObjectCacheImpl.cpp

Issue 1059503002: Re-land: Don't keep recreating AXMenuListPopup (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@suppress_extra_events
Patch Set: Fix optgroup Created 5 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
« no previous file with comments | « Source/modules/accessibility/AXMenuListPopup.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/accessibility/AXObjectCacheImpl.cpp
diff --git a/Source/modules/accessibility/AXObjectCacheImpl.cpp b/Source/modules/accessibility/AXObjectCacheImpl.cpp
index ecdc664789c58f5d518502ac01511449010b577b..8bce3f7a8d4173982977190f9302a766a6914f78 100644
--- a/Source/modules/accessibility/AXObjectCacheImpl.cpp
+++ b/Source/modules/accessibility/AXObjectCacheImpl.cpp
@@ -203,6 +203,21 @@ AXObject* AXObjectCacheImpl::get(LayoutObject* layoutObject)
return m_objects.get(axID);
}
+// Returns true if |node| is an <option> element and its parent <select>
+// is a menu list (not a list box).
+static bool isMenuListOption(Node* node)
+{
+ if (!isHTMLOptionElement(node))
+ return false;
+ Element* parent = node->parentElement();
+ if (isHTMLOptGroupElement(parent))
+ parent = parent->parentElement();
+ if (!isHTMLSelectElement(parent))
+ return false;
+ LayoutObject* layoutObject = toHTMLSelectElement(parent)->layoutObject();
+ return layoutObject && layoutObject->isMenuList();
+}
+
AXObject* AXObjectCacheImpl::get(Node* node)
{
if (!node)
@@ -214,7 +229,7 @@ AXObject* AXObjectCacheImpl::get(Node* node)
AXID nodeID = m_nodeObjectMapping.get(node);
ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID));
- if (node->layoutObject() && nodeID && !layoutID) {
+ if (node->layoutObject() && nodeID && !layoutID && !isMenuListOption(node)) {
// This can happen if an AXNodeObject is created for a node that's not
// laid out, but later something changes and it gets a layoutObject (like if it's
// reparented).
@@ -312,6 +327,9 @@ PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObject* layoutO
PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node)
{
+ if (isMenuListOption(node))
+ return AXMenuListOption::create(toHTMLOptionElement(node), this);
+
return AXNodeObject::create(node, this);
}
@@ -368,7 +386,7 @@ AXObject* AXObjectCacheImpl::getOrCreate(Node* node)
// Or if it's a hidden element, but we still want to expose it because of other ARIA attributes.
bool inCanvasSubtree = node->parentElement()->isInCanvasSubtree();
bool isHidden = !node->layoutObject() && isNodeAriaVisible(node);
- if (!inCanvasSubtree && !isHidden)
+ if (!inCanvasSubtree && !isHidden && !isMenuListOption(node))
return 0;
RefPtr<AXObject> newObj = createFromNode(node);
@@ -461,9 +479,6 @@ AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role)
case MenuListPopupRole:
obj = AXMenuListPopup::create(this);
break;
- case MenuListOptionRole:
- obj = AXMenuListOption::create(this);
- break;
case SpinButtonRole:
obj = AXSpinButton::create(this);
break;
« no previous file with comments | « Source/modules/accessibility/AXMenuListPopup.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698