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

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

Issue 899163003: Move rendering/RenderObject to layout/LayoutObject. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
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 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return 0; 181 return 0;
182 182
183 AXID axID = m_widgetObjectMapping.get(widget); 183 AXID axID = m_widgetObjectMapping.get(widget);
184 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); 184 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
185 if (!axID) 185 if (!axID)
186 return 0; 186 return 0;
187 187
188 return m_objects.get(axID); 188 return m_objects.get(axID);
189 } 189 }
190 190
191 AXObject* AXObjectCacheImpl::get(RenderObject* renderer) 191 AXObject* AXObjectCacheImpl::get(LayoutObject* renderer)
192 { 192 {
193 if (!renderer) 193 if (!renderer)
194 return 0; 194 return 0;
195 195
196 AXID axID = m_renderObjectMapping.get(renderer); 196 AXID axID = m_layoutObjectMapping.get(renderer);
197 ASSERT(!HashTraits<AXID>::isDeletedValue(axID)); 197 ASSERT(!HashTraits<AXID>::isDeletedValue(axID));
198 if (!axID) 198 if (!axID)
199 return 0; 199 return 0;
200 200
201 return m_objects.get(axID); 201 return m_objects.get(axID);
202 } 202 }
203 203
204 AXObject* AXObjectCacheImpl::get(Node* node) 204 AXObject* AXObjectCacheImpl::get(Node* node)
205 { 205 {
206 if (!node) 206 if (!node)
207 return 0; 207 return 0;
208 208
209 AXID renderID = node->renderer() ? m_renderObjectMapping.get(node->renderer( )) : 0; 209 AXID renderID = node->renderer() ? m_layoutObjectMapping.get(node->renderer( )) : 0;
210 ASSERT(!HashTraits<AXID>::isDeletedValue(renderID)); 210 ASSERT(!HashTraits<AXID>::isDeletedValue(renderID));
211 211
212 AXID nodeID = m_nodeObjectMapping.get(node); 212 AXID nodeID = m_nodeObjectMapping.get(node);
213 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID)); 213 ASSERT(!HashTraits<AXID>::isDeletedValue(nodeID));
214 214
215 if (node->renderer() && nodeID && !renderID) { 215 if (node->renderer() && nodeID && !renderID) {
216 // This can happen if an AXNodeObject is created for a node that's not 216 // This can happen if an AXNodeObject is created for a node that's not
217 // rendered, but later something changes and it gets a renderer (like if it's 217 // rendered, but later something changes and it gets a renderer (like if it's
218 // reparented). 218 // reparented).
219 remove(nodeID); 219 remove(nodeID);
(...skipping 25 matching lines...) Expand all
245 // FIXME: This probably belongs on Node. 245 // FIXME: This probably belongs on Node.
246 // FIXME: This should take a const char*, but one caller passes nullAtom. 246 // FIXME: This should take a const char*, but one caller passes nullAtom.
247 bool nodeHasRole(Node* node, const String& role) 247 bool nodeHasRole(Node* node, const String& role)
248 { 248 {
249 if (!node || !node->isElementNode()) 249 if (!node || !node->isElementNode())
250 return false; 250 return false;
251 251
252 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role); 252 return equalIgnoringCase(toElement(node)->getAttribute(roleAttr), role);
253 } 253 }
254 254
255 PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(RenderObject* rendere r) 255 PassRefPtr<AXObject> AXObjectCacheImpl::createFromRenderer(LayoutObject* rendere r)
256 { 256 {
257 // FIXME: How could renderer->node() ever not be an Element? 257 // FIXME: How could renderer->node() ever not be an Element?
258 Node* node = renderer->node(); 258 Node* node = renderer->node();
259 259
260 // If the node is aria role="list" or the aria role is empty and its a 260 // If the node is aria role="list" or the aria role is empty and its a
261 // ul/ol/dl type (it shouldn't be a list if aria says otherwise). 261 // ul/ol/dl type (it shouldn't be a list if aria says otherwise).
262 if (node && ((nodeHasRole(node, "list") || nodeHasRole(node, "directory")) 262 if (node && ((nodeHasRole(node, "list") || nodeHasRole(node, "directory"))
263 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(*node) || isHTMLO ListElement(*node) || isHTMLDListElement(*node))))) 263 || (nodeHasRole(node, nullAtom) && (isHTMLUListElement(*node) || isHTMLO ListElement(*node) || isHTMLDListElement(*node)))))
264 return AXList::create(renderer, this); 264 return AXList::create(renderer, this);
265 265
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 getAXID(newObj.get()); 377 getAXID(newObj.get());
378 378
379 m_nodeObjectMapping.set(node, newObj->axObjectID()); 379 m_nodeObjectMapping.set(node, newObj->axObjectID());
380 m_objects.set(newObj->axObjectID(), newObj); 380 m_objects.set(newObj->axObjectID(), newObj);
381 newObj->init(); 381 newObj->init();
382 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 382 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
383 383
384 return newObj.get(); 384 return newObj.get();
385 } 385 }
386 386
387 AXObject* AXObjectCacheImpl::getOrCreate(RenderObject* renderer) 387 AXObject* AXObjectCacheImpl::getOrCreate(LayoutObject* renderer)
388 { 388 {
389 if (!renderer) 389 if (!renderer)
390 return 0; 390 return 0;
391 391
392 if (AXObject* obj = get(renderer)) 392 if (AXObject* obj = get(renderer))
393 return obj; 393 return obj;
394 394
395 RefPtr<AXObject> newObj = createFromRenderer(renderer); 395 RefPtr<AXObject> newObj = createFromRenderer(renderer);
396 396
397 // Will crash later if we have two objects for the same renderer. 397 // Will crash later if we have two objects for the same renderer.
398 ASSERT(!get(renderer)); 398 ASSERT(!get(renderer));
399 399
400 getAXID(newObj.get()); 400 getAXID(newObj.get());
401 401
402 m_renderObjectMapping.set(renderer, newObj->axObjectID()); 402 m_layoutObjectMapping.set(renderer, newObj->axObjectID());
403 m_objects.set(newObj->axObjectID(), newObj); 403 m_objects.set(newObj->axObjectID(), newObj);
404 newObj->init(); 404 newObj->init();
405 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored()); 405 newObj->setLastKnownIsIgnoredValue(newObj->accessibilityIsIgnored());
406 406
407 return newObj.get(); 407 return newObj.get();
408 } 408 }
409 409
410 AXObject* AXObjectCacheImpl::getOrCreate(AbstractInlineTextBox* inlineTextBox) 410 AXObject* AXObjectCacheImpl::getOrCreate(AbstractInlineTextBox* inlineTextBox)
411 { 411 {
412 if (!inlineTextBox) 412 if (!inlineTextBox)
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 obj->detach(); 495 obj->detach();
496 removeAXID(obj); 496 removeAXID(obj);
497 497
498 // finally remove the object 498 // finally remove the object
499 if (!m_objects.take(axID)) 499 if (!m_objects.take(axID))
500 return; 500 return;
501 501
502 ASSERT(m_objects.size() >= m_idsInUse.size()); 502 ASSERT(m_objects.size() >= m_idsInUse.size());
503 } 503 }
504 504
505 void AXObjectCacheImpl::remove(RenderObject* renderer) 505 void AXObjectCacheImpl::remove(LayoutObject* renderer)
506 { 506 {
507 if (!renderer) 507 if (!renderer)
508 return; 508 return;
509 509
510 AXID axID = m_renderObjectMapping.get(renderer); 510 AXID axID = m_layoutObjectMapping.get(renderer);
511 remove(axID); 511 remove(axID);
512 m_renderObjectMapping.remove(renderer); 512 m_layoutObjectMapping.remove(renderer);
513 } 513 }
514 514
515 void AXObjectCacheImpl::remove(Node* node) 515 void AXObjectCacheImpl::remove(Node* node)
516 { 516 {
517 if (!node) 517 if (!node)
518 return; 518 return;
519 519
520 removeNodeForUse(node); 520 removeNodeForUse(node);
521 521
522 // This is all safe even if we didn't have a mapping. 522 // This is all safe even if we didn't have a mapping.
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 } 628 }
629 node = node->parentNode(); 629 node = node->parentNode();
630 } 630 }
631 } 631 }
632 632
633 void AXObjectCacheImpl::textChanged(Node* node) 633 void AXObjectCacheImpl::textChanged(Node* node)
634 { 634 {
635 textChanged(getOrCreate(node)); 635 textChanged(getOrCreate(node));
636 } 636 }
637 637
638 void AXObjectCacheImpl::textChanged(RenderObject* renderer) 638 void AXObjectCacheImpl::textChanged(LayoutObject* renderer)
639 { 639 {
640 textChanged(getOrCreate(renderer)); 640 textChanged(getOrCreate(renderer));
641 } 641 }
642 642
643 void AXObjectCacheImpl::textChanged(AXObject* obj) 643 void AXObjectCacheImpl::textChanged(AXObject* obj)
644 { 644 {
645 if (!obj) 645 if (!obj)
646 return; 646 return;
647 647
648 bool parentAlreadyExists = obj->parentObjectIfExists(); 648 bool parentAlreadyExists = obj->parentObjectIfExists();
649 obj->textChanged(); 649 obj->textChanged();
650 postNotification(obj, obj->document(), AXObjectCacheImpl::AXTextChanged, tru e); 650 postNotification(obj, obj->document(), AXObjectCacheImpl::AXTextChanged, tru e);
651 if (parentAlreadyExists) 651 if (parentAlreadyExists)
652 obj->notifyIfIgnoredValueChanged(); 652 obj->notifyIfIgnoredValueChanged();
653 } 653 }
654 654
655 void AXObjectCacheImpl::updateCacheAfterNodeIsAttached(Node* node) 655 void AXObjectCacheImpl::updateCacheAfterNodeIsAttached(Node* node)
656 { 656 {
657 // Calling get() will update the AX object if we had an AXNodeObject but now we need 657 // Calling get() will update the AX object if we had an AXNodeObject but now we need
658 // an AXRenderObject, because it was reparented to a location outside of a c anvas. 658 // an AXRenderObject, because it was reparented to a location outside of a c anvas.
659 get(node); 659 get(node);
660 } 660 }
661 661
662 void AXObjectCacheImpl::childrenChanged(Node* node) 662 void AXObjectCacheImpl::childrenChanged(Node* node)
663 { 663 {
664 childrenChanged(get(node)); 664 childrenChanged(get(node));
665 } 665 }
666 666
667 void AXObjectCacheImpl::childrenChanged(RenderObject* renderer) 667 void AXObjectCacheImpl::childrenChanged(LayoutObject* renderer)
668 { 668 {
669 childrenChanged(get(renderer)); 669 childrenChanged(get(renderer));
670 } 670 }
671 671
672 void AXObjectCacheImpl::childrenChanged(AXObject* obj) 672 void AXObjectCacheImpl::childrenChanged(AXObject* obj)
673 { 673 {
674 if (!obj) 674 if (!obj)
675 return; 675 return;
676 676
677 obj->childrenChanged(); 677 obj->childrenChanged();
(...skipping 12 matching lines...) Expand all
690 continue; 690 continue;
691 691
692 if (!obj->axObjectCache()) 692 if (!obj->axObjectCache())
693 continue; 693 continue;
694 694
695 #if ENABLE(ASSERT) 695 #if ENABLE(ASSERT)
696 // Make sure none of the render views are in the process of being layed out. 696 // Make sure none of the render views are in the process of being layed out.
697 // Notifications should only be sent after the renderer has finished 697 // Notifications should only be sent after the renderer has finished
698 if (obj->isAXRenderObject()) { 698 if (obj->isAXRenderObject()) {
699 AXRenderObject* renderObj = toAXRenderObject(obj); 699 AXRenderObject* renderObj = toAXRenderObject(obj);
700 RenderObject* renderer = renderObj->renderer(); 700 LayoutObject* renderer = renderObj->renderer();
701 if (renderer && renderer->view()) 701 if (renderer && renderer->view())
702 ASSERT(!renderer->view()->layoutState()); 702 ASSERT(!renderer->view()->layoutState());
703 } 703 }
704 #endif 704 #endif
705 705
706 AXNotification notification = m_notificationsToPost[i].second; 706 AXNotification notification = m_notificationsToPost[i].second;
707 postPlatformNotification(obj, notification); 707 postPlatformNotification(obj, notification);
708 708
709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() && obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored()) 709 if (notification == AXChildrenChanged && obj->parentObjectIfExists() && obj->lastKnownIsIgnoredValue() != obj->accessibilityIsIgnored())
710 childrenChanged(obj->parentObject()); 710 childrenChanged(obj->parentObject());
711 } 711 }
712 712
713 m_notificationsToPost.clear(); 713 m_notificationsToPost.clear();
714 } 714 }
715 715
716 void AXObjectCacheImpl::postNotification(RenderObject* renderer, AXNotification notification, bool postToElement) 716 void AXObjectCacheImpl::postNotification(LayoutObject* renderer, AXNotification notification, bool postToElement)
717 { 717 {
718 if (!renderer) 718 if (!renderer)
719 return; 719 return;
720 720
721 m_modificationCount++; 721 m_modificationCount++;
722 722
723 // Get an accessibility object that already exists. One should not be create d here 723 // Get an accessibility object that already exists. One should not be create d here
724 // because a render update may be in progress and creating an AX object can re-trigger a layout 724 // because a render update may be in progress and creating an AX object can re-trigger a layout
725 RefPtr<AXObject> object = get(renderer); 725 RefPtr<AXObject> object = get(renderer);
726 while (!object && renderer) { 726 while (!object && renderer) {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 postNotification(node, AXObjectCacheImpl::AXCheckedStateChanged, true); 778 postNotification(node, AXObjectCacheImpl::AXCheckedStateChanged, true);
779 } 779 }
780 780
781 void AXObjectCacheImpl::selectedChildrenChanged(Node* node) 781 void AXObjectCacheImpl::selectedChildrenChanged(Node* node)
782 { 782 {
783 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree 783 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree
784 // to find the container which should send out the notification. 784 // to find the container which should send out the notification.
785 postNotification(node, AXSelectedChildrenChanged, false); 785 postNotification(node, AXSelectedChildrenChanged, false);
786 } 786 }
787 787
788 void AXObjectCacheImpl::selectedChildrenChanged(RenderObject* renderer) 788 void AXObjectCacheImpl::selectedChildrenChanged(LayoutObject* renderer)
789 { 789 {
790 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree 790 // postToElement is false so that you can pass in any child of an element an d it will go up the parent tree
791 // to find the container which should send out the notification. 791 // to find the container which should send out the notification.
792 postNotification(renderer, AXSelectedChildrenChanged, false); 792 postNotification(renderer, AXSelectedChildrenChanged, false);
793 } 793 }
794 794
795 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view) 795 void AXObjectCacheImpl::handleScrollbarUpdate(FrameView* view)
796 { 796 {
797 if (!view) 797 if (!view)
798 return; 798 return;
799 799
800 // We don't want to create a scroll view from this method, only update an ex isting one. 800 // We don't want to create a scroll view from this method, only update an ex isting one.
801 if (AXObject* scrollViewObject = get(view)) { 801 if (AXObject* scrollViewObject = get(view)) {
802 m_modificationCount++; 802 m_modificationCount++;
803 scrollViewObject->updateChildrenIfNecessary(); 803 scrollViewObject->updateChildrenIfNecessary();
804 } 804 }
805 } 805 }
806 806
807 void AXObjectCacheImpl::handleLayoutComplete(RenderObject* renderer) 807 void AXObjectCacheImpl::handleLayoutComplete(LayoutObject* renderer)
808 { 808 {
809 if (!renderer) 809 if (!renderer)
810 return; 810 return;
811 811
812 m_modificationCount++; 812 m_modificationCount++;
813 813
814 // Create the AXObject if it didn't yet exist - that's always safe at the en d of a layout, and it 814 // Create the AXObject if it didn't yet exist - that's always safe at the en d of a layout, and it
815 // allows an AX notification to be sent when a page has its first layout, ra ther than when the 815 // allows an AX notification to be sent when a page has its first layout, ra ther than when the
816 // document first loads. 816 // document first loads.
817 if (AXObject* obj = getOrCreate(renderer)) 817 if (AXObject* obj = getOrCreate(renderer))
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 postNotification(element, AXObjectCacheImpl::AXInvalidStatusChanged, tru e); 869 postNotification(element, AXObjectCacheImpl::AXInvalidStatusChanged, tru e);
870 else 870 else
871 postNotification(element, AXObjectCacheImpl::AXAriaAttributeChanged, tru e); 871 postNotification(element, AXObjectCacheImpl::AXAriaAttributeChanged, tru e);
872 } 872 }
873 873
874 void AXObjectCacheImpl::labelChanged(Element* element) 874 void AXObjectCacheImpl::labelChanged(Element* element)
875 { 875 {
876 textChanged(toHTMLLabelElement(element)->control()); 876 textChanged(toHTMLLabelElement(element)->control());
877 } 877 }
878 878
879 void AXObjectCacheImpl::recomputeIsIgnored(RenderObject* renderer) 879 void AXObjectCacheImpl::recomputeIsIgnored(LayoutObject* renderer)
880 { 880 {
881 if (AXObject* obj = get(renderer)) 881 if (AXObject* obj = get(renderer))
882 obj->notifyIfIgnoredValueChanged(); 882 obj->notifyIfIgnoredValueChanged();
883 } 883 }
884 884
885 void AXObjectCacheImpl::inlineTextBoxesUpdated(RenderObject* renderer) 885 void AXObjectCacheImpl::inlineTextBoxesUpdated(LayoutObject* renderer)
886 { 886 {
887 if (!inlineTextBoxAccessibilityEnabled()) 887 if (!inlineTextBoxAccessibilityEnabled())
888 return; 888 return;
889 889
890 // Only update if the accessibility object already exists and it's 890 // Only update if the accessibility object already exists and it's
891 // not already marked as dirty. 891 // not already marked as dirty.
892 if (AXObject* obj = get(renderer)) { 892 if (AXObject* obj = get(renderer)) {
893 if (!obj->needsToUpdateChildren()) { 893 if (!obj->needsToUpdateChildren()) {
894 obj->setNeedsToUpdateChildren(); 894 obj->setNeedsToUpdateChildren();
895 postNotification(renderer, AXChildrenChanged, true); 895 postNotification(renderer, AXChildrenChanged, true);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 1062
1063 void AXObjectCacheImpl::handleScrollPositionChanged(FrameView* frameView) 1063 void AXObjectCacheImpl::handleScrollPositionChanged(FrameView* frameView)
1064 { 1064 {
1065 // Prefer to fire the scroll position changed event on the frame view's chil d web area, if possible. 1065 // Prefer to fire the scroll position changed event on the frame view's chil d web area, if possible.
1066 AXObject* targetAXObject = getOrCreate(frameView); 1066 AXObject* targetAXObject = getOrCreate(frameView);
1067 if (targetAXObject && !targetAXObject->children().isEmpty()) 1067 if (targetAXObject && !targetAXObject->children().isEmpty())
1068 targetAXObject = targetAXObject->children()[0].get(); 1068 targetAXObject = targetAXObject->children()[0].get();
1069 postPlatformNotification(targetAXObject, AXScrollPositionChanged); 1069 postPlatformNotification(targetAXObject, AXScrollPositionChanged);
1070 } 1070 }
1071 1071
1072 void AXObjectCacheImpl::handleScrollPositionChanged(RenderObject* renderObject) 1072 void AXObjectCacheImpl::handleScrollPositionChanged(LayoutObject* layoutObject)
1073 { 1073 {
1074 postPlatformNotification(getOrCreate(renderObject), AXScrollPositionChanged) ; 1074 postPlatformNotification(getOrCreate(layoutObject), AXScrollPositionChanged) ;
1075 } 1075 }
1076 1076
1077 const AtomicString& AXObjectCacheImpl::computedRoleForNode(Node* node) 1077 const AtomicString& AXObjectCacheImpl::computedRoleForNode(Node* node)
1078 { 1078 {
1079 AXObject* obj = getOrCreate(node); 1079 AXObject* obj = getOrCreate(node);
1080 if (!obj) 1080 if (!obj)
1081 return AXObject::roleName(UnknownRole); 1081 return AXObject::roleName(UnknownRole);
1082 return AXObject::roleName(obj->roleValue()); 1082 return AXObject::roleName(obj->roleValue());
1083 } 1083 }
1084 1084
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect) 1121 void AXObjectCacheImpl::setCanvasObjectBounds(Element* element, const LayoutRect & rect)
1122 { 1122 {
1123 AXObject* obj = getOrCreate(element); 1123 AXObject* obj = getOrCreate(element);
1124 if (!obj) 1124 if (!obj)
1125 return; 1125 return;
1126 1126
1127 obj->setElementRect(rect); 1127 obj->setElementRect(rect);
1128 } 1128 }
1129 1129
1130 } // namespace blink 1130 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXObjectCacheImpl.h ('k') | Source/modules/accessibility/AXRenderObject.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698