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

Side by Side Diff: Source/core/accessibility/AccessibilityRenderObject.cpp

Issue 24253004: Cleanup: Start using toFoo methods as part of newly adopted coding guideline. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 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) 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 { 220 {
221 if (!m_explicitElementRect.isEmpty()) 221 if (!m_explicitElementRect.isEmpty())
222 return m_explicitElementRect; 222 return m_explicitElementRect;
223 if (!m_renderer) 223 if (!m_renderer)
224 return LayoutRect(); 224 return LayoutRect();
225 if (!m_renderer->isBox()) 225 if (!m_renderer->isBox())
226 return computeElementRect(); 226 return computeElementRect();
227 227
228 for (const AccessibilityObject* obj = this; obj; obj = obj->parentObject()) { 228 for (const AccessibilityObject* obj = this; obj; obj = obj->parentObject()) {
229 if (obj->isAccessibilityRenderObject()) 229 if (obj->isAccessibilityRenderObject())
230 static_cast<const AccessibilityRenderObject*>(obj)->checkCachedEleme ntRect(); 230 toAccessibilityRenderObject(obj)->checkCachedElementRect();
231 } 231 }
232 for (const AccessibilityObject* obj = this; obj; obj = obj->parentObject()) { 232 for (const AccessibilityObject* obj = this; obj; obj = obj->parentObject()) {
233 if (obj->isAccessibilityRenderObject()) 233 if (obj->isAccessibilityRenderObject())
234 static_cast<const AccessibilityRenderObject*>(obj)->updateCachedElem entRect(); 234 toAccessibilityRenderObject(obj)->updateCachedElementRect();
235 } 235 }
236 236
237 return m_cachedElementRect; 237 return m_cachedElementRect;
238 } 238 }
239 239
240 void AccessibilityRenderObject::setRenderer(RenderObject* renderer) 240 void AccessibilityRenderObject::setRenderer(RenderObject* renderer)
241 { 241 {
242 m_renderer = renderer; 242 m_renderer = renderer;
243 setNode(renderer->node()); 243 setNode(renderer->node());
244 } 244 }
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 return String(); 1150 return String();
1151 1151
1152 return plainText(rangeOfContents(node).get(), textIteratorBehavi orForTextRange()); 1152 return plainText(rangeOfContents(node).get(), textIteratorBehavi orForTextRange());
1153 } 1153 }
1154 } 1154 }
1155 1155
1156 // Sometimes text fragments don't have Nodes associated with them (like when 1156 // Sometimes text fragments don't have Nodes associated with them (like when
1157 // CSS content is used to insert text or when a RenderCounter is used.) 1157 // CSS content is used to insert text or when a RenderCounter is used.)
1158 RenderText* renderTextObject = toRenderText(m_renderer); 1158 RenderText* renderTextObject = toRenderText(m_renderer);
1159 if (renderTextObject->isTextFragment()) 1159 if (renderTextObject->isTextFragment())
1160 return String(static_cast<RenderTextFragment*>(m_renderer)->contentS tring()); 1160 return String(toRenderTextFragment(m_renderer)->contentString());
1161 else 1161 else
1162 return String(renderTextObject->text()); 1162 return String(renderTextObject->text());
1163 } 1163 }
1164 1164
1165 return AccessibilityNodeObject::textUnderElement(); 1165 return AccessibilityNodeObject::textUnderElement();
1166 } 1166 }
1167 1167
1168 // 1168 //
1169 // Accessibility Text - (To be deprecated). 1169 // Accessibility Text - (To be deprecated).
1170 // 1170 //
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1317 1317
1318 AccessibilityObject* result = obj->document().axObjectCache()->getOrCreate(o bj); 1318 AccessibilityObject* result = obj->document().axObjectCache()->getOrCreate(o bj);
1319 result->updateChildrenIfNecessary(); 1319 result->updateChildrenIfNecessary();
1320 1320
1321 // Allow the element to perform any hit-testing it might need to do to reach non-render children. 1321 // Allow the element to perform any hit-testing it might need to do to reach non-render children.
1322 result = result->elementAccessibilityHitTest(point); 1322 result = result->elementAccessibilityHitTest(point);
1323 1323
1324 if (result && result->accessibilityIsIgnored()) { 1324 if (result && result->accessibilityIsIgnored()) {
1325 // If this element is the label of a control, a hit test should return t he control. 1325 // If this element is the label of a control, a hit test should return t he control.
1326 if (result->isAccessibilityRenderObject()) { 1326 if (result->isAccessibilityRenderObject()) {
1327 AccessibilityObject* controlObject = static_cast<AccessibilityRender Object*>(result)->correspondingControlForLabelElement(); 1327 AccessibilityObject* controlObject = toAccessibilityRenderObject(res ult)->correspondingControlForLabelElement();
1328 if (controlObject && !controlObject->exposesTitleUIElement()) 1328 if (controlObject && !controlObject->exposesTitleUIElement())
1329 return controlObject; 1329 return controlObject;
1330 } 1330 }
1331 1331
1332 result = result->parentObjectUnignored(); 1332 result = result->parentObjectUnignored();
1333 } 1333 }
1334 1334
1335 return result; 1335 return result;
1336 } 1336 }
1337 1337
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 // 1687 //
1688 1688
1689 void AccessibilityRenderObject::handleActiveDescendantChanged() 1689 void AccessibilityRenderObject::handleActiveDescendantChanged()
1690 { 1690 {
1691 Element* element = toElement(renderer()->node()); 1691 Element* element = toElement(renderer()->node());
1692 if (!element) 1692 if (!element)
1693 return; 1693 return;
1694 Document& doc = renderer()->document(); 1694 Document& doc = renderer()->document();
1695 if (!doc.frame()->selection().isFocusedAndActive() || doc.focusedElement() ! = element) 1695 if (!doc.frame()->selection().isFocusedAndActive() || doc.focusedElement() ! = element)
1696 return; 1696 return;
1697 AccessibilityRenderObject* activedescendant = static_cast<AccessibilityRende rObject*>(activeDescendant()); 1697 AccessibilityRenderObject* activedescendant = toAccessibilityRenderObject(ac tiveDescendant());
1698 1698
1699 if (activedescendant && shouldNotifyActiveDescendant()) 1699 if (activedescendant && shouldNotifyActiveDescendant())
1700 doc.axObjectCache()->postNotification(m_renderer, AXObjectCache::AXActiv eDescendantChanged, true); 1700 doc.axObjectCache()->postNotification(m_renderer, AXObjectCache::AXActiv eDescendantChanged, true);
1701 } 1701 }
1702 1702
1703 void AccessibilityRenderObject::handleAriaExpandedChanged() 1703 void AccessibilityRenderObject::handleAriaExpandedChanged()
1704 { 1704 {
1705 // Find if a parent of this object should handle aria-expanded changes. 1705 // Find if a parent of this object should handle aria-expanded changes.
1706 AccessibilityObject* containerParent = this->parentObject(); 1706 AccessibilityObject* containerParent = this->parentObject();
1707 while (containerParent) { 1707 while (containerParent) {
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
2190 { 2190 {
2191 Node* node = this->node(); 2191 Node* node = this->node();
2192 if (!node || !node->hasTagName(inputTag)) 2192 if (!node || !node->hasTagName(inputTag))
2193 return; 2193 return;
2194 2194
2195 HTMLInputElement* input = toHTMLInputElement(node); 2195 HTMLInputElement* input = toHTMLInputElement(node);
2196 Element* spinButtonElement = input->userAgentShadowRoot()->getElementById(Sh adowElementNames::spinButton()); 2196 Element* spinButtonElement = input->userAgentShadowRoot()->getElementById(Sh adowElementNames::spinButton());
2197 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement()) 2197 if (!spinButtonElement || !spinButtonElement->isSpinButtonElement())
2198 return; 2198 return;
2199 2199
2200 AccessibilitySpinButton* axSpinButton = static_cast<AccessibilitySpinButton* >(axObjectCache()->getOrCreate(SpinButtonRole)); 2200 AccessibilitySpinButton* axSpinButton = toAccessibilitySpinButton(axObjectCa che()->getOrCreate(SpinButtonRole));
2201 axSpinButton->setSpinButtonElement(toSpinButtonElement(spinButtonElement)); 2201 axSpinButton->setSpinButtonElement(toSpinButtonElement(spinButtonElement));
2202 axSpinButton->setParent(this); 2202 axSpinButton->setParent(this);
2203 m_children.append(axSpinButton); 2203 m_children.append(axSpinButton);
2204 } 2204 }
2205 2205
2206 void AccessibilityRenderObject::addImageMapChildren() 2206 void AccessibilityRenderObject::addImageMapChildren()
2207 { 2207 {
2208 RenderBoxModelObject* cssBox = renderBoxModelObject(); 2208 RenderBoxModelObject* cssBox = renderBoxModelObject();
2209 if (!cssBox || !cssBox->isRenderImage()) 2209 if (!cssBox || !cssBox->isRenderImage())
2210 return; 2210 return;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 // ARIA spec says that when a parent object is presentational, and it has re quired child elements, 2319 // ARIA spec says that when a parent object is presentational, and it has re quired child elements,
2320 // those child elements are also presentational. For example, <li> becomes p resentational from <ul>. 2320 // those child elements are also presentational. For example, <li> becomes p resentational from <ul>.
2321 // http://www.w3.org/WAI/PF/aria/complete#presentation 2321 // http://www.w3.org/WAI/PF/aria/complete#presentation
2322 if (roleValue() != ListItemRole && roleValue() != ListMarkerRole) 2322 if (roleValue() != ListItemRole && roleValue() != ListMarkerRole)
2323 return false; 2323 return false;
2324 2324
2325 AccessibilityObject* parent = parentObject(); 2325 AccessibilityObject* parent = parentObject();
2326 if (!parent->isAccessibilityRenderObject()) 2326 if (!parent->isAccessibilityRenderObject())
2327 return false; 2327 return false;
2328 2328
2329 Node* elementNode = static_cast<AccessibilityRenderObject*>(parent)->node(); 2329 Node* elementNode = toAccessibilityRenderObject(parent)->node();
2330 if (!elementNode || !elementNode->isElementNode()) 2330 if (!elementNode || !elementNode->isElementNode())
2331 return false; 2331 return false;
2332 2332
2333 QualifiedName tagName = toElement(elementNode)->tagQName(); 2333 QualifiedName tagName = toElement(elementNode)->tagQName();
2334 if (tagName == ulTag || tagName == olTag || tagName == dlTag) 2334 if (tagName == ulTag || tagName == olTag || tagName == dlTag)
2335 return parent->roleValue() == PresentationalRole; 2335 return parent->roleValue() == PresentationalRole;
2336 2336
2337 return false; 2337 return false;
2338 } 2338 }
2339 2339
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 if (label && label->renderer()) { 2375 if (label && label->renderer()) {
2376 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect(); 2376 LayoutRect labelRect = axObjectCache()->getOrCreate(label)->elementR ect();
2377 result.unite(labelRect); 2377 result.unite(labelRect);
2378 } 2378 }
2379 } 2379 }
2380 2380
2381 return result; 2381 return result;
2382 } 2382 }
2383 2383
2384 } // namespace WebCore 2384 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/accessibility/AccessibilityMenuList.cpp ('k') | Source/core/accessibility/AccessibilityTableHeaderContainer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698