OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/accessibility/AXRadioInput.h" | 5 #include "modules/accessibility/AXRadioInput.h" |
6 | 6 |
7 #include "core/InputTypeNames.h" | 7 #include "core/InputTypeNames.h" |
8 #include "core/html/HTMLInputElement.h" | 8 #include "core/html/HTMLInputElement.h" |
9 #include "core/html/forms/RadioInputType.h" | 9 #include "core/html/forms/RadioInputType.h" |
10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 | 32 |
33 void AXRadioInput::UpdatePosAndSetSize(int position) { | 33 void AXRadioInput::UpdatePosAndSetSize(int position) { |
34 if (position) | 34 if (position) |
35 pos_in_set_ = position; | 35 pos_in_set_ = position; |
36 set_size_ = SizeOfRadioGroup(); | 36 set_size_ = SizeOfRadioGroup(); |
37 } | 37 } |
38 | 38 |
39 void AXRadioInput::RequestUpdateToNextNode(bool forward) { | 39 void AXRadioInput::RequestUpdateToNextNode(bool forward) { |
40 HTMLInputElement* next_element = | 40 HTMLInputElement* next_element = |
41 RadioInputType::NextRadioButtonInGroup(GetElement(), forward); | 41 RadioInputType::NextRadioButtonInGroup(GetElement(), forward); |
42 AXObject* next_a_xobject = AxObjectCache().Get(next_element); | 42 AXObjectImpl* next_a_xobject = AxObjectCache().Get(next_element); |
43 if (!next_a_xobject || !next_a_xobject->IsAXRadioInput()) | 43 if (!next_a_xobject || !next_a_xobject->IsAXRadioInput()) |
44 return; | 44 return; |
45 | 45 |
46 int position = 0; | 46 int position = 0; |
47 if (forward) | 47 if (forward) |
48 position = PosInSet() + 1; | 48 position = PosInSet() + 1; |
49 // If it is backward, it keeps position as positions are already assigned for | 49 // If it is backward, it keeps position as positions are already assigned for |
50 // previous objects. updatePosAndSetSize() is called with '0' and it doesn't | 50 // previous objects. updatePosAndSetSize() is called with '0' and it doesn't |
51 // modify m_posInSet and updates m_setSize as size is increased. | 51 // modify m_posInSet and updates m_setSize as size is increased. |
52 | 52 |
(...skipping 25 matching lines...) Expand all Loading... |
78 | 78 |
79 bool AXRadioInput::CalculatePosInSet() { | 79 bool AXRadioInput::CalculatePosInSet() { |
80 // Calculate 'posInSet' attribute when AXRadioInputs need to be updated | 80 // Calculate 'posInSet' attribute when AXRadioInputs need to be updated |
81 // as a new AXRadioInput Object is added or one of objects from RadioGroup is | 81 // as a new AXRadioInput Object is added or one of objects from RadioGroup is |
82 // removed. | 82 // removed. |
83 bool need_to_update_prev = false; | 83 bool need_to_update_prev = false; |
84 int position = 1; | 84 int position = 1; |
85 HTMLInputElement* prev_element = | 85 HTMLInputElement* prev_element = |
86 RadioInputType::NextRadioButtonInGroup(GetElement(), false); | 86 RadioInputType::NextRadioButtonInGroup(GetElement(), false); |
87 if (prev_element) { | 87 if (prev_element) { |
88 AXObject* object = AxObjectCache().Get(prev_element); | 88 AXObjectImpl* object = AxObjectCache().Get(prev_element); |
89 // If the previous element doesn't have AXObject yet, caculate position from | 89 // If the previous element doesn't have AXObjectImpl yet, caculate position |
90 // the first element. Otherwise, get position from the previous AXObject. | 90 // from the first element. Otherwise, get position from the previous |
| 91 // AXObjectImpl. |
91 if (!object || !object->IsAXRadioInput()) { | 92 if (!object || !object->IsAXRadioInput()) { |
92 position = CountFromFirstElement(); | 93 position = CountFromFirstElement(); |
93 } else { | 94 } else { |
94 position = object->PosInSet() + 1; | 95 position = object->PosInSet() + 1; |
95 // It returns true if previous objects need to be updated. | 96 // It returns true if previous objects need to be updated. |
96 // When AX tree exists already and a new node is inserted, | 97 // When AX tree exists already and a new node is inserted, |
97 // as updating is started from the inserted node, | 98 // as updating is started from the inserted node, |
98 // we need to update setSize for previous nodes. | 99 // we need to update setSize for previous nodes. |
99 if (SetSize() != object->SetSize()) | 100 if (SetSize() != object->SetSize()) |
100 need_to_update_prev = true; | 101 need_to_update_prev = true; |
(...skipping 24 matching lines...) Expand all Loading... |
125 | 126 |
126 int AXRadioInput::SizeOfRadioGroup() const { | 127 int AXRadioInput::SizeOfRadioGroup() const { |
127 int size = GetElement()->SizeOfRadioGroup(); | 128 int size = GetElement()->SizeOfRadioGroup(); |
128 // If it has no size in Group, it means that there is only itself. | 129 // If it has no size in Group, it means that there is only itself. |
129 if (!size) | 130 if (!size) |
130 return 1; | 131 return 1; |
131 return size; | 132 return size; |
132 } | 133 } |
133 | 134 |
134 } // namespace blink | 135 } // namespace blink |
OLD | NEW |