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

Unified Diff: Source/core/accessibility/AXListBoxOption.cpp

Issue 347773002: Implement select listbox using shadow DOM (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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/core/accessibility/AXListBoxOption.h ('k') | Source/core/accessibility/AXObjectCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/accessibility/AXListBoxOption.cpp
diff --git a/Source/core/accessibility/AXListBoxOption.cpp b/Source/core/accessibility/AXListBoxOption.cpp
index 8e24712572eae69f9692a6b64fb0cfe520f04468..6164fa6eb292d24e37cc5ecc5015289393685637 100644
--- a/Source/core/accessibility/AXListBoxOption.cpp
+++ b/Source/core/accessibility/AXListBoxOption.cpp
@@ -30,7 +30,6 @@
#include "core/accessibility/AXListBoxOption.h"
#include "core/accessibility/AXObjectCache.h"
-#include "core/html/HTMLOptGroupElement.h"
#include "core/html/HTMLOptionElement.h"
#include "core/html/HTMLSelectElement.h"
#include "core/rendering/RenderListBox.h"
@@ -40,8 +39,8 @@ namespace WebCore {
using namespace HTMLNames;
-AXListBoxOption::AXListBoxOption()
- : m_optionElement(0)
+AXListBoxOption::AXListBoxOption(RenderObject* renderer)
+ : AXRenderObject(renderer)
{
}
@@ -49,23 +48,20 @@ AXListBoxOption::~AXListBoxOption()
{
}
-PassRefPtr<AXListBoxOption> AXListBoxOption::create()
+PassRefPtr<AXListBoxOption> AXListBoxOption::create(RenderObject* renderer)
{
- return adoptRef(new AXListBoxOption());
+ return adoptRef(new AXListBoxOption(renderer));
}
bool AXListBoxOption::isEnabled() const
{
- if (!m_optionElement)
- return false;
-
- if (isHTMLOptGroupElement(*m_optionElement))
+ if (!node())
return false;
if (equalIgnoringCase(getAttribute(aria_disabledAttr), "true"))
return false;
- if (m_optionElement->hasAttribute(disabledAttr))
+ if (toElement(node())->hasAttribute(disabledAttr))
return false;
return true;
@@ -73,10 +69,7 @@ bool AXListBoxOption::isEnabled() const
bool AXListBoxOption::isSelected() const
{
- if (!isHTMLOptionElement(m_optionElement))
- return false;
-
- return toHTMLOptionElement(m_optionElement)->selected();
+ return isHTMLOptionElement(node()) && toHTMLOptionElement(node())->selected();
}
bool AXListBoxOption::isSelectedOptionActive() const
@@ -88,45 +81,23 @@ bool AXListBoxOption::isSelectedOptionActive() const
return listBoxParentNode->activeSelectionEndListIndex() == listBoxOptionIndex();
}
-LayoutRect AXListBoxOption::elementRect() const
-{
- LayoutRect rect;
- if (!m_optionElement)
- return rect;
-
- HTMLSelectElement* listBoxParentNode = listBoxOptionParentNode();
- if (!listBoxParentNode)
- return rect;
-
- RenderObject* listBoxRenderer = listBoxParentNode->renderer();
- if (!listBoxRenderer)
- return rect;
-
- LayoutRect parentRect = listBoxRenderer->document().axObjectCache()->getOrCreate(listBoxRenderer)->elementRect();
- int index = listBoxOptionIndex();
- if (index != -1)
- rect = toRenderListBox(listBoxRenderer)->itemBoundingBoxRect(parentRect.location(), index);
-
- return rect;
-}
-
bool AXListBoxOption::computeAccessibilityIsIgnored() const
{
- if (!m_optionElement)
+ if (!node())
return true;
if (accessibilityIsIgnoredByDefault())
return true;
- return parentObject()->accessibilityIsIgnored();
+ return false;
}
bool AXListBoxOption::canSetSelectedAttribute() const
{
- if (!isHTMLOptionElement(m_optionElement))
+ if (!isHTMLOptionElement(node()))
return false;
- if (m_optionElement->isDisabledFormControl())
+ if (toHTMLOptionElement(node())->isDisabledFormControl())
return false;
HTMLSelectElement* selectElement = listBoxOptionParentNode();
@@ -138,36 +109,19 @@ bool AXListBoxOption::canSetSelectedAttribute() const
String AXListBoxOption::stringValue() const
{
- if (!m_optionElement)
+ if (!node())
return String();
const AtomicString& ariaLabel = getAttribute(aria_labelAttr);
if (!ariaLabel.isNull())
return ariaLabel;
- if (isHTMLOptionElement(*m_optionElement))
- return toHTMLOptionElement(m_optionElement)->text();
-
- if (isHTMLOptGroupElement(*m_optionElement))
- return toHTMLOptGroupElement(m_optionElement)->groupLabelText();
+ if (isHTMLOptionElement(node()))
+ return toHTMLOptionElement(node())->text();
return String();
}
-Element* AXListBoxOption::actionElement() const
-{
- return m_optionElement;
-}
-
-AXObject* AXListBoxOption::parentObject() const
-{
- HTMLSelectElement* parentNode = listBoxOptionParentNode();
- if (!parentNode)
- return 0;
-
- return m_optionElement->document().axObjectCache()->getOrCreate(parentNode);
-}
-
void AXListBoxOption::setSelected(bool selected)
{
HTMLSelectElement* selectElement = listBoxOptionParentNode();
@@ -188,23 +142,17 @@ void AXListBoxOption::setSelected(bool selected)
HTMLSelectElement* AXListBoxOption::listBoxOptionParentNode() const
{
- if (!m_optionElement)
+ if (!node())
return 0;
- if (isHTMLOptionElement(*m_optionElement))
- return toHTMLOptionElement(m_optionElement)->ownerSelectElement();
-
- if (isHTMLOptGroupElement(*m_optionElement))
- return toHTMLOptGroupElement(m_optionElement)->ownerSelectElement();
+ if (isHTMLOptionElement(node()))
+ return toHTMLOptionElement(node())->ownerSelectElement();
return 0;
}
int AXListBoxOption::listBoxOptionIndex() const
{
- if (!m_optionElement)
- return -1;
-
HTMLSelectElement* selectElement = listBoxOptionParentNode();
if (!selectElement)
return -1;
@@ -212,7 +160,7 @@ int AXListBoxOption::listBoxOptionIndex() const
const WillBeHeapVector<RawPtrWillBeMember<HTMLElement> >& listItems = selectElement->listItems();
unsigned length = listItems.size();
for (unsigned i = 0; i < length; i++) {
- if (listItems[i] == m_optionElement)
+ if (listItems[i] == node())
return i;
}
« no previous file with comments | « Source/core/accessibility/AXListBoxOption.h ('k') | Source/core/accessibility/AXObjectCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698