1 /*
   2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #undef IMPL
  27 
  28 #include "config.h"
  29 
  30 #include <WebCore/HTMLButtonElement.h>
  31 #include <WebCore/HTMLFormElement.h>
  32 #include <WebCore/HTMLNames.h>
  33 #include <WebCore/NodeList.h>
  34 #include <WebCore/JSMainThreadExecState.h>
  35 
  36 #include <wtf/RefPtr.h>
  37 #include <wtf/GetPtr.h>
  38 
  39 #include "JavaDOMUtils.h"
  40 #include <wtf/java/JavaEnv.h>
  41 
  42 using namespace WebCore;
  43 
  44 extern "C" {
  45 
  46 #define IMPL (static_cast<HTMLButtonElement*>(jlong_to_ptr(peer)))
  47 
  48 
  49 // Attributes
  50 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getAutofocusImpl(JNIEnv*, jclass, jlong peer)
  51 {
  52     WebCore::JSMainThreadNullState state;
  53     return IMPL->hasAttribute(WebCore::HTMLNames::autofocusAttr);
  54 }
  55 
  56 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setAutofocusImpl(JNIEnv*, jclass, jlong peer, jboolean value)
  57 {
  58     WebCore::JSMainThreadNullState state;
  59     IMPL->setBooleanAttribute(WebCore::HTMLNames::autofocusAttr, value);
  60 }
  61 
  62 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getDisabledImpl(JNIEnv*, jclass, jlong peer)
  63 {
  64     WebCore::JSMainThreadNullState state;
  65     return IMPL->hasAttribute(WebCore::HTMLNames::disabledAttr);
  66 }
  67 
  68 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setDisabledImpl(JNIEnv*, jclass, jlong peer, jboolean value)
  69 {
  70     WebCore::JSMainThreadNullState state;
  71     IMPL->setBooleanAttribute(WebCore::HTMLNames::disabledAttr, value);
  72 }
  73 
  74 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormImpl(JNIEnv* env, jclass, jlong peer)
  75 {
  76     WebCore::JSMainThreadNullState state;
  77     return JavaReturn<HTMLFormElement>(env, WTF::getPtr(IMPL->form()));
  78 }
  79 
  80 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormActionImpl(JNIEnv* env, jclass, jlong peer)
  81 {
  82     WebCore::JSMainThreadNullState state;
  83     return JavaReturn<String>(env, IMPL->formAction());
  84 }
  85 
  86 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setFormActionImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  87 {
  88     WebCore::JSMainThreadNullState state;
  89     IMPL->setFormAction(String(env, value));
  90 }
  91 
  92 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormEnctypeImpl(JNIEnv* env, jclass, jlong peer)
  93 {
  94     WebCore::JSMainThreadNullState state;
  95     return JavaReturn<String>(env, IMPL->formEnctype());
  96 }
  97 
  98 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setFormEnctypeImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  99 {
 100     WebCore::JSMainThreadNullState state;
 101     IMPL->setFormEnctype(String(env, value));
 102 }
 103 
 104 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormMethodImpl(JNIEnv* env, jclass, jlong peer)
 105 {
 106     WebCore::JSMainThreadNullState state;
 107     return JavaReturn<String>(env, IMPL->formMethod());
 108 }
 109 
 110 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setFormMethodImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 111 {
 112     WebCore::JSMainThreadNullState state;
 113     IMPL->setFormMethod(String(env, value));
 114 }
 115 
 116 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getTypeImpl(JNIEnv* env, jclass, jlong peer)
 117 {
 118     WebCore::JSMainThreadNullState state;
 119     return JavaReturn<String>(env, IMPL->type());
 120 }
 121 
 122 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setTypeImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 123 {
 124     WebCore::JSMainThreadNullState state;
 125     IMPL->setType(String(env, value));
 126 }
 127 
 128 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormNoValidateImpl(JNIEnv*, jclass, jlong peer)
 129 {
 130     WebCore::JSMainThreadNullState state;
 131     return IMPL->hasAttribute(WebCore::HTMLNames::formnovalidateAttr);
 132 }
 133 
 134 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setFormNoValidateImpl(JNIEnv*, jclass, jlong peer, jboolean value)
 135 {
 136     WebCore::JSMainThreadNullState state;
 137     IMPL->setBooleanAttribute(WebCore::HTMLNames::formnovalidateAttr, value);
 138 }
 139 
 140 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getFormTargetImpl(JNIEnv* env, jclass, jlong peer)
 141 {
 142     WebCore::JSMainThreadNullState state;
 143     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::formtargetAttr));
 144 }
 145 
 146 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setFormTargetImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 147 {
 148     WebCore::JSMainThreadNullState state;
 149     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::formtargetAttr, String(env, value));
 150 }
 151 
 152 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getNameImpl(JNIEnv* env, jclass, jlong peer)
 153 {
 154     WebCore::JSMainThreadNullState state;
 155     return JavaReturn<String>(env, IMPL->getNameAttribute());
 156 }
 157 
 158 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setNameImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 159 {
 160     WebCore::JSMainThreadNullState state;
 161     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, String(env, value));
 162 }
 163 
 164 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getValueImpl(JNIEnv* env, jclass, jlong peer)
 165 {
 166     WebCore::JSMainThreadNullState state;
 167     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::valueAttr));
 168 }
 169 
 170 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setValueImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 171 {
 172     WebCore::JSMainThreadNullState state;
 173     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::valueAttr, String(env, value));
 174 }
 175 
 176 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getWillValidateImpl(JNIEnv*, jclass, jlong peer)
 177 {
 178     WebCore::JSMainThreadNullState state;
 179     return IMPL->willValidate();
 180 }
 181 
 182 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getValidationMessageImpl(JNIEnv* env, jclass, jlong peer)
 183 {
 184     WebCore::JSMainThreadNullState state;
 185     return JavaReturn<String>(env, IMPL->validationMessage());
 186 }
 187 
 188 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getLabelsImpl(JNIEnv* env, jclass, jlong peer)
 189 {
 190     WebCore::JSMainThreadNullState state;
 191     return JavaReturn<NodeList>(env, WTF::getPtr(IMPL->labels()));
 192 }
 193 
 194 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_getAccessKeyImpl(JNIEnv* env, jclass, jlong peer)
 195 {
 196     WebCore::JSMainThreadNullState state;
 197     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::accesskeyAttr));
 198 }
 199 
 200 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setAccessKeyImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 201 {
 202     WebCore::JSMainThreadNullState state;
 203     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::accesskeyAttr, String(env, value));
 204 }
 205 
 206 
 207 // Functions
 208 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_checkValidityImpl(JNIEnv*, jclass, jlong peer)
 209 {
 210     WebCore::JSMainThreadNullState state;
 211     return IMPL->checkValidity();
 212 }
 213 
 214 
 215 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_setCustomValidityImpl(JNIEnv* env, jclass, jlong peer
 216     , jstring error)
 217 {
 218     WebCore::JSMainThreadNullState state;
 219     IMPL->setCustomValidity(String(env, error));
 220 }
 221 
 222 
 223 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLButtonElementImpl_clickImpl(JNIEnv*, jclass, jlong peer)
 224 {
 225     WebCore::JSMainThreadNullState state;
 226     IMPL->click();
 227 }
 228 
 229 
 230 }