[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

steveblock at google.com steveblock at google.com
Thu Apr 8 01:13:58 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 9a33e9031daf53cb4ce5756103d6b56750a9e55f
Author: steveblock at google.com <steveblock at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Jan 19 01:12:43 2010 +0000

    Script attributes are copied and pasted, making cross-domain attacks possible (30019)
    <rdar://problem/6008809>
    https://bugs.webkit.org/show_bug.cgi?id=30019
    
    Patch by Enrica Casucci <enrica at apple.com> on 2010-01-18
    Reviewed by Darin Adler.
    
    When we create the document fragment from a markup string,
    either to perform a paste operation or a drag and drop, we
    want to remove all the event handlers and any attribute that contain
    a value that leads to code execution.
    The HTMLParser class is now aware of the needs of stripping these attributes.
    I've modified the call to createMarkupString for every platform.
    
    Test: editing/pasteboard/paste-noscript.html
    
    * WebCore.base.exp:
    * dom/Element.cpp:
    (WebCore::isEventHandlerAttribute):
    (WebCore::Element::setAttributeMap):
    * dom/Element.h:
    * dom/MappedAttributeEntry.h:
    (WebCore::):
    * editing/markup.cpp:
    (WebCore::createFragmentFromMarkup):
    * editing/markup.h:
    * html/HTMLElement.cpp:
    (WebCore::HTMLElement::createContextualFragment):
    * html/HTMLElement.h:
    * html/HTMLParser.cpp:
    (WebCore::HTMLParser::HTMLParser):
    (WebCore::HTMLParser::parseToken):
    * html/HTMLParser.h:
    * html/HTMLTokenizer.cpp:
    (WebCore::HTMLTokenizer::HTMLTokenizer):
    (WebCore::parseHTMLDocumentFragment):
    * html/HTMLTokenizer.h:
    * platform/chromium/DragDataChromium.cpp:
    (WebCore::DragData::asFragment):
    * platform/chromium/PasteboardChromium.cpp:
    (WebCore::Pasteboard::documentFragment):
    * platform/gtk/PasteboardGtk.cpp:
    (WebCore::Pasteboard::documentFragment):
    * platform/mac/PasteboardMac.mm:
    (WebCore::Pasteboard::documentFragment):
    * platform/qt/DragDataQt.cpp:
    (WebCore::DragData::asFragment):
    * platform/qt/PasteboardQt.cpp:
    (WebCore::Pasteboard::documentFragment):
    * platform/win/ClipboardUtilitiesWin.cpp:
    (WebCore::fragmentFromCF_HTML):
    (WebCore::fragmentFromHTML):
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53443 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.jscbindings.mk b/WebCore/Android.jscbindings.mk
index 0e4e7ed..1a7f413 100644
--- a/WebCore/Android.jscbindings.mk
+++ b/WebCore/Android.jscbindings.mk
@@ -183,9 +183,9 @@ LOCAL_SRC_FILES += \
 	bridge/c/c_instance.cpp \
 	bridge/c/c_runtime.cpp \
 	bridge/c/c_utility.cpp \
-	bridge/jni/jni_class.cpp \
 	bridge/jni/jni_runtime.cpp \
 	bridge/jni/jni_utility.cpp \
+	bridge/jni/jsc/JavaClassJSC.cpp \
 	bridge/jni/jsc/JavaInstanceJSC.cpp \
 	bridge/jni/jsc/jni_utility_private.cpp \
 	bridge/npruntime.cpp \
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 6f1418c..3e4a3e1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -102,6 +102,24 @@
 
         Reviewed by Adam Barth.
 
+        Moves JSC-specific version of JavaClass from bridge/jni/jni_class to bridge/jni/jsc/JavaClassJSC
+        https://bugs.webkit.org/show_bug.cgi?id=33561
+
+        No new tests, refactoring only.
+
+        * Android.jscbindings.mk: Modified. Removed jni_class.cpp and added JavaClassJSC.cpp
+        * GNUmakefile.am: Modified. Removed jni_class.h and added JavaClassJSC.h
+        * WebCore.xcodeproj/project.pbxproj: Modified. Removed jni_class.[cpp|h] and added JavaClassJSC.[cpp|h]
+        * bridge/jni/jni_class.cpp: Removed.
+        * bridge/jni/jni_class.h: Removed.
+        * bridge/jni/jsc/JavaClassJSC.cpp: Copied from WebCore/bridge/jni/jni_class.cpp.
+        * bridge/jni/jsc/JavaClassJSC.h: Copied from WebCore/bridge/jni/jni_class.h.
+        * bridge/jni/jsc/JavaInstanceJSC.cpp: Modified. Includes JavaClassJSC.h
+
+2010-01-18  Steve Block  <steveblock at google.com>
+
+        Reviewed by Adam Barth.
+
         Fix style in WebCore/bridge/jni/jsc/JavaInstanceJSC.[cpp|h]
         https://bugs.webkit.org/show_bug.cgi?id=33792
 
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index a10b89a..52dee53 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -504,10 +504,10 @@ webcore_sources += \
 	WebCore/bridge/c/c_runtime.h \
 	WebCore/bridge/c/c_utility.cpp \
 	WebCore/bridge/c/c_utility.h \
-	WebCore/bridge/jni/jni_class.h \
 	WebCore/bridge/jni/jni_jsobject.h \
 	WebCore/bridge/jni/jni_runtime.h \
 	WebCore/bridge/jni/jni_utility.h \
+	WebCore/bridge/jni/jsc/JavaClassJSC.h \
 	WebCore/bridge/jni/jsc/JavaInstanceJSC.h \
 	WebCore/bridge/npapi.h \
 	WebCore/bridge/npruntime.cpp \
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 81a3369..dad0a91 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -303,8 +303,6 @@
 		1A569CFC0D7E2B82007C3983 /* c_runtime.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CCB0D7E2B82007C3983 /* c_runtime.h */; };
 		1A569CFD0D7E2B82007C3983 /* c_utility.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CCC0D7E2B82007C3983 /* c_utility.cpp */; };
 		1A569CFE0D7E2B82007C3983 /* c_utility.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CCD0D7E2B82007C3983 /* c_utility.h */; };
-		1A569CFF0D7E2B82007C3983 /* jni_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CCF0D7E2B82007C3983 /* jni_class.cpp */; };
-		1A569D000D7E2B82007C3983 /* jni_class.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD00D7E2B82007C3983 /* jni_class.h */; };
 		1A569D030D7E2B82007C3983 /* jni_jsobject.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */; };
 		1A569D040D7E2B82007C3983 /* jni_jsobject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A569CD40D7E2B82007C3983 /* jni_jsobject.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		1A569D050D7E2B82007C3983 /* jni_objc.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1A569CD50D7E2B82007C3983 /* jni_objc.mm */; };
@@ -1117,6 +1115,8 @@
 		59A9E7B21104759400DFB4C1 /* JavaInstanceJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */; };
 		59C77F2A10545B3B00506104 /* GeolocationServiceMock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */; };
 		59C77F2B10545B3B00506104 /* GeolocationServiceMock.h in Headers */ = {isa = PBXBuildFile; fileRef = 59C77F2910545B3B00506104 /* GeolocationServiceMock.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		59E560A71105336600AA1258 /* JavaClassJSC.h in Headers */ = {isa = PBXBuildFile; fileRef = 59E560A61105336600AA1258 /* JavaClassJSC.h */; };
+		59E560A91105336F00AA1258 /* JavaClassJSC.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 59E560A81105336F00AA1258 /* JavaClassJSC.cpp */; };
 		5D15E3AB0F9E6AC1009E0E3F /* XMLTokenizerScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */; };
 		5D15E3AC0F9E6AC1009E0E3F /* XMLTokenizerScope.h in Headers */ = {isa = PBXBuildFile; fileRef = 5D15E3AA0F9E6AC1009E0E3F /* XMLTokenizerScope.h */; };
 		5D874F130D161D3200796C3B /* NetscapePlugInStreamLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93E227DD0AF589AD00D48324 /* NetscapePlugInStreamLoader.cpp */; };
@@ -5550,8 +5550,6 @@
 		1A569CCB0D7E2B82007C3983 /* c_runtime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c_runtime.h; sourceTree = "<group>"; };
 		1A569CCC0D7E2B82007C3983 /* c_utility.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = c_utility.cpp; sourceTree = "<group>"; };
 		1A569CCD0D7E2B82007C3983 /* c_utility.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = c_utility.h; sourceTree = "<group>"; };
-		1A569CCF0D7E2B82007C3983 /* jni_class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = jni_class.cpp; sourceTree = "<group>"; };
-		1A569CD00D7E2B82007C3983 /* jni_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_class.h; sourceTree = "<group>"; };
 		1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jni_jsobject.mm; sourceTree = "<group>"; };
 		1A569CD40D7E2B82007C3983 /* jni_jsobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = jni_jsobject.h; sourceTree = "<group>"; };
 		1A569CD50D7E2B82007C3983 /* jni_objc.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = jni_objc.mm; sourceTree = "<group>"; };
@@ -6470,6 +6468,8 @@
 		59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaInstanceJSC.h; path = jsc/JavaInstanceJSC.h; sourceTree = "<group>"; };
 		59C77F2810545B3B00506104 /* GeolocationServiceMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = GeolocationServiceMock.cpp; path = mock/GeolocationServiceMock.cpp; sourceTree = "<group>"; };
 		59C77F2910545B3B00506104 /* GeolocationServiceMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GeolocationServiceMock.h; path = mock/GeolocationServiceMock.h; sourceTree = "<group>"; };
+		59E560A61105336600AA1258 /* JavaClassJSC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaClassJSC.h; path = jsc/JavaClassJSC.h; sourceTree = "<group>"; };
+		59E560A81105336F00AA1258 /* JavaClassJSC.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaClassJSC.cpp; path = jsc/JavaClassJSC.cpp; sourceTree = "<group>"; };
 		5D15E3A90F9E6AC1009E0E3F /* XMLTokenizerScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLTokenizerScope.cpp; sourceTree = "<group>"; };
 		5D15E3AA0F9E6AC1009E0E3F /* XMLTokenizerScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLTokenizerScope.h; sourceTree = "<group>"; };
 		5D925B650F64D4DD00B847F0 /* ScrollBehavior.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScrollBehavior.cpp; sourceTree = "<group>"; };
@@ -10346,8 +10346,6 @@
 			isa = PBXGroup;
 			children = (
 				599D1E2F10C97D4C00E0EF12 /* jsc */,
-				1A569CCF0D7E2B82007C3983 /* jni_class.cpp */,
-				1A569CD00D7E2B82007C3983 /* jni_class.h */,
 				1A569CD40D7E2B82007C3983 /* jni_jsobject.h */,
 				1A569CD30D7E2B82007C3983 /* jni_jsobject.mm */,
 				1A569CD50D7E2B82007C3983 /* jni_objc.mm */,
