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

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

Issue 1072273006: Oilpan: Prepare moving AXObject to heap (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 102
103 AXObjectCacheImpl::~AXObjectCacheImpl() 103 AXObjectCacheImpl::~AXObjectCacheImpl()
104 { 104 {
105 ASSERT(m_hasBeenDisposed); 105 ASSERT(m_hasBeenDisposed);
106 } 106 }
107 107
108 void AXObjectCacheImpl::dispose() 108 void AXObjectCacheImpl::dispose()
109 { 109 {
110 m_notificationPostTimer.stop(); 110 m_notificationPostTimer.stop();
111 111
112 #if ENABLE(OILPAN)
113 for (auto& entry : m_layoutObjectMapping) {
haraken 2015/05/28 10:48:41 Don't we need to call detach() for AbstractInlineT
114 entry.value->detach();
115 }
116 m_layoutObjectMapping.clear();
117
118 HeapHashMap<AXID, WeakMember<AXObject>>::iterator end = m_objects.end();
119 for (HeapHashMap<AXID, WeakMember<AXObject>>::iterator it = m_objects.begin( ); it != end; ++it) {
120 AXObject* obj = (*it).value.get();
121 obj->detach();
122 }
haraken 2015/05/28 10:48:41 You'll need to call m_objects.clear(). Otherwise,
123 #else
112 HashMap<AXID, RefPtr<AXObject>>::iterator end = m_objects.end(); 124 HashMap<AXID, RefPtr<AXObject>>::iterator end = m_objects.end();
113 for (HashMap<AXID, RefPtr<AXObject>>::iterator it = m_objects.begin(); it != end; ++it) { 125 for (HashMap<AXID, RefPtr<AXObject>>::iterator it = m_objects.begin(); it != end; ++it) {
114 AXObject* obj = (*it).value.get(); 126 AXObject* obj = (*it).value.get();
115 obj->detach(); 127 obj->detach();
116 removeAXID(obj); 128 removeAXID(obj);
117 } 129 }
130 #endif
118 131
119 #if ENABLE(ASSERT) 132 #if ENABLE(ASSERT)
120 m_hasBeenDisposed = true; 133 m_hasBeenDisposed = true;
121 #endif 134 #endif
122 } 135 }
123 136
124 AXObject* AXObjectCacheImpl::root() 137 AXObject* AXObjectCacheImpl::root()
125 { 138 {
126 return getOrCreate(&m_document); 139 return getOrCreate(&m_document);
127 } 140 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 obj = obj->parentObjectUnignored(); 200 obj = obj->parentObjectUnignored();
188 201
189 return obj; 202 return obj;
190 } 203 }
191 204
192 AXObject* AXObjectCacheImpl::get(Widget* widget) 205 AXObject* AXObjectCacheImpl::get(Widget* widget)
193 { 206 {
194 if (!widget) 207 if (!widget)
195 return 0; 208 return 0;
196 209
210 #if ENABLE(OILPAN)
211 return m_widgetObjectMapping.get(widget);
212 #else
197 AXID axID = m_widgetObjectMapping.get(widget); 213 AXID axID = m_widgetObjectMapping.get(widget);
198 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); 214 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
199 if (!axID) 215 if (!axID)
200 return 0; 216 return 0;
201 217
202 return m_objects.get(axID); 218 return m_objects.get(axID);
219 #endif
203 } 220 }
204 221
205 AXObject* AXObjectCacheImpl::get(LayoutObject* layoutObject) 222 AXObject* AXObjectCacheImpl::get(LayoutObject* layoutObject)
206 { 223 {
207 if (!layoutObject) 224 if (!layoutObject)
208 return 0; 225 return 0;
209 226
227 #if ENABLE(OILPAN)
228 return m_layoutObjectMapping.get(layoutObject);
229 #else
210 AXID axID = m_layoutObjectMapping.get(layoutObject); 230 AXID axID = m_layoutObjectMapping.get(layoutObject);
211 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); 231 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
212 if (!axID) 232 if (!axID)
213 return 0; 233 return 0;
214 234
215 return m_objects.get(axID); 235 return m_objects.get(axID);
236 #endif
216 } 237 }
217 238
218 // Returns true if |node| is an <option> element and its parent <select> 239 // Returns true if |node| is an <option> element and its parent <select>
219 // is a menu list (not a list box). 240 // is a menu list (not a list box).
220 static bool isMenuListOption(Node* node) 241 static bool isMenuListOption(Node* node)
221 { 242 {
222 if (!isHTMLOptionElement(node)) 243 if (!isHTMLOptionElement(node))
223 return false; 244 return false;
224 HTMLSelectElement* select = toHTMLOptionElement(node)->ownerSelectElement(); 245 HTMLSelectElement* select = toHTMLOptionElement(node)->ownerSelectElement();
225 if (!select) 246 if (!select)
226 return false; 247 return false;
227 LayoutObject* layoutObject = select->layoutObject(); 248 LayoutObject* layoutObject = select->layoutObject();
228 return layoutObject && layoutObject->isMenuList(); 249 return layoutObject && layoutObject->isMenuList();
229 } 250 }
230 251
231 AXObject* AXObjectCacheImpl::get(Node* node) 252 AXObject* AXObjectCacheImpl::get(Node* node)
232 { 253 {
233 if (!node) 254 if (!node)
234 return 0; 255 return 0;
235 256
257 #if ENABLE(OILPAN)
258 AXObject* layoutAXObject = node->layoutObject() ? m_layoutObjectMapping.get (node->layoutObject()) : nullptr;
259 AXObject* nodeAXObject = m_nodeObjectMapping.get(node);
260 if (node->layoutObject() && nodeAXObject && !layoutAXObject && !isMenuListOp tion(node)) {
261 // This can happen if an AXNodeObject is created for a node that's not
262 // laid out, but later something changes and it gets a layoutObject (lik e if it's
263 // reparented).
264 remove(nodeAXObject);
265 return nullptr;
266 }
267 return layoutAXObject ? layoutAXObject : nodeAXObject;
268 #else
236 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou tObject()) : 0; 269 AXID layoutID = node->layoutObject() ? m_layoutObjectMapping.get(node->layou tObject()) : 0;
237 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID)); 270 ASSERT(!HashTraits<AXID>::isDeletedValue(layoutID));
238 271
239 AXID nodeID = m_nodeObjectMapping.get(node); 272 AXID nodeID = m_nodeObjectMapping.get(node);
240 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); 273 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID));
241 274
242 if (node->layoutObject() && nodeID && !layoutID && !isMenuListOption(node)) { 275 if (node->layoutObject() && nodeID && !layoutID && !isMenuListOption(node)) {
243 // This can happen if an AXNodeObject is created for a node that's not 276 // This can happen if an AXNodeObject is created for a node that's not
244 // laid out, but later something changes and it gets a layoutObject (lik e if it's 277 // laid out, but later something changes and it gets a layoutObject (lik e if it's
245 // reparented). 278 // reparented).
246 remove(nodeID); 279 remove(nodeID);
247 return 0; 280 return 0;
248 } 281 }
249 282
250 if (layoutID) 283 if (layoutID)
251 return m_objects.get(layoutID); 284 return m_objects.get(layoutID);
252 285
253 if (!nodeID) 286 if (!nodeID)
254 return 0; 287 return 0;
255 288
256 return m_objects.get(nodeID); 289 return m_objects.get(nodeID);
290 #endif
257 } 291 }
258 292
259 AXObject* AXObjectCacheImpl::get(AbstractInlineTextBox* inlineTextBox) 293 AXObject* AXObjectCacheImpl::get(AbstractInlineTextBox* inlineTextBox)
260 { 294 {
261 if (!inlineTextBox) 295 if (!inlineTextBox)
262 return 0; 296 return 0;
263 297
298 #if ENABLE(OILPAN)
299 return m_inlineTextBoxObjectMapping.get(inlineTextBox);
300 #else
264 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); 301 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox);
265 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); 302 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
266 if (!axID) 303 if (!axID)
267 return 0; 304 return 0;
268 305
269 return m_objects.get(axID); 306 return m_objects.get(axID);
307 #endif
270 } 308 }
271 309
272 // FIXME: This probably belongs on Node. 310 // FIXME: This probably belongs on Node.
273 // FIXME: This should take a const char*, but one caller passes nullAtom. 311 // FIXME: This should take a const char*, but one caller passes nullAtom.
274 bool nodeHasRole(Node* node, const String& role) 312 bool nodeHasRole(Node* node, const String& role)
275 { 313 {
276 if (!node || !node->isElementNode()) 314 if (!node || !node->isElementNode())
277 return false; 315 return false;
278 316
279 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); 317 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role);
280 } 318 }
281 319
282 PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObject* layoutO bject) 320 PassRefPtrWillBeRawPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObj ect* layoutObject)
283 { 321 {
284 // FIXME: How could layoutObject->node() ever not be an Element? 322 // FIXME: How could layoutObject->node() ever not be an Element?
285 Node* node = layoutObject->node(); 323 Node* node = layoutObject->node();
286 324
287 // If the node is aria role="list" or the aria role is empty and its a 325 // If the node is aria role="list" or the aria role is empty and its a
288 // ul/ol/dl type (it shouldn't be a list if aria says otherwise). 326 // ul/ol/dl type (it shouldn't be a list if aria says otherwise).
289 if (nodeHasRole(node, "list") || nodeHasRole(node, "directory") 327 if (nodeHasRole(node, "list") || nodeHasRole(node, "directory")
290 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(node) || isHTMLOL istElement(node) || isHTMLDListElement(node)))) 328 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(node) || isHTMLOL istElement(node) || isHTMLDListElement(node))))
291 return AXList::create(layoutObject, this); 329 return AXList::create(layoutObject, this);
292 330
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 return AXProgressIndicator::create(toLayoutProgress(cssBox), this); 366 return AXProgressIndicator::create(toLayoutProgress(cssBox), this);
329 367
330 // input type=range 368 // input type=range
331 if (cssBox->isSlider()) 369 if (cssBox->isSlider())
332 return AXSlider::create(toLayoutSlider(cssBox), this); 370 return AXSlider::create(toLayoutSlider(cssBox), this);
333 } 371 }
334 372
335 return AXLayoutObject::create(layoutObject, this); 373 return AXLayoutObject::create(layoutObject, this);
336 } 374 }
337 375
338 PassRefPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node) 376 PassRefPtrWillBeRawPtr<AXObject> AXObjectCacheImpl::createFromNode(Node* node)
339 { 377 {
340 if (isMenuListOption(node)) 378 if (isMenuListOption(node))
341 return AXMenuListOption::create(toHTMLOptionElement(node), this); 379 return AXMenuListOption::create(toHTMLOptionElement(node), this);
342 380
343 return AXNodeObject::create(node, this); 381 return AXNodeObject::create(node, this);
344 } 382 }
345 383
346 PassRefPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(AbstractInlineTe xtBox* inlineTextBox) 384 PassRefPtrWillBeRawPtr<AXObject> AXObjectCacheImpl::createFromInlineTextBox(Abst ractInlineTextBox* inlineTextBox)
347 { 385 {
348 return AXInlineTextBox::create(inlineTextBox, this); 386 return AXInlineTextBox::create(inlineTextBox, this);
349 } 387 }
350 388
351 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget) 389 AXObject* AXObjectCacheImpl::getOrCreate(Widget* widget)
352 { 390 {
353 if (!widget) 391 if (!widget)
354 return 0; 392 return 0;
355 393
356 if (AXObject* obj = get(widget)) 394 if (AXObject* obj = get(widget))
357 return obj; 395 return obj;
358 396
359 RefPtr<AXObject> newObj = nullptr; 397 RefPtrWillBeRawPtr<AXObject> newObj = nullptr;
360 if (widget->isFrameView()) 398 if (widget->isFrameView())
361 newObj = AXScrollView::create(toFrameView(widget), this); 399 newObj = AXScrollView::create(toFrameView(widget), this);
362 else if (widget->isScrollbar()) 400 else if (widget->isScrollbar())
363 newObj = AXScrollbar::create(toScrollbar(widget), this); 401 newObj = AXScrollbar::create(toScrollbar(widget), this);
364 402
365 // Will crash later if we have two objects for the same widget. 403 // Will crash later if we have two objects for the same widget.
366 ASSERT(!get(widget)); 404 ASSERT(!get(widget));
367 405
368 // Catch the case if an (unsupported) widget type is used. Only FrameView an d ScrollBar are supported now. 406 // Catch the case if an (unsupported) widget type is used. Only FrameView an d ScrollBar are supported now.
369 ASSERT(newObj); 407 ASSERT(newObj);
370 if (!newObj) 408 if (!newObj)
371 return 0; 409 return 0;
372 410
373 getAXID(newObj.get()); 411 getAXID(newObj.get());
374 412
413 #if ENABLE(OILPAN)
414 m_widgetObjectMapping.set(widget, newObj);
415 #else
375 m_widgetObjectMapping.set(widget, newObj->axObjectID()); 416 m_widgetObjectMapping.set(widget, newObj->axObjectID());
417 #endif
376 m_objects.set(newObj->axObjectID(), newObj); 418 m_objects.set(newObj->axObjectID(), newObj);
377 newObj->init(); 419 newObj->init();
378 return newObj.get(); 420 return newObj.get();
379 } 421 }
380 422
381 AXObject* AXObjectCacheImpl::getOrCreate(Node* node) 423 AXObject* AXObjectCacheImpl::getOrCreate(Node* node)
382 { 424 {
383 if (!node) 425 if (!node)
384 return 0; 426 return 0;
385 427
386 if (AXObject* obj = get(node)) 428 if (AXObject* obj = get(node))
387 return obj; 429 return obj;
388 430
389 if (node->layoutObject()) 431 if (node->layoutObject())
390 return getOrCreate(node->layoutObject()); 432 return getOrCreate(node->layoutObject());
391 433
392 if (!node->parentElement()) 434 if (!node->parentElement())
393 return 0; 435 return 0;
394 436
395 if (isHTMLHeadElement(node)) 437 if (isHTMLHeadElement(node))
396 return 0; 438 return 0;
397 439
398 RefPtr<AXObject> newObj = createFromNode(node); 440 RefPtrWillBeRawPtr<AXObject> newObj = createFromNode(node);
399 441
400 // Will crash later if we have two objects for the same node. 442 // Will crash later if we have two objects for the same node.
401 ASSERT(!get(node)); 443 ASSERT(!get(node));
402 444
403 getAXID(newObj.get()); 445 getAXID(newObj.get());
404 446
447 #if ENABLE(OILPAN)
448 m_nodeObjectMapping.set(node, newObj);
449 #else
405 m_nodeObjectMapping.set(node, newObj->axObjectID()); 450 m_nodeObjectMapping.set(node, newObj->axObjectID());
451 #endif
406 m_objects.set(newObj->axObjectID(), newObj); 452 m_objects.set(newObj->axObjectID(), newObj);
407 newObj->init(); 453 newObj->init();
408 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 454 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
409 455
410 return newObj.get(); 456 return newObj.get();
411 } 457 }
412 458
413 AXObject* AXObjectCacheImpl::getOrCreate(LayoutObject* layoutObject) 459 AXObject* AXObjectCacheImpl::getOrCreate(LayoutObject* layoutObject)
414 { 460 {
415 if (!layoutObject) 461 if (!layoutObject)
416 return 0; 462 return 0;
417 463
418 if (AXObject* obj = get(layoutObject)) 464 if (AXObject* obj = get(layoutObject))
419 return obj; 465 return obj;
420 466
421 RefPtr<AXObject> newObj = createFromRenderer(layoutObject); 467 RefPtrWillBeRawPtr<AXObject> newObj = createFromRenderer(layoutObject);
422 468
423 // Will crash later if we have two objects for the same layoutObject. 469 // Will crash later if we have two objects for the same layoutObject.
424 ASSERT(!get(layoutObject)); 470 ASSERT(!get(layoutObject));
425 471
426 getAXID(newObj.get()); 472 getAXID(newObj.get());
427 473
474 #if ENABLE(OILPAN)
475 m_layoutObjectMapping.set(layoutObject, newObj);
476 #else
428 m_layoutObjectMapping.set(layoutObject, newObj->axObjectID()); 477 m_layoutObjectMapping.set(layoutObject, newObj->axObjectID());
478 #endif
429 m_objects.set(newObj->axObjectID(), newObj); 479 m_objects.set(newObj->axObjectID(), newObj);
430 newObj->init(); 480 newObj->init();
431 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 481 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
432 482
433 return newObj.get(); 483 return newObj.get();
434 } 484 }
435 485
436 AXObject* AXObjectCacheImpl::getOrCreate(AbstractInlineTextBox* inlineTextBox) 486 AXObject* AXObjectCacheImpl::getOrCreate(AbstractInlineTextBox* inlineTextBox)
437 { 487 {
438 if (!inlineTextBox) 488 if (!inlineTextBox)
439 return 0; 489 return 0;
440 490
441 if (AXObject* obj = get(inlineTextBox)) 491 if (AXObject* obj = get(inlineTextBox))
442 return obj; 492 return obj;
443 493
444 RefPtr<AXObject> newObj = createFromInlineTextBox(inlineTextBox); 494 RefPtrWillBeRawPtr<AXObject> newObj = createFromInlineTextBox(inlineTextBox) ;
445 495
446 // Will crash later if we have two objects for the same inlineTextBox. 496 // Will crash later if we have two objects for the same inlineTextBox.
447 ASSERT(!get(inlineTextBox)); 497 ASSERT(!get(inlineTextBox));
448 498
449 getAXID(newObj.get()); 499 getAXID(newObj.get());
450 500
501 #if ENABLE(OILPAN)
502 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj);
503 #else
451 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj->axObjectID()); 504 m_inlineTextBoxObjectMapping.set(inlineTextBox, newObj->axObjectID());
505 #endif
452 m_objects.set(newObj->axObjectID(), newObj); 506 m_objects.set(newObj->axObjectID(), newObj);
453 newObj->init(); 507 newObj->init();
454 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 508 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
455 509
456 return newObj.get(); 510 return newObj.get();
457 } 511 }
458 512
459 AXObject* AXObjectCacheImpl::rootObject() 513 AXObject* AXObjectCacheImpl::rootObject()
460 { 514 {
461 if (!accessibilityEnabled()) 515 if (!accessibilityEnabled())
462 return 0; 516 return 0;
463 517
464 return getOrCreate(m_document.view()); 518 return getOrCreate(m_document.view());
465 } 519 }
466 520
467 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role) 521 AXObject* AXObjectCacheImpl::getOrCreate(AccessibilityRole role)
468 { 522 {
469 RefPtr<AXObject> obj = nullptr; 523 RefPtrWillBeRawPtr<AXObject> obj = nullptr;
470 524
471 // will be filled in... 525 // will be filled in...
472 switch (role) { 526 switch (role) {
473 case ImageMapLinkRole: 527 case ImageMapLinkRole:
474 obj = AXImageMapLink::create(this); 528 obj = AXImageMapLink::create(this);
475 break; 529 break;
476 case ColumnRole: 530 case ColumnRole:
477 obj = AXTableColumn::create(this); 531 obj = AXTableColumn::create(this);
478 break; 532 break;
479 case TableHeaderContainerRole: 533 case TableHeaderContainerRole:
(...skipping 18 matching lines...) Expand all
498 if (obj) 552 if (obj)
499 getAXID(obj.get()); 553 getAXID(obj.get());
500 else 554 else
501 return 0; 555 return 0;
502 556
503 m_objects.set(obj->axObjectID(), obj); 557 m_objects.set(obj->axObjectID(), obj);
504 obj->init(); 558 obj->init();
505 return obj.get(); 559 return obj.get();
506 } 560 }
507 561
562 #if ENABLE(OILPAN)
563 void AXObjectCacheImpl::remove(AXObject* obj)
564 {
565 if (!obj)
566 return;
567
568 obj->detach();
haraken 2015/05/28 10:48:41 I think you still need to explicitly remove the ob
569 }
570 #else
508 void AXObjectCacheImpl::remove(AXID axID) 571 void AXObjectCacheImpl::remove(AXID axID)
509 { 572 {
510 if (!axID) 573 if (!axID)
511 return; 574 return;
512 575
513 // first fetch object to operate some cleanup functions on it 576 // first fetch object to operate some cleanup functions on it
514 AXObject* obj = m_objects.get(axID); 577 AXObject* obj = m_objects.get(axID);
515 if (!obj) 578 if (!obj)
516 return; 579 return;
517 580
518 obj->detach(); 581 obj->detach();
519 removeAXID(obj); 582 removeAXID(obj);
520 583
521 // finally remove the object 584 // finally remove the object
522 if (!m_objects.take(axID)) 585 if (!m_objects.take(axID))
523 return; 586 return;
524 587
525 ASSERT(m_objects.size() >= m_idsInUse.size()); 588 ASSERT(m_objects.size() >= m_idsInUse.size());
526 } 589 }
590 #endif
527 591
528 void AXObjectCacheImpl::remove(LayoutObject* layoutObject) 592 void AXObjectCacheImpl::remove(LayoutObject* layoutObject)
529 { 593 {
530 if (!layoutObject) 594 if (!layoutObject)
531 return; 595 return;
532 596
597 #if ENABLE(OILPAN)
598 AXObject* axLayoutObject = m_layoutObjectMapping.get(layoutObject);
599 if (axLayoutObject) {
600 axLayoutObject->detach();
601 remove(axLayoutObject);
602 }
603 #else
533 AXID axID = m_layoutObjectMapping.get(layoutObject); 604 AXID axID = m_layoutObjectMapping.get(layoutObject);
534 remove(axID); 605 remove(axID);
606 #endif
535 m_layoutObjectMapping.remove(layoutObject); 607 m_layoutObjectMapping.remove(layoutObject);
536 } 608 }
537 609
538 void AXObjectCacheImpl::remove(Node* node) 610 void AXObjectCacheImpl::remove(Node* node)
539 { 611 {
540 if (!node) 612 if (!node)
541 return; 613 return;
542 614
543 removeNodeForUse(node); 615 removeNodeForUse(node);
544 616
545 // This is all safe even if we didn't have a mapping. 617 // This is all safe even if we didn't have a mapping.
618 #if ENABLE(OILPAN)
619 remove(m_nodeObjectMapping.get(node));
620 #else
546 AXID axID = m_nodeObjectMapping.get(node); 621 AXID axID = m_nodeObjectMapping.get(node);
547 remove(axID); 622 remove(axID);
623 #endif
548 m_nodeObjectMapping.remove(node); 624 m_nodeObjectMapping.remove(node);
549 625
550 if (node->layoutObject()) { 626 if (node->layoutObject()) {
551 remove(node->layoutObject()); 627 remove(node->layoutObject());
552 return; 628 return;
553 } 629 }
554 } 630 }
555 631
556 void AXObjectCacheImpl::remove(Widget* view) 632 void AXObjectCacheImpl::remove(Widget* view)
557 { 633 {
558 if (!view) 634 if (!view)
559 return; 635 return;
560 636
637 #if ENABLE(OILPAN)
638 remove(m_widgetObjectMapping.get(view));
639 #else
561 AXID axID = m_widgetObjectMapping.get(view); 640 AXID axID = m_widgetObjectMapping.get(view);
562 remove(axID); 641 remove(axID);
642 #endif
563 m_widgetObjectMapping.remove(view); 643 m_widgetObjectMapping.remove(view);
564 } 644 }
565 645
566 void AXObjectCacheImpl::remove(AbstractInlineTextBox* inlineTextBox) 646 void AXObjectCacheImpl::remove(AbstractInlineTextBox* inlineTextBox)
567 { 647 {
568 if (!inlineTextBox) 648 if (!inlineTextBox)
569 return; 649 return;
570 650
651 #if ENABLE(OILPAN)
652 remove(m_inlineTextBoxObjectMapping.get(inlineTextBox));
653 #else
571 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox); 654 AXID axID = m_inlineTextBoxObjectMapping.get(inlineTextBox);
572 remove(axID); 655 remove(axID);
656 #endif
573 m_inlineTextBoxObjectMapping.remove(inlineTextBox); 657 m_inlineTextBoxObjectMapping.remove(inlineTextBox);
574 } 658 }
575 659
576 // FIXME: Oilpan: Use a weak hashmap for this instead.
577 void AXObjectCacheImpl::clearWeakMembers(Visitor* visitor) 660 void AXObjectCacheImpl::clearWeakMembers(Visitor* visitor)
578 { 661 {
579 Vector<Node*> deadNodes; 662 Vector<Node*> deadNodes;
580 for (HashMap<Node*, AXID>::iterator it = m_nodeObjectMapping.begin(); it != m_nodeObjectMapping.end(); ++it) { 663 for (auto& entry : m_nodeObjectMapping) {
haraken 2015/05/28 10:48:41 Why is this needed? The weak processing should hav
581 if (!visitor->isHeapObjectAlive(it->key)) 664 if (!visitor->isHeapObjectAlive(entry.key))
582 deadNodes.append(it->key); 665 deadNodes.append(entry.key);
583 } 666 }
584 for (unsigned i = 0; i < deadNodes.size(); ++i) 667 for (unsigned i = 0; i < deadNodes.size(); ++i)
585 remove(deadNodes[i]); 668 remove(deadNodes[i]);
586 669
587 Vector<Widget*> deadWidgets; 670 Vector<Widget*> deadWidgets;
588 for (HashMap<Widget*, AXID>::iterator it = m_widgetObjectMapping.begin(); 671 for (auto& entry : m_widgetObjectMapping) {
haraken 2015/05/28 10:48:41 Ditto. This weak processing won't be needed.
589 it != m_widgetObjectMapping.end(); ++it) { 672 if (!visitor->isHeapObjectAlive(entry.key))
590 if (!visitor->isHeapObjectAlive(it->key)) 673 deadWidgets.append(entry.key);
591 deadWidgets.append(it->key);
592 } 674 }
593 for (unsigned i = 0; i < deadWidgets.size(); ++i) 675 for (unsigned i = 0; i < deadWidgets.size(); ++i)
594 remove(deadWidgets[i]); 676 remove(deadWidgets[i]);
677
678 #if ENABLE(OILPAN)
haraken 2015/05/28 10:48:41 Remove the #if flag. AXObjectCacheImpl::clearWeakM
679 Vector<AXID> deadIds;
680 for (auto& entry : m_objects) {
681 if (entry.value)
haraken 2015/05/28 10:48:41 This should be !visitor->isHeapObjectAlive(entry.v
682 deadIds.append(entry.key);
683 }
684 for (auto& axID : deadIds) {
685 m_objects.take(axID);
686 }
687 #endif
595 } 688 }
haraken 2015/05/28 10:48:41 If I'm not missing something, I guess we can remov
596 689
597 AXID AXObjectCacheImpl::platformGenerateAXID() const 690 AXID AXObjectCacheImpl::platformGenerateAXID() const
598 { 691 {
599 static AXID lastUsedID = 0; 692 static AXID lastUsedID = 0;
600 693
601 // Generate a new ID. 694 // Generate a new ID.
602 AXID objID = lastUsedID; 695 AXID objID = lastUsedID;
603 do { 696 do {
604 ++objID; 697 ++objID;
605 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con tains(objID)); 698 } while (!objID || HashTraits<AXID>::isDeletedValue(objID) || m_idsInUse.con tains(objID));
(...skipping 13 matching lines...) Expand all
619 } 712 }
620 713
621 objID = platformGenerateAXID(); 714 objID = platformGenerateAXID();
622 715
623 m_idsInUse.add(objID); 716 m_idsInUse.add(objID);
624 obj->setAXObjectID(objID); 717 obj->setAXObjectID(objID);
625 718
626 return objID; 719 return objID;
627 } 720 }
628 721
722 #if !ENABLE(OILPAN)
629 void AXObjectCacheImpl::removeAXID(AXObject* object) 723 void AXObjectCacheImpl::removeAXID(AXObject* object)
630 { 724 {
631 if (!object) 725 if (!object)
632 return; 726 return;
633 727
634 AXID objID = object->axObjectID(); 728 AXID objID = object->axObjectID();
635 if (!objID) 729 if (!objID)
636 return; 730 return;
637 ASSERT(!HashTraits<AXID>::isDeletedValue(objID)); 731 removeAXID(objID);
638 ASSERT(m_idsInUse.contains(objID));
639 object->setAXObjectID(0); 732 object->setAXObjectID(0);
640 m_idsInUse.remove(objID); 733 }
734 #endif
735
736 void AXObjectCacheImpl::removeAXID(AXID axID)
737 {
738 if (!axID)
739 return;
740 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
741 ASSERT(m_idsInUse.contains(axID));
742 m_idsInUse.remove(axID);
641 } 743 }
642 744
643 void AXObjectCacheImpl::selectionChanged(Node* node) 745 void AXObjectCacheImpl::selectionChanged(Node* node)
644 { 746 {
645 // Find the nearest ancestor that already has an accessibility object, since we 747 // Find the nearest ancestor that already has an accessibility object, since we
646 // might be in the middle of a layout. 748 // might be in the middle of a layout.
647 while (node) { 749 while (node) {
648 if (AXObject* obj = get(node)) { 750 if (AXObject* obj = get(node)) {
649 obj->selectionChanged(); 751 obj->selectionChanged();
650 return; 752 return;
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 AXObject* obj = getOrCreate(element); 1259 AXObject* obj = getOrCreate(element);
1158 if (!obj) 1260 if (!obj)
1159 return; 1261 return;
1160 1262
1161 obj->setElementRect(rect); 1263 obj->setElementRect(rect);
1162 } 1264 }
1163 1265
1164 DEFINE_TRACE(AXObjectCacheImpl) 1266 DEFINE_TRACE(AXObjectCacheImpl)
1165 { 1267 {
1166 AXObjectCache::trace(visitor); 1268 AXObjectCache::trace(visitor);
1269 #if ENABLE(OILPAN)
1270 visitor->trace(m_objects);
1271 visitor->trace(m_layoutObjectMapping);
1272 visitor->trace(m_widgetObjectMapping);
1273 visitor->trace(m_nodeObjectMapping);
1274 visitor->trace(m_inlineTextBoxObjectMapping);
1275 visitor->trace(m_notificationsToPost);
1276 visitor->trace(m_textMarkerNodes);
1167 visitor->template registerWeakMembers<AXObjectCacheImpl, &AXObjectCacheImpl: :clearWeakMembers>(this); 1277 visitor->template registerWeakMembers<AXObjectCacheImpl, &AXObjectCacheImpl: :clearWeakMembers>(this);
1278 #endif
1168 } 1279 }
1169 1280
1170 } // namespace blink 1281 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698