1/*
2 * Copyright (C) 2008 Apple Ltd.
3 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB.  If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 */
20
21#include "config.h"
22#include "AccessibilityObject.h"
23
24#include <glib-object.h>
25
26#if HAVE(ACCESSIBILITY)
27
28namespace WebCore {
29
30bool AccessibilityObject::accessibilityIgnoreAttachment() const
31{
32    return false;
33}
34
35AccessibilityObjectPlatformInclusion AccessibilityObject::accessibilityPlatformIncludesObject() const
36{
37    AccessibilityObject* parent = parentObject();
38    if (!parent)
39        return DefaultBehavior;
40
41    if (isMenuListPopup() || isMenuListOption())
42        return IgnoreObject;
43
44    // When a list item is made up entirely of children (e.g. paragraphs)
45    // the list item gets ignored. We need it.
46    if (isGroup() && parent->isList())
47        return IncludeObject;
48
49    // Entries and password fields have extraneous children which we want to ignore.
50    if (parent->isPasswordField() || parent->isTextControl())
51        return IgnoreObject;
52
53    // The object containing the text should implement AtkText itself.
54    if (roleValue() == StaticTextRole)
55        return IgnoreObject;
56
57    return DefaultBehavior;
58}
59
60AccessibilityObjectWrapper* AccessibilityObject::wrapper() const
61{
62    return m_wrapper;
63}
64
65void AccessibilityObject::setWrapper(AccessibilityObjectWrapper* wrapper)
66{
67    if (wrapper == m_wrapper)
68        return;
69
70    if (m_wrapper)
71        g_object_unref(m_wrapper);
72
73    m_wrapper = wrapper;
74
75    if (m_wrapper)
76        g_object_ref(m_wrapper);
77}
78
79} // namespace WebCore
80
81#endif // HAVE(ACCESSIBILITY)
82