1 /*
2 * Copyright (C) 2010 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 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */
25
26 #ifndef AccessibilityTextMarker_h
27 #define AccessibilityTextMarker_h
28
29 #include <JavaScriptCore/JSObjectRef.h>
30
31 #if PLATFORM(MAC)
32 #define SUPPORTS_AX_TEXTMARKERS 1
33 #else
34 #define SUPPORTS_AX_TEXTMARKERS 0
35 #endif
36
37 #if PLATFORM(MAC)
38 #include <wtf/RetainPtr.h>
39 typedef CFTypeRef PlatformTextMarker;
40 typedef CFTypeRef PlatformTextMarkerRange;
41 #else
42 typedef void* PlatformTextMarker;
43 typedef void* PlatformTextMarkerRange;
44 #endif
45
46 class AccessibilityUIElement;
47
48 class AccessibilityTextMarker {
49 public:
50 AccessibilityTextMarker(PlatformTextMarker);
51 AccessibilityTextMarker(const AccessibilityTextMarker&);
52 ~AccessibilityTextMarker();
53
54 PlatformTextMarker platformTextMarker() const;
55
56 static JSObjectRef makeJSAccessibilityTextMarker(JSContextRef, const AccessibilityTextMarker&);
57 bool isEqual(AccessibilityTextMarker*);
58
59 private:
60 static JSClassRef getJSClass();
61 #if PLATFORM(MAC)
62 RetainPtr<PlatformTextMarker> m_textMarker;
63 #else
64 PlatformTextMarker m_textMarker;
65 #endif
66 };
67
68 class AccessibilityTextMarkerRange {
69 public:
70 AccessibilityTextMarkerRange(PlatformTextMarkerRange);
71 AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange&);
72 ~AccessibilityTextMarkerRange();
73
74 PlatformTextMarkerRange platformTextMarkerRange() const;
75
76 static JSObjectRef makeJSAccessibilityTextMarkerRange(JSContextRef, const AccessibilityTextMarkerRange&);
77 bool isEqual(AccessibilityTextMarkerRange*);
78
79 private:
80 static JSClassRef getJSClass();
81 #if PLATFORM(MAC)
82 RetainPtr<PlatformTextMarkerRange> m_textMarkerRange;
83 #else
84 PlatformTextMarkerRange m_textMarkerRange;
85 #endif
86 };
87
88 AccessibilityTextMarker* toTextMarker(JSObjectRef object);
89 AccessibilityTextMarkerRange* toTextMarkerRange(JSObjectRef object);
90
91 #if !SUPPORTS_AX_TEXTMARKERS
AccessibilityTextMarker(PlatformTextMarker)92 inline AccessibilityTextMarker::AccessibilityTextMarker(PlatformTextMarker) { }
AccessibilityTextMarker(const AccessibilityTextMarker &)93 inline AccessibilityTextMarker::AccessibilityTextMarker(const AccessibilityTextMarker&) { }
~AccessibilityTextMarker()94 inline AccessibilityTextMarker::~AccessibilityTextMarker() { }
isEqual(AccessibilityTextMarker *)95 inline bool AccessibilityTextMarker::isEqual(AccessibilityTextMarker*) { return false; }
platformTextMarker()96 inline PlatformTextMarker AccessibilityTextMarker::platformTextMarker() const { return m_textMarker; }
97
AccessibilityTextMarkerRange(PlatformTextMarkerRange)98 inline AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(PlatformTextMarkerRange) { }
AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange &)99 inline AccessibilityTextMarkerRange::AccessibilityTextMarkerRange(const AccessibilityTextMarkerRange&) { }
~AccessibilityTextMarkerRange()100 inline AccessibilityTextMarkerRange::~AccessibilityTextMarkerRange() { }
isEqual(AccessibilityTextMarkerRange *)101 inline bool AccessibilityTextMarkerRange::isEqual(AccessibilityTextMarkerRange*) { return false; }
platformTextMarkerRange()102 inline PlatformTextMarkerRange AccessibilityTextMarkerRange::platformTextMarkerRange() const { return m_textMarkerRange; }
103 #endif
104
105 #endif // AccessibilityUIElement_h
106