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

Side by Side Diff: content/browser/accessibility/browser_accessibility.cc

Issue 1941463002: Removes the restriction placed on the role of the accessibility object when calling the next/previo… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment and discovered that images don't work. Created 4 years, 7 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
« no previous file with comments | « no previous file | content/renderer/accessibility/blink_ax_tree_source.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/accessibility/browser_accessibility.h" 5 #include "content/browser/accessibility/browser_accessibility.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 } 184 }
185 185
186 return nullptr; 186 return nullptr;
187 } 187 }
188 188
189 bool BrowserAccessibility::IsPreviousSiblingOnSameLine() const { 189 bool BrowserAccessibility::IsPreviousSiblingOnSameLine() const {
190 const BrowserAccessibility* previous_sibling = GetPreviousSibling(); 190 const BrowserAccessibility* previous_sibling = GetPreviousSibling();
191 if (!previous_sibling) 191 if (!previous_sibling)
192 return false; 192 return false;
193 193
194 const BrowserAccessibility* text_object = this; 194 // Line linkage information might not be provided on non-leaf objects.
195 while (!text_object->IsTextOnlyObject()) { 195 const BrowserAccessibility* leaf_object = PlatformDeepestFirstChild();
196 // If we don't find a text object, then sibling cannot be on the same line. 196 if (!leaf_object)
197 if (!text_object->InternalChildCount()) 197 leaf_object = this;
198 return false;
199 text_object = text_object->InternalGetChild(0);
200 }
201 198
202 int32_t previous_on_line_id; 199 int32_t previous_on_line_id;
203 if (text_object->GetIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID, 200 if (leaf_object->GetIntAttribute(ui::AX_ATTR_PREVIOUS_ON_LINE_ID,
204 &previous_on_line_id)) { 201 &previous_on_line_id)) {
205 const BrowserAccessibility* previous_on_line = 202 const BrowserAccessibility* previous_on_line =
206 manager()->GetFromID(previous_on_line_id); 203 manager()->GetFromID(previous_on_line_id);
207 // In the case of static text objects, the object designated to be the 204 // In the case of a static text sibling, the object designated to be the
208 // previous object on this line might be a child of the previous sibling, 205 // previous object on this line might be one of its children, i.e. the last
209 // i.e. the last inline text box of the previous static text object. 206 // inline text box.
210 return previous_on_line && 207 return previous_on_line &&
211 previous_on_line->IsDescendantOf(previous_sibling); 208 previous_on_line->IsDescendantOf(previous_sibling);
212 } 209 }
213 return false; 210 return false;
214 } 211 }
215 212
216 bool BrowserAccessibility::IsNextSiblingOnSameLine() const { 213 bool BrowserAccessibility::IsNextSiblingOnSameLine() const {
217 const BrowserAccessibility* next_sibling = GetNextSibling(); 214 const BrowserAccessibility* next_sibling = GetNextSibling();
218 if (!next_sibling) 215 if (!next_sibling)
219 return false; 216 return false;
220 217
221 const BrowserAccessibility* text_object = this; 218 // Line linkage information might not be provided on non-leaf objects.
222 while (!text_object->IsTextOnlyObject()) { 219 const BrowserAccessibility* leaf_object = PlatformDeepestLastChild();
223 // If we don't find a text object, then sibling cannot be on the same line. 220 if (!leaf_object)
224 if (!text_object->InternalChildCount()) 221 leaf_object = this;
225 return false;
226 text_object = text_object->InternalGetChild(0);
227 }
228 222
229 int32_t next_on_line_id; 223 int32_t next_on_line_id;
230 if (text_object->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID, 224 if (leaf_object->GetIntAttribute(ui::AX_ATTR_NEXT_ON_LINE_ID,
231 &next_on_line_id)) { 225 &next_on_line_id)) {
232 const BrowserAccessibility* next_on_line = 226 const BrowserAccessibility* next_on_line =
233 manager()->GetFromID(next_on_line_id); 227 manager()->GetFromID(next_on_line_id);
234 // In the case of static text objects, the object designated to be the next 228 // In the case of a static text sibling, the object designated to be the
235 // object on this line might be a child of the next sibling, i.e. the first 229 // next object on this line might be one of its children, i.e. the last
236 // inline text box of the next static text object. 230 // inline text box.
237 return next_on_line && next_on_line->IsDescendantOf(next_sibling); 231 return next_on_line && next_on_line->IsDescendantOf(next_sibling);
238 } 232 }
239 return false; 233 return false;
240 } 234 }
241 235
242 BrowserAccessibility* BrowserAccessibility::PlatformDeepestFirstChild() const { 236 BrowserAccessibility* BrowserAccessibility::PlatformDeepestFirstChild() const {
243 if (!PlatformChildCount()) 237 if (!PlatformChildCount())
244 return nullptr; 238 return nullptr;
245 239
246 BrowserAccessibility* deepest_child = PlatformGetChild(0); 240 BrowserAccessibility* deepest_child = PlatformGetChild(0);
(...skipping 924 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 break; 1165 break;
1172 1166
1173 manager = root->GetParent()->manager(); 1167 manager = root->GetParent()->manager();
1174 root = manager->GetRoot(); 1168 root = manager->GetRoot();
1175 } 1169 }
1176 1170
1177 return bounds; 1171 return bounds;
1178 } 1172 }
1179 1173
1180 } // namespace content 1174 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/accessibility/blink_ax_tree_source.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698