OLD | NEW |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 LayoutObject* firstChildInContinuation(const RenderInline& rendere
r) | 83 static inline LayoutObject* firstChildInContinuation(const RenderInline& rendere
r) |
84 { | 84 { |
85 RenderBoxModelObject* r = renderer.continuation(); | 85 LayoutBoxModelObject* 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 (LayoutObject* 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(LayoutObject* 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 LayoutBoxModelObject* renderer = toLayoutBoxModelObject(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 LayoutObject* firstChildConsideringContinuation(LayoutObject* rend
erer) | 110 static inline LayoutObject* firstChildConsideringContinuation(LayoutObject* rend
erer) |
111 { | 111 { |
112 LayoutObject* firstChild = renderer->slowFirstChild(); | 112 LayoutObject* firstChild = renderer->slowFirstChild(); |
113 | 113 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 150 |
151 return prev; | 151 return prev; |
152 } | 152 } |
153 | 153 |
154 static inline bool lastChildHasContinuation(LayoutObject* renderer) | 154 static inline bool lastChildHasContinuation(LayoutObject* renderer) |
155 { | 155 { |
156 LayoutObject* 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(LayoutObject* renderer) | 160 static LayoutBoxModelObject* 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(LayoutObject* renderer, AXObjectCacheImpl* axObje
ctCache) | 170 AXRenderObject::AXRenderObject(LayoutObject* renderer, AXObjectCacheImpl* axObje
ctCache) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 | 207 |
208 return m_cachedElementRect; | 208 return m_cachedElementRect; |
209 } | 209 } |
210 | 210 |
211 void AXRenderObject::setRenderer(LayoutObject* 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 LayoutBoxModelObject* AXRenderObject::layoutBoxModelObject() 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 toLayoutBoxModelObject(m_renderer); |
222 } | 222 } |
223 | 223 |
224 Document* AXRenderObject::topDocument() const | 224 Document* AXRenderObject::topDocument() const |
225 { | 225 { |
226 if (!document()) | 226 if (!document()) |
227 return 0; | 227 return 0; |
228 return &document()->topDocument(); | 228 return &document()->topDocument(); |
229 } | 229 } |
230 | 230 |
231 bool AXRenderObject::shouldNotifyActiveDescendant() const | 231 bool AXRenderObject::shouldNotifyActiveDescendant() const |
(...skipping 15 matching lines...) Expand all Loading... |
247 if (!m_renderer || !m_renderer->isBox()) | 247 if (!m_renderer || !m_renderer->isBox()) |
248 return 0; | 248 return 0; |
249 | 249 |
250 RenderBox* box = toRenderBox(m_renderer); | 250 RenderBox* box = toRenderBox(m_renderer); |
251 if (!box->canBeScrolledAndHasScrollableArea()) | 251 if (!box->canBeScrolledAndHasScrollableArea()) |
252 return 0; | 252 return 0; |
253 | 253 |
254 return box->scrollableArea(); | 254 return box->scrollableArea(); |
255 } | 255 } |
256 | 256 |
257 static bool isImageOrAltText(RenderBoxModelObject* box, Node* node) | 257 static bool isImageOrAltText(LayoutBoxModelObject* box, Node* node) |
258 { | 258 { |
259 if (box && box->isImage()) | 259 if (box && box->isImage()) |
260 return true; | 260 return true; |
261 if (isHTMLImageElement(node)) | 261 if (isHTMLImageElement(node)) |
262 return true; | 262 return true; |
263 if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent
()) | 263 if (isHTMLInputElement(node) && toHTMLInputElement(node)->hasFallbackContent
()) |
264 return true; | 264 return true; |
265 return false; | 265 return false; |
266 } | 266 } |
267 | 267 |
268 AccessibilityRole AXRenderObject::determineAccessibilityRole() | 268 AccessibilityRole AXRenderObject::determineAccessibilityRole() |
269 { | 269 { |
270 if (!m_renderer) | 270 if (!m_renderer) |
271 return UnknownRole; | 271 return UnknownRole; |
272 | 272 |
273 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) | 273 if ((m_ariaRole = determineAriaRoleAttribute()) != UnknownRole) |
274 return m_ariaRole; | 274 return m_ariaRole; |
275 | 275 |
276 Node* node = m_renderer->node(); | 276 Node* node = m_renderer->node(); |
277 RenderBoxModelObject* cssBox = renderBoxModelObject(); | 277 LayoutBoxModelObject* cssBox = layoutBoxModelObject(); |
278 | 278 |
279 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) | 279 if ((cssBox && cssBox->isListItem()) || isHTMLLIElement(node)) |
280 return ListItemRole; | 280 return ListItemRole; |
281 if (m_renderer->isListMarker()) | 281 if (m_renderer->isListMarker()) |
282 return ListMarkerRole; | 282 return ListMarkerRole; |
283 if (m_renderer->isBR()) | 283 if (m_renderer->isBR()) |
284 return LineBreakRole; | 284 return LineBreakRole; |
285 if (isHTMLLegendElement(node)) | 285 if (isHTMLLegendElement(node)) |
286 return LegendRole; | 286 return LegendRole; |
287 if (m_renderer->isText()) | 287 if (m_renderer->isText()) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 #endif | 402 #endif |
403 m_renderer = 0; | 403 m_renderer = 0; |
404 } | 404 } |
405 | 405 |
406 // | 406 // |
407 // Check object role or purpose. | 407 // Check object role or purpose. |
408 // | 408 // |
409 | 409 |
410 bool AXRenderObject::isAttachment() const | 410 bool AXRenderObject::isAttachment() const |
411 { | 411 { |
412 RenderBoxModelObject* renderer = renderBoxModelObject(); | 412 LayoutBoxModelObject* renderer = layoutBoxModelObject(); |
413 if (!renderer) | 413 if (!renderer) |
414 return false; | 414 return false; |
415 // Widgets are the replaced elements that we represent to AX as attachments | 415 // Widgets are the replaced elements that we represent to AX as attachments |
416 bool isLayoutPart = renderer->isLayoutPart(); | 416 bool isLayoutPart = renderer->isLayoutPart(); |
417 ASSERT(!isLayoutPart || (renderer->isReplaced() && !isImage())); | 417 ASSERT(!isLayoutPart || (renderer->isReplaced() && !isImage())); |
418 return isLayoutPart; | 418 return isLayoutPart; |
419 } | 419 } |
420 | 420 |
421 static bool isLinkable(const AXObject& object) | 421 static bool isLinkable(const AXObject& object) |
422 { | 422 { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 (LayoutObject* 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() && toLayoutBoxModelObject(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 |
590 if (m_renderer->isBR()) | 590 if (m_renderer->isBR()) |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 default: | 915 default: |
916 return emptyString(); | 916 return emptyString(); |
917 } | 917 } |
918 } | 918 } |
919 | 919 |
920 String AXRenderObject::stringValue() const | 920 String AXRenderObject::stringValue() const |
921 { | 921 { |
922 if (!m_renderer) | 922 if (!m_renderer) |
923 return String(); | 923 return String(); |
924 | 924 |
925 RenderBoxModelObject* cssBox = renderBoxModelObject(); | 925 LayoutBoxModelObject* cssBox = layoutBoxModelObject(); |
926 | 926 |
927 if (ariaRoleAttribute() == StaticTextRole) { | 927 if (ariaRoleAttribute() == StaticTextRole) { |
928 String staticText = text(); | 928 String staticText = text(); |
929 if (!staticText.length()) | 929 if (!staticText.length()) |
930 staticText = textUnderElement(TextUnderElementAll); | 930 staticText = textUnderElement(TextUnderElementAll); |
931 return staticText; | 931 return staticText; |
932 } | 932 } |
933 | 933 |
934 if (m_renderer->isText()) | 934 if (m_renderer->isText()) |
935 return textUnderElement(TextUnderElementAll); | 935 return textUnderElement(TextUnderElementAll); |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1701 Position(node, range.start + range.length, Position::PositionIsOffsetInA
nchor), DOWNSTREAM)); | 1701 Position(node, range.start + range.length, Position::PositionIsOffsetInA
nchor), DOWNSTREAM)); |
1702 } | 1702 } |
1703 | 1703 |
1704 void AXRenderObject::setValue(const String& string) | 1704 void AXRenderObject::setValue(const String& string) |
1705 { | 1705 { |
1706 if (!node() || !node()->isElementNode()) | 1706 if (!node() || !node()->isElementNode()) |
1707 return; | 1707 return; |
1708 if (!m_renderer || !m_renderer->isBoxModelObject()) | 1708 if (!m_renderer || !m_renderer->isBoxModelObject()) |
1709 return; | 1709 return; |
1710 | 1710 |
1711 RenderBoxModelObject* renderer = toRenderBoxModelObject(m_renderer); | 1711 LayoutBoxModelObject* renderer = toLayoutBoxModelObject(m_renderer); |
1712 if (renderer->isTextField() && isHTMLInputElement(*node())) | 1712 if (renderer->isTextField() && isHTMLInputElement(*node())) |
1713 toHTMLInputElement(*node()).setValue(string); | 1713 toHTMLInputElement(*node()).setValue(string); |
1714 else if (renderer->isTextArea() && isHTMLTextAreaElement(*node())) | 1714 else if (renderer->isTextArea() && isHTMLTextAreaElement(*node())) |
1715 toHTMLTextAreaElement(*node()).setValue(string); | 1715 toHTMLTextAreaElement(*node()).setValue(string); |
1716 } | 1716 } |
1717 | 1717 |
1718 // FIXME: This function should use an IntSize to avoid the conversion below. | 1718 // FIXME: This function should use an IntSize to avoid the conversion below. |
1719 void AXRenderObject::scrollTo(const IntPoint& point) const | 1719 void AXRenderObject::scrollTo(const IntPoint& point) const |
1720 { | 1720 { |
1721 if (!m_renderer || !m_renderer->isBox()) | 1721 if (!m_renderer || !m_renderer->isBox()) |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2042 } | 2042 } |
2043 | 2043 |
2044 bool AXRenderObject::layoutObjectIsObservable(LayoutObject* 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() && toLayou
tBoxModelObject(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 LayoutObject* AXRenderObject::renderParentObject() const | 2062 LayoutObject* AXRenderObject::renderParentObject() const |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2216 return; | 2216 return; |
2217 | 2217 |
2218 AXSpinButton* axSpinButton = toAXSpinButton(axObjectCache()->getOrCreate(Spi
nButtonRole)); | 2218 AXSpinButton* axSpinButton = toAXSpinButton(axObjectCache()->getOrCreate(Spi
nButtonRole)); |
2219 axSpinButton->setSpinButtonElement(toSpinButtonElement(spinButtonElement)); | 2219 axSpinButton->setSpinButtonElement(toSpinButtonElement(spinButtonElement)); |
2220 axSpinButton->setParent(this); | 2220 axSpinButton->setParent(this); |
2221 m_children.append(axSpinButton); | 2221 m_children.append(axSpinButton); |
2222 } | 2222 } |
2223 | 2223 |
2224 void AXRenderObject::addImageMapChildren() | 2224 void AXRenderObject::addImageMapChildren() |
2225 { | 2225 { |
2226 RenderBoxModelObject* cssBox = renderBoxModelObject(); | 2226 LayoutBoxModelObject* cssBox = layoutBoxModelObject(); |
2227 if (!cssBox || !cssBox->isLayoutImage()) | 2227 if (!cssBox || !cssBox->isLayoutImage()) |
2228 return; | 2228 return; |
2229 | 2229 |
2230 HTMLMapElement* map = toLayoutImage(cssBox)->imageMap(); | 2230 HTMLMapElement* map = toLayoutImage(cssBox)->imageMap(); |
2231 if (!map) | 2231 if (!map) |
2232 return; | 2232 return; |
2233 | 2233 |
2234 for (HTMLAreaElement& area : Traversal<HTMLAreaElement>::descendantsOf(*map)
) { | 2234 for (HTMLAreaElement& area : Traversal<HTMLAreaElement>::descendantsOf(*map)
) { |
2235 // add an <area> element for this child if it has a link | 2235 // add an <area> element for this child if it has a link |
2236 if (area.isLink()) { | 2236 if (area.isLink()) { |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |