rev 11020 : 8201563: Update copyright header for files modified in 2018
Reviewed-by:

   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/Node.h>
  32 #include <WebCore/NodeFilter.h>
  33 #include <WebCore/TreeWalker.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<TreeWalker*>(jlong_to_ptr(peer)))
  47 
  48 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_dispose(JNIEnv*, jclass, jlong peer)
  49 {
  50     IMPL->deref();
  51 }
  52 
  53 
  54 // Attributes
  55 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_getRootImpl(JNIEnv* env, jclass, jlong peer)
  56 {
  57     WebCore::JSMainThreadNullState state;
  58     return JavaReturn<Node>(env, WTF::getPtr(IMPL->root()));
  59 }
  60 
  61 JNIEXPORT jint JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_getWhatToShowImpl(JNIEnv*, jclass, jlong peer)
  62 {
  63     WebCore::JSMainThreadNullState state;
  64     return IMPL->whatToShow();
  65 }
  66 
  67 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_getFilterImpl(JNIEnv* env, jclass, jlong peer)
  68 {
  69     WebCore::JSMainThreadNullState state;
  70     return JavaReturn<NodeFilter>(env, WTF::getPtr(IMPL->filter()));
  71 }
  72 
  73 JNIEXPORT jboolean JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_getExpandEntityReferencesImpl(JNIEnv*, jclass, jlong)
  74 {
  75     WebCore::JSMainThreadNullState state;
  76     return JNI_FALSE;
  77 }
  78 
  79 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_getCurrentNodeImpl(JNIEnv* env, jclass, jlong peer)
  80 {
  81     WebCore::JSMainThreadNullState state;
  82     return JavaReturn<Node>(env, WTF::getPtr(IMPL->currentNode()));
  83 }
  84 
  85 JNIEXPORT void JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_setCurrentNodeImpl(JNIEnv* env, jclass, jlong peer, jlong value)
  86 {
  87     WebCore::JSMainThreadNullState state;
  88     if (!value) {
  89         raiseTypeErrorException(env);
  90         return;
  91     }
  92     IMPL->setCurrentNode(*static_cast<Node*>(jlong_to_ptr(value)));
  93 }
  94 
  95 
  96 // Functions
  97 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_parentNodeImpl(JNIEnv* env, jclass, jlong peer)
  98 {
  99     WebCore::JSMainThreadNullState state;
 100 
 101     auto result = IMPL->parentNode();
 102     if (result.hasException()) {
 103         return {};
 104     }
 105     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 106 }
 107 
 108 
 109 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_firstChildImpl(JNIEnv* env, jclass, jlong peer)
 110 {
 111     WebCore::JSMainThreadNullState state;
 112 
 113     auto result = IMPL->firstChild();
 114     if (result.hasException()) {
 115         return {};
 116     }
 117     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 118 }
 119 
 120 
 121 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_lastChildImpl(JNIEnv* env, jclass, jlong peer)
 122 {
 123     WebCore::JSMainThreadNullState state;
 124 
 125     auto result = IMPL->lastChild();
 126     if (result.hasException()) {
 127         return {};
 128     }
 129     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 130 }
 131 
 132 
 133 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_previousSiblingImpl(JNIEnv* env, jclass, jlong peer)
 134 {
 135     WebCore::JSMainThreadNullState state;
 136 
 137     auto result = IMPL->previousSibling();
 138     if (result.hasException()) {
 139         return {};
 140     }
 141     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 142 }
 143 
 144 
 145 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_nextSiblingImpl(JNIEnv* env, jclass, jlong peer)
 146 {
 147     WebCore::JSMainThreadNullState state;
 148 
 149     auto result = IMPL->nextSibling();
 150     if (result.hasException()) {
 151         return {};
 152     }
 153     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 154 }
 155 
 156 
 157 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_previousNodeImpl(JNIEnv* env, jclass, jlong peer)
 158 {
 159     WebCore::JSMainThreadNullState state;
 160 
 161     auto result = IMPL->previousNode();
 162     if (result.hasException()) {
 163         return {};
 164     }
 165     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 166 }
 167 
 168 
 169 JNIEXPORT jlong JNICALL Java_com_sun_webkit_dom_TreeWalkerImpl_nextNodeImpl(JNIEnv* env, jclass, jlong peer)
 170 {
 171     WebCore::JSMainThreadNullState state;
 172 
 173     auto result = IMPL->nextNode();
 174     if (result.hasException()) {
 175         return {};
 176     }
 177     return JavaReturn<Node>(env, WTF::getPtr(result.releaseReturnValue()));
 178 }
 179 
 180 
 181 }
--- EOF ---