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/DeprecatedCSSOMPrimitiveValue.h> 31 #include <WebCore/DeprecatedCSSOMCounter.h> 32 #include "DOMException.h" 33 #include <WebCore/DeprecatedCSSOMRGBColor.h> 34 #include <WebCore/DeprecatedCSSOMRect.h> 35 #include <WebCore/JSMainThreadExecState.h> 36 37 #include <wtf/RefPtr.h> 38 #include <wtf/GetPtr.h> 39 40 #include "JavaDOMUtils.h" 41 #include <wtf/java/JavaEnv.h> 42 43 using namespace WebCore; 44 45 extern "C" { 46 47 #define IMPL (static_cast<DeprecatedCSSOMPrimitiveValue*>(jlong_to_ptr(peer))) 48 49 50 // Attributes 51 JNIEXPORT jshort JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getPrimitiveTypeImpl(JNIEnv*, jclass, jlong peer) 52 { 53 WebCore::JSMainThreadNullState state; 54 return IMPL->primitiveType(); 55 } 56 57 58 // Functions 59 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_setFloatValueImpl(JNIEnv* env, jclass, jlong peer 60 , jshort unitType 61 , jfloat floatValue) 62 { 63 WebCore::JSMainThreadNullState state; 64 raiseOnDOMError(env, IMPL->setFloatValue(unitType 65 , floatValue)); 66 } 67 68 69 JNIEXPORT jfloat JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getFloatValueImpl(JNIEnv* env, jclass, jlong peer 70 , jshort unitType) 71 { 72 WebCore::JSMainThreadNullState state; 73 return raiseOnDOMError(env, IMPL->getFloatValue(unitType)); 74 } 75 76 77 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_setStringValueImpl(JNIEnv* env, jclass, jlong peer 78 , jshort stringType 79 , jstring stringValue) 80 { 81 WebCore::JSMainThreadNullState state; 82 raiseOnDOMError(env, IMPL->setStringValue(stringType 83 , String(env, stringValue))); 84 } 85 86 87 JNIEXPORT jstring JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getStringValueImpl(JNIEnv* env, jclass, jlong peer) 88 { 89 WebCore::JSMainThreadNullState state; 90 return JavaReturn<String>(env, raiseOnDOMError(env, IMPL->getStringValue())); 91 } 92 93 94 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getCounterValueImpl(JNIEnv* env, jclass, jlong peer) 95 { 96 WebCore::JSMainThreadNullState state; 97 return JavaReturn<DeprecatedCSSOMCounter>(env, WTF::getPtr(raiseOnDOMError(env, IMPL->getCounterValue()))); 98 } 99 100 101 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getRectValueImpl(JNIEnv* env, jclass, jlong peer) 102 { 103 WebCore::JSMainThreadNullState state; 104 return JavaReturn<DeprecatedCSSOMRect>(env, WTF::getPtr(raiseOnDOMError(env, IMPL->getRectValue()))); 105 } 106 107 108 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_CSSPrimitiveValueImpl_getRGBColorValueImpl(JNIEnv* env, jclass, jlong peer) 109 { 110 WebCore::JSMainThreadNullState state; 111 return JavaReturn<DeprecatedCSSOMRGBColor>(env, WTF::getPtr(raiseOnDOMError(env, IMPL->getRGBColorValue()))); 112 } 113 114 115 }