Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKitLegacy / mac / DOM / DOMHTMLImageElement.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 "DOMHTMLImageElementInternal.h"
27
28 #import "DOMNodeInternal.h"
29 #import "DOMPrivate.h"
30 #import "ExceptionHandlers.h"
31 #import <WebCore/HTMLImageElement.h>
32 #import <WebCore/HTMLNames.h>
33 #import <WebCore/HitTestResult.h>
34 #import <WebCore/JSExecState.h>
35 #import <WebCore/ThreadCheck.h>
36 #import <WebCore/WebScriptObjectPrivate.h>
37 #import <wtf/GetPtr.h>
38 #import <wtf/URL.h>
39
40 #define IMPL static_cast<WebCore::HTMLImageElement*>(reinterpret_cast<WebCore::Node*>(_internal))
41
42 @implementation DOMHTMLImageElement
43
44 - (NSString *)name
45 {
46     WebCore::JSMainThreadNullState state;
47     return IMPL->getNameAttribute();
48 }
49
50 - (void)setName:(NSString *)newName
51 {
52     WebCore::JSMainThreadNullState state;
53     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, newName);
54 }
55
56 - (NSString *)align
57 {
58     WebCore::JSMainThreadNullState state;
59     return IMPL->getAttribute(WebCore::HTMLNames::alignAttr);
60 }
61
62 - (void)setAlign:(NSString *)newAlign
63 {
64     WebCore::JSMainThreadNullState state;
65     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::alignAttr, newAlign);
66 }
67
68 - (NSString *)alt
69 {
70     WebCore::JSMainThreadNullState state;
71     return IMPL->getAttribute(WebCore::HTMLNames::altAttr);
72 }
73
74 - (void)setAlt:(NSString *)newAlt
75 {
76     WebCore::JSMainThreadNullState state;
77     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::altAttr, newAlt);
78 }
79
80 - (NSString *)border
81 {
82     WebCore::JSMainThreadNullState state;
83     return IMPL->getAttribute(WebCore::HTMLNames::borderAttr);
84 }
85
86 - (void)setBorder:(NSString *)newBorder
87 {
88     WebCore::JSMainThreadNullState state;
89     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::borderAttr, newBorder);
90 }
91
92 - (NSString *)crossOrigin
93 {
94     WebCore::JSMainThreadNullState state;
95     return IMPL->crossOrigin();
96 }
97
98 - (void)setCrossOrigin:(NSString *)newCrossOrigin
99 {
100     WebCore::JSMainThreadNullState state;
101     IMPL->setCrossOrigin(newCrossOrigin);
102 }
103
104 - (int)height
105 {
106     WebCore::JSMainThreadNullState state;
107     return IMPL->height();
108 }
109
110 - (void)setHeight:(int)newHeight
111 {
112     WebCore::JSMainThreadNullState state;
113     IMPL->setHeight(newHeight);
114 }
115
116 - (int)hspace
117 {
118     WebCore::JSMainThreadNullState state;
119     return IMPL->getIntegralAttribute(WebCore::HTMLNames::hspaceAttr);
120 }
121
122 - (void)setHspace:(int)newHspace
123 {
124     WebCore::JSMainThreadNullState state;
125     IMPL->setIntegralAttribute(WebCore::HTMLNames::hspaceAttr, newHspace);
126 }
127
128 - (BOOL)isMap
129 {
130     WebCore::JSMainThreadNullState state;
131     return IMPL->hasAttributeWithoutSynchronization(WebCore::HTMLNames::ismapAttr);
132 }
133
134 - (void)setIsMap:(BOOL)newIsMap
135 {
136     WebCore::JSMainThreadNullState state;
137     IMPL->setBooleanAttribute(WebCore::HTMLNames::ismapAttr, newIsMap);
138 }
139
140 - (NSString *)longDesc
141 {
142     WebCore::JSMainThreadNullState state;
143     return IMPL->getURLAttribute(WebCore::HTMLNames::longdescAttr);
144 }
145
146 - (void)setLongDesc:(NSString *)newLongDesc
147 {
148     WebCore::JSMainThreadNullState state;
149     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::longdescAttr, newLongDesc);
150 }
151
152 - (NSString *)src
153 {
154     WebCore::JSMainThreadNullState state;
155     return IMPL->getURLAttribute(WebCore::HTMLNames::srcAttr);
156 }
157
158 - (void)setSrc:(NSString *)newSrc
159 {
160     WebCore::JSMainThreadNullState state;
161     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::srcAttr, newSrc);
162 }
163
164 - (NSString *)srcset
165 {
166     WebCore::JSMainThreadNullState state;
167     return IMPL->getAttribute(WebCore::HTMLNames::srcsetAttr);
168 }
169
170 - (void)setSrcset:(NSString *)newSrcset
171 {
172     WebCore::JSMainThreadNullState state;
173     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::srcsetAttr, newSrcset);
174 }
175
176 - (NSString *)sizes
177 {
178     WebCore::JSMainThreadNullState state;
179     return IMPL->getAttribute(WebCore::HTMLNames::sizesAttr);
180 }
181
182 - (void)setSizes:(NSString *)newSizes
183 {
184     WebCore::JSMainThreadNullState state;
185     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::sizesAttr, newSizes);
186 }
187
188 - (NSString *)currentSrc
189 {
190     WebCore::JSMainThreadNullState state;
191     return IMPL->currentSrc();
192 }
193
194 - (NSString *)useMap
195 {
196     WebCore::JSMainThreadNullState state;
197     return IMPL->getAttribute(WebCore::HTMLNames::usemapAttr);
198 }
199
200 - (void)setUseMap:(NSString *)newUseMap
201 {
202     WebCore::JSMainThreadNullState state;
203     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::usemapAttr, newUseMap);
204 }
205
206 - (int)vspace
207 {
208     WebCore::JSMainThreadNullState state;
209     return IMPL->getIntegralAttribute(WebCore::HTMLNames::vspaceAttr);
210 }
211
212 - (void)setVspace:(int)newVspace
213 {
214     WebCore::JSMainThreadNullState state;
215     IMPL->setIntegralAttribute(WebCore::HTMLNames::vspaceAttr, newVspace);
216 }
217
218 - (int)width
219 {
220     WebCore::JSMainThreadNullState state;
221     return IMPL->width();
222 }
223
224 - (void)setWidth:(int)newWidth
225 {
226     WebCore::JSMainThreadNullState state;
227     IMPL->setWidth(newWidth);
228 }
229
230 - (BOOL)complete
231 {
232     WebCore::JSMainThreadNullState state;
233     return IMPL->complete();
234 }
235
236 - (NSString *)lowsrc
237 {
238     WebCore::JSMainThreadNullState state;
239     return IMPL->getURLAttribute(WebCore::HTMLNames::lowsrcAttr);
240 }
241
242 - (void)setLowsrc:(NSString *)newLowsrc
243 {
244     WebCore::JSMainThreadNullState state;
245     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::lowsrcAttr, newLowsrc);
246 }
247
248 - (int)naturalHeight
249 {
250     WebCore::JSMainThreadNullState state;
251     return IMPL->naturalHeight();
252 }
253
254 - (int)naturalWidth
255 {
256     WebCore::JSMainThreadNullState state;
257     return IMPL->naturalWidth();
258 }
259
260 - (int)x
261 {
262     WebCore::JSMainThreadNullState state;
263     return IMPL->x();
264 }
265
266 - (int)y
267 {
268     WebCore::JSMainThreadNullState state;
269     return IMPL->y();
270 }
271
272 - (NSString *)altDisplayString
273 {
274     WebCore::JSMainThreadNullState state;
275     return WebCore::displayString(IMPL->alt(), core(self));
276 }
277
278 - (NSURL *)absoluteImageURL
279 {
280     WebCore::JSMainThreadNullState state;
281     return [self _getURLAttribute:@"src"];
282 }
283
284 @end
285
286 WebCore::HTMLImageElement* core(DOMHTMLImageElement *wrapper)
287 {
288     return wrapper ? reinterpret_cast<WebCore::HTMLImageElement*>(wrapper->_internal) : 0;
289 }