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

Side by Side Diff: Source/modules/accessibility/AXObjectCacheImpl.cpp

Issue 1175533004: Refactor: Clear m_axObjectCache when AXObject detaches (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added ASSERT Created 5 years, 6 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) 2014, Google Inc. All rights reserved. 2 * Copyright (C) 2014, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObject* layoutO bject) 269 PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObject* layoutO bject)
270 { 270 {
271 // FIXME: How could layoutObject->node() ever not be an Element? 271 // FIXME: How could layoutObject->node() ever not be an Element?
272 Node* node = layoutObject->node(); 272 Node* node = layoutObject->node();
273 273
274 // If the node is aria role="list" or the aria role is empty and its a 274 // If the node is aria role="list" or the aria role is empty and its a
275 // ul/ol/dl type (it shouldn't be a list if aria says otherwise). 275 // ul/ol/dl type (it shouldn't be a list if aria says otherwise).
276 if (nodeHasRole(node, "list") || nodeHasRole(node, "directory") 276 if (nodeHasRole(node, "list") || nodeHasRole(node, "directory")
277 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(node) || isHTMLOL istElement(node) || isHTMLDListElement(node)))) 277 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(node) || isHTMLOL istElement(node) || isHTMLDListElement(node))))
278 return AXList::create(layoutObject, this); 278 return AXList::create(layoutObject, *this);
279 279
280 // aria tables 280 // aria tables
281 if (nodeHasRole(node, "grid") || nodeHasRole(node, "treegrid")) 281 if (nodeHasRole(node, "grid") || nodeHasRole(node, "treegrid"))
282 return AXARIAGrid::create(layoutObject, this); 282 return AXARIAGrid::create(layoutObject, *this);
283 if (nodeHasRole(node, "row")) 283 if (nodeHasRole(node, "row"))
284 return AXARIAGridRow::create(layoutObject, this); 284 return AXARIAGridRow::create(layoutObject, *this);
285 if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "columnheader") || no deHasRole(node, "rowheader")) 285 if (nodeHasRole(node, "gridcell") || nodeHasRole(node, "columnheader") || no deHasRole(node, "rowheader"))
286 return AXARIAGridCell::create(layoutObject, this); 286 return AXARIAGridCell::create(layoutObject, *this);
287 287
288 // media controls 288 // media controls
289 if (node && node->isMediaControlElement()) 289 if (node && node->isMediaControlElement())
290 return AccessibilityMediaControl::create(layoutObject, this); 290 return AccessibilityMediaControl::create(layoutObject, *this);
291 291
292 if (isHTMLOptionElement(node)) 292 if (isHTMLOptionElement(node))
293 return AXListBoxOption::create(layoutObject, this); 293 return AXListBoxOption::create(layoutObject, *this);
294 294
295 if (layoutObject->isSVGRoot()) 295 if (layoutObject->isSVGRoot())
296 return AXSVGRoot::create(layoutObject, this); 296 return AXSVGRoot::create(layoutObject, *this);
297 297
298 if (layoutObject->isBoxModelObject()) { 298 if (layoutObject->isBoxModelObject()) {
299 LayoutBoxModelObject* cssBox = toLayoutBoxModelObject(layoutObject); 299 LayoutBoxModelObject* cssBox = toLayoutBoxModelObject(layoutObject);
300 if (cssBox->isListBox()) 300 if (cssBox->isListBox())
301 return AXListBox::create(toLayoutListBox(cssBox), this); 301 return AXListBox::create(toLayoutListBox(cssBox), *this);
302 if (cssBox->isMenuList()) 302 if (cssBox->isMenuList())
303 return AXMenuList::create(toLayoutMenuList(cssBox), this); 303 return AXMenuList::create(toLayoutMenuList(cssBox), *this);
304 304
305 // standard tables 305 // standard tables
306 if (cssBox->isTable()) 306 if (cssBox->isTable())
307 return AXTable::create(toLayoutTable(cssBox), this); 307 return AXTable::create(toLayoutTable(cssBox), *this);
308 if (cssBox->isTableRow()) 308 if (cssBox->isTableRow())
309 return AXTableRow::create(toLayoutTableRow(cssBox), this); 309 return AXTableRow::create(toLayoutTableRow(cssBox), *this);
310 if (cssBox->isTableCell()) 310 if (cssBox->isTableCell())
311 return AXTableCell::create(toLayoutTableCell(cssBox), this); 311 return AXTableCell::create(toLayoutTableCell(cssBox), *this);
312 312
313 // progress bar 313 // progress bar
314 if (cssBox->isProgress()) 314 if (cssBox->isProgress())
315 return AXProgressIndicator::create(toLayoutProgress(cssBox), this); 315 return AXProgressIndicator::create(toLayoutProgress(cssBox), *this);
316 316
317 // input type=range 317 // input type=range
318 if (cssBox->isSlider()) 318 if (cssBox->isSlider())
319 return AXSlider::create(toLayoutSlider(cssBox), this); 319 return AXSlider::create(toLayoutSlider(cssBox), *this);
320 } 320 }
321 321
322 return AXLayoutObject::create(layoutObject, this); 322 return AXLayoutObject::create(layoutObject, *this);
323 } 323 }
324 324
325 PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node) 325 PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node)
326 { 326 {
327 if (isMenuListOption(node)) 327 if (isMenuListOption(node))
328 return AXMenuListOption::create(toHTMLOptionElement(node), this); 328 return AXMenuListOption::create(toHTMLOptionElement(node), *this);
329 329
330 return AXNodeObject::create(node, this); 330 return AXNodeObject::create(node, *this);
331 } 331 }
332 332
333 PassRefPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTe xtBox* inlineTextBox) 333 PassRefPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTe xtBox* inlineTextBox)
334 { 334 {
335 return AXInlineTextBox::create(inlineTextBox, this); 335 return AXInlineTextBox::create(inlineTextBox, *this);
336 } 336 }
337 337
338 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) 338 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget)
339 { 339 {
340 if (!widget) 340 if (!widget)
341 return 0; 341 return 0;
342 342
343 if (AXObject* obj = get(widget)) 343 if (AXObject* obj = get(widget))
344 return obj; 344 return obj;
345 345
346 RefPtr<AXObject> newObj = nullptr; 346 RefPtr<AXObject> newObj = nullptr;
347 if (widget->isFrameView()) { 347 if (widget->isFrameView()) {
348 FrameView* frameView = toFrameView(widget); 348 FrameView* frameView = toFrameView(widget);
349 349
350 // Don't create an AXScrollView for a FrameView that isn't attached to a frame, 350 // Don't create an AXScrollView for a FrameView that isn't attached to a frame,
351 // for example if it's in the process of being disposed. 351 // for example if it's in the process of being disposed.
352 if (frameView->frame().view() != frameView || !frameView->layoutView()) 352 if (frameView->frame().view() != frameView || !frameView->layoutView())
353 return 0; 353 return 0;
354 354
355 newObj = AXScrollView::create(toFrameView(widget), this); 355 newObj = AXScrollView::create(toFrameView(widget), *this);
356 } else if (widget->isScrollbar()) 356 } else if (widget->isScrollbar()) {
357 newObj = AXScrollbar::create(toScrollbar(widget), this); 357 newObj = AXScrollbar::create(toScrollbar(widget), *this);
358 }
358 359
359 // Will crash later if we have two objects for the same widget. 360 // Will crash later if we have two objects for the same widget.
360 ASSERT(!get(widget)); 361 ASSERT(!get(widget));
361 362
362 // Catch the case if an (unsupported) widget type is used. Only FrameView an d ScrollBar are supported now. 363 // Catch the case if an (unsupported) widget type is used. Only FrameView an d ScrollBar are supported now.
363 ASSERT(newObj); 364 ASSERT(newObj);
364 if (!newObj) 365 if (!newObj)
365 return 0; 366 return 0;
366 367
367 getAXID(newObj.get()); 368 getAXID(newObj.get());
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return getOrCreate(m_document.view()); 462 return getOrCreate(m_document.view());
462 } 463 }
463 464
464 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role) 465 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role)
465 { 466 {
466 RefPtr<AXObject> obj = nullptr; 467 RefPtr<AXObject> obj = nullptr;
467 468
468 // will be filled in... 469 // will be filled in...
469 switch (role) { 470 switch (role) {
470 case ImageMapLinkRole: 471 case ImageMapLinkRole:
471 obj = AXImageMapLink::create(this); 472 obj = AXImageMapLink::create(*this);
472 break; 473 break;
473 case ColumnRole: 474 case ColumnRole:
474 obj = AXTableColumn::create(this); 475 obj = AXTableColumn::create(*this);
475 break; 476 break;
476 case TableHeaderContainerRole: 477 case TableHeaderContainerRole:
477 obj = AXTableHeaderContainer::create(this); 478 obj = AXTableHeaderContainer::create(*this);
478 break; 479 break;
479 case SliderThumbRole: 480 case SliderThumbRole:
480 obj = AXSliderThumb::create(this); 481 obj = AXSliderThumb::create(*this);
481 break; 482 break;
482 case MenuListPopupRole: 483 case MenuListPopupRole:
483 obj = AXMenuListPopup::create(this); 484 obj = AXMenuListPopup::create(*this);
484 break; 485 break;
485 case SpinButtonRole: 486 case SpinButtonRole:
486 obj = AXSpinButton::create(this); 487 obj = AXSpinButton::create(*this);
487 break; 488 break;
488 case SpinButtonPartRole: 489 case SpinButtonPartRole:
489 obj = AXSpinButtonPart::create(this); 490 obj = AXSpinButtonPart::create(*this);
490 break; 491 break;
491 default: 492 default:
492 obj = nullptr; 493 obj = nullptr;
493 } 494 }
494 495
495 if (obj) 496 if (obj)
496 getAXID(obj.get()); 497 getAXID(obj.get());
497 else 498 else
498 return 0; 499 return 0;
499 500
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 706
706 m_notificationPostTimer.stop(); 707 m_notificationPostTimer.stop();
707 708
708 unsigned i = 0, count = m_notificationsToPost.size(); 709 unsigned i = 0, count = m_notificationsToPost.size();
709 for (i = 0; i < count; ++i) { 710 for (i = 0; i < count; ++i) {
710 AXObject* obj = m_notificationsToPost[i].first.get(); 711 AXObject* obj = m_notificationsToPost[i].first.get();
711 712
712 if (!obj->axObjectID()) 713 if (!obj->axObjectID())
713 continue; 714 continue;
714 715
715 if (!obj->axObjectCache()) 716 if (obj->isDetached())
716 continue; 717 continue;
717 718
718 #if ENABLE(ASSERT) 719 #if ENABLE(ASSERT)
719 // Make sure none of the layout views are in the process of being layed out. 720 // Make sure none of the layout views are in the process of being layed out.
720 // Notifications should only be sent after the layoutObject has finished 721 // Notifications should only be sent after the layoutObject has finished
721 if (obj->isAXLayoutObject()) { 722 if (obj->isAXLayoutObject()) {
722 AXLayoutObject* layoutObj = toAXLayoutObject(obj); 723 AXLayoutObject* layoutObj = toAXLayoutObject(obj);
723 LayoutObject* layoutObject = layoutObj->layoutObject(); 724 LayoutObject* layoutObject = layoutObj->layoutObject();
724 if (layoutObject && layoutObject->view()) 725 if (layoutObject && layoutObject->view())
725 ASSERT(!layoutObject->view()->layoutState()); 726 ASSERT(!layoutObject->view()->layoutState());
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
1347 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect) 1348 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect)
1348 { 1349 {
1349 AXObject* obj = getOrCreate(element); 1350 AXObject* obj = getOrCreate(element);
1350 if (!obj) 1351 if (!obj)
1351 return; 1352 return;
1352 1353
1353 obj->setElementRect(rect); 1354 obj->setElementRect(rect);
1354 } 1355 }
1355 1356
1356 } // namespace blink 1357 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXObject.cpp ('k') | Source/modules/accessibility/AXProgressIndicator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698