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/DOMWindow.h>
  31 #include <WebCore/Document.h>
  32 #include <WebCore/HTMLFrameElement.h>
  33 #include <WebCore/HTMLNames.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<HTMLFrameElement*>(jlong_to_ptr(peer)))
  47 
  48 
  49 // Attributes
  50 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getFrameBorderImpl(JNIEnv* env, jclass, jlong peer)
  51 {
  52     WebCore::JSMainThreadNullState state;
  53     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::frameborderAttr));
  54 }
  55 
  56 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setFrameBorderImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  57 {
  58     WebCore::JSMainThreadNullState state;
  59     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::frameborderAttr, String(env, value));
  60 }
  61 
  62 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getLongDescImpl(JNIEnv* env, jclass, jlong peer)
  63 {
  64     WebCore::JSMainThreadNullState state;
  65     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::longdescAttr));
  66 }
  67 
  68 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setLongDescImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  69 {
  70     WebCore::JSMainThreadNullState state;
  71     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::longdescAttr, String(env, value));
  72 }
  73 
  74 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getMarginHeightImpl(JNIEnv* env, jclass, jlong peer)
  75 {
  76     WebCore::JSMainThreadNullState state;
  77     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::marginheightAttr));
  78 }
  79 
  80 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setMarginHeightImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  81 {
  82     WebCore::JSMainThreadNullState state;
  83     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::marginheightAttr, String(env, value));
  84 }
  85 
  86 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getMarginWidthImpl(JNIEnv* env, jclass, jlong peer)
  87 {
  88     WebCore::JSMainThreadNullState state;
  89     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::marginwidthAttr));
  90 }
  91 
  92 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setMarginWidthImpl(JNIEnv* env, jclass, jlong peer, jstring value)
  93 {
  94     WebCore::JSMainThreadNullState state;
  95     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::marginwidthAttr, String(env, value));
  96 }
  97 
  98 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getNameImpl(JNIEnv* env, jclass, jlong peer)
  99 {
 100     WebCore::JSMainThreadNullState state;
 101     return JavaReturn<String>(env, IMPL->getNameAttribute());
 102 }
 103 
 104 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setNameImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 105 {
 106     WebCore::JSMainThreadNullState state;
 107     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::nameAttr, String(env, value));
 108 }
 109 
 110 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getNoResizeImpl(JNIEnv*, jclass, jlong peer)
 111 {
 112     WebCore::JSMainThreadNullState state;
 113     return IMPL->hasAttribute(WebCore::HTMLNames::noresizeAttr);
 114 }
 115 
 116 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setNoResizeImpl(JNIEnv*, jclass, jlong peer, jboolean value)
 117 {
 118     WebCore::JSMainThreadNullState state;
 119     IMPL->setBooleanAttribute(WebCore::HTMLNames::noresizeAttr, value);
 120 }
 121 
 122 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getScrollingImpl(JNIEnv* env, jclass, jlong peer)
 123 {
 124     WebCore::JSMainThreadNullState state;
 125     return JavaReturn<String>(env, IMPL->getAttribute(WebCore::HTMLNames::scrollingAttr));
 126 }
 127 
 128 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setScrollingImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 129 {
 130     WebCore::JSMainThreadNullState state;
 131     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::scrollingAttr, String(env, value));
 132 }
 133 
 134 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getSrcImpl(JNIEnv* env, jclass, jlong peer)
 135 {
 136     WebCore::JSMainThreadNullState state;
 137     return JavaReturn<String>(env, IMPL->getURLAttribute(WebCore::HTMLNames::srcAttr));
 138 }
 139 
 140 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setSrcImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 141 {
 142     WebCore::JSMainThreadNullState state;
 143     IMPL->setAttributeWithoutSynchronization(WebCore::HTMLNames::srcAttr, String(env, value));
 144 }
 145 
 146 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getContentDocumentImpl(JNIEnv* env, jclass, jlong peer)
 147 {
 148     WebCore::JSMainThreadNullState state;
 149     return JavaReturn<Document>(env, WTF::getPtr(IMPL->contentDocument()));
 150 }
 151 
 152 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getContentWindowImpl(JNIEnv* env, jclass, jlong peer)
 153 {
 154     WebCore::JSMainThreadNullState state;
 155     return JavaReturn<DOMWindow>(env, WTF::getPtr(IMPL->contentWindow()));
 156 }
 157 
 158 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getLocationImpl(JNIEnv* env, jclass, jlong peer)
 159 {
 160     WebCore::JSMainThreadNullState state;
 161     return JavaReturn<String>(env, IMPL->location());
 162 }
 163 
 164 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_setLocationImpl(JNIEnv* env, jclass, jlong peer, jstring value)
 165 {
 166     WebCore::JSMainThreadNullState state;
 167     IMPL->setLocation(String(env, value));
 168 }
 169 
 170 JNIEXPORT jint JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getWidthImpl(JNIEnv*, jclass, jlong peer)
 171 {
 172     WebCore::JSMainThreadNullState state;
 173     return IMPL->width();
 174 }
 175 
 176 JNIEXPORT jint JNICALL Java_com_sun_webkit_dom_HTMLFrameElementImpl_getHeightImpl(JNIEnv*, jclass, jlong peer)
 177 {
 178     WebCore::JSMainThreadNullState state;
 179     return IMPL->height();
 180 }
 181 
 182 }