1 /*
2 * Copyright (C) 2008 Apple 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
6 * are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
14 * its contributors may be used to endorse or promote products derived
15 * from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
18 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #include "config.h"
30 #include "AccessibilityTableRow.h"
31
32 #include "AccessibilityTableCell.h"
33 #include "AXObjectCache.h"
34 #include "HTMLNames.h"
35 #include "HTMLTableRowElement.h"
36 #include "RenderObject.h"
37 #include "RenderTableCell.h"
38 #include "RenderTableRow.h"
39
40 using namespace std;
41
42 namespace WebCore {
43
44 using namespace HTMLNames;
45
AccessibilityTableRow(RenderObject * renderer)46 AccessibilityTableRow::AccessibilityTableRow(RenderObject* renderer)
47 : AccessibilityRenderObject(renderer)
48 {
49 }
50
~AccessibilityTableRow()51 AccessibilityTableRow::~AccessibilityTableRow()
52 {
53 }
54
create(RenderObject * renderer)55 PassRefPtr<AccessibilityTableRow> AccessibilityTableRow::create(RenderObject* renderer)
56 {
57 return adoptRef(new AccessibilityTableRow(renderer));
58 }
59
roleValue() const60 AccessibilityRole AccessibilityTableRow::roleValue() const
61 {
62 if (!isTableRow())
63 return AccessibilityRenderObject::roleValue();
64
65 return RowRole;
66 }
67
isTableRow() const68 bool AccessibilityTableRow::isTableRow() const
69 {
70 if (!m_renderer)
71 return true;
72
73 AccessibilityObject* renderTable = axObjectCache()->get(static_cast<RenderTableRow*>(m_renderer)->table());
74 if (!renderTable->isDataTable())
75 return false;
76
77 return true;
78 }
79
accessibilityIsIgnored() const80 bool AccessibilityTableRow::accessibilityIsIgnored() const
81 {
82 if (!isTableRow())
83 return AccessibilityRenderObject::accessibilityIsIgnored();
84
85 return false;
86 }
87
headerObject()88 AccessibilityObject* AccessibilityTableRow::headerObject()
89 {
90 AccessibilityChildrenVector rowChildren = children();
91 if (!rowChildren.size())
92 return 0;
93
94 // check the first element in the row to see if it is a TH element
95 AccessibilityObject* cell = rowChildren[0].get();
96 if (!cell->isTableCell())
97 return 0;
98
99 RenderObject* cellRenderer = static_cast<AccessibilityTableCell*>(cell)->renderer();
100 if (!cellRenderer)
101 return 0;
102
103 Node* cellNode = cellRenderer->element();
104 if (!cellNode || !cellNode->hasTagName(thTag))
105 return 0;
106
107 return cell;
108 }
109
110 } // namespace WebCore
111