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

Side by Side Diff: Source/modules/accessibility/AXRenderObject.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
« no previous file with comments | « Source/modules/accessibility/AXRenderObject.h ('k') | Source/modules/accessibility/AXSVGRoot.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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "modules/accessibility/AXTable.h" 73 #include "modules/accessibility/AXTable.h"
74 #include "platform/text/PlatformLocale.h" 74 #include "platform/text/PlatformLocale.h"
75 #include "wtf/StdLibExtras.h" 75 #include "wtf/StdLibExtras.h"
76 76
77 using blink::WebLocalizedString; 77 using blink::WebLocalizedString;
78 78
79 namespace blink { 79 namespace blink {
80 80
81 using namespace HTMLNames; 81 using namespace HTMLNames;
82 82
83 static inline RenderObject* firstChildInContinuation(const RenderInline& rendere r) 83 static inline LayoutObject* firstChildInContinuation(const RenderInline& rendere r)
84 { 84 {
85 RenderBoxModelObject* r = renderer.continuation(); 85 RenderBoxModelObject* r = renderer.continuation();
86 86
87 while (r) { 87 while (r) {
88 if (r->isRenderBlock()) 88 if (r->isRenderBlock())
89 return r; 89 return r;
90 if (RenderObject* child = r->slowFirstChild()) 90 if (LayoutObject* child = r->slowFirstChild())
91 return child; 91 return child;
92 r = toRenderInline(r)->continuation(); 92 r = toRenderInline(r)->continuation();
93 } 93 }
94 94
95 return 0; 95 return 0;
96 } 96 }
97 97
98 static inline bool isInlineWithContinuation(RenderObject* object) 98 static inline bool isInlineWithContinuation(LayoutObject* object)
99 { 99 {
100 if (!object->isBoxModelObject()) 100 if (!object->isBoxModelObject())
101 return false; 101 return false;
102 102
103 RenderBoxModelObject* renderer = toRenderBoxModelObject(object); 103 RenderBoxModelObject* renderer = toRenderBoxModelObject(object);
104 if (!renderer->isRenderInline()) 104 if (!renderer->isRenderInline())
105 return false; 105 return false;
106 106
107 return toRenderInline(renderer)->continuation(); 107 return toRenderInline(renderer)->continuation();
108 } 108 }
109 109
110 static inline RenderObject* firstChildConsideringContinuation(RenderObject* rend erer) 110 static inline LayoutObject* firstChildConsideringContinuation(LayoutObject* rend erer)
111 { 111 {
112 RenderObject* firstChild = renderer->slowFirstChild(); 112 LayoutObject* firstChild = renderer->slowFirstChild();
113 113
114 if (!firstChild && isInlineWithContinuation(renderer)) 114 if (!firstChild && isInlineWithContinuation(renderer))
115 firstChild = firstChildInContinuation(toRenderInline(*renderer)); 115 firstChild = firstChildInContinuation(toRenderInline(*renderer));
116 116
117 return firstChild; 117 return firstChild;
118 } 118 }
119 119
120 static inline RenderInline* startOfContinuations(RenderObject* r) 120 static inline RenderInline* startOfContinuations(LayoutObject* r)
121 { 121 {
122 if (r->isInlineElementContinuation()) { 122 if (r->isInlineElementContinuation()) {
123 return toRenderInline(r->node()->renderer()); 123 return toRenderInline(r->node()->renderer());
124 } 124 }
125 125
126 // Blocks with a previous continuation always have a next continuation 126 // Blocks with a previous continuation always have a next continuation
127 if (r->isRenderBlock() && toRenderBlock(r)->inlineElementContinuation()) 127 if (r->isRenderBlock() && toRenderBlock(r)->inlineElementContinuation())
128 return toRenderInline(toRenderBlock(r)->inlineElementContinuation()->nod e()->renderer()); 128 return toRenderInline(toRenderBlock(r)->inlineElementContinuation()->nod e()->renderer());
129 129
130 return 0; 130 return 0;
131 } 131 }
132 132
133 static inline RenderObject* endOfContinuations(RenderObject* renderer) 133 static inline LayoutObject* endOfContinuations(LayoutObject* renderer)
134 { 134 {
135 RenderObject* prev = renderer; 135 LayoutObject* prev = renderer;
136 RenderObject* cur = renderer; 136 LayoutObject* cur = renderer;
137 137
138 if (!cur->isRenderInline() && !cur->isRenderBlock()) 138 if (!cur->isRenderInline() && !cur->isRenderBlock())
139 return renderer; 139 return renderer;
140 140
141 while (cur) { 141 while (cur) {
142 prev = cur; 142 prev = cur;
143 if (cur->isRenderInline()) { 143 if (cur->isRenderInline()) {
144 cur = toRenderInline(cur)->inlineElementContinuation(); 144 cur = toRenderInline(cur)->inlineElementContinuation();
145 ASSERT(cur || !toRenderInline(prev)->continuation()); 145 ASSERT(cur || !toRenderInline(prev)->continuation());
146 } else { 146 } else {
147 cur = toRenderBlock(cur)->inlineElementContinuation(); 147 cur = toRenderBlock(cur)->inlineElementContinuation();
148 } 148 }
149 } 149 }
150 150
151 return prev; 151 return prev;
152 } 152 }
153 153
154 static inline bool lastChildHasContinuation(RenderObject* renderer) 154 static inline bool lastChildHasContinuation(LayoutObject* renderer)
155 { 155 {
156 RenderObject* lastChild = renderer->slowLastChild(); 156 LayoutObject* lastChild = renderer->slowLastChild();
157 return lastChild && isInlineWithContinuation(lastChild); 157 return lastChild && isInlineWithContinuation(lastChild);
158 } 158 }
159 159
160 static RenderBoxModelObject* nextContinuation(RenderObject* renderer) 160 static RenderBoxModelObject* nextContinuation(LayoutObject* renderer)
161 { 161 {
162 ASSERT(renderer); 162 ASSERT(renderer);
163 if (renderer->isRenderInline() && !renderer->isReplaced()) 163 if (renderer->isRenderInline() && !renderer->isReplaced())
164 return toRenderInline(renderer)->continuation(); 164 return toRenderInline(renderer)->continuation();
165 if (renderer->isRenderBlock()) 165 if (renderer->isRenderBlock())
166 return toRenderBlock(renderer)->inlineElementContinuation(); 166 return toRenderBlock(renderer)->inlineElementContinuation();
167 return 0; 167 return 0;
168 } 168 }
169 169
170 AXRenderObject::AXRenderObject(RenderObject* renderer, AXObjectCacheImpl* axObje ctCache) 170 AXRenderObject::AXRenderObject(LayoutObject* renderer, AXObjectCacheImpl* axObje ctCache)
171 : AXNodeObject(renderer->node(), axObjectCache) 171 : AXNodeObject(renderer->node(), axObjectCache)
172 , m_renderer(renderer) 172 , m_renderer(renderer)
173 , m_cachedElementRectDirty(true) 173 , m_cachedElementRectDirty(true)
174 { 174 {
175 #if ENABLE(ASSERT) 175 #if ENABLE(ASSERT)
176 m_renderer->setHasAXObject(true); 176 m_renderer->setHasAXObject(true);
177 #endif 177 #endif
178 } 178 }
179 179
180 PassRefPtr<AXRenderObject> AXRenderObject::create(RenderObject* renderer, AXObje ctCacheImpl* axObjectCache) 180 PassRefPtr<AXRenderObject> AXRenderObject::create(LayoutObject* renderer, AXObje ctCacheImpl* axObjectCache)
181 { 181 {
182 return adoptRef(new AXRenderObject(renderer, axObjectCache)); 182 return adoptRef(new AXRenderObject(renderer, axObjectCache));
183 } 183 }
184 184
185 AXRenderObject::~AXRenderObject() 185 AXRenderObject::~AXRenderObject()
186 { 186 {
187 ASSERT(isDetached()); 187 ASSERT(isDetached());
188 } 188 }
189 189
190 LayoutRect AXRenderObject::elementRect() const 190 LayoutRect AXRenderObject::elementRect() const
(...skipping 10 matching lines...) Expand all
201 toAXRenderObject(obj)->checkCachedElementRect(); 201 toAXRenderObject(obj)->checkCachedElementRect();
202 } 202 }
203 for (const AXObject* obj = this; obj; obj = obj->parentObject()) { 203 for (const AXObject* obj = this; obj; obj = obj->parentObject()) {
204 if (obj->isAXRenderObject()) 204 if (obj->isAXRenderObject())
205 toAXRenderObject(obj)->updateCachedElementRect(); 205 toAXRenderObject(obj)->updateCachedElementRect();
206 } 206 }
207 207
208 return m_cachedElementRect; 208 return m_cachedElementRect;
209 } 209 }
210 210
211 void AXRenderObject::setRenderer(RenderObject* renderer) 211 void AXRenderObject::setRenderer(LayoutObject* renderer)
212 { 212 {
213 m_renderer = renderer; 213 m_renderer = renderer;
214 setNode(renderer->node()); 214 setNode(renderer->node());
215 } 215 }
216 216
217 RenderBoxModelObject* AXRenderObject::renderBoxModelObject() const 217 RenderBoxModelObject* AXRenderObject::renderBoxModelObject() const
218 { 218 {
219 if (!m_renderer || !m_renderer->isBoxModelObject()) 219 if (!m_renderer || !m_renderer->isBoxModelObject())
220 return 0; 220 return 0;
221 return toRenderBoxModelObject(m_renderer); 221 return toRenderBoxModelObject(m_renderer);
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 // An ARIA tree can only have tree items and static text as children. 569 // An ARIA tree can only have tree items and static text as children.
570 if (!isAllowedChildOfTree()) 570 if (!isAllowedChildOfTree())
571 return true; 571 return true;
572 572
573 // TODO: we should refactor this - but right now this is necessary to make 573 // TODO: we should refactor this - but right now this is necessary to make
574 // sure scroll areas stay in the tree. 574 // sure scroll areas stay in the tree.
575 if (isAttachment()) 575 if (isAttachment())
576 return false; 576 return false;
577 577
578 // ignore popup menu items because AppKit does 578 // ignore popup menu items because AppKit does
579 for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->p arent()) { 579 for (LayoutObject* parent = m_renderer->parent(); parent; parent = parent->p arent()) {
580 if (parent->isBoxModelObject() && toRenderBoxModelObject(parent)->isMenu List()) 580 if (parent->isBoxModelObject() && toRenderBoxModelObject(parent)->isMenu List())
581 return true; 581 return true;
582 } 582 }
583 583
584 // find out if this element is inside of a label element. 584 // find out if this element is inside of a label element.
585 // if so, it may be ignored because it's the label for a checkbox or radio b utton 585 // if so, it may be ignored because it's the label for a checkbox or radio b utton
586 AXObject* controlObject = correspondingControlForLabelElement(); 586 AXObject* controlObject = correspondingControlForLabelElement();
587 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec t->isCheckboxOrRadio()) 587 if (controlObject && !controlObject->exposesTitleUIElement() && controlObjec t->isCheckboxOrRadio())
588 return true; 588 return true;
589 589
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 1219
1220 const AtomicString& ariaHelp = getAttribute(aria_helpAttr); 1220 const AtomicString& ariaHelp = getAttribute(aria_helpAttr);
1221 if (!ariaHelp.isEmpty()) 1221 if (!ariaHelp.isEmpty())
1222 return ariaHelp; 1222 return ariaHelp;
1223 1223
1224 String describedBy = ariaDescribedByAttribute(); 1224 String describedBy = ariaDescribedByAttribute();
1225 if (!describedBy.isEmpty()) 1225 if (!describedBy.isEmpty())
1226 return describedBy; 1226 return describedBy;
1227 1227
1228 String description = accessibilityDescription(); 1228 String description = accessibilityDescription();
1229 for (RenderObject* curr = m_renderer; curr; curr = curr->parent()) { 1229 for (LayoutObject* curr = m_renderer; curr; curr = curr->parent()) {
1230 if (curr->node() && curr->node()->isHTMLElement()) { 1230 if (curr->node() && curr->node()->isHTMLElement()) {
1231 const AtomicString& summary = toElement(curr->node())->getAttribute( summaryAttr); 1231 const AtomicString& summary = toElement(curr->node())->getAttribute( summaryAttr);
1232 if (!summary.isEmpty()) 1232 if (!summary.isEmpty())
1233 return summary; 1233 return summary;
1234 1234
1235 // The title attribute should be used as help text unless it is alre ady being used as descriptive text. 1235 // The title attribute should be used as help text unless it is alre ady being used as descriptive text.
1236 const AtomicString& title = toElement(curr->node())->getAttribute(ti tleAttr); 1236 const AtomicString& title = toElement(curr->node())->getAttribute(ti tleAttr);
1237 if (!title.isEmpty() && description != title) 1237 if (!title.isEmpty() && description != title)
1238 return title; 1238 return title;
1239 } 1239 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1352 // Allow the hit test to return media control buttons. 1352 // Allow the hit test to return media control buttons.
1353 if (node->isInShadowTree() && (!isHTMLInputElement(*node) || !node->isMediaC ontrolElement())) 1353 if (node->isInShadowTree() && (!isHTMLInputElement(*node) || !node->isMediaC ontrolElement()))
1354 node = node->shadowHost(); 1354 node = node->shadowHost();
1355 1355
1356 if (isHTMLAreaElement(node)) 1356 if (isHTMLAreaElement(node))
1357 return accessibilityImageMapHitTest(toHTMLAreaElement(node), point); 1357 return accessibilityImageMapHitTest(toHTMLAreaElement(node), point);
1358 1358
1359 if (isHTMLOptionElement(node)) 1359 if (isHTMLOptionElement(node))
1360 node = toHTMLOptionElement(*node).ownerSelectElement(); 1360 node = toHTMLOptionElement(*node).ownerSelectElement();
1361 1361
1362 RenderObject* obj = node->renderer(); 1362 LayoutObject* obj = node->renderer();
1363 if (!obj) 1363 if (!obj)
1364 return 0; 1364 return 0;
1365 1365
1366 AXObject* result = axObjectCache()->getOrCreate(obj); 1366 AXObject* result = axObjectCache()->getOrCreate(obj);
1367 result->updateChildrenIfNecessary(); 1367 result->updateChildrenIfNecessary();
1368 1368
1369 // Allow the element to perform any hit-testing it might need to do to reach non-render children. 1369 // Allow the element to perform any hit-testing it might need to do to reach non-render children.
1370 result = result->elementAccessibilityHitTest(point); 1370 result = result->elementAccessibilityHitTest(point);
1371 1371
1372 if (result && result->accessibilityIsIgnored()) { 1372 if (result && result->accessibilityIsIgnored()) {
(...skipping 30 matching lines...) Expand all
1403 if (ariaRoleAttribute() == MenuBarRole) 1403 if (ariaRoleAttribute() == MenuBarRole)
1404 return axObjectCache()->getOrCreate(m_renderer->parent()); 1404 return axObjectCache()->getOrCreate(m_renderer->parent());
1405 1405
1406 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child 1406 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child
1407 if (ariaRoleAttribute() == MenuRole) { 1407 if (ariaRoleAttribute() == MenuRole) {
1408 AXObject* parent = menuButtonForMenu(); 1408 AXObject* parent = menuButtonForMenu();
1409 if (parent) 1409 if (parent)
1410 return parent; 1410 return parent;
1411 } 1411 }
1412 1412
1413 RenderObject* parentObj = renderParentObject(); 1413 LayoutObject* parentObj = renderParentObject();
1414 if (parentObj) 1414 if (parentObj)
1415 return axObjectCache()->getOrCreate(parentObj); 1415 return axObjectCache()->getOrCreate(parentObj);
1416 1416
1417 // WebArea's parent should be the scroll view containing it. 1417 // WebArea's parent should be the scroll view containing it.
1418 if (isWebArea()) 1418 if (isWebArea())
1419 return axObjectCache()->getOrCreate(m_renderer->frame()->view()); 1419 return axObjectCache()->getOrCreate(m_renderer->frame()->view());
1420 1420
1421 return 0; 1421 return 0;
1422 } 1422 }
1423 1423
1424 AXObject* AXRenderObject::computeParentIfExists() const 1424 AXObject* AXRenderObject::computeParentIfExists() const
1425 { 1425 {
1426 if (!m_renderer) 1426 if (!m_renderer)
1427 return 0; 1427 return 0;
1428 1428
1429 if (ariaRoleAttribute() == MenuBarRole) 1429 if (ariaRoleAttribute() == MenuBarRole)
1430 return axObjectCache()->get(m_renderer->parent()); 1430 return axObjectCache()->get(m_renderer->parent());
1431 1431
1432 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child 1432 // menuButton and its corresponding menu are DOM siblings, but Accessibility needs them to be parent/child
1433 if (ariaRoleAttribute() == MenuRole) { 1433 if (ariaRoleAttribute() == MenuRole) {
1434 AXObject* parent = menuButtonForMenu(); 1434 AXObject* parent = menuButtonForMenu();
1435 if (parent) 1435 if (parent)
1436 return parent; 1436 return parent;
1437 } 1437 }
1438 1438
1439 RenderObject* parentObj = renderParentObject(); 1439 LayoutObject* parentObj = renderParentObject();
1440 if (parentObj) 1440 if (parentObj)
1441 return axObjectCache()->get(parentObj); 1441 return axObjectCache()->get(parentObj);
1442 1442
1443 // WebArea's parent should be the scroll view containing it. 1443 // WebArea's parent should be the scroll view containing it.
1444 if (isWebArea()) 1444 if (isWebArea())
1445 return axObjectCache()->get(m_renderer->frame()->view()); 1445 return axObjectCache()->get(m_renderer->frame()->view());
1446 1446
1447 return 0; 1447 return 0;
1448 } 1448 }
1449 1449
1450 // 1450 //
1451 // Low-level accessibility tree exploration, only for use within the accessibili ty module. 1451 // Low-level accessibility tree exploration, only for use within the accessibili ty module.
1452 // 1452 //
1453 1453
1454 AXObject* AXRenderObject::firstChild() const 1454 AXObject* AXRenderObject::firstChild() const
1455 { 1455 {
1456 if (!m_renderer) 1456 if (!m_renderer)
1457 return 0; 1457 return 0;
1458 1458
1459 RenderObject* firstChild = firstChildConsideringContinuation(m_renderer); 1459 LayoutObject* firstChild = firstChildConsideringContinuation(m_renderer);
1460 1460
1461 if (!firstChild) 1461 if (!firstChild)
1462 return 0; 1462 return 0;
1463 1463
1464 return axObjectCache()->getOrCreate(firstChild); 1464 return axObjectCache()->getOrCreate(firstChild);
1465 } 1465 }
1466 1466
1467 AXObject* AXRenderObject::nextSibling() const 1467 AXObject* AXRenderObject::nextSibling() const
1468 { 1468 {
1469 if (!m_renderer) 1469 if (!m_renderer)
1470 return 0; 1470 return 0;
1471 1471
1472 RenderObject* nextSibling = 0; 1472 LayoutObject* nextSibling = 0;
1473 1473
1474 RenderInline* inlineContinuation = m_renderer->isRenderBlock() ? toRenderBlo ck(m_renderer)->inlineElementContinuation() : 0; 1474 RenderInline* inlineContinuation = m_renderer->isRenderBlock() ? toRenderBlo ck(m_renderer)->inlineElementContinuation() : 0;
1475 if (inlineContinuation) { 1475 if (inlineContinuation) {
1476 // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's first child. 1476 // Case 1: node is a block and has an inline continuation. Next sibling is the inline continuation's first child.
1477 nextSibling = firstChildConsideringContinuation(inlineContinuation); 1477 nextSibling = firstChildConsideringContinuation(inlineContinuation);
1478 } else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_rend erer)) { 1478 } else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_rend erer)) {
1479 // Case 2: Anonymous block parent of the start of a continuation - skip all the way to 1479 // Case 2: Anonymous block parent of the start of a continuation - skip all the way to
1480 // after the parent of the end, since everything in between will be link ed up via the continuation. 1480 // after the parent of the end, since everything in between will be link ed up via the continuation.
1481 RenderObject* lastParent = endOfContinuations(toRenderBlock(m_renderer)- >lastChild())->parent(); 1481 LayoutObject* lastParent = endOfContinuations(toRenderBlock(m_renderer)- >lastChild())->parent();
1482 while (lastChildHasContinuation(lastParent)) 1482 while (lastChildHasContinuation(lastParent))
1483 lastParent = endOfContinuations(lastParent->slowLastChild())->parent (); 1483 lastParent = endOfContinuations(lastParent->slowLastChild())->parent ();
1484 nextSibling = lastParent->nextSibling(); 1484 nextSibling = lastParent->nextSibling();
1485 } else if (RenderObject* ns = m_renderer->nextSibling()) { 1485 } else if (LayoutObject* ns = m_renderer->nextSibling()) {
1486 // Case 3: node has an actual next sibling 1486 // Case 3: node has an actual next sibling
1487 nextSibling = ns; 1487 nextSibling = ns;
1488 } else if (isInlineWithContinuation(m_renderer)) { 1488 } else if (isInlineWithContinuation(m_renderer)) {
1489 // Case 4: node is an inline with a continuation. Next sibling is the ne xt sibling of the end 1489 // Case 4: node is an inline with a continuation. Next sibling is the ne xt sibling of the end
1490 // of the continuation chain. 1490 // of the continuation chain.
1491 nextSibling = endOfContinuations(m_renderer)->nextSibling(); 1491 nextSibling = endOfContinuations(m_renderer)->nextSibling();
1492 } else if (isInlineWithContinuation(m_renderer->parent())) { 1492 } else if (isInlineWithContinuation(m_renderer->parent())) {
1493 // Case 5: node has no next sibling, and its parent is an inline with a continuation. 1493 // Case 5: node has no next sibling, and its parent is an inline with a continuation.
1494 RenderObject* continuation = toRenderInline(m_renderer->parent())->conti nuation(); 1494 LayoutObject* continuation = toRenderInline(m_renderer->parent())->conti nuation();
1495 1495
1496 if (continuation->isRenderBlock()) { 1496 if (continuation->isRenderBlock()) {
1497 // Case 5a: continuation is a block - in this case the block itself is the next sibling. 1497 // Case 5a: continuation is a block - in this case the block itself is the next sibling.
1498 nextSibling = continuation; 1498 nextSibling = continuation;
1499 } else { 1499 } else {
1500 // Case 5b: continuation is an inline - in this case the inline's fi rst child is the next sibling. 1500 // Case 5b: continuation is an inline - in this case the inline's fi rst child is the next sibling.
1501 nextSibling = firstChildConsideringContinuation(continuation); 1501 nextSibling = firstChildConsideringContinuation(continuation);
1502 } 1502 }
1503 } 1503 }
1504 1504
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1555 1555
1556 void AXRenderObject::clearChildren() 1556 void AXRenderObject::clearChildren()
1557 { 1557 {
1558 AXObject::clearChildren(); 1558 AXObject::clearChildren();
1559 m_childrenDirty = false; 1559 m_childrenDirty = false;
1560 } 1560 }
1561 1561
1562 AXObject* AXRenderObject::observableObject() const 1562 AXObject* AXRenderObject::observableObject() const
1563 { 1563 {
1564 // Find the object going up the parent chain that is used in accessibility t o monitor certain notifications. 1564 // Find the object going up the parent chain that is used in accessibility t o monitor certain notifications.
1565 for (RenderObject* renderer = m_renderer; renderer && renderer->node(); rend erer = renderer->parent()) { 1565 for (LayoutObject* renderer = m_renderer; renderer && renderer->node(); rend erer = renderer->parent()) {
1566 if (renderObjectIsObservable(renderer)) 1566 if (layoutObjectIsObservable(renderer))
1567 return axObjectCache()->getOrCreate(renderer); 1567 return axObjectCache()->getOrCreate(renderer);
1568 } 1568 }
1569 1569
1570 return 0; 1570 return 0;
1571 } 1571 }
1572 1572
1573 // 1573 //
1574 // Properties of the object's owning document or page. 1574 // Properties of the object's owning document or page.
1575 // 1575 //
1576 1576
(...skipping 24 matching lines...) Expand all
1601 if (!m_renderer) 1601 if (!m_renderer)
1602 return 0; 1602 return 0;
1603 return &m_renderer->document(); 1603 return &m_renderer->document();
1604 } 1604 }
1605 1605
1606 FrameView* AXRenderObject::documentFrameView() const 1606 FrameView* AXRenderObject::documentFrameView() const
1607 { 1607 {
1608 if (!m_renderer) 1608 if (!m_renderer)
1609 return 0; 1609 return 0;
1610 1610
1611 // this is the RenderObject's Document's LocalFrame's FrameView 1611 // this is the LayoutObject's Document's LocalFrame's FrameView
1612 return m_renderer->document().view(); 1612 return m_renderer->document().view();
1613 } 1613 }
1614 1614
1615 Element* AXRenderObject::anchorElement() const 1615 Element* AXRenderObject::anchorElement() const
1616 { 1616 {
1617 if (!m_renderer) 1617 if (!m_renderer)
1618 return 0; 1618 return 0;
1619 1619
1620 AXObjectCacheImpl* cache = axObjectCache(); 1620 AXObjectCacheImpl* cache = axObjectCache();
1621 RenderObject* currRenderer; 1621 LayoutObject* currRenderer;
1622 1622
1623 // Search up the render tree for a RenderObject with a DOM node. Defer to an earlier continuation, though. 1623 // Search up the render tree for a LayoutObject with a DOM node. Defer to an earlier continuation, though.
1624 for (currRenderer = m_renderer; currRenderer && !currRenderer->node(); currR enderer = currRenderer->parent()) { 1624 for (currRenderer = m_renderer; currRenderer && !currRenderer->node(); currR enderer = currRenderer->parent()) {
1625 if (currRenderer->isAnonymousBlock()) { 1625 if (currRenderer->isAnonymousBlock()) {
1626 RenderObject* continuation = toRenderBlock(currRenderer)->continuati on(); 1626 LayoutObject* continuation = toRenderBlock(currRenderer)->continuati on();
1627 if (continuation) 1627 if (continuation)
1628 return cache->getOrCreate(continuation)->anchorElement(); 1628 return cache->getOrCreate(continuation)->anchorElement();
1629 } 1629 }
1630 } 1630 }
1631 1631
1632 // bail if none found 1632 // bail if none found
1633 if (!currRenderer) 1633 if (!currRenderer)
1634 return 0; 1634 return 0;
1635 1635
1636 // search up the DOM tree for an anchor element 1636 // search up the DOM tree for an anchor element
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1805 // 1805 //
1806 // Text metrics. Most of these should be deprecated, needs major cleanup. 1806 // Text metrics. Most of these should be deprecated, needs major cleanup.
1807 // 1807 //
1808 1808
1809 // NOTE: Consider providing this utility method as AX API 1809 // NOTE: Consider providing this utility method as AX API
1810 int AXRenderObject::index(const VisiblePosition& position) const 1810 int AXRenderObject::index(const VisiblePosition& position) const
1811 { 1811 {
1812 if (position.isNull() || !isTextControl()) 1812 if (position.isNull() || !isTextControl())
1813 return -1; 1813 return -1;
1814 1814
1815 if (renderObjectContainsPosition(m_renderer, position.deepEquivalent())) 1815 if (layoutObjectContainsPosition(m_renderer, position.deepEquivalent()))
1816 return indexForVisiblePosition(position); 1816 return indexForVisiblePosition(position);
1817 1817
1818 return -1; 1818 return -1;
1819 } 1819 }
1820 1820
1821 VisiblePosition AXRenderObject::visiblePositionForIndex(int index) const 1821 VisiblePosition AXRenderObject::visiblePositionForIndex(int index) const
1822 { 1822 {
1823 if (!m_renderer) 1823 if (!m_renderer)
1824 return VisiblePosition(); 1824 return VisiblePosition();
1825 1825
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 AXObject::AccessibilityChildrenVector children = parent->children(); 2034 AXObject::AccessibilityChildrenVector children = parent->children();
2035 unsigned count = children.size(); 2035 unsigned count = children.size();
2036 for (unsigned k = 0; k < count; ++k) { 2036 for (unsigned k = 0; k < count; ++k) {
2037 if (children[k]->elementRect().contains(point)) 2037 if (children[k]->elementRect().contains(point))
2038 return children[k].get(); 2038 return children[k].get();
2039 } 2039 }
2040 2040
2041 return 0; 2041 return 0;
2042 } 2042 }
2043 2043
2044 bool AXRenderObject::renderObjectIsObservable(RenderObject* renderer) const 2044 bool AXRenderObject::layoutObjectIsObservable(LayoutObject* renderer) const
2045 { 2045 {
2046 // AX clients will listen for AXValueChange on a text control. 2046 // AX clients will listen for AXValueChange on a text control.
2047 if (renderer->isTextControl()) 2047 if (renderer->isTextControl())
2048 return true; 2048 return true;
2049 2049
2050 // AX clients will listen for AXSelectedChildrenChanged on listboxes. 2050 // AX clients will listen for AXSelectedChildrenChanged on listboxes.
2051 Node* node = renderer->node(); 2051 Node* node = renderer->node();
2052 if (nodeHasRole(node, "listbox") || (renderer->isBoxModelObject() && toRende rBoxModelObject(renderer)->isListBox())) 2052 if (nodeHasRole(node, "listbox") || (renderer->isBoxModelObject() && toRende rBoxModelObject(renderer)->isListBox()))
2053 return true; 2053 return true;
2054 2054
2055 // Textboxes should send out notifications. 2055 // Textboxes should send out notifications.
2056 if (nodeHasRole(node, "textbox")) 2056 if (nodeHasRole(node, "textbox"))
2057 return true; 2057 return true;
2058 2058
2059 return false; 2059 return false;
2060 } 2060 }
2061 2061
2062 RenderObject* AXRenderObject::renderParentObject() const 2062 LayoutObject* AXRenderObject::renderParentObject() const
2063 { 2063 {
2064 if (!m_renderer) 2064 if (!m_renderer)
2065 return 0; 2065 return 0;
2066 2066
2067 RenderObject* startOfConts = m_renderer->isRenderBlock() ? startOfContinuati ons(m_renderer) : 0; 2067 LayoutObject* startOfConts = m_renderer->isRenderBlock() ? startOfContinuati ons(m_renderer) : 0;
2068 if (startOfConts) { 2068 if (startOfConts) {
2069 // Case 1: node is a block and is an inline's continuation. Parent 2069 // Case 1: node is a block and is an inline's continuation. Parent
2070 // is the start of the continuation chain. 2070 // is the start of the continuation chain.
2071 return startOfConts; 2071 return startOfConts;
2072 } 2072 }
2073 2073
2074 RenderObject* parent = m_renderer->parent(); 2074 LayoutObject* parent = m_renderer->parent();
2075 startOfConts = parent && parent->isRenderInline() ? startOfContinuations(par ent) : 0; 2075 startOfConts = parent && parent->isRenderInline() ? startOfContinuations(par ent) : 0;
2076 if (startOfConts) { 2076 if (startOfConts) {
2077 // Case 2: node's parent is an inline which is some node's continuation; parent is 2077 // Case 2: node's parent is an inline which is some node's continuation; parent is
2078 // the earliest node in the continuation chain. 2078 // the earliest node in the continuation chain.
2079 return startOfConts; 2079 return startOfConts;
2080 } 2080 }
2081 2081
2082 RenderObject* firstChild = parent ? parent->slowFirstChild() : 0; 2082 LayoutObject* firstChild = parent ? parent->slowFirstChild() : 0;
2083 if (firstChild && firstChild->node()) { 2083 if (firstChild && firstChild->node()) {
2084 // Case 3: The first sibling is the beginning of a continuation chain. F ind the origin of that continuation. 2084 // Case 3: The first sibling is the beginning of a continuation chain. F ind the origin of that continuation.
2085 // Get the node's renderer and follow that continuation chain until the first child is found. 2085 // Get the node's renderer and follow that continuation chain until the first child is found.
2086 for (RenderObject* nodeRenderFirstChild = firstChild->node()->renderer() ; nodeRenderFirstChild != firstChild; nodeRenderFirstChild = firstChild->node()- >renderer()) { 2086 for (LayoutObject* nodeRenderFirstChild = firstChild->node()->renderer() ; nodeRenderFirstChild != firstChild; nodeRenderFirstChild = firstChild->node()- >renderer()) {
2087 for (RenderObject* contsTest = nodeRenderFirstChild; contsTest; cont sTest = nextContinuation(contsTest)) { 2087 for (LayoutObject* contsTest = nodeRenderFirstChild; contsTest; cont sTest = nextContinuation(contsTest)) {
2088 if (contsTest == firstChild) { 2088 if (contsTest == firstChild) {
2089 parent = nodeRenderFirstChild->parent(); 2089 parent = nodeRenderFirstChild->parent();
2090 break; 2090 break;
2091 } 2091 }
2092 } 2092 }
2093 RenderObject* newFirstChild = parent->slowFirstChild(); 2093 LayoutObject* newFirstChild = parent->slowFirstChild();
2094 if (firstChild == newFirstChild) 2094 if (firstChild == newFirstChild)
2095 break; 2095 break;
2096 firstChild = newFirstChild; 2096 firstChild = newFirstChild;
2097 if (!firstChild->node()) 2097 if (!firstChild->node())
2098 break; 2098 break;
2099 } 2099 }
2100 } 2100 }
2101 2101
2102 return parent; 2102 return parent;
2103 } 2103 }
2104 2104
2105 bool AXRenderObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) const 2105 bool AXRenderObject::isDescendantOfElementType(const HTMLQualifiedName& tagName) const
2106 { 2106 {
2107 for (RenderObject* parent = m_renderer->parent(); parent; parent = parent->p arent()) { 2107 for (LayoutObject* parent = m_renderer->parent(); parent; parent = parent->p arent()) {
2108 if (parent->node() && parent->node()->hasTagName(tagName)) 2108 if (parent->node() && parent->node()->hasTagName(tagName))
2109 return true; 2109 return true;
2110 } 2110 }
2111 return false; 2111 return false;
2112 } 2112 }
2113 2113
2114 bool AXRenderObject::isSVGImage() const 2114 bool AXRenderObject::isSVGImage() const
2115 { 2115 {
2116 return remoteSVGRootElement(); 2116 return remoteSVGRootElement();
2117 } 2117 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 return false; 2362 return false;
2363 2363
2364 if (parent->roleValue() == NoneRole || parent->roleValue() == Presentational Role) 2364 if (parent->roleValue() == NoneRole || parent->roleValue() == Presentational Role)
2365 return ariaRoleAttribute() == UnknownRole; 2365 return ariaRoleAttribute() == UnknownRole;
2366 2366
2367 return false; 2367 return false;
2368 } 2368 }
2369 2369
2370 LayoutRect AXRenderObject::computeElementRect() const 2370 LayoutRect AXRenderObject::computeElementRect() const
2371 { 2371 {
2372 RenderObject* obj = m_renderer; 2372 LayoutObject* obj = m_renderer;
2373 2373
2374 if (!obj) 2374 if (!obj)
2375 return LayoutRect(); 2375 return LayoutRect();
2376 2376
2377 if (obj->node()) // If we are a continuation, we want to make sure to use th e primary renderer. 2377 if (obj->node()) // If we are a continuation, we want to make sure to use th e primary renderer.
2378 obj = obj->node()->renderer(); 2378 obj = obj->node()->renderer();
2379 2379
2380 // absoluteFocusRingBoundingBox will query the hierarchy below this element, which for large webpages can be very slow. 2380 // absoluteFocusRingBoundingBox will query the hierarchy below this element, which for large webpages can be very slow.
2381 // For a web area, which will have the most elements of any element, absolut eQuads should be used. 2381 // For a web area, which will have the most elements of any element, absolut eQuads should be used.
2382 // We should also use absoluteQuads for SVG elements, otherwise transforms w on't be applied. 2382 // We should also use absoluteQuads for SVG elements, otherwise transforms w on't be applied.
(...skipping 28 matching lines...) Expand all
2411 if (label && label->renderer()) { 2411 if (label && label->renderer()) {
2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2412 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2413 result.unite(labelRect); 2413 result.unite(labelRect);
2414 } 2414 }
2415 } 2415 }
2416 2416
2417 return result; 2417 return result;
2418 } 2418 }
2419 2419
2420 } // namespace blink 2420 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/accessibility/AXRenderObject.h ('k') | Source/modules/accessibility/AXSVGRoot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698