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

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: Clean up code 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
Index: Source/modules/accessibility/AXObjectCacheImpl.cpp
diff --git a/Source/modules/accessibility/AXObjectCacheImpl.cpp b/Source/modules/accessibility/AXObjectCacheImpl.cpp
index a70a16ea3b0420532e71bb8a1c3df47f56d8772b..50067a9d5ba7ea038cca316ff1eb8b75d3e724b0 100644
--- a/Source/modules/accessibility/AXObjectCacheImpl.cpp
+++ b/Source/modules/accessibility/AXObjectCacheImpl.cpp
@@ -203,6 +203,19 @@ 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 (!parent || !isHTMLSelectElement(parent))
je_julie(Not used) 2015/04/06 08:42:51 You can remove !parent because isHTMLSelectElement
dmazzoni 2015/04/06 15:42:12 Done.
+ return false;
+ LayoutObject* layoutObject = toHTMLSelectElement(node->parentElement())->layoutObject();
+ return layoutObject && layoutObject->isMenuList();
+}
+
AXObject* AXObjectCacheImpl::get(Node* node)
{
if (!node)
@@ -214,7 +227,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 +325,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 +384,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 +477,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;

Powered by Google App Engine
This is Rietveld 408576698