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

Side by Side 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: fixed typo Created 4 years, 9 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 20 matching lines...) Expand all
31 public: 31 public:
32 static PassOwnPtrWillBeRawPtr<RadioButtonGroup> create(); 32 static PassOwnPtrWillBeRawPtr<RadioButtonGroup> create();
33 bool isEmpty() const { return m_members.isEmpty(); } 33 bool isEmpty() const { return m_members.isEmpty(); }
34 bool isRequired() const { return m_requiredCount; } 34 bool isRequired() const { return m_requiredCount; }
35 HTMLInputElement* checkedButton() const { return m_checkedButton; } 35 HTMLInputElement* checkedButton() const { return m_checkedButton; }
36 void add(HTMLInputElement*); 36 void add(HTMLInputElement*);
37 void updateCheckedState(HTMLInputElement*); 37 void updateCheckedState(HTMLInputElement*);
38 void requiredAttributeChanged(HTMLInputElement*); 38 void requiredAttributeChanged(HTMLInputElement*);
39 void remove(HTMLInputElement*); 39 void remove(HTMLInputElement*);
40 bool contains(HTMLInputElement*) const; 40 bool contains(HTMLInputElement*) const;
41 unsigned sizeOfMembers() const;
tkent 2016/03/01 01:43:00 I'd like name it "size" simply.
je_julie(Not used) 2016/03/01 13:46:07 I'll change it at next patch.
41 42
42 DECLARE_TRACE(); 43 DECLARE_TRACE();
43 44
44 private: 45 private:
45 RadioButtonGroup(); 46 RadioButtonGroup();
46 void setNeedsValidityCheckForAllButtons(); 47 void setNeedsValidityCheckForAllButtons();
47 bool isValid() const; 48 bool isValid() const;
48 void setCheckedButton(HTMLInputElement*); 49 void setCheckedButton(HTMLInputElement*);
49 50
50 // The map records the 'required' state of each (button) element. 51 // The map records the 'required' state of each (button) element.
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 ASSERT(!m_requiredCount); 174 ASSERT(!m_requiredCount);
174 ASSERT(!m_checkedButton); 175 ASSERT(!m_checkedButton);
175 } else if (wasValid != isValid()) { 176 } else if (wasValid != isValid()) {
176 setNeedsValidityCheckForAllButtons(); 177 setNeedsValidityCheckForAllButtons();
177 } 178 }
178 if (!wasValid) { 179 if (!wasValid) {
179 // A radio button not in a group is always valid. We need to make it 180 // A radio button not in a group is always valid. We need to make it
180 // valid only if the group was invalid. 181 // valid only if the group was invalid.
181 button->setNeedsValidityCheck(); 182 button->setNeedsValidityCheck();
182 } 183 }
184
185 // Send notification to update AX attributes for AXObjects which radiobutton group has.
186 if (!m_members.isEmpty()) {
187 HTMLInputElement* input = m_members.begin()->key;
188 if (AXObjectCache* cache = input->document().existingAXObjectCache())
189 cache->radiobuttonRemovedFromGroup(input);
190 }
183 } 191 }
184 192
185 void RadioButtonGroup::setNeedsValidityCheckForAllButtons() 193 void RadioButtonGroup::setNeedsValidityCheckForAllButtons()
186 { 194 {
187 for (auto& element : m_members) { 195 for (auto& element : m_members) {
188 HTMLInputElement* const button = element.key; 196 HTMLInputElement* const button = element.key;
189 ASSERT(button->type() == InputTypeNames::radio); 197 ASSERT(button->type() == InputTypeNames::radio);
190 button->setNeedsValidityCheck(); 198 button->setNeedsValidityCheck();
191 } 199 }
192 } 200 }
193 201
194 bool RadioButtonGroup::contains(HTMLInputElement* button) const 202 bool RadioButtonGroup::contains(HTMLInputElement* button) const
195 { 203 {
196 return m_members.contains(button); 204 return m_members.contains(button);
197 } 205 }
198 206
207 unsigned RadioButtonGroup::sizeOfMembers() const
208 {
209 return m_members.size();
210 }
211
199 DEFINE_TRACE(RadioButtonGroup) 212 DEFINE_TRACE(RadioButtonGroup)
200 { 213 {
201 #if ENABLE(OILPAN) 214 #if ENABLE(OILPAN)
202 visitor->trace(m_members); 215 visitor->trace(m_members);
203 visitor->trace(m_checkedButton); 216 visitor->trace(m_checkedButton);
204 #endif 217 #endif
205 } 218 }
206 219
207 // ---------------------------------------------------------------- 220 // ----------------------------------------------------------------
208 221
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 { 283 {
271 ASSERT(element->type() == InputTypeNames::radio); 284 ASSERT(element->type() == InputTypeNames::radio);
272 if (element->name().isEmpty()) 285 if (element->name().isEmpty())
273 return false; 286 return false;
274 if (!m_nameToGroupMap) 287 if (!m_nameToGroupMap)
275 return false; 288 return false;
276 RadioButtonGroup* group = m_nameToGroupMap->get(element->name()); 289 RadioButtonGroup* group = m_nameToGroupMap->get(element->name());
277 return group && group->isRequired() && group->contains(element); 290 return group && group->isRequired() && group->contains(element);
278 } 291 }
279 292
293 unsigned RadioButtonGroupScope::sizeOfGroup(const HTMLInputElement* element) con st
294 {
295 if (!m_nameToGroupMap)
296 return 0;
297
298 RadioButtonGroup* group = m_nameToGroupMap->get(element->name());
299 if (!group)
300 return 0;
301 return group->sizeOfMembers();
302 }
303
280 void RadioButtonGroupScope::removeButton(HTMLInputElement* element) 304 void RadioButtonGroupScope::removeButton(HTMLInputElement* element)
281 { 305 {
282 ASSERT(element->type() == InputTypeNames::radio); 306 ASSERT(element->type() == InputTypeNames::radio);
283 if (element->name().isEmpty()) 307 if (element->name().isEmpty())
284 return; 308 return;
285 if (!m_nameToGroupMap) 309 if (!m_nameToGroupMap)
286 return; 310 return;
287 311
288 RadioButtonGroup* group = m_nameToGroupMap->get(element->name()); 312 RadioButtonGroup* group = m_nameToGroupMap->get(element->name());
289 if (!group) 313 if (!group)
290 return; 314 return;
291 group->remove(element); 315 group->remove(element);
292 if (group->isEmpty()) { 316 if (group->isEmpty()) {
293 // We don't remove an empty RadioButtonGroup from m_nameToGroupMap for 317 // We don't remove an empty RadioButtonGroup from m_nameToGroupMap for
294 // better performance. 318 // better performance.
295 ASSERT(!group->isRequired()); 319 ASSERT(!group->isRequired());
296 ASSERT_WITH_SECURITY_IMPLICATION(!group->checkedButton()); 320 ASSERT_WITH_SECURITY_IMPLICATION(!group->checkedButton());
297 } 321 }
298 } 322 }
299 323
300 DEFINE_TRACE(RadioButtonGroupScope) 324 DEFINE_TRACE(RadioButtonGroupScope)
301 { 325 {
302 #if ENABLE(OILPAN) 326 #if ENABLE(OILPAN)
303 visitor->trace(m_nameToGroupMap); 327 visitor->trace(m_nameToGroupMap);
304 #endif 328 #endif
305 } 329 }
306 330
307 } // namespace blink 331 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698