Move URL from WebCore to WTF
[WebKit-https.git] / Source / WebKitLegacy / mac / DOM / DOMHTMLFormElement.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 "DOMHTMLFormElementInternal.h"
27
28 #import "DOMHTMLCollectionInternal.h"
29 #import "DOMNodeInternal.h"
30 #import "ExceptionHandlers.h"
31 #import <WebCore/HTMLCollection.h>
32 #import <WebCore/HTMLFormElement.h>
33 #import <WebCore/HTMLNames.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::HTMLFormElement*>(reinterpret_cast<WebCore::Node*>(_internal))
41
42 @implementation DOMHTMLFormElement
43
44 - (NSString *)acceptCharset
45 {
46     WebCore::JSMainThreadNullState state;
47     return IMPL->getAttribute(WebCore::HTMLNames::accept_charsetAttr);
48 }
49
50 - (void)setAcceptCharset:(NSString *)newAcceptCharset
51 {
52     WebCore::JSMainThreadNullState state;
53     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::accept_charsetAttr, newAcceptCharset);
54 }
55
56 - (NSString *)action
57 {
58     WebCore::JSMainThreadNullState state;
59     return IMPL->getURLAttribute(WebCore::HTMLNames::actionAttr);
60 }
61
62 - (void)setAction:(NSString *)newAction
63 {
64     WebCore::JSMainThreadNullState state;
65     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::actionAttr, newAction);
66 }
67
68 - (NSString *)autocomplete
69 {
70     WebCore::JSMainThreadNullState state;
71     return IMPL->autocomplete();
72 }
73
74 - (void)setAutocomplete:(NSString *)newAutocomplete
75 {
76     WebCore::JSMainThreadNullState state;
77     IMPL->setAutocomplete(newAutocomplete);
78 }
79
80 - (NSString *)enctype
81 {
82     WebCore::JSMainThreadNullState state;
83     return IMPL->enctype();
84 }
85
86 - (void)setEnctype:(NSString *)newEnctype
87 {
88     WebCore::JSMainThreadNullState state;
89     IMPL->setEnctype(newEnctype);
90 }
91
92 - (NSString *)encoding
93 {
94     WebCore::JSMainThreadNullState state;
95     return IMPL->enctype();
96 }
97
98 - (void)setEncoding:(NSString *)newEncoding
99 {
100     WebCore::JSMainThreadNullState state;
101     IMPL->setEnctype(newEncoding);
102 }
103
104 - (NSString *)method
105 {
106     WebCore::JSMainThreadNullState state;
107     return IMPL->method();
108 }
109
110 - (void)setMethod:(NSString *)newMethod
111 {
112     WebCore::JSMainThreadNullState state;
113     IMPL->setMethod(newMethod);
114 }
115
116 - (NSString *)name
117 {
118     WebCore::JSMainThreadNullState state;
119     return IMPL->getNameAttribute();
120 }
121
122 - (void)setName:(NSString *)newName
123 {
124     WebCore::JSMainThreadNullState state;
125     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, newName);
126 }
127
128 - (BOOL)noValidate
129 {
130     WebCore::JSMainThreadNullState state;
131     return IMPL->hasAttributeWithoutSynchronization(WebCore::HTMLNames::novalidateAttr);
132 }
133
134 - (void)setNoValidate:(BOOL)newNoValidate
135 {
136     WebCore::JSMainThreadNullState state;
137     IMPL->setBooleanAttribute(WebCore::HTMLNames::novalidateAttr, newNoValidate);
138 }
139
140 - (NSString *)target
141 {
142     WebCore::JSMainThreadNullState state;
143     return IMPL->getAttribute(WebCore::HTMLNames::targetAttr);
144 }
145
146 - (void)setTarget:(NSString *)newTarget
147 {
148     WebCore::JSMainThreadNullState state;
149     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::targetAttr, newTarget);
150 }
151
152 - (DOMHTMLCollection *)elements
153 {
154     WebCore::JSMainThreadNullState state;
155     return kit(WTF::getPtr(IMPL->elementsForNativeBindings()));
156 }
157
158 - (int)length
159 {
160     WebCore::JSMainThreadNullState state;
161     return IMPL->length();
162 }
163
164 - (void)submit
165 {
166     WebCore::JSMainThreadNullState state;
167     IMPL->submit();
168 }
169
170 - (void)reset
171 {
172     WebCore::JSMainThreadNullState state;
173     IMPL->reset();
174 }
175
176 - (BOOL)checkValidity
177 {
178     WebCore::JSMainThreadNullState state;
179     return IMPL->checkValidity();
180 }
181
182 @end
183
184 DOMHTMLFormElement *kit(WebCore::HTMLFormElement* value)
185 {
186     WebCoreThreadViolationCheckRoundOne();
187     return static_cast<DOMHTMLFormElement*>(kit(static_cast<WebCore::Node*>(value)));
188 }