~ubuntu-branches/ubuntu/raring/qtwebkit-source/raring-proposed

« back to all changes in this revision

Viewing changes to Source/WebKit2/WebProcess/Plugins/Netscape/JSNPObject.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2013-02-18 14:24:18 UTC
  • Revision ID: package-import@ubuntu.com-20130218142418-eon0jmjg3nj438uy
Tags: upstream-2.3
ImportĀ upstreamĀ versionĀ 2.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2010 Apple Inc. All rights reserved.
 
3
 *
 
4
 * Redistribution and use in source and binary forms, with or without
 
5
 * modification, are permitted provided that the following conditions
 
6
 * are met:
 
7
 * 1. Redistributions of source code must retain the above copyright
 
8
 *    notice, this list of conditions and the following disclaimer.
 
9
 * 2. Redistributions in binary form must reproduce the above copyright
 
10
 *    notice, this list of conditions and the following disclaimer in the
 
11
 *    documentation and/or other materials provided with the distribution.
 
12
 *
 
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 
14
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 
15
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 
16
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 
17
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 
18
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 
19
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 
20
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 
21
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 
22
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 
23
 * THE POSSIBILITY OF SUCH DAMAGE.
 
24
 */
 
25
 
 
26
#ifndef JSNPObject_h
 
27
#define JSNPObject_h
 
28
 
 
29
#if ENABLE(NETSCAPE_PLUGIN_API)
 
30
 
 
31
#include <JavaScriptCore/JSGlobalObject.h>
 
32
#include <JavaScriptCore/JSObject.h>
 
33
#include <JavaScriptCore/ObjectPrototype.h>
 
34
 
 
35
typedef void* NPIdentifier;
 
36
struct NPObject;
 
37
 
 
38
namespace WebKit {
 
39
 
 
40
class NPRuntimeObjectMap;
 
41
    
 
42
// JSNPObject is a JSObject that wraps an NPObject.
 
43
 
 
44
class JSNPObject : public JSC::JSDestructibleObject {
 
45
public:
 
46
    typedef JSC::JSDestructibleObject Base;
 
47
 
 
48
    static JSNPObject* create(JSC::JSGlobalObject* globalObject, NPRuntimeObjectMap* objectMap, NPObject* npObject)
 
49
    {
 
50
        JSC::Structure* structure = createStructure(globalObject->globalData(), globalObject, globalObject->objectPrototype());
 
51
        JSNPObject* object = new (JSC::allocateCell<JSNPObject>(globalObject->globalData().heap)) JSNPObject(globalObject, structure, objectMap, npObject);
 
52
        object->finishCreation(globalObject);
 
53
        return object;
 
54
    }
 
55
 
 
56
    ~JSNPObject();
 
57
    static void destroy(JSCell*);
 
58
 
 
59
    void invalidate();
 
60
 
 
61
    // Used to invalidate an NPObject asynchronously.
 
62
    NPObject* leakNPObject();
 
63
 
 
64
    JSC::JSValue callMethod(JSC::ExecState*, NPIdentifier methodName);
 
65
    JSC::JSValue callObject(JSC::ExecState*);
 
66
    JSC::JSValue callConstructor(JSC::ExecState*);
 
67
 
 
68
    static const JSC::ClassInfo s_info;
 
69
 
 
70
    NPObject* npObject() const { return m_npObject; }
 
71
 
 
72
protected:
 
73
    void finishCreation(JSC::JSGlobalObject*);
 
74
 
 
75
private:
 
76
    JSNPObject(JSC::JSGlobalObject*, JSC::Structure*, NPRuntimeObjectMap*, NPObject*);
 
77
 
 
78
    static const unsigned StructureFlags = JSC::OverridesGetOwnPropertySlot | JSC::OverridesGetPropertyNames | JSObject::StructureFlags;
 
79
    
 
80
    static JSC::Structure* createStructure(JSC::JSGlobalData& globalData, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
 
81
    {
 
82
        return JSC::Structure::create(globalData, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), &s_info);
 
83
    }
 
84
 
 
85
    static JSC::CallType getCallData(JSC::JSCell*, JSC::CallData&);
 
86
    static JSC::ConstructType getConstructData(JSC::JSCell*, JSC::ConstructData&);
 
87
 
 
88
    static bool getOwnPropertySlot(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::PropertySlot&);
 
89
    static bool getOwnPropertyDescriptor(JSC::JSObject*, JSC::ExecState*, JSC::PropertyName, JSC::PropertyDescriptor&);
 
90
    static void put(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName, JSC::JSValue, JSC::PutPropertySlot&);
 
91
 
 
92
    static bool deleteProperty(JSC::JSCell*, JSC::ExecState*, JSC::PropertyName);
 
93
    static bool deletePropertyByIndex(JSC::JSCell*, JSC::ExecState*, unsigned propertyName);
 
94
 
 
95
    bool deleteProperty(JSC::ExecState*, NPIdentifier propertyName);
 
96
 
 
97
    static void getOwnPropertyNames(JSC::JSObject*, JSC::ExecState*, JSC::PropertyNameArray&, JSC::EnumerationMode);
 
98
 
 
99
    static JSC::JSValue propertyGetter(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 
100
    static JSC::JSValue methodGetter(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 
101
    static JSC::JSObject* throwInvalidAccessError(JSC::ExecState*);
 
102
 
 
103
    NPRuntimeObjectMap* m_objectMap;
 
104
    NPObject* m_npObject;
 
105
};
 
106
 
 
107
} // namespace WebKit
 
108
 
 
109
#endif // ENABLE(NETSCAPE_PLUGIN_API)
 
110
 
 
111
#endif // JSNPObject_h