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

Side by Side Diff: Source/modules/accessibility/AXARIAGrid.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) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 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 19 matching lines...) Expand all
30 #include "modules/accessibility/AXARIAGrid.h" 30 #include "modules/accessibility/AXARIAGrid.h"
31 31
32 #include "core/layout/LayoutObject.h" 32 #include "core/layout/LayoutObject.h"
33 #include "modules/accessibility/AXObjectCacheImpl.h" 33 #include "modules/accessibility/AXObjectCacheImpl.h"
34 #include "modules/accessibility/AXTableColumn.h" 34 #include "modules/accessibility/AXTableColumn.h"
35 #include "modules/accessibility/AXTableRow.h" 35 #include "modules/accessibility/AXTableRow.h"
36 36
37 37
38 namespace blink { 38 namespace blink {
39 39
40 AXARIAGrid::AXARIAGrid(LayoutObject* layoutObject, AXObjectCacheImpl* axObjectCa che) 40 AXARIAGrid::AXARIAGrid(LayoutObject* layoutObject, AXObjectCacheImpl& axObjectCa che)
41 : AXTable(layoutObject, axObjectCache) 41 : AXTable(layoutObject, axObjectCache)
42 { 42 {
43 } 43 }
44 44
45 AXARIAGrid::~AXARIAGrid() 45 AXARIAGrid::~AXARIAGrid()
46 { 46 {
47 } 47 }
48 48
49 PassRefPtr<AXARIAGrid> AXARIAGrid::create(LayoutObject* layoutObject, AXObjectCa cheImpl* axObjectCache) 49 PassRefPtr<AXARIAGrid> AXARIAGrid::create(LayoutObject* layoutObject, AXObjectCa cheImpl& axObjectCache)
50 { 50 {
51 return adoptRef(new AXARIAGrid(layoutObject, axObjectCache)); 51 return adoptRef(new AXARIAGrid(layoutObject, axObjectCache));
52 } 52 }
53 53
54 bool AXARIAGrid::addTableCellChild(AXObject* child, HashSet<AXObject*>& appended Rows, unsigned& columnCount) 54 bool AXARIAGrid::addTableCellChild(AXObject* child, HashSet<AXObject*>& appended Rows, unsigned& columnCount)
55 { 55 {
56 if (!child || !child->isTableRow() || child->ariaRoleAttribute() != RowRole) 56 if (!child || !child->isTableRow() || child->ariaRoleAttribute() != RowRole)
57 return false; 57 return false;
58 58
59 AXTableRow* row = toAXTableRow(child); 59 AXTableRow* row = toAXTableRow(child);
(...skipping 25 matching lines...) Expand all
85 85
86 if (!isAXTable()) { 86 if (!isAXTable()) {
87 AXLayoutObject::addChildren(); 87 AXLayoutObject::addChildren();
88 return; 88 return;
89 } 89 }
90 90
91 m_haveChildren = true; 91 m_haveChildren = true;
92 if (!m_layoutObject) 92 if (!m_layoutObject)
93 return; 93 return;
94 94
95 AXObjectCacheImpl* axCache = axObjectCache(); 95 AXObjectCacheImpl& axCache = axObjectCache();
96 96
97 // add only rows that are labeled as aria rows 97 // add only rows that are labeled as aria rows
98 HashSet<AXObject*> appendedRows; 98 HashSet<AXObject*> appendedRows;
99 unsigned columnCount = 0; 99 unsigned columnCount = 0;
100 for (RefPtr<AXObject> child = firstChild(); child; child = child->nextSiblin g()) { 100 for (RefPtr<AXObject> child = firstChild(); child; child = child->nextSiblin g()) {
101 101
102 if (!addTableCellChild(child.get(), appendedRows, columnCount)) { 102 if (!addTableCellChild(child.get(), appendedRows, columnCount)) {
103 103
104 // in case the layout tree doesn't match the expected ARIA hierarchy , look at the children 104 // in case the layout tree doesn't match the expected ARIA hierarchy , look at the children
105 if (!child->hasChildren()) 105 if (!child->hasChildren())
106 child->addChildren(); 106 child->addChildren();
107 107
108 // The children of this non-row will contain all non-ignored element s (recursing to find them). 108 // The children of this non-row will contain all non-ignored element s (recursing to find them).
109 // This allows the table to dive arbitrarily deep to find the rows. 109 // This allows the table to dive arbitrarily deep to find the rows.
110 for (const auto& childObject : child->children()) 110 for (const auto& childObject : child->children())
111 addTableCellChild(childObject.get(), appendedRows, columnCount); 111 addTableCellChild(childObject.get(), appendedRows, columnCount);
112 } 112 }
113 } 113 }
114 114
115 // make the columns based on the number of columns in the first body 115 // make the columns based on the number of columns in the first body
116 for (unsigned i = 0; i < columnCount; ++i) { 116 for (unsigned i = 0; i < columnCount; ++i) {
117 AXTableColumn* column = toAXTableColumn(axCache->getOrCreate(ColumnRole) ); 117 AXTableColumn* column = toAXTableColumn(axCache.getOrCreate(ColumnRole)) ;
118 column->setColumnIndex((int)i); 118 column->setColumnIndex((int)i);
119 column->setParent(this); 119 column->setParent(this);
120 m_columns.append(column); 120 m_columns.append(column);
121 if (!column->accessibilityIsIgnored()) 121 if (!column->accessibilityIsIgnored())
122 m_children.append(column); 122 m_children.append(column);
123 } 123 }
124 124
125 AXObject* headerContainerObject = headerContainer(); 125 AXObject* headerContainerObject = headerContainer();
126 if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored( )) 126 if (headerContainerObject && !headerContainerObject->accessibilityIsIgnored( ))
127 m_children.append(headerContainerObject); 127 m_children.append(headerContainerObject);
128 } 128 }
129 129
130 } // namespace blink 130 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXARIAGrid.h ('k') | Source/modules/accessibility/AXARIAGridCell.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698