diff options
Diffstat (limited to 'WebCore/bindings/v8/custom')
19 files changed, 155 insertions, 123 deletions
diff --git a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp index 6ae3a3e..2c89b95 100644 --- a/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.cpp @@ -36,7 +36,7 @@ #include "V8Binding.h" #include "V8Proxy.h" #include "V8Int8Array.h" -#include "V8FloatArray.h" +#include "V8Float32Array.h" #include "V8Int32Array.h" #include "V8Int16Array.h" #include "V8Uint8Array.h" @@ -52,7 +52,7 @@ v8::Handle<v8::Value> toV8(ArrayBufferView* impl) if (impl->isByteArray()) return toV8(static_cast<Int8Array*>(impl)); if (impl->isFloatArray()) - return toV8(static_cast<FloatArray*>(impl)); + return toV8(static_cast<Float32Array*>(impl)); if (impl->isIntArray()) return toV8(static_cast<Int32Array*>(impl)); if (impl->isShortArray()) diff --git a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp index 4cc6ac2..7d1cfc1 100644 --- a/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp +++ b/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp @@ -33,8 +33,10 @@ #include "V8Console.h" #include "Console.h" +#include "MemoryInfo.h" #include "ScriptProfile.h" #include "V8Binding.h" +#include "V8MemoryInfo.h" #include "V8Proxy.h" #include "V8ScriptProfile.h" @@ -42,11 +44,23 @@ namespace WebCore { typedef Vector<RefPtr<ScriptProfile> > ProfilesArray; -v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String>, const v8::AccessorInfo&) +v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { INC_STATS("DOM.Console.profilesAccessorGetter"); - // FIXME: Provide a real implementation. - return v8::Array::New(0); + Console* imp = V8Console::toNative(info.Holder()); + const ProfilesArray& profiles = imp->profiles(); + v8::Handle<v8::Array> result = v8::Array::New(profiles.size()); + int index = 0; + ProfilesArray::const_iterator end = profiles.end(); + for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter) + result->Set(v8::Integer::New(index++), toV8(iter->get())); + return result; +} + +v8::Handle<v8::Value> V8Console::memoryAccessorGetter(v8::Local<v8::String>, const v8::AccessorInfo&) +{ + INC_STATS("DOM.Console.memoryAccessorGetter"); + return toV8(MemoryInfo::create()); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp index 5e20e376..18f27cb 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.cpp @@ -26,15 +26,16 @@ #include "config.h" #include "V8CustomPositionCallback.h" -#include "Frame.h" +#include "ScriptExecutionContext.h" #include "V8CustomVoidCallback.h" // For invokeCallback #include "V8Geoposition.h" +#include "V8Proxy.h" namespace WebCore { -V8CustomPositionCallback::V8CustomPositionCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) +V8CustomPositionCallback::V8CustomPositionCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : PositionCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) { } @@ -47,7 +48,17 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position) { v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); + // ActiveDOMObject will null our pointer to the ScriptExecutionContext when it goes away. + ScriptExecutionContext* scriptContext = scriptExecutionContext(); + if (!scriptContext) + return; + + // The lookup of the proxy will fail if the Frame has been detached. + V8Proxy* proxy = V8Proxy::retrieve(scriptContext); + if (!proxy) + return; + + v8::Handle<v8::Context> context = proxy->context(); if (context.IsEmpty()) return; @@ -57,11 +68,11 @@ void V8CustomPositionCallback::handleEvent(Geoposition* position) toV8(position) }; - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); + // Protect the script context until the callback returns. + RefPtr<ScriptExecutionContext> protector(scriptContext); bool callbackReturnValue = false; - invokeCallback(m_callback, 1, argv, callbackReturnValue, m_frame->document()); + invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptContext); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomPositionCallback.h b/WebCore/bindings/v8/custom/V8CustomPositionCallback.h index d2290ee..61db922 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionCallback.h +++ b/WebCore/bindings/v8/custom/V8CustomPositionCallback.h @@ -27,6 +27,7 @@ #define V8CustomPositionCallback_h #include "PositionCallback.h" + #include <v8.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -35,23 +36,23 @@ namespace WebCore { class Frame; class Geoposition; +class ScriptExecutionContext; class V8CustomPositionCallback : public PositionCallback { public: - static PassRefPtr<V8CustomPositionCallback> create(v8::Local<v8::Value> value, Frame* frame) + static PassRefPtr<V8CustomPositionCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) { ASSERT(value->IsObject()); - return adoptRef(new V8CustomPositionCallback(value->ToObject(), frame)); + return adoptRef(new V8CustomPositionCallback(value->ToObject(), context)); } virtual ~V8CustomPositionCallback(); virtual void handleEvent(Geoposition*); private: - V8CustomPositionCallback(v8::Local<v8::Object>, Frame*); + V8CustomPositionCallback(v8::Local<v8::Object>, ScriptExecutionContext*); v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; }; } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp index bd42d94..36b5e04 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.cpp @@ -26,15 +26,16 @@ #include "config.h" #include "V8CustomPositionErrorCallback.h" -#include "Frame.h" +#include "ScriptExecutionContext.h" #include "V8CustomVoidCallback.h" // For invokeCallback #include "V8PositionError.h" +#include "V8Proxy.h" namespace WebCore { -V8CustomPositionErrorCallback::V8CustomPositionErrorCallback(v8::Local<v8::Object> callback, Frame* frame) - : m_callback(v8::Persistent<v8::Object>::New(callback)) - , m_frame(frame) +V8CustomPositionErrorCallback::V8CustomPositionErrorCallback(v8::Local<v8::Object> callback, ScriptExecutionContext* context) + : PositionErrorCallback(context) + , m_callback(v8::Persistent<v8::Object>::New(callback)) { } @@ -47,7 +48,17 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error) { v8::HandleScope handleScope; - v8::Handle<v8::Context> context = V8Proxy::context(m_frame.get()); + // ActiveDOMObject will null our pointer to the ScriptExecutionContext when it goes away. + ScriptExecutionContext* scriptContext = scriptExecutionContext(); + if (!scriptContext) + return; + + // The lookup of the proxy will fail if the Frame has been detached. + V8Proxy* proxy = V8Proxy::retrieve(scriptContext); + if (!proxy) + return; + + v8::Handle<v8::Context> context = proxy->context(); if (context.IsEmpty()) return; @@ -57,11 +68,11 @@ void V8CustomPositionErrorCallback::handleEvent(PositionError* error) toV8(error) }; - // Protect the frame until the callback returns. - RefPtr<Frame> protector(m_frame); + // Protect the script context until the callback returns. + RefPtr<ScriptExecutionContext> protector(scriptContext); bool callbackReturnValue = false; - invokeCallback(m_callback, 1, argv, callbackReturnValue, m_frame->document()); + invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptContext); } } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h index aaf56a7..5211b60 100644 --- a/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h +++ b/WebCore/bindings/v8/custom/V8CustomPositionErrorCallback.h @@ -27,6 +27,7 @@ #define V8CustomPositionErrorCallback_h #include "PositionErrorCallback.h" + #include <v8.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -35,23 +36,23 @@ namespace WebCore { class Frame; class PositionError; +class ScriptExecutionContext; class V8CustomPositionErrorCallback : public PositionErrorCallback { public: - static PassRefPtr<V8CustomPositionErrorCallback> create(v8::Local<v8::Value> value, Frame* frame) + static PassRefPtr<V8CustomPositionErrorCallback> create(v8::Local<v8::Value> value, ScriptExecutionContext* context) { ASSERT(value->IsObject()); - return adoptRef(new V8CustomPositionErrorCallback(value->ToObject(), frame)); + return adoptRef(new V8CustomPositionErrorCallback(value->ToObject(), context)); } virtual ~V8CustomPositionErrorCallback(); virtual void handleEvent(PositionError*); private: - V8CustomPositionErrorCallback(v8::Local<v8::Object>, Frame*); + V8CustomPositionErrorCallback(v8::Local<v8::Object>, ScriptExecutionContext*); v8::Persistent<v8::Object> m_callback; - RefPtr<Frame> m_frame; }; } // namespace WebCore diff --git a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp index 3bdc79b..6603344 100644 --- a/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp @@ -39,6 +39,7 @@ #include "V8Proxy.h" #include "V8SQLError.h" #include "V8SQLTransaction.h" +#include <wtf/Assertions.h> namespace WebCore { @@ -52,9 +53,16 @@ bool V8SQLStatementErrorCallback::handleEvent(ScriptExecutionContext* context, S v8::Context::Scope scope(v8Context); + v8::Handle<v8::Value> transactionHandle = toV8(transaction); + v8::Handle<v8::Value> errorHandle = toV8(error); + if (transactionHandle.IsEmpty() || errorHandle.IsEmpty()) { + CRASH(); + return true; + } + v8::Handle<v8::Value> argv[] = { - toV8(transaction), - toV8(error) + transactionHandle, + errorHandle }; // Protect the context until the callback returns. diff --git a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp index bc7bb6c..25e7e0d 100644 --- a/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp +++ b/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp @@ -40,6 +40,7 @@ namespace WebCore { V8CustomVoidCallback::V8CustomVoidCallback(v8::Local<v8::Object> callback, ScriptExecutionContext *context) : m_callback(v8::Persistent<v8::Object>::New(callback)) , m_scriptExecutionContext(context) + , m_worldContext(UseCurrentWorld) { } @@ -52,7 +53,7 @@ void V8CustomVoidCallback::handleEvent() { v8::HandleScope handleScope; - v8::Handle<v8::Context> v8Context = toV8Context(m_scriptExecutionContext.get(), WorldContextHandle(UseCurrentWorld)); + v8::Handle<v8::Context> v8Context = toV8Context(m_scriptExecutionContext.get(), m_worldContext); if (v8Context.IsEmpty()) return; diff --git a/WebCore/bindings/v8/custom/V8CustomVoidCallback.h b/WebCore/bindings/v8/custom/V8CustomVoidCallback.h index 03a47bc..94bb782 100644 --- a/WebCore/bindings/v8/custom/V8CustomVoidCallback.h +++ b/WebCore/bindings/v8/custom/V8CustomVoidCallback.h @@ -32,6 +32,7 @@ #define V8CustomVoidCallback_h #include "VoidCallback.h" +#include "WorldContextHandle.h" #include <v8.h> #include <wtf/PassRefPtr.h> #include <wtf/RefPtr.h> @@ -56,6 +57,7 @@ private: v8::Persistent<v8::Object> m_callback; RefPtr<ScriptExecutionContext> m_scriptExecutionContext; + WorldContextHandle m_worldContext; }; // Returns false if callback failed (null, wrong type, or threw exception). diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp index 4867cfe..25564ee 100644 --- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp +++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp @@ -72,7 +72,7 @@ #if ENABLE(3D_CANVAS) #include "V8ArrayBuffer.h" #include "V8Int8Array.h" -#include "V8FloatArray.h" +#include "V8Float32Array.h" #include "V8Int32Array.h" #include "V8Int16Array.h" #include "V8Uint8Array.h" @@ -308,7 +308,7 @@ v8::Handle<v8::Value> V8DOMWindow::WebGLUnsignedIntArrayAccessorGetter(v8::Local v8::Handle<v8::Value> V8DOMWindow::WebGLFloatArrayAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) { DOMWindow* window = V8DOMWindow::toNative(info.Holder()); - return V8DOMWrapper::getConstructor(&V8FloatArray::info, window); + return V8DOMWrapper::getConstructor(&V8Float32Array::info, window); } #endif diff --git a/WebCore/bindings/v8/custom/V8FloatArrayCustom.cpp b/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp index ebc65db..93c5e91 100644 --- a/WebCore/bindings/v8/custom/V8FloatArrayCustom.cpp +++ b/WebCore/bindings/v8/custom/V8Float32ArrayCustom.cpp @@ -33,34 +33,34 @@ #if ENABLE(3D_CANVAS) #include "ArrayBuffer.h" -#include "FloatArray.h" +#include "Float32Array.h" #include "V8Binding.h" #include "V8ArrayBuffer.h" #include "V8ArrayBufferViewCustom.h" -#include "V8FloatArray.h" +#include "V8Float32Array.h" #include "V8Proxy.h" namespace WebCore { -v8::Handle<v8::Value> V8FloatArray::constructorCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Float32Array::constructorCallback(const v8::Arguments& args) { - INC_STATS("DOM.FloatArray.Contructor"); + INC_STATS("DOM.Float32Array.Contructor"); - return constructWebGLArray<FloatArray, float>(args, &info, v8::kExternalFloatArray); + return constructWebGLArray<Float32Array, float>(args, &info, v8::kExternalFloatArray); } -v8::Handle<v8::Value> V8FloatArray::setCallback(const v8::Arguments& args) +v8::Handle<v8::Value> V8Float32Array::setCallback(const v8::Arguments& args) { - INC_STATS("DOM.FloatArray.set()"); - return setWebGLArrayHelper<FloatArray, V8FloatArray>(args); + INC_STATS("DOM.Float32Array.set()"); + return setWebGLArrayHelper<Float32Array, V8Float32Array>(args); } -v8::Handle<v8::Value> toV8(FloatArray* impl) +v8::Handle<v8::Value> toV8(Float32Array* impl) { if (!impl) return v8::Null(); - v8::Handle<v8::Object> wrapper = V8FloatArray::wrap(impl); + v8::Handle<v8::Object> wrapper = V8Float32Array::wrap(impl); if (!wrapper.IsEmpty()) wrapper->SetIndexedPropertiesToExternalArrayData(impl->baseAddress(), v8::kExternalFloatArray, impl->length()); return wrapper; diff --git a/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp index 7173be1..649c45f 100644 --- a/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp +++ b/WebCore/bindings/v8/custom/V8GeolocationCustom.cpp @@ -26,8 +26,8 @@ #include "config.h" #include "V8Geolocation.h" +#include "Frame.h" #include "Geolocation.h" - #include "V8Binding.h" #include "V8CustomPositionCallback.h" #include "V8CustomPositionErrorCallback.h" @@ -56,8 +56,7 @@ static PassRefPtr<PositionCallback> createPositionCallback(v8::Local<v8::Value> return 0; } - Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); - return V8CustomPositionCallback::create(value, frame); + return V8CustomPositionCallback::create(value, getScriptExecutionContext()); } static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(v8::Local<v8::Value> value, bool& succeeded) @@ -75,8 +74,7 @@ static PassRefPtr<PositionErrorCallback> createPositionErrorCallback(v8::Local<v return 0; } - Frame* frame = V8Proxy::retrieveFrameForCurrentContext(); - return V8CustomPositionErrorCallback::create(value, frame); + return V8CustomPositionErrorCallback::create(value, getScriptExecutionContext()); } static PassRefPtr<PositionOptions> createPositionOptions(v8::Local<v8::Value> value, bool& succeeded) diff --git a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp index 66e326c..d2f8c96 100644 --- a/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLCanvasElementCustom.cpp @@ -105,7 +105,7 @@ v8::Handle<v8::Value> V8HTMLCanvasElement::toDataURLCallback(const v8::Arguments HTMLCanvasElement* canvas = V8HTMLCanvasElement::toNative(holder); String type = toWebCoreString(args[0]); ExceptionCode ec = 0; - String result = canvas->toDataURL(type, quality, ec); + String result = canvas->toDataURL(type, &quality, ec); V8Proxy::setDOMException(ec); return v8StringOrUndefined(result); } diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp index 86f2eb5..e6f1b8f 100644 --- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp +++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp @@ -49,48 +49,37 @@ namespace WebCore { -v8::Handle<v8::Boolean> V8HTMLDocument::namedPropertyDeleter(v8::Local<v8::String> name, const v8::AccessorInfo& info) +v8::Local<v8::Object> V8HTMLDocument::WrapInShadowObject(v8::Local<v8::Object> wrapper, Node* impl) { - // Only handle document.all. Insert the marker object into the - // shadow internal field to signal that document.all is no longer - // shadowed. - AtomicString key = v8StringToAtomicWebCoreString(name); - DEFINE_STATIC_LOCAL(const AtomicString, all, ("all")); - if (key != all) - return deletionNotHandledByInterceptor(); - - ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount); - v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex); - info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, marker); - return v8::True(); -} - -v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) -{ - INC_STATS("DOM.HTMLDocument.NamedPropertyGetter"); - AtomicString key = v8StringToAtomicWebCoreString(name); - - // Special case for document.all. If the value in the shadow - // internal field is not the marker object, then document.all has - // been temporarily shadowed and we return the value. - DEFINE_STATIC_LOCAL(const AtomicString, all, ("all")); - if (key == all) { - ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount); - v8::Local<v8::Value> marker = info.Holder()->GetInternalField(V8HTMLDocument::markerIndex); - v8::Local<v8::Value> value = info.Holder()->GetInternalField(V8HTMLDocument::shadowIndex); - if (marker != value) - return value; + DEFINE_STATIC_LOCAL(v8::Persistent<v8::Function>, shadowConstructor, ()); + if (shadowConstructor.IsEmpty()) { + v8::Local<v8::FunctionTemplate> shadowTemplate = v8::FunctionTemplate::New(); + if (shadowTemplate.IsEmpty()) + return v8::Local<v8::Object>(); + shadowTemplate->SetClassName(v8::String::New("HTMLDocument")); + shadowTemplate->Inherit(V8HTMLDocument::GetTemplate()); + shadowTemplate->InstanceTemplate()->SetInternalFieldCount(V8HTMLDocument::internalFieldCount); + shadowConstructor = v8::Persistent<v8::Function>::New(shadowTemplate->GetFunction()); + if (shadowConstructor.IsEmpty()) + return v8::Local<v8::Object>(); } - HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder()); + ASSERT(!shadowConstructor.IsEmpty()); + v8::Local<v8::Object> shadow = shadowConstructor->NewInstance(); + if (shadow.IsEmpty()) + return v8::Local<v8::Object>(); + V8DOMWrapper::setDOMWrapper(shadow, &V8HTMLDocument::info, impl); + shadow->SetPrototype(wrapper); + return shadow; +} - // Fast case for named elements that are not there. - if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl())) - return v8::Handle<v8::Value>(); +v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key) +{ + ASSERT(htmlDocument->hasNamedItem(key.impl()) || htmlDocument->hasExtraNamedItem(key.impl())); RefPtr<HTMLCollection> items = htmlDocument->documentNamedItems(key); if (!items->length()) - return notHandledByInterceptor(); + return v8::Handle<v8::Value>(); if (items->length() == 1) { Node* node = items->firstItem(); @@ -104,13 +93,6 @@ v8::Handle<v8::Value> V8HTMLDocument::namedPropertyGetter(v8::Local<v8::String> return toV8(items.release()); } -v8::Handle<v8::Value> V8HTMLDocument::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo &info) -{ - INC_STATS("DOM.HTMLDocument.IndexedPropertyGetter"); - v8::Local<v8::Integer> indexV8 = v8::Integer::NewFromUnsigned(index); - return namedPropertyGetter(indexV8->ToString(), info); -} - // HTMLDocument ---------------------------------------------------------------- // Concatenates "args" to a string. If args is empty, returns empty string. @@ -193,10 +175,8 @@ v8::Handle<v8::Value> V8HTMLDocument::allAccessorGetter(v8::Local<v8::String> na void V8HTMLDocument::allAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) { - INC_STATS("DOM.HTMLDocument.all._set"); - v8::Handle<v8::Object> holder = info.Holder(); - ASSERT(info.Holder()->InternalFieldCount() == V8HTMLDocument::internalFieldCount); - info.Holder()->SetInternalField(V8HTMLDocument::shadowIndex, value); + // Just emulate a normal JS behaviour---install a property on this. + info.This()->ForceSet(name, value); } v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject) @@ -210,12 +190,6 @@ v8::Handle<v8::Value> toV8(HTMLDocument* impl, bool forceNewObject) if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame())) proxy->windowShell()->updateDocumentWrapper(wrapper); } - // Create marker object and insert it in two internal fields. - // This is used to implement temporary shadowing of document.all. - ASSERT(wrapper->InternalFieldCount() == V8HTMLDocument::internalFieldCount); - v8::Local<v8::Object> marker = v8::Object::New(); - wrapper->SetInternalField(V8HTMLDocument::markerIndex, marker); - wrapper->SetInternalField(V8HTMLDocument::shadowIndex, marker); return wrapper; } diff --git a/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp b/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp index 905b23d..d9da174 100644 --- a/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp +++ b/WebCore/bindings/v8/custom/V8NamedNodesCollection.cpp @@ -46,7 +46,7 @@ Node* V8NamedNodesCollection::itemWithName(const AtomicString& id) const { for (unsigned i = 0; i < m_nodes.size(); ++i) { Node* node = m_nodes[i].get(); - if (node->hasAttributes() && node->attributes()->id() == id) + if (node->hasID() && static_cast<Element*>(node)->getIdAttribute() == id) return node; } return 0; diff --git a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp index 20a5471..8cc3983 100644 --- a/WebCore/bindings/v8/custom/V8NodeListCustom.cpp +++ b/WebCore/bindings/v8/custom/V8NodeListCustom.cpp @@ -45,7 +45,7 @@ v8::Handle<v8::Value> V8NodeList::namedPropertyGetter(v8::Local<v8::String> name { INC_STATS("DOM.NodeList.NamedPropertyGetter"); NodeList* list = V8NodeList::toNative(info.Holder()); - String key = toWebCoreString(name); + AtomicString key = v8ValueToAtomicWebCoreString(name); // Length property cannot be overridden. DEFINE_STATIC_LOCAL(const AtomicString, length, ("length")); diff --git a/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp b/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp index 51a57c0..58f34bf 100644 --- a/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp +++ b/WebCore/bindings/v8/custom/V8PopStateEventCustom.cpp @@ -35,8 +35,6 @@ #include "SerializedScriptValue.h" #include "V8Proxy.h" -#include <v8.h> - namespace WebCore { v8::Handle<v8::Value> V8PopStateEvent::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) diff --git a/WebCore/bindings/v8/custom/V8StorageCustom.cpp b/WebCore/bindings/v8/custom/V8StorageCustom.cpp index 70d8a09..d0a0d92 100755 --- a/WebCore/bindings/v8/custom/V8StorageCustom.cpp +++ b/WebCore/bindings/v8/custom/V8StorageCustom.cpp @@ -79,6 +79,19 @@ v8::Handle<v8::Value> V8Storage::namedPropertyGetter(v8::Local<v8::String> name, return storageGetter(name, info); } +v8::Handle<v8::Integer> V8Storage::namedPropertyQuery(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info) +{ + INC_STATS("DOM.Storage.NamedPropertyQuery"); + + Storage* storage = V8Storage::toNative(info.Holder()); + String name = toWebCoreString(v8Name); + + if (storage->contains(name) && name != "length") + return v8::Integer::New(v8::None); + + return v8::Handle<v8::Integer>(); +} + static v8::Handle<v8::Value> storageSetter(v8::Local<v8::String> v8Name, v8::Local<v8::Value> v8Value, const v8::AccessorInfo& info) { Storage* storage = V8Storage::toNative(info.Holder()); diff --git a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp index 7a031b1..5da4b3e 100644 --- a/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp +++ b/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp @@ -44,7 +44,7 @@ #include "V8ArrayBufferView.h" #include "V8WebGLBuffer.h" #include "V8Int8Array.h" -#include "V8FloatArray.h" +#include "V8Float32Array.h" #include "V8WebGLFramebuffer.h" #include "V8Int32Array.h" #include "V8WebGLProgram.h" @@ -392,21 +392,21 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& FunctionToCall functionToCall) { // Forms: // * glUniform1fv(WebGLUniformLocation location, Array data); - // * glUniform1fv(WebGLUniformLocation location, FloatArray data); + // * glUniform1fv(WebGLUniformLocation location, Float32Array data); // * glUniform2fv(WebGLUniformLocation location, Array data); - // * glUniform2fv(WebGLUniformLocation location, FloatArray data); + // * glUniform2fv(WebGLUniformLocation location, Float32Array data); // * glUniform3fv(WebGLUniformLocation location, Array data); - // * glUniform3fv(WebGLUniformLocation location, FloatArray data); + // * glUniform3fv(WebGLUniformLocation location, Float32Array data); // * glUniform4fv(WebGLUniformLocation location, Array data); - // * glUniform4fv(WebGLUniformLocation location, FloatArray data); + // * glUniform4fv(WebGLUniformLocation location, Float32Array data); // * glVertexAttrib1fv(GLint index, Array data); - // * glVertexAttrib1fv(GLint index, FloatArray data); + // * glVertexAttrib1fv(GLint index, Float32Array data); // * glVertexAttrib2fv(GLint index, Array data); - // * glVertexAttrib2fv(GLint index, FloatArray data); + // * glVertexAttrib2fv(GLint index, Float32Array data); // * glVertexAttrib3fv(GLint index, Array data); - // * glVertexAttrib3fv(GLint index, FloatArray data); + // * glVertexAttrib3fv(GLint index, Float32Array data); // * glVertexAttrib4fv(GLint index, Array data); - // * glVertexAttrib4fv(GLint index, FloatArray data); + // * glVertexAttrib4fv(GLint index, Float32Array data); if (args.Length() != 2) { V8Proxy::setDOMException(SYNTAX_ERR); @@ -424,8 +424,8 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments& WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder()); - if (V8FloatArray::HasInstance(args[1])) { - FloatArray* array = V8FloatArray::toNative(args[1]->ToObject()); + if (V8Float32Array::HasInstance(args[1])) { + Float32Array* array = V8Float32Array::toNative(args[1]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (functionToCall) { @@ -592,13 +592,13 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, { // Forms: // * glUniformMatrix2fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix2fv(GLint location, GLboolean transpose, FloatArray data); + // * glUniformMatrix2fv(GLint location, GLboolean transpose, Float32Array data); // * glUniformMatrix3fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix3fv(GLint location, GLboolean transpose, FloatArray data); + // * glUniformMatrix3fv(GLint location, GLboolean transpose, Float32Array data); // * glUniformMatrix4fv(GLint location, GLboolean transpose, Array data); - // * glUniformMatrix4fv(GLint location, GLboolean transpose, FloatArray data); + // * glUniformMatrix4fv(GLint location, GLboolean transpose, Float32Array data); // - // FIXME: need to change to accept FloatArray as well. + // FIXME: need to change to accept Float32Array as well. if (args.Length() != 3) { V8Proxy::setDOMException(SYNTAX_ERR); return notHandledByInterceptor(); @@ -610,8 +610,8 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args, WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok); bool transpose = args[1]->BooleanValue(); - if (V8FloatArray::HasInstance(args[2])) { - FloatArray* array = V8FloatArray::toNative(args[2]->ToObject()); + if (V8Float32Array::HasInstance(args[2])) { + Float32Array* array = V8Float32Array::toNative(args[2]->ToObject()); ASSERT(array != NULL); ExceptionCode ec = 0; switch (matrixSize) { |