1 /*
   2  * Copyright (c) 2013, 2017, 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 "DOMException.h"
  31 #include <WebCore/HTMLCollection.h>
  32 #include <WebCore/HTMLElement.h>
  33 #include <WebCore/HTMLNames.h>
  34 #include <WebCore/HTMLTableCaptionElement.h>
  35 #include <WebCore/HTMLTableElement.h>
  36 #include <WebCore/HTMLTableSectionElement.h>
  37 #include <WebCore/JSMainThreadExecState.h>
  38 
  39 #include <wtf/RefPtr.h>
  40 #include <wtf/GetPtr.h>
  41 
  42 #include "JavaDOMUtils.h"
  43 #include <wtf/java/JavaEnv.h>
  44 
  45 using namespace WebCore;
  46 
  47 extern "C" {
  48 
  49 #define IMPL (static_cast<HTMLTableElement*>(jlong_to_ptr(peer)))
  50 
  51 
  52 // Attributes
  53 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getCaptionImpl(JNIEnv* env, jclass, jlong peer)
  54 {
  55     WebCore::JSMainThreadNullState state;
  56     return JavaReturn<HTMLTableCaptionElement>(env, WTF::getPtr(IMPL->caption()));
  57 }
  58 
  59 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setCaptionImpl(JNIEnv*, jclass, jlong peer, jlong value)
  60 {
  61     WebCore::JSMainThreadNullState state;
  62     IMPL->setCaption(static_cast<HTMLTableCaptionElement*>(jlong_to_ptr(value)));
  63 }
  64 
  65 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getTHeadImpl(JNIEnv* env, jclass, jlong peer)
  66 {
  67     WebCore::JSMainThreadNullState state;
  68     return JavaReturn<HTMLTableSectionElement>(env, WTF::getPtr(IMPL->tHead()));
  69 }
  70 
  71 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setTHeadImpl(JNIEnv*, jclass, jlong peer, jlong value)
  72 {
  73     WebCore::JSMainThreadNullState state;
  74     IMPL->setTHead(static_cast<HTMLTableSectionElement*>(jlong_to_ptr(value)));
  75 }
  76 
  77 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getTFootImpl(JNIEnv* env, jclass, jlong peer)
  78 {
  79     WebCore::JSMainThreadNullState state;
  80     return JavaReturn<HTMLTableSectionElement>(env, WTF::getPtr(IMPL->tFoot()));
  81 }
  82 
  83 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setTFootImpl(JNIEnv*, jclass, jlong peer, jlong value)
  84 {
  85     WebCore::JSMainThreadNullState state;
  86     IMPL->setTFoot(static_cast<HTMLTableSectionElement*>(jlong_to_ptr(value)));
  87 }
  88 
  89 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getRowsImpl(JNIEnv* env, jclass, jlong peer)
  90 {
  91     WebCore::JSMainThreadNullState state;
  92     return JavaReturn<HTMLCollection>(env, WTF::getPtr(IMPL->rows()));
  93 }
  94 
  95 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getTBodiesImpl(JNIEnv* env, jclass, jlong peer)
  96 {
  97     WebCore::JSMainThreadNullState state;
  98     return JavaReturn<HTMLCollection>(env, WTF::getPtr(IMPL->tBodies()));
  99 }
 100 
 101 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getAlignImpl(JNIEnv* env, jclass, jlong peer)
 102 {
 103     WebCore::JSMainThreadNullState state;
 104     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::alignAttr));
 105 }
 106 
 107 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setAlignImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 108 {
 109     WebCore::JSMainThreadNullState state;
 110     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::alignAttr, String(env, value));
 111 }
 112 
 113 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getBgColorImpl(JNIEnv* env, jclass, jlong peer)
 114 {
 115     WebCore::JSMainThreadNullState state;
 116     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::bgcolorAttr));
 117 }
 118 
 119 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setBgColorImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 120 {
 121     WebCore::JSMainThreadNullState state;
 122     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::bgcolorAttr, String(env, value));
 123 }
 124 
 125 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getBorderImpl(JNIEnv* env, jclass, jlong peer)
 126 {
 127     WebCore::JSMainThreadNullState state;
 128     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::borderAttr));
 129 }
 130 
 131 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setBorderImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 132 {
 133     WebCore::JSMainThreadNullState state;
 134     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::borderAttr, String(env, value));
 135 }
 136 
 137 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getCellPaddingImpl(JNIEnv* env, jclass, jlong peer)
 138 {
 139     WebCore::JSMainThreadNullState state;
 140     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::cellpaddingAttr));
 141 }
 142 
 143 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setCellPaddingImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 144 {
 145     WebCore::JSMainThreadNullState state;
 146     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::cellpaddingAttr, String(env, value));
 147 }
 148 
 149 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getCellSpacingImpl(JNIEnv* env, jclass, jlong peer)
 150 {
 151     WebCore::JSMainThreadNullState state;
 152     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::cellspacingAttr));
 153 }
 154 
 155 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setCellSpacingImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 156 {
 157     WebCore::JSMainThreadNullState state;
 158     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::cellspacingAttr, String(env, value));
 159 }
 160 
 161 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getFrameImpl(JNIEnv* env, jclass, jlong peer)
 162 {
 163     WebCore::JSMainThreadNullState state;
 164     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::frameAttr));
 165 }
 166 
 167 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setFrameImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 168 {
 169     WebCore::JSMainThreadNullState state;
 170     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::frameAttr, String(env, value));
 171 }
 172 
 173 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getRulesImpl(JNIEnv* env, jclass, jlong peer)
 174 {
 175     WebCore::JSMainThreadNullState state;
 176     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::rulesAttr));
 177 }
 178 
 179 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setRulesImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 180 {
 181     WebCore::JSMainThreadNullState state;
 182     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::rulesAttr, String(env, value));
 183 }
 184 
 185 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getSummaryImpl(JNIEnv* env, jclass, jlong peer)
 186 {
 187     WebCore::JSMainThreadNullState state;
 188     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::summaryAttr));
 189 }
 190 
 191 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setSummaryImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 192 {
 193     WebCore::JSMainThreadNullState state;
 194     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::summaryAttr, String(env, value));
 195 }
 196 
 197 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_getWidthImpl(JNIEnv* env, jclass, jlong peer)
 198 {
 199     WebCore::JSMainThreadNullState state;
 200     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::widthAttr));
 201 }
 202 
 203 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_setWidthImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 204 {
 205     WebCore::JSMainThreadNullState state;
 206     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::widthAttr, String(env, value));
 207 }
 208 
 209 
 210 // Functions
 211 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_createTHeadImpl(JNIEnv* env, jclass, jlong peer)
 212 {
 213     WebCore::JSMainThreadNullState state;
 214     return JavaReturn<HTMLElement>(env, WTF::getPtr(IMPL->createTHead()));
 215 }
 216 
 217 
 218 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_deleteTHeadImpl(JNIEnv*, jclass, jlong peer)
 219 {
 220     WebCore::JSMainThreadNullState state;
 221     IMPL->deleteTHead();
 222 }
 223 
 224 
 225 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_createTFootImpl(JNIEnv* env, jclass, jlong peer)
 226 {
 227     WebCore::JSMainThreadNullState state;
 228     return JavaReturn<HTMLElement>(env, WTF::getPtr(IMPL->createTFoot()));
 229 }
 230 
 231 
 232 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_deleteTFootImpl(JNIEnv*, jclass, jlong peer)
 233 {
 234     WebCore::JSMainThreadNullState state;
 235     IMPL->deleteTFoot();
 236 }
 237 
 238 
 239 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_createTBodyImpl(JNIEnv* env, jclass, jlong peer)
 240 {
 241     WebCore::JSMainThreadNullState state;
 242     return JavaReturn<HTMLElement>(env, WTF::getPtr(IMPL->createTBody()));
 243 }
 244 
 245 
 246 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_createCaptionImpl(JNIEnv* env, jclass, jlong peer)
 247 {
 248     WebCore::JSMainThreadNullState state;
 249     return JavaReturn<HTMLElement>(env, WTF::getPtr(IMPL->createCaption()));
 250 }
 251 
 252 
 253 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_deleteCaptionImpl(JNIEnv*, jclass, jlong peer)
 254 {
 255     WebCore::JSMainThreadNullState state;
 256     IMPL->deleteCaption();
 257 }
 258 
 259 
 260 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_insertRowImpl(JNIEnv* env, jclass, jlong peer
 261     , jint index)
 262 {
 263     WebCore::JSMainThreadNullState state;
 264     return JavaReturn<HTMLElement>(env, WTF::getPtr(raiseOnDOMError(env, IMPL->insertRow(index))));
 265 }
 266 
 267 
 268 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLTableElementImpl_deleteRowImpl(JNIEnv* env, jclass, jlong peer
 269     , jint index)
 270 {
 271     WebCore::JSMainThreadNullState state;
 272     raiseOnDOMError(env, IMPL->deleteRow(index));
 273 }
 274 
 275 
 276 }