@@ -11060,6 +11058,8 @@
 		599D1E2F10C97D4C00E0EF12 /* jsc */ = {
 			isa = PBXGroup;
 			children = (
+				59E560A81105336F00AA1258 /* JavaClassJSC.cpp */,
+				59E560A61105336600AA1258 /* JavaClassJSC.h */,
 				59A9E7B11104759400DFB4C1 /* JavaInstanceJSC.h */,
 				59A9E7AF1104758800DFB4C1 /* JavaInstanceJSC.cpp */,
 				599D1E3010C97D6E00E0EF12 /* jni_utility_private.cpp */,
@@ -17149,7 +17149,6 @@
 				1C81BA0E0E97348300266E07 /* JavaScriptDebugServer.h in Headers */,
 				1C81BA010E9733CB00266E07 /* JavaScriptProfile.h in Headers */,
 				1C81B9FF0E9733CB00266E07 /* JavaScriptProfileNode.h in Headers */,
-				1A569D000D7E2B82007C3983 /* jni_class.h in Headers */,
 				1A569D040D7E2B82007C3983 /* jni_jsobject.h in Headers */,
 				1A569D070D7E2B82007C3983 /* jni_runtime.h in Headers */,
 				1A569D090D7E2B82007C3983 /* jni_utility.h in Headers */,
@@ -18358,6 +18357,7 @@
 				6EE8A77310F803F3005A4A24 /* JSWebGLContextAttributes.h in Headers */,
 				E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */,
 				59A9E7B21104759400DFB4C1 /* JavaInstanceJSC.h in Headers */,
+				59E560A71105336600AA1258 /* JavaClassJSC.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -19323,7 +19323,6 @@
 				1C81BA0D0E97348300266E07 /* JavaScriptDebugServer.cpp in Sources */,
 				1C81BA020E9733CB00266E07 /* JavaScriptProfile.cpp in Sources */,
 				1C81BA000E9733CB00266E07 /* JavaScriptProfileNode.cpp in Sources */,
-				1A569CFF0D7E2B82007C3983 /* jni_class.cpp in Sources */,
 				1A569D030D7E2B82007C3983 /* jni_jsobject.mm in Sources */,
 				1A569D050D7E2B82007C3983 /* jni_objc.mm in Sources */,
 				1A569D060D7E2B82007C3983 /* jni_runtime.cpp in Sources */,
@@ -20523,6 +20522,7 @@
 				6EE8A77210F803F3005A4A24 /* JSWebGLContextAttributes.cpp in Sources */,
 				E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */,
 				59A9E7B01104758800DFB4C1 /* JavaInstanceJSC.cpp in Sources */,
+				59E560A91105336F00AA1258 /* JavaClassJSC.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/bridge/jni/jni_class.cpp b/WebCore/bridge/jni/jni_class.cpp
deleted file mode 100644
index 6728e7b..0000000
--- a/WebCore/bridge/jni/jni_class.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#include "config.h"
-#include "jni_class.h"
-
-#if ENABLE(MAC_JAVA_BRIDGE)
-
-#include "JSDOMWindow.h"
-#include <runtime/Identifier.h>
-#include <runtime/JSLock.h>
-#include "jni_utility.h"
-#include "jni_runtime.h"
-
-using namespace JSC::Bindings;
-
-JavaClass::JavaClass(jobject anInstance)
-{
-    jobject aClass = callJNIMethod<jobject>(anInstance, "getClass", "()Ljava/lang/Class;");
-    
-    if (!aClass) {
-        fprintf(stderr, "%s:  unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance);
-        return;
-    }
-    
-    jstring className = (jstring)callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;");
-    const char *classNameC = getCharactersFromJString(className);
-    _name = strdup(classNameC);
-    releaseCharactersForJString(className, classNameC);
-
-    int i;
-    JNIEnv *env = getJNIEnv();
-
-    // Get the fields
-    jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
-    int numFields = env->GetArrayLength(fields);    
-    for (i = 0; i < numFields; i++) {
-        jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i);
-        JavaField *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
-        {
-            JSLock lock(SilenceAssertionsOnly);
-            _fields.set(aField->name(), aField);
-        }
-        env->DeleteLocalRef(aJField);
-    }
-
-    // Get the methods
-    jarray methods = (jarray)callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;");
-    int numMethods = env->GetArrayLength(methods);
-    for (i = 0; i < numMethods; i++) {
-        jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i);
-        JavaMethod *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
-        MethodList* methodList;
-        {
-            JSLock lock(SilenceAssertionsOnly);
-
-            methodList = _methods.get(aMethod->name());
-            if (!methodList) {
-                methodList = new MethodList();
-                _methods.set(aMethod->name(), methodList);
-            }
-        }
-        methodList->append(aMethod);
-        env->DeleteLocalRef(aJMethod);
-    }    
-
-    env->DeleteLocalRef(fields);
-    env->DeleteLocalRef(methods);
-    env->DeleteLocalRef(aClass);
-}
-
-JavaClass::~JavaClass() {
-    free((void *)_name);
-
-    JSLock lock(SilenceAssertionsOnly);
-
-    deleteAllValues(_fields);
-    _fields.clear();
-
-    MethodListMap::const_iterator end = _methods.end();
-    for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) {
-        const MethodList* methodList = it->second;
-        deleteAllValues(*methodList);
-        delete methodList;
-    }
-    _methods.clear();
-}
-
-MethodList JavaClass::methodsNamed(const Identifier& identifier, Instance*) const
-{
-    MethodList *methodList = _methods.get(identifier.ustring().rep());
-    
-    if (methodList)
-        return *methodList;
-    return MethodList();
-}
-
-Field *JavaClass::fieldNamed(const Identifier& identifier, Instance*) const
-{
-    return _fields.get(identifier.ustring().rep());
-}
-
-bool JavaClass::isNumberClass() const
-{
-    return ((strcmp(_name, "java.lang.Byte") == 0 ||
-             strcmp(_name, "java.lang.Short") == 0 ||
-             strcmp(_name, "java.lang.Integer") == 0 ||
-             strcmp(_name, "java.lang.Long") == 0 ||
-             strcmp(_name, "java.lang.Float") == 0 ||
-             strcmp(_name, "java.lang.Double") == 0) );
-}
-
-bool JavaClass::isBooleanClass() const
-{
-    return strcmp(_name, "java.lang.Boolean") == 0;
-}
-
-bool JavaClass::isStringClass() const
-{
-    return strcmp(_name, "java.lang.String") == 0;
-}
-
-#endif // ENABLE(MAC_JAVA_BRIDGE)
diff --git a/WebCore/bridge/jni/jni_class.h b/WebCore/bridge/jni/jni_class.h
deleted file mode 100644
index 890b4d3..0000000
--- a/WebCore/bridge/jni/jni_class.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#ifndef JNI_CLASS_H_
-#define JNI_CLASS_H_
-
-#if ENABLE(MAC_JAVA_BRIDGE)
-
-#include <jni_runtime.h>
-#include <wtf/HashMap.h>
-
-namespace JSC {
-
-namespace Bindings {
-
-class JavaClass : public Class {
-public:
-    JavaClass (jobject anInstance);
-    ~JavaClass ();
-
-    virtual MethodList methodsNamed(const Identifier&, Instance* instance) const;    
-    virtual Field *fieldNamed(const Identifier&, Instance* instance) const;
-    
-    bool isNumberClass() const;
-    bool isBooleanClass() const;
-    bool isStringClass() const;
-    
-private:
-    const char *_name;
-    FieldMap _fields;
-    MethodListMap _methods;
-};
-
-} // namespace Bindings
-
-} // namespace JSC
-
-#endif // ENABLE(MAC_JAVA_BRIDGE)
-
-#endif // JNI_CLASS_H_
diff --git a/WebCore/bridge/jni/jsc/JavaClassJSC.cpp b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
new file mode 100644
index 0000000..3e30a4a
--- /dev/null
+++ b/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "JavaClassJSC.h"
+
+#if ENABLE(MAC_JAVA_BRIDGE)
+
+#include "JSDOMWindow.h"
+#include <runtime/Identifier.h>
+#include <runtime/JSLock.h>
+#include "jni_utility.h"
+#include "jni_runtime.h"
+
+using namespace JSC::Bindings;
+
+JavaClass::JavaClass(jobject anInstance)
+{
+    jobject aClass = callJNIMethod<jobject>(anInstance, "getClass", "()Ljava/lang/Class;");
+    
+    if (!aClass) {
+        fprintf(stderr, "%s:  unable to call getClass on instance %p\n", __PRETTY_FUNCTION__, anInstance);
+        return;
+    }
+    
+    jstring className = (jstring)callJNIMethod<jobject>(aClass, "getName", "()Ljava/lang/String;");
+    const char *classNameC = getCharactersFromJString(className);
+    _name = strdup(classNameC);
+    releaseCharactersForJString(className, classNameC);
+
+    int i;
+    JNIEnv *env = getJNIEnv();
+
+    // Get the fields
+    jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
+    int numFields = env->GetArrayLength(fields);    
+    for (i = 0; i < numFields; i++) {
+        jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i);
+        JavaField *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
+        {
+            JSLock lock(SilenceAssertionsOnly);
+            _fields.set(aField->name(), aField);
+        }
+        env->DeleteLocalRef(aJField);
+    }
+
+    // Get the methods
+    jarray methods = (jarray)callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;");
+    int numMethods = env->GetArrayLength(methods);
+    for (i = 0; i < numMethods; i++) {
+        jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i);
+        JavaMethod *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
+        MethodList* methodList;
+        {
+            JSLock lock(SilenceAssertionsOnly);
+
+            methodList = _methods.get(aMethod->name());
+            if (!methodList) {
+                methodList = new MethodList();
+                _methods.set(aMethod->name(), methodList);
+            }
+        }
+        methodList->append(aMethod);
+        env->DeleteLocalRef(aJMethod);
+    }    
+
+    env->DeleteLocalRef(fields);
+    env->DeleteLocalRef(methods);
+    env->DeleteLocalRef(aClass);
+}
+
+JavaClass::~JavaClass() {
+    free((void *)_name);
+
+    JSLock lock(SilenceAssertionsOnly);
+
+    deleteAllValues(_fields);
+    _fields.clear();
+
+    MethodListMap::const_iterator end = _methods.end();
+    for (MethodListMap::const_iterator it = _methods.begin(); it != end; ++it) {
+        const MethodList* methodList = it->second;
+        deleteAllValues(*methodList);
+        delete methodList;
+    }
+    _methods.clear();
+}
+
+MethodList JavaClass::methodsNamed(const Identifier& identifier, Instance*) const
+{
+    MethodList *methodList = _methods.get(identifier.ustring().rep());
+    
+    if (methodList)
+        return *methodList;
+    return MethodList();
+}
+
+Field *JavaClass::fieldNamed(const Identifier& identifier, Instance*) const
+{
+    return _fields.get(identifier.ustring().rep());
+}
+
+bool JavaClass::isNumberClass() const
+{
+    return ((strcmp(_name, "java.lang.Byte") == 0 ||
+             strcmp(_name, "java.lang.Short") == 0 ||
+             strcmp(_name, "java.lang.Integer") == 0 ||
+             strcmp(_name, "java.lang.Long") == 0 ||
+             strcmp(_name, "java.lang.Float") == 0 ||
+             strcmp(_name, "java.lang.Double") == 0) );
+}
+
+bool JavaClass::isBooleanClass() const
+{
+    return strcmp(_name, "java.lang.Boolean") == 0;
+}
+
+bool JavaClass::isStringClass() const
+{
+    return strcmp(_name, "java.lang.String") == 0;
+}
+
+#endif // ENABLE(MAC_JAVA_BRIDGE)
diff --git a/WebCore/bridge/jni/jsc/JavaClassJSC.h b/WebCore/bridge/jni/jsc/JavaClassJSC.h
new file mode 100644
index 0000000..cbf7160
--- /dev/null
+++ b/WebCore/bridge/jni/jsc/JavaClassJSC.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef JavaClassJSC_h
+#define JavaClassJSC_h
+
+#if ENABLE(MAC_JAVA_BRIDGE)
+
+#include <jni_runtime.h>
+#include <wtf/HashMap.h>
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaClass : public Class {
+public:
+    JavaClass (jobject anInstance);
+    ~JavaClass ();
+
+    virtual MethodList methodsNamed(const Identifier&, Instance* instance) const;    
+    virtual Field *fieldNamed(const Identifier&, Instance* instance) const;
+    
+    bool isNumberClass() const;
+    bool isBooleanClass() const;
+    bool isStringClass() const;
+    
+private:
+    const char *_name;
+    FieldMap _fields;
+    MethodListMap _methods;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // ENABLE(MAC_JAVA_BRIDGE)
+
+#endif // JavaClassJSC_h
diff --git a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
index 37f413e..17e0147 100644
--- a/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
+++ b/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
@@ -28,7 +28,7 @@
 
 #if ENABLE(MAC_JAVA_BRIDGE)
 
-#include "jni_class.h"
+#include "JavaClassJSC.h"
 #include "jni_runtime.h"
 #include "jni_utility.h"
 #include "jni_utility_private.h"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list