Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKitLegacy / mac / DOM / DOMCharacterData.mm
1 /*
2  * Copyright (C) 2004-2016 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 #import "DOMCharacterData.h"
27
28 #import "DOMElementInternal.h"
29 #import "DOMNodeInternal.h"
30 #import <WebCore/Element.h>
31 #import "ExceptionHandlers.h"
32 #import <WebCore/JSExecState.h>
33 #import <WebCore/ThreadCheck.h>
34 #import <WebCore/WebScriptObjectPrivate.h>
35 #import <WebCore/CharacterData.h>
36 #import <wtf/GetPtr.h>
37 #import <wtf/URL.h>
38
39 #define IMPL static_cast<WebCore::CharacterData*>(reinterpret_cast<WebCore::Node*>(_internal))
40
41 @implementation DOMCharacterData
42
43 - (NSString *)data
44 {
45     WebCore::JSMainThreadNullState state;
46     return IMPL->data();
47 }
48
49 - (void)setData:(NSString *)newData
50 {
51     WebCore::JSMainThreadNullState state;
52     IMPL->setData(newData);
53 }
54
55 - (unsigned)length
56 {
57     WebCore::JSMainThreadNullState state;
58     return IMPL->length();
59 }
60
61 - (DOMElement *)previousElementSibling
62 {
63     WebCore::JSMainThreadNullState state;
64     return kit(WTF::getPtr(IMPL->previousElementSibling()));
65 }
66
67 - (DOMElement *)nextElementSibling
68 {
69     WebCore::JSMainThreadNullState state;
70     return kit(WTF::getPtr(IMPL->nextElementSibling()));
71 }
72
73 - (NSString *)substringData:(unsigned)offset length:(unsigned)inLength
74 {
75     WebCore::JSMainThreadNullState state;
76     return raiseOnDOMError(IMPL->substringData(offset, inLength));
77 }
78
79 - (void)appendData:(NSString *)inData
80 {
81     WebCore::JSMainThreadNullState state;
82     IMPL->appendData(inData);
83 }
84
85 - (void)insertData:(unsigned)offset data:(NSString *)inData
86 {
87     WebCore::JSMainThreadNullState state;
88     raiseOnDOMError(IMPL->insertData(offset, inData));
89 }
90
91 - (void)deleteData:(unsigned)offset length:(unsigned)inLength
92 {
93     WebCore::JSMainThreadNullState state;
94     raiseOnDOMError(IMPL->deleteData(offset, inLength));
95 }
96
97 - (void)replaceData:(unsigned)offset length:(unsigned)inLength data:(NSString *)inData
98 {
99     WebCore::JSMainThreadNullState state;
100     raiseOnDOMError(IMPL->replaceData(offset, inLength, inData));
101 }
102
103 - (void)remove
104 {
105     WebCore::JSMainThreadNullState state;
106     raiseOnDOMError(IMPL->remove());
107 }
108
109 @end
110
111 @implementation DOMCharacterData (DOMCharacterDataDeprecated)
112
113 - (NSString *)substringData:(unsigned)offset :(unsigned)inLength
114 {
115     return [self substringData:offset length:inLength];
116 }
117
118 - (void)insertData:(unsigned)offset :(NSString *)inData
119 {
120     [self insertData:offset data:inData];
121 }
122
123 - (void)deleteData:(unsigned)offset :(unsigned)inLength
124 {
125     [self deleteData:offset length:inLength];
126 }
127
128 - (void)replaceData:(unsigned)offset :(unsigned)inLength :(NSString *)inData
129 {
130     [self replaceData:offset length:inLength data:inData];
131 }
132
133 @end