2 * Copyright (C) 2009 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
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
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.
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.
32 #include "public/web/WebAXObject.h"
34 #include "core/HTMLNames.h"
35 #include "core/css/CSSPrimitiveValueMappings.h"
36 #include "core/dom/Document.h"
37 #include "core/dom/Node.h"
38 #include "core/frame/FrameHost.h"
39 #include "core/frame/FrameView.h"
40 #include "core/frame/VisualViewport.h"
41 #include "core/input/EventHandler.h"
42 #include "core/layout/LayoutView.h"
43 #include "core/style/ComputedStyle.h"
44 #include "core/page/Page.h"
45 #include "modules/accessibility/AXObject.h"
46 #include "modules/accessibility/AXObjectCacheImpl.h"
47 #include "modules/accessibility/AXTable.h"
48 #include "modules/accessibility/AXTableCell.h"
49 #include "modules/accessibility/AXTableColumn.h"
50 #include "modules/accessibility/AXTableRow.h"
51 #include "platform/PlatformKeyboardEvent.h"
52 #include "public/platform/WebPoint.h"
53 #include "public/platform/WebRect.h"
54 #include "public/platform/WebString.h"
55 #include "public/platform/WebURL.h"
56 #include "public/web/WebDocument.h"
57 #include "public/web/WebElement.h"
58 #include "public/web/WebNode.h"
59 #include "web/WebLocalFrameImpl.h"
60 #include "web/WebViewImpl.h"
61 #include "wtf/text/StringBuilder.h"
66 // It's not safe to call some WebAXObject APIs if a layout is pending.
67 // Clients should call updateLayoutAndCheckValidity first.
68 static bool isLayoutClean(Document
* document
)
70 if (!document
|| !document
->view())
72 return document
->lifecycle().state() >= DocumentLifecycle::LayoutClean
73 || ((document
->lifecycle().state() == DocumentLifecycle::StyleClean
|| document
->lifecycle().state() == DocumentLifecycle::LayoutSubtreeChangeClean
)
74 && !document
->view()->needsLayout());
78 WebScopedAXContext::WebScopedAXContext(WebDocument
& rootDocument
)
79 : m_private(ScopedAXObjectCache::create(*rootDocument
.unwrap
<Document
>()))
83 WebScopedAXContext::~WebScopedAXContext()
88 WebAXObject
WebScopedAXContext::root() const
90 return WebAXObject(static_cast<AXObjectCacheImpl
*>(m_private
->get())->root());
93 void WebAXObject::reset()
98 void WebAXObject::assign(const WebAXObject
& other
)
100 m_private
= other
.m_private
;
103 bool WebAXObject::equals(const WebAXObject
& n
) const
105 return m_private
.get() == n
.m_private
.get();
108 bool WebAXObject::isDetached() const
110 if (m_private
.isNull())
113 return m_private
->isDetached();
116 int WebAXObject::axID() const
121 return m_private
->axObjectID();
124 bool WebAXObject::updateLayoutAndCheckValidity()
127 Document
* document
= m_private
->document();
128 if (!document
|| !document
->topDocument().view())
130 document
->view()->updateAllLifecyclePhases();
133 // Doing a layout can cause this object to be invalid, so check again.
134 return !isDetached();
137 WebString
WebAXObject::actionVerb() const
142 return m_private
->actionVerb();
145 bool WebAXObject::canDecrement() const
150 return m_private
->isSlider();
153 bool WebAXObject::canIncrement() const
158 return m_private
->isSlider();
161 bool WebAXObject::canPress() const
166 return m_private
->actionElement() || m_private
->isButton() || m_private
->isMenuRelated();
169 bool WebAXObject::canSetFocusAttribute() const
174 return m_private
->canSetFocusAttribute();
177 bool WebAXObject::canSetValueAttribute() const
182 return m_private
->canSetValueAttribute();
185 unsigned WebAXObject::childCount() const
190 return m_private
->children().size();
193 WebAXObject
WebAXObject::childAt(unsigned index
) const
196 return WebAXObject();
198 if (m_private
->children().size() <= index
)
199 return WebAXObject();
201 return WebAXObject(m_private
->children()[index
]);
204 WebAXObject
WebAXObject::parentObject() const
207 return WebAXObject();
209 return WebAXObject(m_private
->parentObject());
212 bool WebAXObject::canSetSelectedAttribute() const
217 return m_private
->canSetSelectedAttribute();
220 bool WebAXObject::isAnchor() const
225 return m_private
->isAnchor();
228 bool WebAXObject::isAriaReadOnly() const
233 return equalIgnoringCase(m_private
->getAttribute(HTMLNames::aria_readonlyAttr
), "true");
236 WebString
WebAXObject::ariaAutoComplete() const
241 return m_private
->ariaAutoComplete();
244 bool WebAXObject::isButtonStateMixed() const
249 return m_private
->checkboxOrRadioValue() == ButtonStateMixed
;
252 bool WebAXObject::isChecked() const
257 return m_private
->isChecked();
260 bool WebAXObject::isClickable() const
265 return m_private
->isClickable();
268 bool WebAXObject::isCollapsed() const
273 return m_private
->isCollapsed();
276 bool WebAXObject::isControl() const
281 return m_private
->isControl();
284 bool WebAXObject::isEnabled() const
289 return m_private
->isEnabled();
292 WebAXExpanded
WebAXObject::isExpanded() const
295 return WebAXExpandedUndefined
;
297 return static_cast<WebAXExpanded
>(m_private
->isExpanded());
300 bool WebAXObject::isFocused() const
305 return m_private
->isFocused();
308 bool WebAXObject::isHovered() const
313 return m_private
->isHovered();
316 bool WebAXObject::isIndeterminate() const
321 return m_private
->isIndeterminate();
324 bool WebAXObject::isLinked() const
329 return m_private
->isLinked();
332 bool WebAXObject::isLoaded() const
337 return m_private
->isLoaded();
340 bool WebAXObject::isMultiSelectable() const
345 return m_private
->isMultiSelectable();
348 bool WebAXObject::isOffScreen() const
353 return m_private
->isOffScreen();
356 bool WebAXObject::isPasswordField() const
361 return m_private
->isPasswordField();
364 bool WebAXObject::isPressed() const
369 return m_private
->isPressed();
372 bool WebAXObject::isReadOnly() const
377 return m_private
->isReadOnly();
380 bool WebAXObject::isRequired() const
385 return m_private
->isRequired();
388 bool WebAXObject::isSelected() const
393 return m_private
->isSelected();
396 bool WebAXObject::isSelectedOptionActive() const
401 return m_private
->isSelectedOptionActive();
404 bool WebAXObject::isVisible() const
409 return m_private
->isVisible();
412 bool WebAXObject::isVisited() const
417 return m_private
->isVisited();
420 WebString
WebAXObject::accessKey() const
425 return WebString(m_private
->accessKey());
428 unsigned WebAXObject::backgroundColor() const
433 // RGBA32 is an alias for unsigned int.
434 return m_private
->backgroundColor();
437 unsigned WebAXObject::color() const
442 // RGBA32 is an alias for unsigned int.
443 return m_private
->color();
447 void WebAXObject::colorValue(int& r
, int& g
, int& b
) const
452 unsigned color
= m_private
->colorValue();
453 r
= (color
>> 16) & 0xFF;
454 g
= (color
>> 8) & 0xFF;
458 unsigned WebAXObject::colorValue() const
463 // RGBA32 is an alias for unsigned int.
464 return m_private
->colorValue();
467 WebAXObject
WebAXObject::ariaActiveDescendant() const
470 return WebAXObject();
472 return WebAXObject(m_private
->activeDescendant());
475 bool WebAXObject::ariaControls(WebVector
<WebAXObject
>& controlsElements
) const
480 AXObject::AccessibilityChildrenVector controls
;
481 m_private
->ariaControlsElements(controls
);
483 WebVector
<WebAXObject
> result(controls
.size());
484 for (size_t i
= 0; i
< controls
.size(); i
++)
485 result
[i
] = WebAXObject(controls
[i
]);
486 controlsElements
.swap(result
);
491 bool WebAXObject::ariaHasPopup() const
496 return m_private
->ariaHasPopup();
499 bool WebAXObject::ariaFlowTo(WebVector
<WebAXObject
>& flowToElements
) const
504 AXObject::AccessibilityChildrenVector flowTo
;
505 m_private
->ariaFlowToElements(flowTo
);
507 WebVector
<WebAXObject
> result(flowTo
.size());
508 for (size_t i
= 0; i
< flowTo
.size(); i
++)
509 result
[i
] = WebAXObject(flowTo
[i
]);
510 flowToElements
.swap(result
);
515 bool WebAXObject::isEditable() const
520 return m_private
->isEditable();
523 bool WebAXObject::isMultiline() const
528 return m_private
->isMultiline();
531 bool WebAXObject::isRichlyEditable() const
536 return m_private
->isRichlyEditable();
539 int WebAXObject::posInSet() const
544 return m_private
->posInSet();
547 int WebAXObject::setSize() const
552 return m_private
->setSize();
555 bool WebAXObject::isInLiveRegion() const
560 return 0 != m_private
->liveRegionRoot();
563 bool WebAXObject::liveRegionAtomic() const
568 return m_private
->liveRegionAtomic();
571 bool WebAXObject::liveRegionBusy() const
576 return m_private
->liveRegionBusy();
579 WebString
WebAXObject::liveRegionRelevant() const
584 return m_private
->liveRegionRelevant();
587 WebString
WebAXObject::liveRegionStatus() const
592 return m_private
->liveRegionStatus();
595 bool WebAXObject::containerLiveRegionAtomic() const
600 return m_private
->containerLiveRegionAtomic();
603 bool WebAXObject::containerLiveRegionBusy() const
608 return m_private
->containerLiveRegionBusy();
611 WebString
WebAXObject::containerLiveRegionRelevant() const
616 return m_private
->containerLiveRegionRelevant();
619 WebString
WebAXObject::containerLiveRegionStatus() const
624 return m_private
->containerLiveRegionStatus();
627 bool WebAXObject::ariaOwns(WebVector
<WebAXObject
>& ownsElements
) const
629 // aria-owns rearranges the accessibility tree rather than just
630 // exposing an attribute.
632 // FIXME(dmazzoni): remove this function after we stop calling it
633 // from Chromium. http://crbug.com/489590
638 WebRect
WebAXObject::boundingBoxRect() const
643 ASSERT(isLayoutClean(m_private
->document()));
645 return pixelSnappedIntRect(m_private
->elementRect());
648 float WebAXObject::fontSize() const
653 return m_private
->fontSize();
656 bool WebAXObject::canvasHasFallbackContent() const
661 return m_private
->canvasHasFallbackContent();
664 WebPoint
WebAXObject::clickPoint() const
669 return WebPoint(m_private
->clickPoint());
672 WebAXInvalidState
WebAXObject::invalidState() const
675 return WebAXInvalidStateUndefined
;
677 return static_cast<WebAXInvalidState
>(m_private
->invalidState());
680 // Only used when invalidState() returns WebAXInvalidStateOther.
681 WebString
WebAXObject::ariaInvalidValue() const
686 return m_private
->ariaInvalidValue();
689 double WebAXObject::estimatedLoadingProgress() const
694 return m_private
->estimatedLoadingProgress();
697 int WebAXObject::headingLevel() const
702 return m_private
->headingLevel();
705 int WebAXObject::hierarchicalLevel() const
710 return m_private
->hierarchicalLevel();
713 // FIXME: This method passes in a point that has page scale applied but assumes that (0, 0)
714 // is the top left of the visual viewport. In other words, the point has the VisualViewport
715 // scale applied, but not the VisualViewport offset. crbug.com/459591.
716 WebAXObject
WebAXObject::hitTest(const WebPoint
& point
) const
719 return WebAXObject();
721 IntPoint contentsPoint
= m_private
->documentFrameView()->soonToBeRemovedUnscaledViewportToContents(point
);
722 AXObject
* hit
= m_private
->accessibilityHitTest(contentsPoint
);
725 return WebAXObject(hit
);
727 if (m_private
->elementRect().contains(contentsPoint
))
730 return WebAXObject();
733 WebString
WebAXObject::keyboardShortcut() const
738 String accessKey
= m_private
->accessKey();
739 if (accessKey
.isNull())
742 DEFINE_STATIC_LOCAL(String
, modifierString
, ());
743 if (modifierString
.isNull()) {
744 unsigned modifiers
= EventHandler::accessKeyModifiers();
745 // Follow the same order as Mozilla MSAA implementation:
746 // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
747 // should not be localized and defines the separator as "+".
748 StringBuilder modifierStringBuilder
;
749 if (modifiers
& PlatformEvent::CtrlKey
)
750 modifierStringBuilder
.appendLiteral("Ctrl+");
751 if (modifiers
& PlatformEvent::AltKey
)
752 modifierStringBuilder
.appendLiteral("Alt+");
753 if (modifiers
& PlatformEvent::ShiftKey
)
754 modifierStringBuilder
.appendLiteral("Shift+");
755 if (modifiers
& PlatformEvent::MetaKey
)
756 modifierStringBuilder
.appendLiteral("Win+");
757 modifierString
= modifierStringBuilder
.toString();
760 return String(modifierString
+ accessKey
);
763 WebString
WebAXObject::language() const
768 return m_private
->language();
771 bool WebAXObject::performDefaultAction() const
776 return m_private
->performDefaultAction();
779 bool WebAXObject::increment() const
784 if (canIncrement()) {
785 m_private
->increment();
791 bool WebAXObject::decrement() const
796 if (canDecrement()) {
797 m_private
->decrement();
803 WebAXOrientation
WebAXObject::orientation() const
806 return WebAXOrientationUndefined
;
808 return static_cast<WebAXOrientation
>(m_private
->orientation());
811 bool WebAXObject::press() const
816 return m_private
->press();
819 WebAXRole
WebAXObject::role() const
822 return WebAXRoleUnknown
;
824 return static_cast<WebAXRole
>(m_private
->roleValue());
827 void WebAXObject::selection(WebAXObject
& anchorObject
, int& anchorOffset
,
828 WebAXObject
& focusObject
, int& focusOffset
) const
831 anchorObject
= WebAXObject();
833 focusObject
= WebAXObject();
838 AXObject::AXRange axSelection
= m_private
->selection();
839 anchorObject
= WebAXObject(axSelection
.anchorObject
);
840 anchorOffset
= axSelection
.anchorOffset
;
841 focusObject
= WebAXObject(axSelection
.focusObject
);
842 focusOffset
= axSelection
.focusOffset
;
846 void WebAXObject::setSelection(const WebAXObject
& anchorObject
, int anchorOffset
,
847 const WebAXObject
& focusObject
, int focusOffset
) const
852 AXObject::AXRange
axSelection(anchorObject
, anchorOffset
,
853 focusObject
, focusOffset
);
854 m_private
->setSelection(axSelection
);
858 unsigned WebAXObject::selectionEnd() const
863 AXObject::AXRange axSelection
= m_private
->selectionUnderObject();
864 if (axSelection
.focusOffset
< 0)
867 return axSelection
.focusOffset
;
870 unsigned WebAXObject::selectionStart() const
875 AXObject::AXRange axSelection
= m_private
->selectionUnderObject();
876 if (axSelection
.anchorOffset
< 0)
879 return axSelection
.anchorOffset
;
882 unsigned WebAXObject::selectionEndLineNumber() const
887 VisiblePosition position
= m_private
->visiblePositionForIndex(selectionEnd());
888 int lineNumber
= m_private
->lineForPosition(position
);
895 unsigned WebAXObject::selectionStartLineNumber() const
900 VisiblePosition position
= m_private
->visiblePositionForIndex(selectionStart());
901 int lineNumber
= m_private
->lineForPosition(position
);
908 void WebAXObject::setFocused(bool on
) const
911 m_private
->setFocused(on
);
914 void WebAXObject::setSelectedTextRange(int selectionStart
, int selectionEnd
) const
919 m_private
->setSelection(AXObject::AXRange(selectionStart
, selectionEnd
));
922 void WebAXObject::setValue(WebString value
) const
927 m_private
->setValue(value
);
930 void WebAXObject::showContextMenu() const
935 Node
* node
= m_private
->node();
939 Element
* element
= nullptr;
940 if (node
->isElementNode()) {
941 element
= toElement(node
);
943 node
->updateDistribution();
944 ContainerNode
* parent
= ComposedTreeTraversal::parent(*node
);
945 ASSERT_WITH_SECURITY_IMPLICATION(parent
->isElementNode());
946 element
= toElement(parent
);
952 LocalFrame
* frame
= element
->document().frame();
956 WebViewImpl
* view
= WebLocalFrameImpl::fromFrame(frame
)->viewImpl();
960 view
->showContextMenuForElement(WebElement(element
));
963 WebString
WebAXObject::stringValue() const
968 return m_private
->stringValue();
971 WebAXTextDirection
WebAXObject::textDirection() const
974 return WebAXTextDirectionLR
;
976 return static_cast<WebAXTextDirection
>(m_private
->textDirection());
979 WebAXTextStyle
WebAXObject::textStyle() const
982 return WebAXTextStyleNone
;
984 return static_cast<WebAXTextStyle
>(m_private
->textStyle());
987 WebURL
WebAXObject::url() const
992 return m_private
->url();
995 WebString
WebAXObject::deprecatedAccessibilityDescription() const
1000 ASSERT(isLayoutClean(m_private
->document()));
1002 return m_private
->deprecatedAccessibilityDescription();
1005 bool WebAXObject::deprecatedAriaDescribedby(WebVector
<WebAXObject
>& describedbyElements
) const
1010 AXObject::AccessibilityChildrenVector describedby
;
1011 m_private
->deprecatedAriaDescribedbyElements(describedby
);
1013 WebVector
<WebAXObject
> result(describedby
.size());
1014 for (size_t i
= 0; i
< describedby
.size(); i
++)
1015 result
[i
] = WebAXObject(describedby
[i
]);
1016 describedbyElements
.swap(result
);
1021 bool WebAXObject::deprecatedAriaLabelledby(WebVector
<WebAXObject
>& labelledbyElements
) const
1026 AXObject::AccessibilityChildrenVector labelledby
;
1027 m_private
->deprecatedAriaLabelledbyElements(labelledby
);
1029 WebVector
<WebAXObject
> result(labelledby
.size());
1030 for (size_t i
= 0; i
< labelledby
.size(); i
++)
1031 result
[i
] = WebAXObject(labelledby
[i
]);
1032 labelledbyElements
.swap(result
);
1037 WebString
WebAXObject::deprecatedHelpText() const
1042 return m_private
->deprecatedHelpText();
1045 WebString
WebAXObject::deprecatedPlaceholder() const
1050 return WebString(m_private
->deprecatedPlaceholder());
1053 WebString
WebAXObject::deprecatedTitle() const
1058 ASSERT(isLayoutClean(m_private
->document()));
1060 return m_private
->deprecatedTitle();
1063 WebAXObject
WebAXObject::deprecatedTitleUIElement() const
1066 return WebAXObject();
1068 if (!m_private
->deprecatedExposesTitleUIElement())
1069 return WebAXObject();
1071 return WebAXObject(m_private
->deprecatedTitleUIElement());
1074 WebString
WebAXObject::accessibilityDescription() const
1076 return deprecatedAccessibilityDescription();
1079 bool WebAXObject::ariaDescribedby(WebVector
<WebAXObject
>& describedbyElements
) const
1081 return deprecatedAriaDescribedby(describedbyElements
);
1084 bool WebAXObject::ariaLabelledby(WebVector
<WebAXObject
>& labelledbyElements
) const
1086 return deprecatedAriaLabelledby(labelledbyElements
);
1089 WebString
WebAXObject::helpText() const
1091 return deprecatedHelpText();
1094 WebString
WebAXObject::placeholder() const
1096 return deprecatedPlaceholder();
1099 WebString
WebAXObject::title() const
1101 return deprecatedTitle();
1104 WebAXObject
WebAXObject::titleUIElement() const
1106 return deprecatedTitleUIElement();
1109 WebString
WebAXObject::name(WebAXNameFrom
& outNameFrom
, WebVector
<WebAXObject
>& outNameObjects
) const
1114 AXNameFrom nameFrom
= AXNameFromAttribute
;
1115 HeapVector
<Member
<AXObject
>> nameObjects
;
1116 WebString result
= m_private
->name(nameFrom
, &nameObjects
);
1117 outNameFrom
= static_cast<WebAXNameFrom
>(nameFrom
);
1119 WebVector
<WebAXObject
> webNameObjects(nameObjects
.size());
1120 for (size_t i
= 0; i
< nameObjects
.size(); i
++)
1121 webNameObjects
[i
] = WebAXObject(nameObjects
[i
]);
1122 outNameObjects
.swap(webNameObjects
);
1127 WebString
WebAXObject::description(WebAXNameFrom nameFrom
, WebAXDescriptionFrom
& outDescriptionFrom
, WebVector
<WebAXObject
>& outDescriptionObjects
) const
1132 AXDescriptionFrom descriptionFrom
;
1133 HeapVector
<Member
<AXObject
>> descriptionObjects
;
1134 String result
= m_private
->description(static_cast<AXNameFrom
>(nameFrom
), descriptionFrom
, &descriptionObjects
);
1135 outDescriptionFrom
= static_cast<WebAXDescriptionFrom
>(descriptionFrom
);
1137 WebVector
<WebAXObject
> webDescriptionObjects(descriptionObjects
.size());
1138 for (size_t i
= 0; i
< descriptionObjects
.size(); i
++)
1139 webDescriptionObjects
[i
] = WebAXObject(descriptionObjects
[i
]);
1140 outDescriptionObjects
.swap(webDescriptionObjects
);
1145 WebString
WebAXObject::placeholder(WebAXNameFrom nameFrom
, WebAXDescriptionFrom descriptionFrom
) const
1150 return m_private
->placeholder(static_cast<AXNameFrom
>(nameFrom
), static_cast<AXDescriptionFrom
>(descriptionFrom
));
1153 bool WebAXObject::supportsRangeValue() const
1158 return m_private
->supportsRangeValue();
1161 WebString
WebAXObject::valueDescription() const
1166 return m_private
->valueDescription();
1169 float WebAXObject::valueForRange() const
1174 return m_private
->valueForRange();
1177 float WebAXObject::maxValueForRange() const
1182 return m_private
->maxValueForRange();
1185 float WebAXObject::minValueForRange() const
1190 return m_private
->minValueForRange();
1193 WebNode
WebAXObject::node() const
1198 Node
* node
= m_private
->node();
1202 return WebNode(node
);
1205 WebDocument
WebAXObject::document() const
1208 return WebDocument();
1210 Document
* document
= m_private
->document();
1212 return WebDocument();
1214 return WebDocument(document
);
1217 bool WebAXObject::hasComputedStyle() const
1222 Document
* document
= m_private
->document();
1224 document
->updateLayoutTreeIfNeeded();
1226 Node
* node
= m_private
->node();
1230 return node
->ensureComputedStyle();
1233 WebString
WebAXObject::computedStyleDisplay() const
1238 Document
* document
= m_private
->document();
1240 document
->updateLayoutTreeIfNeeded();
1242 Node
* node
= m_private
->node();
1246 const ComputedStyle
* computedStyle
= node
->ensureComputedStyle();
1250 return WebString(CSSPrimitiveValue::create(computedStyle
->display())->cssText());
1253 bool WebAXObject::accessibilityIsIgnored() const
1258 return m_private
->accessibilityIsIgnored();
1261 bool WebAXObject::lineBreaks(WebVector
<int>& result
) const
1266 Vector
<int> lineBreaksVector
;
1267 m_private
->lineBreaks(lineBreaksVector
);
1269 size_t vectorSize
= lineBreaksVector
.size();
1270 WebVector
<int> lineBreaksWebVector(vectorSize
);
1271 for (size_t i
= 0; i
< vectorSize
; i
++)
1272 lineBreaksWebVector
[i
] = lineBreaksVector
[i
];
1273 result
.swap(lineBreaksWebVector
);
1278 unsigned WebAXObject::columnCount() const
1283 if (!m_private
->isAXTable())
1286 return toAXTable(m_private
.get())->columnCount();
1289 unsigned WebAXObject::rowCount() const
1294 if (!m_private
->isAXTable())
1297 return toAXTable(m_private
.get())->rowCount();
1300 WebAXObject
WebAXObject::cellForColumnAndRow(unsigned column
, unsigned row
) const
1303 return WebAXObject();
1305 if (!m_private
->isAXTable())
1306 return WebAXObject();
1308 AXTableCell
* cell
= toAXTable(m_private
.get())->cellForColumnAndRow(column
, row
);
1309 return WebAXObject(static_cast<AXObject
*>(cell
));
1312 WebAXObject
WebAXObject::headerContainerObject() const
1315 return WebAXObject();
1317 if (!m_private
->isAXTable())
1318 return WebAXObject();
1320 return WebAXObject(toAXTable(m_private
.get())->headerContainer());
1323 WebAXObject
WebAXObject::rowAtIndex(unsigned rowIndex
) const
1326 return WebAXObject();
1328 if (!m_private
->isAXTable())
1329 return WebAXObject();
1331 const AXObject::AccessibilityChildrenVector
& rows
= toAXTable(m_private
.get())->rows();
1332 if (rowIndex
< rows
.size())
1333 return WebAXObject(rows
[rowIndex
]);
1335 return WebAXObject();
1338 WebAXObject
WebAXObject::columnAtIndex(unsigned columnIndex
) const
1341 return WebAXObject();
1343 if (!m_private
->isAXTable())
1344 return WebAXObject();
1346 const AXObject::AccessibilityChildrenVector
& columns
= toAXTable(m_private
.get())->columns();
1347 if (columnIndex
< columns
.size())
1348 return WebAXObject(columns
[columnIndex
]);
1350 return WebAXObject();
1353 unsigned WebAXObject::rowIndex() const
1358 if (!m_private
->isTableRow())
1361 return toAXTableRow(m_private
.get())->rowIndex();
1364 WebAXObject
WebAXObject::rowHeader() const
1367 return WebAXObject();
1369 if (!m_private
->isTableRow())
1370 return WebAXObject();
1372 return WebAXObject(toAXTableRow(m_private
.get())->headerObject());
1375 void WebAXObject::rowHeaders(WebVector
<WebAXObject
>& rowHeaderElements
) const
1380 if (!m_private
->isAXTable())
1383 AXObject::AccessibilityChildrenVector headers
;
1384 toAXTable(m_private
.get())->rowHeaders(headers
);
1386 size_t headerCount
= headers
.size();
1387 WebVector
<WebAXObject
> result(headerCount
);
1389 for (size_t i
= 0; i
< headerCount
; i
++)
1390 result
[i
] = WebAXObject(headers
[i
]);
1392 rowHeaderElements
.swap(result
);
1395 unsigned WebAXObject::columnIndex() const
1400 if (m_private
->roleValue() != ColumnRole
)
1403 return toAXTableColumn(m_private
.get())->columnIndex();
1406 WebAXObject
WebAXObject::columnHeader() const
1409 return WebAXObject();
1411 if (m_private
->roleValue() != ColumnRole
)
1412 return WebAXObject();
1414 return WebAXObject(toAXTableColumn(m_private
.get())->headerObject());
1417 void WebAXObject::columnHeaders(WebVector
<WebAXObject
>& columnHeaderElements
) const
1422 if (!m_private
->isAXTable())
1425 AXObject::AccessibilityChildrenVector headers
;
1426 toAXTable(m_private
.get())->columnHeaders(headers
);
1428 size_t headerCount
= headers
.size();
1429 WebVector
<WebAXObject
> result(headerCount
);
1431 for (size_t i
= 0; i
< headerCount
; i
++)
1432 result
[i
] = WebAXObject(headers
[i
]);
1434 columnHeaderElements
.swap(result
);
1437 unsigned WebAXObject::cellColumnIndex() const
1442 if (!m_private
->isTableCell())
1445 pair
<unsigned, unsigned> columnRange
;
1446 toAXTableCell(m_private
.get())->columnIndexRange(columnRange
);
1447 return columnRange
.first
;
1450 unsigned WebAXObject::cellColumnSpan() const
1455 if (!m_private
->isTableCell())
1458 pair
<unsigned, unsigned> columnRange
;
1459 toAXTableCell(m_private
.get())->columnIndexRange(columnRange
);
1460 return columnRange
.second
;
1463 unsigned WebAXObject::cellRowIndex() const
1468 if (!m_private
->isTableCell())
1471 pair
<unsigned, unsigned> rowRange
;
1472 toAXTableCell(m_private
.get())->rowIndexRange(rowRange
);
1473 return rowRange
.first
;
1476 unsigned WebAXObject::cellRowSpan() const
1481 if (!m_private
->isTableCell())
1484 pair
<unsigned, unsigned> rowRange
;
1485 toAXTableCell(m_private
.get())->rowIndexRange(rowRange
);
1486 return rowRange
.second
;
1489 WebAXSortDirection
WebAXObject::sortDirection() const
1492 return WebAXSortDirectionUndefined
;
1494 return static_cast<WebAXSortDirection
>(m_private
->sortDirection());
1497 void WebAXObject::loadInlineTextBoxes() const
1502 m_private
->loadInlineTextBoxes();
1505 WebAXObject
WebAXObject::nextOnLine() const
1508 return WebAXObject();
1510 return WebAXObject(m_private
.get()->nextOnLine());
1513 WebAXObject
WebAXObject::previousOnLine() const
1516 return WebAXObject();
1518 return WebAXObject(m_private
.get()->previousOnLine());
1521 void WebAXObject::characterOffsets(WebVector
<int>& offsets
) const
1526 Vector
<int> offsetsVector
;
1527 m_private
->textCharacterOffsets(offsetsVector
);
1529 size_t vectorSize
= offsetsVector
.size();
1530 WebVector
<int> offsetsWebVector(vectorSize
);
1531 for (size_t i
= 0; i
< vectorSize
; i
++)
1532 offsetsWebVector
[i
] = offsetsVector
[i
];
1533 offsets
.swap(offsetsWebVector
);
1536 void WebAXObject::wordBoundaries(WebVector
<int>& starts
, WebVector
<int>& ends
) const
1541 Vector
<AXObject::AXRange
> wordBoundaries
;
1542 m_private
->wordBoundaries(wordBoundaries
);
1544 WebVector
<int> wordStartOffsets(wordBoundaries
.size());
1545 WebVector
<int> wordEndOffsets(wordBoundaries
.size());
1546 for (size_t i
= 0; i
< wordBoundaries
.size(); ++i
) {
1547 ASSERT(wordBoundaries
[i
].isSimple());
1548 wordStartOffsets
[i
] = wordBoundaries
[i
].anchorOffset
;
1549 wordEndOffsets
[i
] = wordBoundaries
[i
].focusOffset
;
1552 starts
.swap(wordStartOffsets
);
1553 ends
.swap(wordEndOffsets
);
1556 bool WebAXObject::isScrollableContainer() const
1561 return m_private
->isScrollableContainer();
1564 WebPoint
WebAXObject::scrollOffset() const
1569 return m_private
->scrollOffset();
1572 WebPoint
WebAXObject::minimumScrollOffset() const
1577 return m_private
->minimumScrollOffset();
1580 WebPoint
WebAXObject::maximumScrollOffset() const
1585 return m_private
->maximumScrollOffset();
1588 void WebAXObject::setScrollOffset(const WebPoint
& offset
) const
1593 m_private
->setScrollOffset(offset
);
1596 void WebAXObject::scrollToMakeVisible() const
1599 m_private
->scrollToMakeVisible();
1602 void WebAXObject::scrollToMakeVisibleWithSubFocus(const WebRect
& subfocus
) const
1605 m_private
->scrollToMakeVisibleWithSubFocus(subfocus
);
1608 void WebAXObject::scrollToGlobalPoint(const WebPoint
& point
) const
1611 m_private
->scrollToGlobalPoint(point
);
1614 WebAXObject::WebAXObject(AXObject
* object
)
1619 WebAXObject
& WebAXObject::operator=(AXObject
* object
)
1625 WebAXObject::operator AXObject
*() const
1627 return m_private
.get();
1630 } // namespace blink