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

Side by Side Diff: Source/modules/accessibility/AXTable.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
« no previous file with comments | « Source/modules/accessibility/AXTable.h ('k') | Source/modules/accessibility/AXTableCell.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple 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 30 matching lines...) Expand all
41 #include "core/layout/LayoutTableCell.h" 41 #include "core/layout/LayoutTableCell.h"
42 #include "modules/accessibility/AXObjectCacheImpl.h" 42 #include "modules/accessibility/AXObjectCacheImpl.h"
43 #include "modules/accessibility/AXTableCell.h" 43 #include "modules/accessibility/AXTableCell.h"
44 #include "modules/accessibility/AXTableColumn.h" 44 #include "modules/accessibility/AXTableColumn.h"
45 #include "modules/accessibility/AXTableRow.h" 45 #include "modules/accessibility/AXTableRow.h"
46 46
47 namespace blink { 47 namespace blink {
48 48
49 using namespace HTMLNames; 49 using namespace HTMLNames;
50 50
51 AXTable::AXTable(LayoutObject* layoutObject, AXObjectCacheImpl* axObjectCache) 51 AXTable::AXTable(LayoutObject* layoutObject, AXObjectCacheImpl& axObjectCache)
52 : AXLayoutObject(layoutObject, axObjectCache) 52 : AXLayoutObject(layoutObject, axObjectCache)
53 , m_headerContainer(nullptr) 53 , m_headerContainer(nullptr)
54 , m_isAXTable(true) 54 , m_isAXTable(true)
55 { 55 {
56 } 56 }
57 57
58 AXTable::~AXTable() 58 AXTable::~AXTable()
59 { 59 {
60 } 60 }
61 61
62 void AXTable::init() 62 void AXTable::init()
63 { 63 {
64 AXLayoutObject::init(); 64 AXLayoutObject::init();
65 m_isAXTable = isTableExposableThroughAccessibility(); 65 m_isAXTable = isTableExposableThroughAccessibility();
66 } 66 }
67 67
68 PassRefPtr<AXTable> AXTable::create(LayoutObject* layoutObject, AXObjectCacheImp l* axObjectCache) 68 PassRefPtr<AXTable> AXTable::create(LayoutObject* layoutObject, AXObjectCacheImp l& axObjectCache)
69 { 69 {
70 return adoptRef(new AXTable(layoutObject, axObjectCache)); 70 return adoptRef(new AXTable(layoutObject, axObjectCache));
71 } 71 }
72 72
73 bool AXTable::hasARIARole() const 73 bool AXTable::hasARIARole() const
74 { 74 {
75 if (!m_layoutObject) 75 if (!m_layoutObject)
76 return false; 76 return false;
77 77
78 AccessibilityRole ariaRole = ariaRoleAttribute(); 78 AccessibilityRole ariaRole = ariaRoleAttribute();
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 return; 364 return;
365 } 365 }
366 366
367 ASSERT(!m_haveChildren); 367 ASSERT(!m_haveChildren);
368 368
369 m_haveChildren = true; 369 m_haveChildren = true;
370 if (!m_layoutObject || !m_layoutObject->isTable()) 370 if (!m_layoutObject || !m_layoutObject->isTable())
371 return; 371 return;
372 372
373 LayoutTable* table = toLayoutTable(m_layoutObject); 373 LayoutTable* table = toLayoutTable(m_layoutObject);
374 AXObjectCacheImpl* axCache = axObjectCache(); 374 AXObjectCacheImpl& axCache = axObjectCache();
375 375
376 Node* tableNode = table->node(); 376 Node* tableNode = table->node();
377 if (!isHTMLTableElement(tableNode)) 377 if (!isHTMLTableElement(tableNode))
378 return; 378 return;
379 379
380 // Add caption 380 // Add caption
381 if (HTMLTableCaptionElement* caption = toHTMLTableElement(tableNode)->capti on()) { 381 if (HTMLTableCaptionElement* caption = toHTMLTableElement(tableNode)->capti on()) {
382 AXObject* captionObject = axCache->getOrCreate(caption); 382 AXObject* captionObject = axCache.getOrCreate(caption);
383 if (captionObject && !captionObject->accessibilityIsIgnored()) 383 if (captionObject && !captionObject->accessibilityIsIgnored())
384 m_children.append(captionObject); 384 m_children.append(captionObject);
385 } 385 }
386 386
387 // Go through all the available sections to pull out the rows and add them a s children. 387 // Go through all the available sections to pull out the rows and add them a s children.
388 table->recalcSectionsIfNeeded(); 388 table->recalcSectionsIfNeeded();
389 LayoutTableSection* tableSection = table->topSection(); 389 LayoutTableSection* tableSection = table->topSection();
390 if (!tableSection) 390 if (!tableSection)
391 return; 391 return;
392 392
393 LayoutTableSection* initialTableSection = tableSection; 393 LayoutTableSection* initialTableSection = tableSection;
394 while (tableSection) { 394 while (tableSection) {
395 395
396 HashSet<AXObject*> appendedRows; 396 HashSet<AXObject*> appendedRows;
397 unsigned numRows = tableSection->numRows(); 397 unsigned numRows = tableSection->numRows();
398 for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) { 398 for (unsigned rowIndex = 0; rowIndex < numRows; ++rowIndex) {
399 399
400 LayoutTableRow* layoutRow = tableSection->rowLayoutObjectAt(rowIndex ); 400 LayoutTableRow* layoutRow = tableSection->rowLayoutObjectAt(rowIndex );
401 if (!layoutRow) 401 if (!layoutRow)
402 continue; 402 continue;
403 403
404 AXObject* rowObject = axCache->getOrCreate(layoutRow); 404 AXObject* rowObject = axCache.getOrCreate(layoutRow);
405 if (!rowObject || !rowObject->isTableRow()) 405 if (!rowObject || !rowObject->isTableRow())
406 continue; 406 continue;
407 407
408 AXTableRow* row = toAXTableRow(rowObject); 408 AXTableRow* row = toAXTableRow(rowObject);
409 // We need to check every cell for a new row, because cell spans 409 // We need to check every cell for a new row, because cell spans
410 // can cause us to miss rows if we just check the first column. 410 // can cause us to miss rows if we just check the first column.
411 if (appendedRows.contains(row)) 411 if (appendedRows.contains(row))
412 continue; 412 continue;
413 413
414 row->setRowIndex(static_cast<int>(m_rows.size())); 414 row->setRowIndex(static_cast<int>(m_rows.size()));
415 m_rows.append(row); 415 m_rows.append(row);
416 if (!row->accessibilityIsIgnored()) 416 if (!row->accessibilityIsIgnored())
417 m_children.append(row); 417 m_children.append(row);
418 appendedRows.add(row); 418 appendedRows.add(row);
419 } 419 }
420 420
421 tableSection = table->sectionBelow(tableSection, SkipEmptySections); 421 tableSection = table->sectionBelow(tableSection, SkipEmptySections);
422 } 422 }
423 423
424 // make the columns based on the number of columns in the first body 424 // make the columns based on the number of columns in the first body
425 unsigned length = initialTableSection->numColumns(); 425 unsigned length = initialTableSection->numColumns();
426 for (unsigned i = 0; i < length; ++i) { 426 for (unsigned i = 0; i < length; ++i) {
427 AXTableColumn* column = toAXTableColumn(axCache->getOrCreate(ColumnRole) ); 427 AXTableColumn* column = toAXTableColumn(axCache.getOrCreate(ColumnRole)) ;
428 column->setColumnIndex((int)i); 428 column->setColumnIndex((int)i);
429 column->setParent(this); 429 column->setParent(this);
430 m_columns.append(column); 430 m_columns.append(column);
431 if (!column->accessibilityIsIgnored()) 431 if (!column->accessibilityIsIgnored())
432 m_children.append(column); 432 m_children.append(column);
433 } 433 }
434 434
435 AXObject* headerContainerObject = headerContainer(); 435 AXObject* headerContainerObject = headerContainer();
436 if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored( )) 436 if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored( ))
437 m_children.append(headerContainerObject); 437 m_children.append(headerContainerObject);
438 } 438 }
439 439
440 AXObject* AXTable::headerContainer() 440 AXObject* AXTable::headerContainer()
441 { 441 {
442 if (m_headerContainer) 442 if (m_headerContainer)
443 return m_headerContainer.get(); 443 return m_headerContainer.get();
444 444
445 AXMockObject* tableHeader = toAXMockObject(axObjectCache()->getOrCreate(Tabl eHeaderContainerRole)); 445 AXMockObject* tableHeader = toAXMockObject(axObjectCache().getOrCreate(Table HeaderContainerRole));
446 tableHeader->setParent(this); 446 tableHeader->setParent(this);
447 447
448 m_headerContainer = tableHeader; 448 m_headerContainer = tableHeader;
449 return m_headerContainer.get(); 449 return m_headerContainer.get();
450 } 450 }
451 451
452 const AXObject::AccessibilityChildrenVector& AXTable::columns() 452 const AXObject::AccessibilityChildrenVector& AXTable::columns()
453 { 453 {
454 updateChildrenIfNecessary(); 454 updateChildrenIfNecessary();
455 455
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 } 586 }
587 587
588 // try the standard 588 // try the standard
589 if (title.isEmpty()) 589 if (title.isEmpty())
590 title = AXLayoutObject::deprecatedTitle(mode); 590 title = AXLayoutObject::deprecatedTitle(mode);
591 591
592 return title; 592 return title;
593 } 593 }
594 594
595 } // namespace blink 595 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXTable.h ('k') | Source/modules/accessibility/AXTableCell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698