blob: 317a5b0fbaaab01c2b04b91eba8aedd34c4a5b76 [file] [log] [blame]
Ben Murdoche69819b2013-07-17 14:56:49 +01001/*
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"
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010032#include "WebAXObject.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010033
34#include "HTMLNames.h"
35#include "WebDocument.h"
36#include "WebNode.h"
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +010037#include "core/accessibility/AXObject.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010038#include "core/accessibility/AXObjectCache.h"
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +010039#include "core/accessibility/AXTable.h"
40#include "core/accessibility/AXTableCell.h"
41#include "core/accessibility/AXTableColumn.h"
42#include "core/accessibility/AXTableRow.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010043#include "core/css/CSSPrimitiveValueMappings.h"
44#include "core/dom/Document.h"
45#include "core/dom/Node.h"
46#include "core/page/EventHandler.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010047#include "core/frame/FrameView.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010048#include "core/rendering/style/RenderStyle.h"
Torne (Richard Coles)1e202182013-10-18 15:46:42 +010049#include "platform/PlatformKeyboardEvent.h"
Ben Murdoche69819b2013-07-17 14:56:49 +010050#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
56using namespace WebCore;
57
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000058namespace blink {
Ben Murdoche69819b2013-07-17 14:56:49 +010059
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010060void WebAXObject::reset()
Ben Murdoche69819b2013-07-17 14:56:49 +010061{
62 m_private.reset();
63}
64
Torne (Richard Coles)51b29062013-11-28 11:56:03 +000065void WebAXObject::assign(const blink::WebAXObject& other)
Ben Murdoche69819b2013-07-17 14:56:49 +010066{
67 m_private = other.m_private;
68}
69
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010070bool WebAXObject::equals(const WebAXObject& n) const
Ben Murdoche69819b2013-07-17 14:56:49 +010071{
72 return m_private.get() == n.m_private.get();
73}
74
75// static
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010076void WebAXObject::enableAccessibility()
Ben Murdoche69819b2013-07-17 14:56:49 +010077{
78 AXObjectCache::enableAccessibility();
79}
80
81// static
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010082bool WebAXObject::accessibilityEnabled()
Ben Murdoche69819b2013-07-17 14:56:49 +010083{
84 return AXObjectCache::accessibilityEnabled();
85}
86
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +010087// static
88void WebAXObject::enableInlineTextBoxAccessibility()
89{
90 AXObjectCache::setInlineTextBoxAccessibility(true);
91}
92
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010093void WebAXObject::startCachingComputedObjectAttributesUntilTreeMutates()
Ben Murdoche69819b2013-07-17 14:56:49 +010094{
95 m_private->axObjectCache()->startCachingComputedObjectAttributesUntilTreeMutates();
96}
97
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +010098void WebAXObject::stopCachingComputedObjectAttributes()
Ben Murdoche69819b2013-07-17 14:56:49 +010099{
100 m_private->axObjectCache()->stopCachingComputedObjectAttributes();
101}
102
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100103bool WebAXObject::isDetached() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100104{
105 if (m_private.isNull())
106 return true;
107
108 return m_private->isDetached();
109}
110
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100111int WebAXObject::axID() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100112{
113 if (isDetached())
114 return -1;
115
116 return m_private->axObjectID();
117}
118
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100119bool WebAXObject::updateBackingStoreAndCheckValidity()
Ben Murdoche69819b2013-07-17 14:56:49 +0100120{
121 if (!isDetached())
122 m_private->updateBackingStore();
123 return !isDetached();
124}
125
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100126WebString WebAXObject::accessibilityDescription() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100127{
128 if (isDetached())
129 return WebString();
130
131 return m_private->accessibilityDescription();
132}
133
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100134WebString WebAXObject::actionVerb() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100135{
136 if (isDetached())
137 return WebString();
138
139 return m_private->actionVerb();
140}
141
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100142bool WebAXObject::canDecrement() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100143{
144 if (isDetached())
145 return false;
146
147 return m_private->isSlider();
148}
149
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100150bool WebAXObject::canIncrement() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100151{
152 if (isDetached())
153 return false;
154
155 return m_private->isSlider();
156}
157
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100158bool WebAXObject::canPress() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100159{
160 if (isDetached())
161 return false;
162
163 return m_private->actionElement() || m_private->isButton() || m_private->isMenuRelated();
164}
165
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100166bool WebAXObject::canSetFocusAttribute() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100167{
168 if (isDetached())
169 return false;
170
171 return m_private->canSetFocusAttribute();
172}
173
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100174bool WebAXObject::canSetValueAttribute() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100175{
176 if (isDetached())
177 return false;
178
179 return m_private->canSetValueAttribute();
180}
181
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100182unsigned WebAXObject::childCount() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100183{
184 if (isDetached())
185 return 0;
186
187 return m_private->children().size();
188}
189
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100190WebAXObject WebAXObject::childAt(unsigned index) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100191{
192 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100193 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100194
195 if (m_private->children().size() <= index)
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100196 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100197
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100198 return WebAXObject(m_private->children()[index]);
Ben Murdoche69819b2013-07-17 14:56:49 +0100199}
200
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100201WebAXObject WebAXObject::parentObject() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100202{
203 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100204 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100205
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100206 return WebAXObject(m_private->parentObject());
Ben Murdoche69819b2013-07-17 14:56:49 +0100207}
208
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100209bool WebAXObject::canSetSelectedAttribute() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100210{
211 if (isDetached())
212 return 0;
213
214 return m_private->canSetSelectedAttribute();
215}
216
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100217bool WebAXObject::isAnchor() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100218{
219 if (isDetached())
220 return 0;
221
222 return m_private->isAnchor();
223}
224
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100225bool WebAXObject::isAriaReadOnly() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100226{
227 if (isDetached())
228 return 0;
229
230 return equalIgnoringCase(m_private->getAttribute(HTMLNames::aria_readonlyAttr), "true");
231}
232
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100233bool WebAXObject::isButtonStateMixed() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100234{
235 if (isDetached())
236 return 0;
237
238 return m_private->checkboxOrRadioValue() == ButtonStateMixed;
239}
240
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100241bool WebAXObject::isChecked() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100242{
243 if (isDetached())
244 return 0;
245
246 return m_private->isChecked();
247}
248
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100249bool WebAXObject::isClickable() const
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100250{
251 if (isDetached())
252 return 0;
253
254 return m_private->isClickable();
255}
256
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100257bool WebAXObject::isCollapsed() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100258{
259 if (isDetached())
260 return 0;
261
262 return m_private->isCollapsed();
263}
264
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100265bool WebAXObject::isControl() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100266{
267 if (isDetached())
268 return 0;
269
270 return m_private->isControl();
271}
272
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100273bool WebAXObject::isEnabled() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100274{
275 if (isDetached())
276 return 0;
277
278 return m_private->isEnabled();
279}
280
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100281bool WebAXObject::isFocused() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100282{
283 if (isDetached())
284 return 0;
285
286 return m_private->isFocused();
287}
288
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100289bool WebAXObject::isHovered() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100290{
291 if (isDetached())
292 return 0;
293
294 return m_private->isHovered();
295}
296
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100297bool WebAXObject::isIndeterminate() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100298{
299 if (isDetached())
300 return 0;
301
302 return m_private->isIndeterminate();
303}
304
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100305bool WebAXObject::isLinked() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100306{
307 if (isDetached())
308 return 0;
309
310 return m_private->isLinked();
311}
312
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100313bool WebAXObject::isLoaded() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100314{
315 if (isDetached())
316 return 0;
317
318 return m_private->isLoaded();
319}
320
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100321bool WebAXObject::isMultiSelectable() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100322{
323 if (isDetached())
324 return 0;
325
326 return m_private->isMultiSelectable();
327}
328
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100329bool WebAXObject::isOffScreen() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100330{
331 if (isDetached())
332 return 0;
333
334 return m_private->isOffScreen();
335}
336
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100337bool WebAXObject::isPasswordField() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100338{
339 if (isDetached())
340 return 0;
341
342 return m_private->isPasswordField();
343}
344
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100345bool WebAXObject::isPressed() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100346{
347 if (isDetached())
348 return 0;
349
350 return m_private->isPressed();
351}
352
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100353bool WebAXObject::isReadOnly() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100354{
355 if (isDetached())
356 return 0;
357
358 return m_private->isReadOnly();
359}
360
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100361bool WebAXObject::isRequired() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100362{
363 if (isDetached())
364 return 0;
365
366 return m_private->isRequired();
367}
368
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100369bool WebAXObject::isSelected() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100370{
371 if (isDetached())
372 return 0;
373
374 return m_private->isSelected();
375}
376
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100377bool WebAXObject::isSelectedOptionActive() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100378{
379 if (isDetached())
380 return false;
381
382 return m_private->isSelectedOptionActive();
383}
384
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100385bool WebAXObject::isVertical() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100386{
387 if (isDetached())
388 return 0;
389
390 return m_private->orientation() == AccessibilityOrientationVertical;
391}
392
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100393bool WebAXObject::isVisible() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100394{
395 if (isDetached())
396 return 0;
397
398 return m_private->isVisible();
399}
400
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100401bool WebAXObject::isVisited() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100402{
403 if (isDetached())
404 return 0;
405
406 return m_private->isVisited();
407}
408
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100409WebString WebAXObject::accessKey() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100410{
411 if (isDetached())
412 return WebString();
413
414 return WebString(m_private->accessKey());
415}
416
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000417WebAXObject WebAXObject::ariaActiveDescendant() const
418{
419 if (isDetached())
420 return WebAXObject();
421
422 return WebAXObject(m_private->activeDescendant());
423}
424
425bool WebAXObject::ariaControls(WebVector<WebAXObject>& controlsElements) const
426{
427 if (isDetached())
428 return false;
429
430 AXObject::AccessibilityChildrenVector controls;
431 m_private->ariaControlsElements(controls);
432
433 WebVector<WebAXObject> result(controls.size());
434 for (size_t i = 0; i < controls.size(); i++)
435 result[i] = WebAXObject(controls[i]);
436 controlsElements.swap(result);
437
438 return true;
439}
440
441bool WebAXObject::ariaDescribedby(WebVector<WebAXObject>& describedbyElements) const
442{
443 if (isDetached())
444 return false;
445
446 AXObject::AccessibilityChildrenVector describedby;
447 m_private->ariaDescribedbyElements(describedby);
448
449 WebVector<WebAXObject> result(describedby.size());
450 for (size_t i = 0; i < describedby.size(); i++)
451 result[i] = WebAXObject(describedby[i]);
452 describedbyElements.swap(result);
453
454 return true;
455}
456
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100457bool WebAXObject::ariaHasPopup() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100458{
459 if (isDetached())
460 return 0;
461
462 return m_private->ariaHasPopup();
463}
464
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000465bool WebAXObject::ariaFlowTo(WebVector<WebAXObject>& flowToElements) const
466{
467 if (isDetached())
468 return false;
469
470 AXObject::AccessibilityChildrenVector flowTo;
471 m_private->ariaFlowToElements(flowTo);
472
473 WebVector<WebAXObject> result(flowTo.size());
474 for (size_t i = 0; i < flowTo.size(); i++)
475 result[i] = WebAXObject(flowTo[i]);
476 flowToElements.swap(result);
477
478 return true;
479}
480
481bool WebAXObject::ariaLabelledby(WebVector<WebAXObject>& labelledbyElements) const
482{
483 if (isDetached())
484 return false;
485
486 AXObject::AccessibilityChildrenVector labelledby;
487 m_private->ariaLabelledbyElements(labelledby);
488
489 WebVector<WebAXObject> result(labelledby.size());
490 for (size_t i = 0; i < labelledby.size(); i++)
491 result[i] = WebAXObject(labelledby[i]);
492 labelledbyElements.swap(result);
493
494 return true;
495}
496
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100497bool WebAXObject::ariaLiveRegionAtomic() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100498{
499 if (isDetached())
500 return 0;
501
502 return m_private->ariaLiveRegionAtomic();
503}
504
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100505bool WebAXObject::ariaLiveRegionBusy() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100506{
507 if (isDetached())
508 return 0;
509
510 return m_private->ariaLiveRegionBusy();
511}
512
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100513WebString WebAXObject::ariaLiveRegionRelevant() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100514{
515 if (isDetached())
516 return WebString();
517
518 return m_private->ariaLiveRegionRelevant();
519}
520
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100521WebString WebAXObject::ariaLiveRegionStatus() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100522{
523 if (isDetached())
524 return WebString();
525
526 return m_private->ariaLiveRegionStatus();
527}
528
Torne (Richard Coles)d5428f32014-03-18 10:21:16 +0000529bool WebAXObject::ariaOwns(WebVector<WebAXObject>& ownsElements) const
530{
531 if (isDetached())
532 return false;
533
534 AXObject::AccessibilityChildrenVector owns;
535 m_private->ariaOwnsElements(owns);
536
537 WebVector<WebAXObject> result(owns.size());
538 for (size_t i = 0; i < owns.size(); i++)
539 result[i] = WebAXObject(owns[i]);
540 ownsElements.swap(result);
541
542 return true;
543}
544
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100545WebRect WebAXObject::boundingBoxRect() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100546{
547 if (isDetached())
548 return WebRect();
549
550 return pixelSnappedIntRect(m_private->elementRect());
551}
552
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100553bool WebAXObject::canvasHasFallbackContent() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100554{
555 if (isDetached())
556 return false;
557
558 return m_private->canvasHasFallbackContent();
559}
560
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100561WebPoint WebAXObject::clickPoint() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100562{
563 if (isDetached())
564 return WebPoint();
565
566 return WebPoint(m_private->clickPoint());
567}
568
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100569void WebAXObject::colorValue(int& r, int& g, int& b) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100570{
571 if (isDetached())
572 return;
573
574 m_private->colorValue(r, g, b);
575}
576
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100577double WebAXObject::estimatedLoadingProgress() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100578{
579 if (isDetached())
580 return 0.0;
581
582 return m_private->estimatedLoadingProgress();
583}
584
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100585WebString WebAXObject::helpText() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100586{
587 if (isDetached())
588 return WebString();
589
590 return m_private->helpText();
591}
592
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100593int WebAXObject::headingLevel() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100594{
595 if (isDetached())
596 return 0;
597
598 return m_private->headingLevel();
599}
600
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100601int WebAXObject::hierarchicalLevel() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100602{
603 if (isDetached())
604 return 0;
605
606 return m_private->hierarchicalLevel();
607}
608
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100609WebAXObject WebAXObject::hitTest(const WebPoint& point) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100610{
611 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100612 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100613
614 IntPoint contentsPoint = m_private->documentFrameView()->windowToContents(point);
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100615 RefPtr<AXObject> hit = m_private->accessibilityHitTest(contentsPoint);
Ben Murdoche69819b2013-07-17 14:56:49 +0100616
617 if (hit)
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100618 return WebAXObject(hit);
Ben Murdoche69819b2013-07-17 14:56:49 +0100619
620 if (m_private->elementRect().contains(contentsPoint))
621 return *this;
622
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100623 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100624}
625
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100626WebString WebAXObject::keyboardShortcut() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100627{
628 if (isDetached())
629 return WebString();
630
631 String accessKey = m_private->accessKey();
632 if (accessKey.isNull())
633 return WebString();
634
635 DEFINE_STATIC_LOCAL(String, modifierString, ());
636 if (modifierString.isNull()) {
637 unsigned modifiers = EventHandler::accessKeyModifiers();
638 // Follow the same order as Mozilla MSAA implementation:
639 // Ctrl+Alt+Shift+Meta+key. MSDN states that keyboard shortcut strings
640 // should not be localized and defines the separator as "+".
641 StringBuilder modifierStringBuilder;
642 if (modifiers & PlatformEvent::CtrlKey)
643 modifierStringBuilder.appendLiteral("Ctrl+");
644 if (modifiers & PlatformEvent::AltKey)
645 modifierStringBuilder.appendLiteral("Alt+");
646 if (modifiers & PlatformEvent::ShiftKey)
647 modifierStringBuilder.appendLiteral("Shift+");
648 if (modifiers & PlatformEvent::MetaKey)
649 modifierStringBuilder.appendLiteral("Win+");
650 modifierString = modifierStringBuilder.toString();
651 }
652
653 return String(modifierString + accessKey);
654}
655
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100656bool WebAXObject::performDefaultAction() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100657{
658 if (isDetached())
659 return false;
660
661 return m_private->performDefaultAction();
662}
663
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100664bool WebAXObject::increment() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100665{
666 if (isDetached())
667 return false;
668
669 if (canIncrement()) {
670 m_private->increment();
671 return true;
672 }
673 return false;
674}
675
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100676bool WebAXObject::decrement() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100677{
678 if (isDetached())
679 return false;
680
681 if (canDecrement()) {
682 m_private->decrement();
683 return true;
684 }
685 return false;
686}
687
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100688bool WebAXObject::press() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100689{
690 if (isDetached())
691 return false;
692
693 return m_private->press();
694}
695
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100696WebAXRole WebAXObject::role() const
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100697{
698 if (isDetached())
Torne (Richard Coles)51b29062013-11-28 11:56:03 +0000699 return blink::WebAXRoleUnknown;
Torne (Richard Coles)c0e19a62013-08-30 15:15:11 +0100700
701 return static_cast<WebAXRole>(m_private->roleValue());
702}
703
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100704unsigned WebAXObject::selectionEnd() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100705{
706 if (isDetached())
707 return 0;
708
709 return m_private->selectedTextRange().start + m_private->selectedTextRange().length;
710}
711
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100712unsigned WebAXObject::selectionStart() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100713{
714 if (isDetached())
715 return 0;
716
717 return m_private->selectedTextRange().start;
718}
719
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100720unsigned WebAXObject::selectionEndLineNumber() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100721{
722 if (isDetached())
723 return 0;
724
725 VisiblePosition position = m_private->visiblePositionForIndex(selectionEnd());
726 int lineNumber = m_private->lineForPosition(position);
727 if (lineNumber < 0)
728 return 0;
729 return lineNumber;
730}
731
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100732unsigned WebAXObject::selectionStartLineNumber() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100733{
734 if (isDetached())
735 return 0;
736
737 VisiblePosition position = m_private->visiblePositionForIndex(selectionStart());
738 int lineNumber = m_private->lineForPosition(position);
739 if (lineNumber < 0)
740 return 0;
741 return lineNumber;
742}
743
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100744void WebAXObject::setFocused(bool on) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100745{
746 if (!isDetached())
747 m_private->setFocused(on);
748}
749
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100750void WebAXObject::setSelectedTextRange(int selectionStart, int selectionEnd) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100751{
752 if (isDetached())
753 return;
754
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +0000755 m_private->setSelectedTextRange(AXObject::PlainTextRange(selectionStart, selectionEnd - selectionStart));
Ben Murdoche69819b2013-07-17 14:56:49 +0100756}
757
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100758WebString WebAXObject::stringValue() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100759{
760 if (isDetached())
761 return WebString();
762
763 return m_private->stringValue();
764}
765
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100766WebString WebAXObject::title() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100767{
768 if (isDetached())
769 return WebString();
770
771 return m_private->title();
772}
773
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100774WebAXObject WebAXObject::titleUIElement() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100775{
776 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100777 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100778
779 if (!m_private->exposesTitleUIElement())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100780 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100781
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100782 return WebAXObject(m_private->titleUIElement());
Ben Murdoche69819b2013-07-17 14:56:49 +0100783}
784
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100785WebURL WebAXObject::url() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100786{
787 if (isDetached())
788 return WebURL();
Ben Murdoch02772c62013-07-26 10:21:05 +0100789
Ben Murdoche69819b2013-07-17 14:56:49 +0100790 return m_private->url();
791}
792
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100793bool WebAXObject::supportsRangeValue() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100794{
795 if (isDetached())
796 return false;
797
798 return m_private->supportsRangeValue();
799}
800
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100801WebString WebAXObject::valueDescription() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100802{
803 if (isDetached())
804 return WebString();
805
806 return m_private->valueDescription();
807}
808
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100809float WebAXObject::valueForRange() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100810{
811 if (isDetached())
812 return 0.0;
813
814 return m_private->valueForRange();
815}
816
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100817float WebAXObject::maxValueForRange() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100818{
819 if (isDetached())
820 return 0.0;
821
822 return m_private->maxValueForRange();
823}
824
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100825float WebAXObject::minValueForRange() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100826{
827 if (isDetached())
828 return 0.0;
829
830 return m_private->minValueForRange();
831}
832
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100833WebNode WebAXObject::node() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100834{
835 if (isDetached())
836 return WebNode();
837
838 Node* node = m_private->node();
839 if (!node)
840 return WebNode();
841
842 return WebNode(node);
843}
844
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100845WebDocument WebAXObject::document() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100846{
847 if (isDetached())
848 return WebDocument();
849
850 Document* document = m_private->document();
851 if (!document)
852 return WebDocument();
853
854 return WebDocument(document);
855}
856
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100857bool WebAXObject::hasComputedStyle() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100858{
859 if (isDetached())
860 return false;
861
862 Document* document = m_private->document();
863 if (document)
Ben Murdoch07a852d2014-03-31 11:51:52 +0100864 document->updateRenderTreeIfNeeded();
Ben Murdoche69819b2013-07-17 14:56:49 +0100865
866 Node* node = m_private->node();
867 if (!node)
868 return false;
869
870 return node->computedStyle();
871}
872
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100873WebString WebAXObject::computedStyleDisplay() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100874{
875 if (isDetached())
876 return WebString();
877
878 Document* document = m_private->document();
879 if (document)
Ben Murdoch07a852d2014-03-31 11:51:52 +0100880 document->updateRenderTreeIfNeeded();
Ben Murdoche69819b2013-07-17 14:56:49 +0100881
882 Node* node = m_private->node();
883 if (!node)
884 return WebString();
885
886 RenderStyle* renderStyle = node->computedStyle();
887 if (!renderStyle)
888 return WebString();
889
890 return WebString(CSSPrimitiveValue::create(renderStyle->display())->getStringValue());
891}
892
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100893bool WebAXObject::accessibilityIsIgnored() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100894{
895 if (isDetached())
896 return false;
897
898 return m_private->accessibilityIsIgnored();
899}
900
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100901bool WebAXObject::lineBreaks(WebVector<int>& result) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100902{
903 if (isDetached())
904 return false;
905
906 Vector<int> lineBreaksVector;
907 m_private->lineBreaks(lineBreaksVector);
908
909 size_t vectorSize = lineBreaksVector.size();
910 WebVector<int> lineBreaksWebVector(vectorSize);
911 for (size_t i = 0; i< vectorSize; i++)
912 lineBreaksWebVector[i] = lineBreaksVector[i];
913 result.swap(lineBreaksWebVector);
914
915 return true;
916}
917
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100918unsigned WebAXObject::columnCount() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100919{
920 if (isDetached())
921 return false;
922
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100923 if (!m_private->isAXTable())
Ben Murdoche69819b2013-07-17 14:56:49 +0100924 return 0;
925
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100926 return toAXTable(m_private.get())->columnCount();
Ben Murdoche69819b2013-07-17 14:56:49 +0100927}
928
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100929unsigned WebAXObject::rowCount() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100930{
931 if (isDetached())
932 return false;
933
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100934 if (!m_private->isAXTable())
Ben Murdoche69819b2013-07-17 14:56:49 +0100935 return 0;
936
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100937 return toAXTable(m_private.get())->rowCount();
Ben Murdoche69819b2013-07-17 14:56:49 +0100938}
939
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100940WebAXObject WebAXObject::cellForColumnAndRow(unsigned column, unsigned row) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100941{
942 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100943 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100944
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100945 if (!m_private->isAXTable())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100946 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100947
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100948 WebCore::AXTableCell* cell = toAXTable(m_private.get())->cellForColumnAndRow(column, row);
949 return WebAXObject(static_cast<WebCore::AXObject*>(cell));
Ben Murdoche69819b2013-07-17 14:56:49 +0100950}
951
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100952WebAXObject WebAXObject::headerContainerObject() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100953{
954 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100955 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100956
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100957 if (!m_private->isAXTable())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100958 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100959
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100960 return WebAXObject(toAXTable(m_private.get())->headerContainer());
Ben Murdoche69819b2013-07-17 14:56:49 +0100961}
962
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100963WebAXObject WebAXObject::rowAtIndex(unsigned rowIndex) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100964{
965 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100966 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100967
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100968 if (!m_private->isAXTable())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100969 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100970
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100971 const AXObject::AccessibilityChildrenVector& rows = toAXTable(m_private.get())->rows();
Ben Murdoche69819b2013-07-17 14:56:49 +0100972 if (rowIndex < rows.size())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100973 return WebAXObject(rows[rowIndex]);
Ben Murdoche69819b2013-07-17 14:56:49 +0100974
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100975 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100976}
977
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100978WebAXObject WebAXObject::columnAtIndex(unsigned columnIndex) const
Ben Murdoche69819b2013-07-17 14:56:49 +0100979{
980 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100981 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100982
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100983 if (!m_private->isAXTable())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100984 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100985
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +0100986 const AXObject::AccessibilityChildrenVector& columns = toAXTable(m_private.get())->columns();
Ben Murdoche69819b2013-07-17 14:56:49 +0100987 if (columnIndex < columns.size())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100988 return WebAXObject(columns[columnIndex]);
Ben Murdoche69819b2013-07-17 14:56:49 +0100989
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100990 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +0100991}
992
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +0100993unsigned WebAXObject::rowIndex() const
Ben Murdoche69819b2013-07-17 14:56:49 +0100994{
995 if (isDetached())
996 return 0;
997
998 if (!m_private->isTableRow())
999 return 0;
1000
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001001 return WebCore::toAXTableRow(m_private.get())->rowIndex();
Ben Murdoche69819b2013-07-17 14:56:49 +01001002}
1003
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001004WebAXObject WebAXObject::rowHeader() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001005{
1006 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001007 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +01001008
1009 if (!m_private->isTableRow())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001010 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +01001011
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001012 return WebAXObject(WebCore::toAXTableRow(m_private.get())->headerObject());
Ben Murdoche69819b2013-07-17 14:56:49 +01001013}
1014
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001015unsigned WebAXObject::columnIndex() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001016{
1017 if (isDetached())
1018 return 0;
1019
1020 if (m_private->roleValue() != ColumnRole)
1021 return 0;
1022
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001023 return WebCore::toAXTableColumn(m_private.get())->columnIndex();
Ben Murdoche69819b2013-07-17 14:56:49 +01001024}
1025
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001026WebAXObject WebAXObject::columnHeader() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001027{
1028 if (isDetached())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001029 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +01001030
1031 if (m_private->roleValue() != ColumnRole)
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001032 return WebAXObject();
Ben Murdoche69819b2013-07-17 14:56:49 +01001033
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001034 return WebAXObject(WebCore::toAXTableColumn(m_private.get())->headerObject());
Ben Murdoche69819b2013-07-17 14:56:49 +01001035}
1036
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001037unsigned WebAXObject::cellColumnIndex() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001038{
1039 if (isDetached())
1040 return 0;
1041
1042 if (!m_private->isTableCell())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001043 return 0;
Ben Murdoche69819b2013-07-17 14:56:49 +01001044
1045 pair<unsigned, unsigned> columnRange;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001046 WebCore::toAXTableCell(m_private.get())->columnIndexRange(columnRange);
Ben Murdoche69819b2013-07-17 14:56:49 +01001047 return columnRange.first;
1048}
1049
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001050unsigned WebAXObject::cellColumnSpan() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001051{
1052 if (isDetached())
1053 return 0;
1054
1055 if (!m_private->isTableCell())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001056 return 0;
Ben Murdoche69819b2013-07-17 14:56:49 +01001057
1058 pair<unsigned, unsigned> columnRange;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001059 WebCore::toAXTableCell(m_private.get())->columnIndexRange(columnRange);
Ben Murdoche69819b2013-07-17 14:56:49 +01001060 return columnRange.second;
1061}
1062
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001063unsigned WebAXObject::cellRowIndex() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001064{
1065 if (isDetached())
1066 return 0;
1067
1068 if (!m_private->isTableCell())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001069 return 0;
Ben Murdoche69819b2013-07-17 14:56:49 +01001070
1071 pair<unsigned, unsigned> rowRange;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001072 WebCore::toAXTableCell(m_private.get())->rowIndexRange(rowRange);
Ben Murdoche69819b2013-07-17 14:56:49 +01001073 return rowRange.first;
1074}
1075
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001076unsigned WebAXObject::cellRowSpan() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001077{
1078 if (isDetached())
1079 return 0;
1080
1081 if (!m_private->isTableCell())
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001082 return 0;
Ben Murdoche69819b2013-07-17 14:56:49 +01001083
1084 pair<unsigned, unsigned> rowRange;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001085 WebCore::toAXTableCell(m_private.get())->rowIndexRange(rowRange);
Ben Murdoche69819b2013-07-17 14:56:49 +01001086 return rowRange.second;
1087}
1088
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001089WebAXTextDirection WebAXObject::textDirection() const
1090{
1091 if (isDetached())
1092 return WebAXTextDirectionLR;
1093
1094 return static_cast<WebAXTextDirection>(m_private->textDirection());
1095}
1096
1097void WebAXObject::characterOffsets(WebVector<int>& offsets) const
1098{
1099 if (isDetached())
1100 return;
1101
1102 Vector<int> offsetsVector;
1103 m_private->textCharacterOffsets(offsetsVector);
1104
1105 size_t vectorSize = offsetsVector.size();
1106 WebVector<int> offsetsWebVector(vectorSize);
1107 for (size_t i = 0; i < vectorSize; i++)
1108 offsetsWebVector[i] = offsetsVector[i];
1109 offsets.swap(offsetsWebVector);
1110}
1111
1112void WebAXObject::wordBoundaries(WebVector<int>& starts, WebVector<int>& ends) const
1113{
1114 if (isDetached())
1115 return;
1116
Torne (Richard Coles)f79f16f2013-10-31 11:16:44 +00001117 Vector<AXObject::PlainTextRange> words;
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001118 m_private->wordBoundaries(words);
1119
1120 WebVector<int> startsWebVector(words.size());
1121 WebVector<int> endsWebVector(words.size());
1122 for (size_t i = 0; i < words.size(); i++) {
1123 startsWebVector[i] = words[i].start;
1124 endsWebVector[i] = words[i].start + words[i].length;
1125 }
1126 starts.swap(startsWebVector);
1127 ends.swap(endsWebVector);
1128}
1129
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001130void WebAXObject::scrollToMakeVisible() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001131{
1132 if (!isDetached())
1133 m_private->scrollToMakeVisible();
1134}
1135
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001136void WebAXObject::scrollToMakeVisibleWithSubFocus(const WebRect& subfocus) const
Ben Murdoche69819b2013-07-17 14:56:49 +01001137{
1138 if (!isDetached())
1139 m_private->scrollToMakeVisibleWithSubFocus(subfocus);
1140}
1141
Torne (Richard Coles)8abfc582013-09-12 12:10:38 +01001142void WebAXObject::scrollToGlobalPoint(const WebPoint& point) const
Ben Murdoche69819b2013-07-17 14:56:49 +01001143{
1144 if (!isDetached())
1145 m_private->scrollToGlobalPoint(point);
1146}
1147
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001148WebAXObject::WebAXObject(const WTF::PassRefPtr<WebCore::AXObject>& object)
Ben Murdoche69819b2013-07-17 14:56:49 +01001149 : m_private(object)
1150{
1151}
1152
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001153WebAXObject& WebAXObject::operator=(const WTF::PassRefPtr<WebCore::AXObject>& object)
Ben Murdoche69819b2013-07-17 14:56:49 +01001154{
1155 m_private = object;
1156 return *this;
1157}
1158
Torne (Richard Coles)bfe35902013-10-22 16:41:51 +01001159WebAXObject::operator WTF::PassRefPtr<WebCore::AXObject>() const
Ben Murdoche69819b2013-07-17 14:56:49 +01001160{
1161 return m_private.get();
1162}
1163
Torne (Richard Coles)51b29062013-11-28 11:56:03 +00001164} // namespace blink