summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-08-24 07:50:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-08-24 07:50:47 -0700
commitc570a147a94b126d4172c30914f53dea17b4c8f5 (patch)
tree99c11741887d21f65d67c5bbdab58b7ba2a5d4d5 /WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
parentc952714bc6809a5ad081baaf9fcc04107b92ea3f (diff)
parent6c65f16005b91786c2b7c0791b9ea1dd684d57f4 (diff)
downloadexternal_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.zip
external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.gz
external_webkit-c570a147a94b126d4172c30914f53dea17b4c8f5.tar.bz2
Merge changes I2e7e2317,Ie6ccde3a,I3e89f231,Id06ff339,I268dfe7d,Icaf70d9f,Ie234f1a0,Iff5c7aaa,I69b75bf0,Ifbf384f4
* changes: Merge WebKit at r65615 : Update WebKit revision number Merge WebKit at r65615 : Ignore http/tests/appcache/origin-quota.html Merge WebKit at r65615 : Android-specific results for Geolocation tests. Merge WebKit at r65615 : Fix GraphicsContext and ImageBuffer. Merge WebKit at r65615 : processingUserGesture() is now static. Merge WebKit at r65615 : UTF8String() becomes utf8(). Merge WebKit at r65615 : Fix include paths for string headers. Merge WebKit at r65615 : Fix Makefiles. Merge WebKit at r65615 : Fix conflicts. Merge WebKit at r65615 : Initial merge by git.
Diffstat (limited to 'WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp')
-rw-r--r--WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp75
1 files changed, 25 insertions, 50 deletions
diff --git a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
index 86f2eb5..24ac47c 100644
--- a/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp
@@ -49,48 +49,38 @@
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::FunctionTemplate>, shadowTemplate, ());
+ if (shadowTemplate.IsEmpty()) {
+ shadowTemplate = v8::Persistent<v8::FunctionTemplate>::New(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);
}
- HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder());
+ v8::Local<v8::Function> shadowConstructor = shadowTemplate->GetFunction();
+ if (shadowConstructor.IsEmpty())
+ return v8::Local<v8::Object>();
- // Fast case for named elements that are not there.
+ 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;
+}
+
+v8::Handle<v8::Value> V8HTMLDocument::GetNamedProperty(HTMLDocument* htmlDocument, const AtomicString& key)
+{
if (!htmlDocument->hasNamedItem(key.impl()) && !htmlDocument->hasExtraNamedItem(key.impl()))
return v8::Handle<v8::Value>();
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 +94,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 +176,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 +191,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;
}