OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "config.h" | |
32 #include "WebAccessibilityObject.h" | |
33 | |
34 #include "HTMLNames.h" | |
35 #include "WebDocument.h" | |
36 #include "WebNode.h" | |
37 #include "core/accessibility/AXObjectCache.h" | |
38 #include "core/accessibility/AccessibilityObject.h" | |
39 #include "core/accessibility/AccessibilityTable.h" | |
40 #include "core/accessibility/AccessibilityTableCell.h" | |
41 #include "core/accessibility/AccessibilityTableColumn.h" | |
42 #include "core/accessibility/AccessibilityTableRow.h" | |
43 #include "core/css/CSSPrimitiveValueMappings.h" | |
44 #include "core/dom/Document.h" | |
45 #include "core/dom/Node.h" | |
46 #include "core/page/EventHandler.h" | |
47 #include "core/page/FrameView.h" | |
48 #include "core/platform/PlatformKeyboardEvent.h" | |
49 #include "core/rendering/style/RenderStyle.h" | |
50 #include "public/platform/WebPoint.h" | |
51 #include "public/platform/WebRect.h" | |
52 #include "public/platform/WebString.h" | |
53 #include "public/platform/WebURL.h" | |
54 #include "wtf/text/StringBuilder.h" | |
55 | |
56 using namespace WebCore; | |
57 | |
58 namespace WebKit { | |
59 | |
60 void WebAccessibilityObject::reset() | |
61 { | |
62 m_private.reset(); | |
63 } | |
64 | |
65 void WebAccessibilityObject::assign(const WebKit::WebAccessibilityObject& other) | |
66 { | |
67 m_private = other.m_private; | |
68 } | |
69 | |
70 bool WebAccessibilityObject::equals(const WebAccessibilityObject& n) const | |
71 { | |
72 return m_private.get() == n.m_private.get(); | |
73 } | |
74 | |
75 // static | |
76 void WebAccessibilityObject::enableAccessibility() | |
77 { | |
78 AXObjectCache::enableAccessibility(); | |
79 } | |
80 | |
81 // static | |
82 bool WebAccessibilityObject::accessibilityEnabled() | |
83 { | |
84 return AXObjectCache::accessibilityEnabled(); | |
85 } | |
86 | |
87 void WebAccessibilityObject::startCachingComputedObjectAttributesUntilTreeMutate
s() | |
88 { | |
89 m_private->axObjectCache()->startCachingComputedObjectAttributesUntilTreeMut
ates(); | |
90 } | |
91 | |
92 void WebAccessibilityObject::stopCachingComputedObjectAttributes() | |
93 { | |
94 m_private->axObjectCache()->stopCachingComputedObjectAttributes(); | |
95 } | |
96 | |
97 bool WebAccessibilityObject::isDetached() const | |
98 { | |
99 if (m_private.isNull()) | |
100 return true; | |
101 | |
102 return m_private->isDetached(); | |
103 } | |
104 | |
105 int WebAccessibilityObject::axID() const | |
106 { | |
107 if (isDetached()) | |
108 return -1; | |
109 | |
110 return m_private->axObjectID(); | |
111 } | |
112 | |
113 bool WebAccessibilityObject::updateBackingStoreAndCheckValidity() | |
114 { | |
115 if (!isDetached()) | |
116 m_private->updateBackingStore(); | |
117 return !isDetached(); | |
118 } | |
119 | |
120 WebString WebAccessibilityObject::accessibilityDescription() const | |
121 { | |
122 if (isDetached()) | |
123 return WebString(); | |
124 | |
125 return m_private->accessibilityDescription(); | |
126 } | |
127 | |
128 WebString WebAccessibilityObject::actionVerb() const | |
129 { | |
130 if (isDetached()) | |
131 return WebString(); | |
132 | |
133 return m_private->actionVerb(); | |
134 } | |
135 | |
136 bool WebAccessibilityObject::canDecrement() const | |
137 { | |
138 if (isDetached()) | |
139 return false; | |
140 | |
141 return m_private->isSlider(); | |
142 } | |
143 | |
144 bool WebAccessibilityObject::canIncrement() const | |
145 { | |
146 if (isDetached()) | |
147 return false; | |
148 | |
149 return m_private->isSlider(); | |
150 } | |
151 | |
152 bool WebAccessibilityObject::canPress() const | |
153 { | |
154 if (isDetached()) | |
155 return false; | |
156 | |
157 return m_private->actionElement() || m_private->isButton() || m_private->isM
enuRelated(); | |
158 } | |
159 | |
160 bool WebAccessibilityObject::canSetFocusAttribute() const | |
161 { | |
162 if (isDetached()) | |
163 return false; | |
164 | |
165 return m_private->canSetFocusAttribute(); | |
166 } | |
167 | |
168 bool WebAccessibilityObject::canSetValueAttribute() const | |
169 { | |
170 if (isDetached()) | |
171 return false; | |
172 | |
173 return m_private->canSetValueAttribute(); | |
174 } | |
175 | |
176 unsigned WebAccessibilityObject::childCount() const | |
177 { | |
178 if (isDetached()) | |
179 return 0; | |
180 | |
181 return m_private->children().size(); | |
182 } | |
183 | |
184 WebAccessibilityObject WebAccessibilityObject::childAt(unsigned index) const | |
185 { | |
186 if (isDetached()) | |
187 return WebAccessibilityObject(); | |
188 | |
189 if (m_private->children().size() <= index) | |
190 return WebAccessibilityObject(); | |
191 | |
192 return WebAccessibilityObject(m_private->children()[index]); | |
193 } | |
194 | |
195 WebAccessibilityObject WebAccessibilityObject::parentObject() const | |
196 { | |
197 if (isDetached()) | |
198 return WebAccessibilityObject(); | |
199 | |
200 return WebAccessibilityObject(m_private->parentObject()); | |
201 } | |
202 | |
203 bool WebAccessibilityObject::canSetSelectedAttribute() const | |
204 { | |
205 if (isDetached()) | |
206 return 0; | |
207 | |
208 return m_private->canSetSelectedAttribute(); | |
209 } | |
210 | |
211 bool WebAccessibilityObject::isAnchor() const | |
212 { | |
213 if (isDetached()) | |
214 return 0; | |
215 | |
216 return m_private->isAnchor(); | |
217 } | |
218 | |
219 bool WebAccessibilityObject::isAriaReadOnly() const | |
220 { | |
221 if (isDetached()) | |
222 return 0; | |
223 | |
224 return equalIgnoringCase(m_private->getAttribute(HTMLNames::aria_readonlyAtt
r), "true"); | |
225 } | |
226 | |
227 bool WebAccessibilityObject::isButtonStateMixed() const | |
228 { | |
229 if (isDetached()) | |
230 return 0; | |
231 | |
232 return m_private->checkboxOrRadioValue() == ButtonStateMixed; | |
233 } | |
234 | |
235 bool WebAccessibilityObject::isChecked() const | |
236 { | |
237 if (isDetached()) | |
238 return 0; | |
239 | |
240 return m_private->isChecked(); | |
241 } | |
242 | |
243 bool WebAccessibilityObject::isClickable() const | |
244 { | |
245 if (isDetached()) | |
246 return 0; | |
247 | |
248 return m_private->isClickable(); | |
249 } | |
250 | |
251 bool WebAccessibilityObject::isCollapsed() const | |
252 { | |
253 if (isDetached()) | |
254 return 0; | |
255 | |
256 return m_private->isCollapsed(); | |
257 } | |
258 | |
259 bool WebAccessibilityObject::isControl() const | |
260 { | |
261 if (isDetached()) | |
262 return 0; | |
263 | |
264 return m_private->isControl(); | |
265 } | |
266 | |
267 bool WebAccessibilityObject::isEnabled() const | |
268 { | |
269 if (isDetached()) | |
270 return 0; | |
271 | |
272 return m_private->isEnabled(); | |
273 } | |
274 | |
275 bool WebAccessibilityObject::isFocused() const | |
276 { | |
277 if (isDetached()) | |
278 return 0; | |
279 | |
280 return m_private->isFocused(); | |
281 } | |
282 | |
283 bool WebAccessibilityObject::isHovered() const | |
284 { | |
285 if (isDetached()) | |
286 return 0; | |
287 | |
288 return m_private->isHovered(); | |
289 } | |
290 | |
291 bool WebAccessibilityObject::isIndeterminate() const | |
292 { | |
293 if (isDetached()) | |
294 return 0; | |
295 | |
296 return m_private->isIndeterminate(); | |
297 } | |
298 | |
299 bool WebAccessibilityObject::isLinked() const | |
300 { | |
301 if (isDetached()) | |
302 return 0; | |
303 | |
304 return m_private->isLinked(); | |
305 } | |
306 | |
307 bool WebAccessibilityObject::isLoaded() const | |
308 { | |
309 if (isDetached()) | |
310 return 0; | |
311 | |
312 return m_private->isLoaded(); | |
313 } | |
314 | |
315 bool WebAccessibilityObject::isMultiSelectable() const | |
316 { | |
317 if (isDetached()) | |
318 return 0; | |
319 | |
320 return m_private->isMultiSelectable(); | |
321 } | |
322 | |
323 bool WebAccessibilityObject::isOffScreen() const | |
324 { | |
325 if (isDetached()) | |
326 return 0; | |
327 | |
328 return m_private->isOffScreen(); | |
329 } | |
330 | |
331 bool WebAccessibilityObject::isPasswordField() const | |
332 { | |
333 if (isDetached()) | |
334 return 0; | |
335 | |
336 return m_private->isPasswordField(); | |
337 } | |
338 | |
339 bool WebAccessibilityObject::isPressed() const | |
340 { | |
341 if (isDetached()) | |
342 return 0; | |
343 | |
344 return m_private->isPressed(); | |
345 } | |
346 | |
347 bool WebAccessibilityObject::isReadOnly() const | |
348 { | |
349 if (isDetached()) | |
350 return 0; | |
351 | |
352 return m_private->isReadOnly(); | |
353 } | |
354 | |
355 bool WebAccessibilityObject::isRequired() const | |
356 { | |
357 if (isDetached()) | |
358 return 0; | |
359 | |
360 return m_private->isRequired(); | |
361 } | |
362 | |
363 bool WebAccessibilityObject::isSelected() const | |
364 { | |
365 if (isDetached()) | |
366 return 0; | |
367 | |
368 return m_private->isSelected(); | |
369 } | |
370 | |
371 bool WebAccessibilityObject::isSelectedOptionActive() const | |
372 { | |
373 if (isDetached()) | |
374 return false; | |
375 | |
376 return m_private->isSelectedOptionActive(); | |
377 } | |
378 | |
379 bool WebAccessibilityObject::isVertical() const | |
380 { | |
381 if (isDetached()) | |
382 return 0; | |
383 | |
384 return m_private->orientation() == AccessibilityOrientationVertical; | |
385 } | |
386 | |
387 bool WebAccessibilityObject::isVisible() const | |
388 { | |
389 if (isDetached()) | |
390 return 0; | |
391 | |
392 return m_private->isVisible(); | |
393 } | |
394 | |
395 bool WebAccessibilityObject::isVisited() const | |
396 { | |
397 if (isDetached()) | |
398 return 0; | |
399 | |
400 return m_private->isVisited(); | |
401 } | |
402 | |
403 WebString WebAccessibilityObject::accessKey() const | |
404 { | |
405 if (isDetached()) | |
406 return WebString(); | |
407 | |
408 return WebString(m_private->accessKey()); | |
409 } | |
410 | |
411 bool WebAccessibilityObject::ariaHasPopup() const | |
412 { | |
413 if (isDetached()) | |
414 return 0; | |
415 | |
416 return m_private->ariaHasPopup(); | |
417 } | |
418 | |
419 bool WebAccessibilityObject::ariaLiveRegionAtomic() const | |
420 { | |
421 if (isDetached()) | |
422 return 0; | |
423 | |
424 return m_private->ariaLiveRegionAtomic(); | |
425 } | |
426 | |
427 bool WebAccessibilityObject::ariaLiveRegionBusy() const | |
428 { | |
429 if (isDetached()) | |
430 return 0; | |
431 | |
432 return m_private->ariaLiveRegionBusy(); | |
433 } | |
434 | |
435 WebString WebAccessibilityObject::ariaLiveRegionRelevant() const | |
436 { | |
437 if (isDetached()) | |
438 return WebString(); | |
439 | |
440 return m_private->ariaLiveRegionRelevant(); | |
441 } | |
442 | |
443 WebString WebAccessibilityObject::ariaLiveRegionStatus() const | |
444 { | |
445 if (isDetached()) | |
446 return WebString(); | |
447 | |
448 return m_private->ariaLiveRegionStatus(); | |
449 } | |
450 | |
451 WebRect WebAccessibilityObject::boundingBoxRect() const | |
452 { | |
453 if (isDetached()) | |
454 return WebRect(); | |
455 | |
456 return pixelSnappedIntRect(m_private->elementRect()); | |
457 } | |
458 | |
459 bool WebAccessibilityObject::canvasHasFallbackContent() const | |
460 { | |
461 if (isDetached()) | |
462 return false; | |
463 | |
464 return m_private->canvasHasFallbackContent(); | |
465 } | |
466 | |
467 WebPoint WebAccessibilityObject::clickPoint() const | |
468 { | |
469 if (isDetached()) | |
470 return WebPoint(); | |
471 | |
472 return WebPoint(m_private->clickPoint()); | |
473 } | |
474 | |
475 void WebAccessibilityObject::colorValue(int& r, int& g, int& b) const | |
476 { | |
477 if (isDetached()) | |
478 return; | |
479 | |
480 m_private->colorValue(r, g, b); | |
481 } | |
482 | |
483 double WebAccessibilityObject::estimatedLoadingProgress() const | |
484 { | |
485 if (isDetached()) | |
486 return 0.0; | |
487 | |
488 return m_private->estimatedLoadingProgress(); | |
489 } | |
490 | |
491 WebString WebAccessibilityObject::helpText() const | |
492 { | |
493 if (isDetached()) | |
494 return WebString(); | |
495 | |
496 return m_private->helpText(); | |
497 } | |
498 | |
499 int WebAccessibilityObject::headingLevel() const | |
500 { | |
501 if (isDetached()) | |
502 return 0; | |
503 | |
504 return m_private->headingLevel(); | |
505 } | |
506 | |
507 int WebAccessibilityObject::hierarchicalLevel() const | |
508 { | |
509 if (isDetached()) | |
510 return 0; | |
511 | |
512 return m_private->hierarchicalLevel(); | |
513 } | |
514 | |
515 WebAccessibilityObject WebAccessibilityObject::hitTest(const WebPoint& point) co
nst | |
516 { | |
517 if (isDetached()) | |
518 return WebAccessibilityObject(); | |
519 | |
520 IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(po
int); | |
521 RefPtr<AccessibilityObject> hit = m_private->accessibilityHitTest(contentsPo
int); | |
522 | |
523 if (hit) | |
524 return WebAccessibilityObject(hit); | |
525 | |
526 if (m_private->elementRect().contains(contentsPoint)) | |
527 return *this; | |
528 | |
529 return WebAccessibilityObject(); | |
530 } | |
531 | |
532 WebString WebAccessibilityObject::keyboardShortcut() const | |
533 { | |
534 if (isDetached()) | |
535 return WebString(); | |
536 | |
537 String accessKey = m_private->accessKey(); | |
538 if (accessKey.isNull()) | |
539 return WebString(); | |
540 | |
541 DEFINE_STATIC_LOCAL(String, modifierString, ()); | |
542 if (modifierString.isNull()) { | |
543 unsigned modifiers = EventHandler::accessKeyModifiers(); | |
544 // Follow the same order as Mozilla MSAA implementation: | |
545 // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings | |
546 // should not be localized and defines the separator as "+". | |
547 StringBuilder modifierStringBuilder; | |
548 if (modifiers & PlatformEvent::CtrlKey) | |
549 modifierStringBuilder.appendLiteral("Ctrl+"); | |
550 if (modifiers & PlatformEvent::AltKey) | |
551 modifierStringBuilder.appendLiteral("Alt+"); | |
552 if (modifiers & PlatformEvent::ShiftKey) | |
553 modifierStringBuilder.appendLiteral("Shift+"); | |
554 if (modifiers & PlatformEvent::MetaKey) | |
555 modifierStringBuilder.appendLiteral("Win+"); | |
556 modifierString = modifierStringBuilder.toString(); | |
557 } | |
558 | |
559 return String(modifierString + accessKey); | |
560 } | |
561 | |
562 bool WebAccessibilityObject::performDefaultAction() const | |
563 { | |
564 if (isDetached()) | |
565 return false; | |
566 | |
567 return m_private->performDefaultAction(); | |
568 } | |
569 | |
570 bool WebAccessibilityObject::increment() const | |
571 { | |
572 if (isDetached()) | |
573 return false; | |
574 | |
575 if (canIncrement()) { | |
576 m_private->increment(); | |
577 return true; | |
578 } | |
579 return false; | |
580 } | |
581 | |
582 bool WebAccessibilityObject::decrement() const | |
583 { | |
584 if (isDetached()) | |
585 return false; | |
586 | |
587 if (canDecrement()) { | |
588 m_private->decrement(); | |
589 return true; | |
590 } | |
591 return false; | |
592 } | |
593 | |
594 bool WebAccessibilityObject::press() const | |
595 { | |
596 if (isDetached()) | |
597 return false; | |
598 | |
599 return m_private->press(); | |
600 } | |
601 | |
602 // Deprecated in favor of role(). | |
603 WebAccessibilityRole WebAccessibilityObject::roleValue() const | |
604 { | |
605 if (isDetached()) | |
606 return WebKit::WebAccessibilityRoleUnknown; | |
607 | |
608 return static_cast<WebAccessibilityRole>(m_private->roleValue()); | |
609 } | |
610 | |
611 WebAXRole WebAccessibilityObject::role() const | |
612 { | |
613 if (isDetached()) | |
614 return WebKit::WebAXRoleUnknown; | |
615 | |
616 return static_cast<WebAXRole>(m_private->roleValue()); | |
617 } | |
618 | |
619 unsigned WebAccessibilityObject::selectionEnd() const | |
620 { | |
621 if (isDetached()) | |
622 return 0; | |
623 | |
624 return m_private->selectedTextRange().start + m_private->selectedTextRange()
.length; | |
625 } | |
626 | |
627 unsigned WebAccessibilityObject::selectionStart() const | |
628 { | |
629 if (isDetached()) | |
630 return 0; | |
631 | |
632 return m_private->selectedTextRange().start; | |
633 } | |
634 | |
635 unsigned WebAccessibilityObject::selectionEndLineNumber() const | |
636 { | |
637 if (isDetached()) | |
638 return 0; | |
639 | |
640 VisiblePosition position = m_private->visiblePositionForIndex(selectionEnd()
); | |
641 int lineNumber = m_private->lineForPosition(position); | |
642 if (lineNumber < 0) | |
643 return 0; | |
644 return lineNumber; | |
645 } | |
646 | |
647 unsigned WebAccessibilityObject::selectionStartLineNumber() const | |
648 { | |
649 if (isDetached()) | |
650 return 0; | |
651 | |
652 VisiblePosition position = m_private->visiblePositionForIndex(selectionStart
()); | |
653 int lineNumber = m_private->lineForPosition(position); | |
654 if (lineNumber < 0) | |
655 return 0; | |
656 return lineNumber; | |
657 } | |
658 | |
659 void WebAccessibilityObject::setFocused(bool on) const | |
660 { | |
661 if (!isDetached()) | |
662 m_private->setFocused(on); | |
663 } | |
664 | |
665 void WebAccessibilityObject::setSelectedTextRange(int selectionStart, int select
ionEnd) const | |
666 { | |
667 if (isDetached()) | |
668 return; | |
669 | |
670 m_private->setSelectedTextRange(PlainTextRange(selectionStart, selectionEnd
- selectionStart)); | |
671 } | |
672 | |
673 WebString WebAccessibilityObject::stringValue() const | |
674 { | |
675 if (isDetached()) | |
676 return WebString(); | |
677 | |
678 return m_private->stringValue(); | |
679 } | |
680 | |
681 WebString WebAccessibilityObject::title() const | |
682 { | |
683 if (isDetached()) | |
684 return WebString(); | |
685 | |
686 return m_private->title(); | |
687 } | |
688 | |
689 WebAccessibilityObject WebAccessibilityObject::titleUIElement() const | |
690 { | |
691 if (isDetached()) | |
692 return WebAccessibilityObject(); | |
693 | |
694 if (!m_private->exposesTitleUIElement()) | |
695 return WebAccessibilityObject(); | |
696 | |
697 return WebAccessibilityObject(m_private->titleUIElement()); | |
698 } | |
699 | |
700 WebURL WebAccessibilityObject::url() const | |
701 { | |
702 if (isDetached()) | |
703 return WebURL(); | |
704 | |
705 return m_private->url(); | |
706 } | |
707 | |
708 bool WebAccessibilityObject::supportsRangeValue() const | |
709 { | |
710 if (isDetached()) | |
711 return false; | |
712 | |
713 return m_private->supportsRangeValue(); | |
714 } | |
715 | |
716 WebString WebAccessibilityObject::valueDescription() const | |
717 { | |
718 if (isDetached()) | |
719 return WebString(); | |
720 | |
721 return m_private->valueDescription(); | |
722 } | |
723 | |
724 float WebAccessibilityObject::valueForRange() const | |
725 { | |
726 if (isDetached()) | |
727 return 0.0; | |
728 | |
729 return m_private->valueForRange(); | |
730 } | |
731 | |
732 float WebAccessibilityObject::maxValueForRange() const | |
733 { | |
734 if (isDetached()) | |
735 return 0.0; | |
736 | |
737 return m_private->maxValueForRange(); | |
738 } | |
739 | |
740 float WebAccessibilityObject::minValueForRange() const | |
741 { | |
742 if (isDetached()) | |
743 return 0.0; | |
744 | |
745 return m_private->minValueForRange(); | |
746 } | |
747 | |
748 WebNode WebAccessibilityObject::node() const | |
749 { | |
750 if (isDetached()) | |
751 return WebNode(); | |
752 | |
753 Node* node = m_private->node(); | |
754 if (!node) | |
755 return WebNode(); | |
756 | |
757 return WebNode(node); | |
758 } | |
759 | |
760 WebDocument WebAccessibilityObject::document() const | |
761 { | |
762 if (isDetached()) | |
763 return WebDocument(); | |
764 | |
765 Document* document = m_private->document(); | |
766 if (!document) | |
767 return WebDocument(); | |
768 | |
769 return WebDocument(document); | |
770 } | |
771 | |
772 bool WebAccessibilityObject::hasComputedStyle() const | |
773 { | |
774 if (isDetached()) | |
775 return false; | |
776 | |
777 Document* document = m_private->document(); | |
778 if (document) | |
779 document->updateStyleIfNeeded(); | |
780 | |
781 Node* node = m_private->node(); | |
782 if (!node) | |
783 return false; | |
784 | |
785 return node->computedStyle(); | |
786 } | |
787 | |
788 WebString WebAccessibilityObject::computedStyleDisplay() const | |
789 { | |
790 if (isDetached()) | |
791 return WebString(); | |
792 | |
793 Document* document = m_private->document(); | |
794 if (document) | |
795 document->updateStyleIfNeeded(); | |
796 | |
797 Node* node = m_private->node(); | |
798 if (!node) | |
799 return WebString(); | |
800 | |
801 RenderStyle* renderStyle = node->computedStyle(); | |
802 if (!renderStyle) | |
803 return WebString(); | |
804 | |
805 return WebString(CSSPrimitiveValue::create(renderStyle->display())->getStrin
gValue()); | |
806 } | |
807 | |
808 bool WebAccessibilityObject::accessibilityIsIgnored() const | |
809 { | |
810 if (isDetached()) | |
811 return false; | |
812 | |
813 return m_private->accessibilityIsIgnored(); | |
814 } | |
815 | |
816 bool WebAccessibilityObject::lineBreaks(WebVector<int>& result) const | |
817 { | |
818 if (isDetached()) | |
819 return false; | |
820 | |
821 Vector<int> lineBreaksVector; | |
822 m_private->lineBreaks(lineBreaksVector); | |
823 | |
824 size_t vectorSize = lineBreaksVector.size(); | |
825 WebVector<int> lineBreaksWebVector(vectorSize); | |
826 for (size_t i = 0; i< vectorSize; i++) | |
827 lineBreaksWebVector[i] = lineBreaksVector[i]; | |
828 result.swap(lineBreaksWebVector); | |
829 | |
830 return true; | |
831 } | |
832 | |
833 unsigned WebAccessibilityObject::columnCount() const | |
834 { | |
835 if (isDetached()) | |
836 return false; | |
837 | |
838 if (!m_private->isAccessibilityTable()) | |
839 return 0; | |
840 | |
841 return static_cast<WebCore::AccessibilityTable*>(m_private.get())->columnCou
nt(); | |
842 } | |
843 | |
844 unsigned WebAccessibilityObject::rowCount() const | |
845 { | |
846 if (isDetached()) | |
847 return false; | |
848 | |
849 if (!m_private->isAccessibilityTable()) | |
850 return 0; | |
851 | |
852 return static_cast<WebCore::AccessibilityTable*>(m_private.get())->rowCount(
); | |
853 } | |
854 | |
855 WebAccessibilityObject WebAccessibilityObject::cellForColumnAndRow(unsigned colu
mn, unsigned row) const | |
856 { | |
857 if (isDetached()) | |
858 return WebAccessibilityObject(); | |
859 | |
860 if (!m_private->isAccessibilityTable()) | |
861 return WebAccessibilityObject(); | |
862 | |
863 WebCore::AccessibilityTableCell* cell = static_cast<WebCore::AccessibilityTa
ble*>(m_private.get())->cellForColumnAndRow(column, row); | |
864 return WebAccessibilityObject(static_cast<WebCore::AccessibilityObject*>(cel
l)); | |
865 } | |
866 | |
867 WebAccessibilityObject WebAccessibilityObject::headerContainerObject() const | |
868 { | |
869 if (isDetached()) | |
870 return WebAccessibilityObject(); | |
871 | |
872 if (!m_private->isAccessibilityTable()) | |
873 return WebAccessibilityObject(); | |
874 | |
875 return WebAccessibilityObject(static_cast<WebCore::AccessibilityTable*>(m_pr
ivate.get())->headerContainer()); | |
876 } | |
877 | |
878 WebAccessibilityObject WebAccessibilityObject::rowAtIndex(unsigned int rowIndex)
const | |
879 { | |
880 if (isDetached()) | |
881 return WebAccessibilityObject(); | |
882 | |
883 if (!m_private->isAccessibilityTable()) | |
884 return WebAccessibilityObject(); | |
885 | |
886 const AccessibilityObject::AccessibilityChildrenVector& rows = static_cast<W
ebCore::AccessibilityTable*>(m_private.get())->rows(); | |
887 if (rowIndex < rows.size()) | |
888 return WebAccessibilityObject(rows[rowIndex]); | |
889 | |
890 return WebAccessibilityObject(); | |
891 } | |
892 | |
893 WebAccessibilityObject WebAccessibilityObject::columnAtIndex(unsigned int column
Index) const | |
894 { | |
895 if (isDetached()) | |
896 return WebAccessibilityObject(); | |
897 | |
898 if (!m_private->isAccessibilityTable()) | |
899 return WebAccessibilityObject(); | |
900 | |
901 const AccessibilityObject::AccessibilityChildrenVector& columns = static_cas
t<WebCore::AccessibilityTable*>(m_private.get())->columns(); | |
902 if (columnIndex < columns.size()) | |
903 return WebAccessibilityObject(columns[columnIndex]); | |
904 | |
905 return WebAccessibilityObject(); | |
906 } | |
907 | |
908 unsigned WebAccessibilityObject::rowIndex() const | |
909 { | |
910 if (isDetached()) | |
911 return 0; | |
912 | |
913 if (!m_private->isTableRow()) | |
914 return 0; | |
915 | |
916 return static_cast<WebCore::AccessibilityTableRow*>(m_private.get())->rowInd
ex(); | |
917 } | |
918 | |
919 WebAccessibilityObject WebAccessibilityObject::rowHeader() const | |
920 { | |
921 if (isDetached()) | |
922 return WebAccessibilityObject(); | |
923 | |
924 if (!m_private->isTableRow()) | |
925 return WebAccessibilityObject(); | |
926 | |
927 return WebAccessibilityObject(static_cast<WebCore::AccessibilityTableRow*>(m
_private.get())->headerObject()); | |
928 } | |
929 | |
930 unsigned WebAccessibilityObject::columnIndex() const | |
931 { | |
932 if (isDetached()) | |
933 return 0; | |
934 | |
935 if (m_private->roleValue() != ColumnRole) | |
936 return 0; | |
937 | |
938 return static_cast<WebCore::AccessibilityTableColumn*>(m_private.get())->col
umnIndex(); | |
939 } | |
940 | |
941 WebAccessibilityObject WebAccessibilityObject::columnHeader() const | |
942 { | |
943 if (isDetached()) | |
944 return WebAccessibilityObject(); | |
945 | |
946 if (m_private->roleValue() != ColumnRole) | |
947 return WebAccessibilityObject(); | |
948 | |
949 return WebAccessibilityObject(static_cast<WebCore::AccessibilityTableColumn*
>(m_private.get())->headerObject()); | |
950 } | |
951 | |
952 unsigned WebAccessibilityObject::cellColumnIndex() const | |
953 { | |
954 if (isDetached()) | |
955 return 0; | |
956 | |
957 if (!m_private->isTableCell()) | |
958 return 0; | |
959 | |
960 pair<unsigned, unsigned> columnRange; | |
961 static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexR
ange(columnRange); | |
962 return columnRange.first; | |
963 } | |
964 | |
965 unsigned WebAccessibilityObject::cellColumnSpan() const | |
966 { | |
967 if (isDetached()) | |
968 return 0; | |
969 | |
970 if (!m_private->isTableCell()) | |
971 return 0; | |
972 | |
973 pair<unsigned, unsigned> columnRange; | |
974 static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->columnIndexR
ange(columnRange); | |
975 return columnRange.second; | |
976 } | |
977 | |
978 unsigned WebAccessibilityObject::cellRowIndex() const | |
979 { | |
980 if (isDetached()) | |
981 return 0; | |
982 | |
983 if (!m_private->isTableCell()) | |
984 return 0; | |
985 | |
986 pair<unsigned, unsigned> rowRange; | |
987 static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRang
e(rowRange); | |
988 return rowRange.first; | |
989 } | |
990 | |
991 unsigned WebAccessibilityObject::cellRowSpan() const | |
992 { | |
993 if (isDetached()) | |
994 return 0; | |
995 | |
996 if (!m_private->isTableCell()) | |
997 return 0; | |
998 | |
999 pair<unsigned, unsigned> rowRange; | |
1000 static_cast<WebCore::AccessibilityTableCell*>(m_private.get())->rowIndexRang
e(rowRange); | |
1001 return rowRange.second; | |
1002 } | |
1003 | |
1004 void WebAccessibilityObject::scrollToMakeVisible() const | |
1005 { | |
1006 if (!isDetached()) | |
1007 m_private->scrollToMakeVisible(); | |
1008 } | |
1009 | |
1010 void WebAccessibilityObject::scrollToMakeVisibleWithSubFocus(const WebRect& subf
ocus) const | |
1011 { | |
1012 if (!isDetached()) | |
1013 m_private->scrollToMakeVisibleWithSubFocus(subfocus); | |
1014 } | |
1015 | |
1016 void WebAccessibilityObject::scrollToGlobalPoint(const WebPoint& point) const | |
1017 { | |
1018 if (!isDetached()) | |
1019 m_private->scrollToGlobalPoint(point); | |
1020 } | |
1021 | |
1022 WebAccessibilityObject::WebAccessibilityObject(const WTF::PassRefPtr<WebCore::Ac
cessibilityObject>& object) | |
1023 : m_private(object) | |
1024 { | |
1025 } | |
1026 | |
1027 WebAccessibilityObject& WebAccessibilityObject::operator=(const WTF::PassRefPtr<
WebCore::AccessibilityObject>& object) | |
1028 { | |
1029 m_private = object; | |
1030 return *this; | |
1031 } | |
1032 | |
1033 WebAccessibilityObject::operator WTF::PassRefPtr<WebCore::AccessibilityObject>()
const | |
1034 { | |
1035 return m_private.get(); | |
1036 } | |
1037 | |
1038 } // namespace WebKit | |
OLD | NEW |