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

Unified Diff: third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp

Issue 1628283002: posinset and setsize for input type, radio, exposed in AX tree (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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/core/html/forms/RadioButtonGroupScope.cpp
diff --git a/third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp b/third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp
index de3c04c523c20dee85f25a5e4359ca70ca2b6f3e..5e7f47bf0c06625dad35916895fee4fc44b441a3 100644
--- a/third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp
+++ b/third_party/WebKit/Source/core/html/forms/RadioButtonGroupScope.cpp
@@ -38,6 +38,8 @@ public:
void requiredAttributeChanged(HTMLInputElement*);
void remove(HTMLInputElement*);
bool contains(HTMLInputElement*) const;
+ unsigned posInMembers(HTMLInputElement*) const;
keishi 2016/01/26 01:32:23 nit: Blink style avoid abbreviations so positionIn
je_julie(Not used) 2016/02/02 00:36:17 Done
+ unsigned sizeOfMembers() const;
DECLARE_TRACE();
@@ -47,7 +49,7 @@ private:
bool isValid() const;
void setCheckedButton(HTMLInputElement*);
- WillBeHeapHashSet<RawPtrWillBeMember<HTMLInputElement>> m_members;
+ WillBeHeapVector<RawPtrWillBeMember<HTMLInputElement>> m_members;
keishi 2016/01/26 01:32:23 This change will conflict with https://codereview.
je_julie(Not used) 2016/02/02 00:36:17 I rebased code on that CL.
RawPtrWillBeMember<HTMLInputElement> m_checkedButton;
size_t m_requiredCount;
};
@@ -81,8 +83,9 @@ void RadioButtonGroup::setCheckedButton(HTMLInputElement* button)
void RadioButtonGroup::add(HTMLInputElement* button)
{
ASSERT(button->type() == InputTypeNames::radio);
- if (!m_members.add(button).isNewEntry)
+ if (m_members.contains(button))
return;
+ m_members.append(button);
bool groupWasValid = isValid();
if (button->isRequired())
++m_requiredCount;
@@ -135,11 +138,11 @@ void RadioButtonGroup::requiredAttributeChanged(HTMLInputElement* button)
void RadioButtonGroup::remove(HTMLInputElement* button)
{
ASSERT(button->type() == InputTypeNames::radio);
- WillBeHeapHashSet<RawPtrWillBeMember<HTMLInputElement>>::iterator it = m_members.find(button);
- if (it == m_members.end())
+ size_t idx = m_members.find(button);
+ if (idx == kNotFound)
return;
bool wasValid = isValid();
- m_members.remove(it);
+ m_members.remove(idx);
if (button->isRequired()) {
ASSERT(m_requiredCount);
--m_requiredCount;
@@ -173,6 +176,22 @@ bool RadioButtonGroup::contains(HTMLInputElement* button) const
return m_members.contains(button);
}
+unsigned RadioButtonGroup::posInMembers(HTMLInputElement* element) const
+{
+ unsigned index = 0;
+ for (HTMLInputElement* const button : m_members) {
+ index++;
+ if (button == element)
+ return index;
+ }
+ return 0;
+}
+
+unsigned RadioButtonGroup::sizeOfMembers() const
+{
+ return m_members.size();
+}
+
DEFINE_TRACE(RadioButtonGroup)
{
#if ENABLE(OILPAN)
@@ -254,6 +273,29 @@ bool RadioButtonGroupScope::isInRequiredGroup(HTMLInputElement* element) const
return group && group->isRequired() && group->contains(element);
}
+unsigned RadioButtonGroupScope::posInGroup(HTMLInputElement* element) const
+{
+ if (!m_nameToGroupMap)
+ return 0;
+
+ RadioButtonGroup* group = m_nameToGroupMap->get(element->name());
+ if (!group)
+ return 0;
+
+ return group->posInMembers(element);
+}
+
+unsigned RadioButtonGroupScope::sizeOfGroup(HTMLInputElement* element) const
+{
+ if (!m_nameToGroupMap)
+ return 0;
+
+ RadioButtonGroup* group = m_nameToGroupMap->get(element->name());
+ if (!group)
+ return 0;
+ return group->sizeOfMembers();
+}
+
void RadioButtonGroupScope::removeButton(HTMLInputElement* element)
{
ASSERT(element->type() == InputTypeNames::radio);

Powered by Google App Engine
This is Rietveld 408576698