summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/js/JSDOMBinding.h
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/js/JSDOMBinding.h')
-rw-r--r--WebCore/bindings/js/JSDOMBinding.h174
1 files changed, 46 insertions, 128 deletions
diff --git a/WebCore/bindings/js/JSDOMBinding.h b/WebCore/bindings/js/JSDOMBinding.h
index 807bf82..209be3f 100644
--- a/WebCore/bindings/js/JSDOMBinding.h
+++ b/WebCore/bindings/js/JSDOMBinding.h
@@ -23,6 +23,8 @@
#define JSDOMBinding_h
#include "JSDOMGlobalObject.h"
+#include "JSDOMWrapper.h"
+#include "DOMWrapperWorld.h"
#include "JSSVGContextCache.h"
#include "Document.h"
#include <runtime/Completion.h>
@@ -52,21 +54,6 @@ namespace WebCore {
class SVGElement;
#endif
- // Base class for all objects in this binding except Window.
- class DOMObject : public JSC::JSObject {
- protected:
- explicit DOMObject(NonNullPassRefPtr<JSC::Structure> structure)
- : JSObject(structure)
- {
- }
-
- virtual bool defineOwnProperty(JSC::ExecState*, const JSC::Identifier&, JSC::PropertyDescriptor&, bool);
-
-#ifndef NDEBUG
- virtual ~DOMObject();
-#endif
- };
-
// FIXME: This class should collapse into DOMObject once all DOMObjects are
// updated to store a globalObject pointer.
class DOMObjectWithGlobalPointer : public DOMObject {
@@ -133,102 +120,6 @@ namespace WebCore {
}
};
- typedef JSC::WeakGCMap<void*, DOMObject*> DOMObjectWrapperMap;
- typedef JSC::WeakGCMap<StringImpl*, JSC::JSString*> JSStringCache;
-
- class DOMWrapperWorld : public RefCounted<DOMWrapperWorld> {
- public:
- static PassRefPtr<DOMWrapperWorld> create(JSC::JSGlobalData* globalData, bool isNormal)
- {
- return adoptRef(new DOMWrapperWorld(globalData, isNormal));
- }
- ~DOMWrapperWorld();
-
- void rememberDocument(Document* document) { documentsWithWrappers.add(document); }
- void forgetDocument(Document* document) { documentsWithWrappers.remove(document); }
-
- // FIXME: can we make this private?
- DOMObjectWrapperMap m_wrappers;
- JSStringCache m_stringCache;
-
- bool isNormal() const { return m_isNormal; }
-
- protected:
- DOMWrapperWorld(JSC::JSGlobalData*, bool isNormal);
-
- private:
- JSC::JSGlobalData* m_globalData;
- HashSet<Document*> documentsWithWrappers;
- bool m_isNormal;
- };
-
- // Map from static HashTable instances to per-GlobalData ones.
- class DOMObjectHashTableMap {
- public:
- static DOMObjectHashTableMap& mapFor(JSC::JSGlobalData&);
-
- ~DOMObjectHashTableMap()
- {
- HashMap<const JSC::HashTable*, JSC::HashTable>::iterator mapEnd = m_map.end();
- for (HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.begin(); iter != m_map.end(); ++iter)
- iter->second.deleteTable();
- }
-
- const JSC::HashTable* get(const JSC::HashTable* staticTable)
- {
- HashMap<const JSC::HashTable*, JSC::HashTable>::iterator iter = m_map.find(staticTable);
- if (iter != m_map.end())
- return &iter->second;
- return &m_map.set(staticTable, JSC::HashTable(*staticTable)).first->second;
- }
-
- private:
- HashMap<const JSC::HashTable*, JSC::HashTable> m_map;
- };
-
- class WebCoreJSClientData : public JSC::JSGlobalData::ClientData, public Noncopyable {
- friend class JSGlobalDataWorldIterator;
-
- public:
- WebCoreJSClientData(JSC::JSGlobalData* globalData)
- : m_normalWorld(DOMWrapperWorld::create(globalData, true))
- {
- m_worldSet.add(m_normalWorld.get());
- }
-
- virtual ~WebCoreJSClientData()
- {
- ASSERT(m_worldSet.contains(m_normalWorld.get()));
- ASSERT(m_worldSet.size() == 1);
- ASSERT(m_normalWorld->hasOneRef());
- m_normalWorld.clear();
- ASSERT(m_worldSet.isEmpty());
- }
-
- DOMWrapperWorld* normalWorld() { return m_normalWorld.get(); }
-
- void getAllWorlds(Vector<DOMWrapperWorld*>& worlds)
- {
- copyToVector(m_worldSet, worlds);
- }
-
- void rememberWorld(DOMWrapperWorld* world)
- {
- ASSERT(!m_worldSet.contains(world));
- m_worldSet.add(world);
- }
- void forgetWorld(DOMWrapperWorld* world)
- {
- ASSERT(m_worldSet.contains(world));
- m_worldSet.remove(world);
- }
-
- DOMObjectHashTableMap hashTableMap;
- private:
- HashSet<DOMWrapperWorld*> m_worldSet;
- RefPtr<DOMWrapperWorld> m_normalWorld;
- };
-
DOMObject* getCachedDOMObjectWrapper(JSC::ExecState*, void* objectHandle);
bool hasCachedDOMObjectWrapper(JSC::JSGlobalData*, void* objectHandle);
void cacheDOMObjectWrapper(JSC::ExecState*, void* objectHandle, DOMObject* wrapper);
@@ -237,8 +128,6 @@ namespace WebCore {
JSNode* getCachedDOMNodeWrapper(JSC::ExecState*, Document*, Node*);
void cacheDOMNodeWrapper(JSC::ExecState*, Document*, Node*, JSNode* wrapper);
- void forgetAllDOMNodesForDocument(Document*);
- void forgetWorldOfDOMNodesForDocument(Document*, DOMWrapperWorld*);
void updateDOMNodeDocument(Node*, Document* oldDocument, Document* newDocument);
void markDOMNodesForDocument(JSC::MarkStack&, Document*);
@@ -253,12 +142,6 @@ namespace WebCore {
JSC::Structure* getCachedDOMStructure(JSC::ExecState*, const JSC::ClassInfo*);
JSC::Structure* cacheDOMStructure(JSC::ExecState*, NonNullPassRefPtr<JSC::Structure>, const JSC::ClassInfo*);
- DOMWrapperWorld* currentWorld(JSC::ExecState*);
- DOMWrapperWorld* normalWorld(JSC::JSGlobalData&);
- DOMWrapperWorld* mainThreadNormalWorld();
- inline DOMWrapperWorld* debuggerWorld() { return mainThreadNormalWorld(); }
- inline DOMWrapperWorld* pluginWorld() { return mainThreadNormalWorld(); }
-
JSC::JSObject* getCachedDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*);
void cacheDOMConstructor(JSC::ExecState*, const JSC::ClassInfo*, JSC::JSObject* constructor);
@@ -375,8 +258,16 @@ namespace WebCore {
// object, to let the engine know that collecting the JSString wrapper is unlikely to save memory.
JSC::JSValue jsOwnedStringOrNull(JSC::ExecState*, const JSC::UString&);
- JSC::UString valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
- JSC::UString valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
+ String identifierToString(const JSC::Identifier&);
+ String ustringToString(const JSC::UString&);
+ JSC::UString stringToUString(const String&);
+
+ AtomicString identifierToAtomicString(const JSC::Identifier&);
+ AtomicString ustringToAtomicString(const JSC::UString&);
+ AtomicStringImpl* findAtomicString(const JSC::Identifier&);
+
+ String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null
+ String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined
// Returns a Date instance for the specified value, or null if the value is NaN or infinity.
JSC::JSValue jsDateOrNull(JSC::ExecState*, double);
@@ -417,18 +308,15 @@ namespace WebCore {
bool allowsAccessFromFrame(JSC::ExecState*, Frame*);
bool allowsAccessFromFrame(JSC::ExecState*, Frame*, String& message);
bool shouldAllowNavigation(JSC::ExecState*, Frame*);
+ bool allowSettingSrcToJavascriptURL(JSC::ExecState*, Element*, const String&, const String&);
+
void printErrorMessageForFrame(Frame*, const String& message);
- JSC::JSValue objectToStringFunctionGetter(JSC::ExecState*, const JSC::Identifier& propertyName, const JSC::PropertySlot&);
+ JSC::JSValue objectToStringFunctionGetter(JSC::ExecState*, JSC::JSValue, const JSC::Identifier& propertyName);
Frame* toLexicalFrame(JSC::ExecState*);
Frame* toDynamicFrame(JSC::ExecState*);
bool processingUserGesture(JSC::ExecState*);
KURL completeURL(JSC::ExecState*, const String& relativeURL);
-
- inline DOMWrapperWorld* currentWorld(JSC::ExecState* exec)
- {
- return static_cast<JSDOMGlobalObject*>(exec->lexicalGlobalObject())->world();
- }
inline JSC::JSValue jsString(JSC::ExecState* exec, const String& s)
{
@@ -437,7 +325,7 @@ namespace WebCore {
return jsEmptyString(exec);
if (stringImpl->length() == 1 && stringImpl->characters()[0] <= 0xFF)
- return jsString(exec, stringImpl->ustring());
+ return jsString(exec, stringToUString(s));
JSStringCache& stringCache = currentWorld(exec)->m_stringCache;
if (JSC::JSString* wrapper = stringCache.get(stringImpl))
@@ -446,6 +334,36 @@ namespace WebCore {
return jsStringSlowCase(exec, stringCache, stringImpl);
}
+ inline DOMObjectWrapperMap& domObjectWrapperMapFor(JSC::ExecState* exec)
+ {
+ return currentWorld(exec)->m_wrappers;
+ }
+
+ inline String ustringToString(const JSC::UString& u)
+ {
+ return u.rep();
+ }
+
+ inline JSC::UString stringToUString(const String& s)
+ {
+ return JSC::UString(s.impl());
+ }
+
+ inline String identifierToString(const JSC::Identifier& i)
+ {
+ return i.ustring().rep();
+ }
+
+ inline AtomicString ustringToAtomicString(const JSC::UString& u)
+ {
+ return AtomicString(u.rep());
+ }
+
+ inline AtomicString identifierToAtomicString(const JSC::Identifier& identifier)
+ {
+ return AtomicString(identifier.ustring().rep());
+ }
+
} // namespace WebCore
#endif // JSDOMBinding_h