summaryrefslogtreecommitdiffstats
path: root/WebCore/bindings/v8/custom
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bindings/v8/custom')
-rw-r--r--WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp13
-rw-r--r--WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp15
-rw-r--r--WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp139
-rw-r--r--WebCore/bindings/v8/custom/V8EntryCustom.cpp61
-rw-r--r--WebCore/bindings/v8/custom/V8EventCustom.cpp3
5 files changed, 226 insertions, 5 deletions
diff --git a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
index 7ca18ab..c8a975b 100644
--- a/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMStringMapCustom.cpp
@@ -33,6 +33,7 @@
#include "DOMStringMap.h"
#include "V8Binding.h"
+#include "V8DOMWrapper.h"
namespace WebCore {
@@ -93,4 +94,16 @@ v8::Handle<v8::Value> V8DOMStringMap::namedPropertySetter(v8::Local<v8::String>
return value;
}
+v8::Handle<v8::Value> toV8(DOMStringMap* impl)
+{
+ if (!impl)
+ return v8::Null();
+ v8::Handle<v8::Object> wrapper = V8DOMStringMap::wrap(impl);
+ // Add a hidden reference from the element to the DOMStringMap.
+ Element* element = impl->element();
+ if (!wrapper.IsEmpty() && element)
+ V8DOMWrapper::setHiddenWindowReference(element->document()->frame(), wrapper);
+ return wrapper;
+}
+
} // namespace WebCore
diff --git a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
index 45cb1b4..f7c75f7 100644
--- a/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp
@@ -605,9 +605,11 @@ bool V8DOMWindow::namedSecurityCheck(v8::Local<v8::Object> host, v8::Local<v8::V
if (key->IsString()) {
String name = toWebCoreString(key);
-
- // Allow access of GET and HAS if index is a subframe.
- if ((type == v8::ACCESS_GET || type == v8::ACCESS_HAS) && target->tree()->child(name))
+ // Notice that we can't call HasRealNamedProperty for ACCESS_HAS
+ // because that would generate infinite recursion.
+ if (type == v8::ACCESS_HAS && target->tree()->child(name))
+ return true;
+ if (type == v8::ACCESS_GET && target->tree()->child(name) && !host->HasRealNamedProperty(key->ToString()))
return true;
}
@@ -628,8 +630,11 @@ bool V8DOMWindow::indexedSecurityCheck(v8::Local<v8::Object> host, uint32_t inde
if (!target)
return false;
- // Allow access of GET and HAS if index is a subframe.
- if ((type == v8::ACCESS_GET || type == v8::ACCESS_HAS) && target->tree()->child(index))
+ // Notice that we can't call HasRealNamedProperty for ACCESS_HAS
+ // because that would generate infinite recursion.
+ if (type == v8::ACCESS_HAS && target->tree()->child(index))
+ return true;
+ if (type == v8::ACCESS_GET && target->tree()->child(index) && !host->HasRealIndexedProperty(index))
return true;
return V8BindingSecurity::canAccessFrame(V8BindingState::Only(), target, false);
diff --git a/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
new file mode 100644
index 0000000..286b154
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8DirectoryEntryCustom.cpp
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "V8DirectoryEntry.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "DirectoryEntry.h"
+#include "ExceptionCode.h"
+#include "V8Binding.h"
+#include "V8BindingMacros.h"
+#include "V8EntryCallback.h"
+#include "V8ErrorCallback.h"
+#include "V8Flags.h"
+#include "V8Proxy.h"
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8DirectoryEntry::getDirectoryCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.DirectoryEntry.getDirectory");
+ DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder());
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]);
+ if (args.Length() <= 1) {
+ imp->getDirectory(path);
+ return v8::Handle<v8::Value>();
+ }
+ RefPtr<Flags> flags;
+ if (!isUndefinedOrNull(args[1]) && args[1]->IsObject() && !V8Flags::HasInstance(args[1])) {
+ EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[1]));
+ flags = Flags::create();
+ v8::Local<v8::Value> v8Create = object->Get(v8::String::New("create"));
+ if (!v8Create.IsEmpty() && !isUndefinedOrNull(v8Create)) {
+ EXCEPTION_BLOCK(bool, isCreate, v8Create->BooleanValue());
+ flags->setCreate(isCreate);
+ }
+ v8::Local<v8::Value> v8Exclusive = object->Get(v8::String::New("exclusive"));
+ if (!v8Exclusive.IsEmpty() && !isUndefinedOrNull(v8Exclusive)) {
+ EXCEPTION_BLOCK(bool, isExclusive, v8Exclusive->BooleanValue());
+ flags->setExclusive(isExclusive);
+ }
+ } else {
+ EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+ flags = adoptRef(tmp_flags);
+ }
+ RefPtr<EntryCallback> successCallback;
+ if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
+ if (!args[2]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ successCallback = V8EntryCallback::create(args[2], getScriptExecutionContext());
+ }
+ RefPtr<ErrorCallback> errorCallback;
+ if (args.Length() > 3 && !args[3]->IsNull() && !args[3]->IsUndefined()) {
+ if (!args[3]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ errorCallback = V8ErrorCallback::create(args[3], getScriptExecutionContext());
+ }
+ imp->getDirectory(path, flags, successCallback, errorCallback);
+ return v8::Handle<v8::Value>();
+}
+
+v8::Handle<v8::Value> V8DirectoryEntry::getFileCallback(const v8::Arguments& args)
+{
+ INC_STATS("DOM.DirectoryEntry.getFile");
+ DirectoryEntry* imp = V8DirectoryEntry::toNative(args.Holder());
+ STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<WithUndefinedOrNullCheck>, path, args[0]);
+ if (args.Length() <= 1) {
+ imp->getFile(path);
+ return v8::Handle<v8::Value>();
+ }
+ RefPtr<Flags> flags;
+ if (!isUndefinedOrNull(args[1]) && args[1]->IsObject() && !V8Flags::HasInstance(args[1])) {
+ EXCEPTION_BLOCK(v8::Handle<v8::Object>, object, v8::Handle<v8::Object>::Cast(args[1]));
+ flags = Flags::create();
+ v8::Local<v8::Value> v8Create = object->Get(v8::String::New("create"));
+ if (!v8Create.IsEmpty() && !isUndefinedOrNull(v8Create)) {
+ EXCEPTION_BLOCK(bool, isCreate, v8Create->BooleanValue());
+ flags->setCreate(isCreate);
+ }
+ v8::Local<v8::Value> v8Exclusive = object->Get(v8::String::New("exclusive"));
+ if (!v8Exclusive.IsEmpty() && !isUndefinedOrNull(v8Exclusive)) {
+ EXCEPTION_BLOCK(bool, isExclusive, v8Exclusive->BooleanValue());
+ flags->setExclusive(isExclusive);
+ }
+ } else {
+ EXCEPTION_BLOCK(Flags*, tmp_flags, V8Flags::HasInstance(args[1]) ? V8Flags::toNative(v8::Handle<v8::Object>::Cast(args[1])) : 0);
+ flags = adoptRef(tmp_flags);
+ }
+ RefPtr<EntryCallback> successCallback;
+ if (args.Length() > 2 && !args[2]->IsNull() && !args[2]->IsUndefined()) {
+ if (!args[2]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ successCallback = V8EntryCallback::create(args[2], getScriptExecutionContext());
+ }
+ RefPtr<ErrorCallback> errorCallback;
+ if (args.Length() > 3 && !args[3]->IsNull() && !args[3]->IsUndefined()) {
+ if (!args[3]->IsObject())
+ return throwError(TYPE_MISMATCH_ERR);
+ errorCallback = V8ErrorCallback::create(args[3], getScriptExecutionContext());
+ }
+ imp->getFile(path, flags, successCallback, errorCallback);
+ return v8::Handle<v8::Value>();
+}
+
+
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/WebCore/bindings/v8/custom/V8EntryCustom.cpp b/WebCore/bindings/v8/custom/V8EntryCustom.cpp
new file mode 100644
index 0000000..c02cd6f
--- /dev/null
+++ b/WebCore/bindings/v8/custom/V8EntryCustom.cpp
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google 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:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * 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.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "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 THE COPYRIGHT
+ * OWNER 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 "Entry.h"
+
+#if ENABLE(FILE_SYSTEM)
+
+#include "V8Attr.h"
+#include "V8Binding.h"
+#include "V8BindingState.h"
+#include "V8DirectoryEntry.h"
+#include "V8Entry.h"
+#include "V8FileEntry.h"
+#include "V8Proxy.h"
+#include <wtf/RefPtr.h>
+
+namespace WebCore {
+
+v8::Handle<v8::Value> toV8(Entry* impl)
+{
+ if (!impl)
+ return v8::Null();
+
+ if (impl->isFile())
+ return toV8(static_cast<FileEntry*>(impl));
+
+ ASSERT(impl->isDirectory());
+ return toV8(static_cast<DirectoryEntry*>(impl));
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(FILE_SYSTEM)
diff --git a/WebCore/bindings/v8/custom/V8EventCustom.cpp b/WebCore/bindings/v8/custom/V8EventCustom.cpp
index e0bb02b..f96ba7a 100644
--- a/WebCore/bindings/v8/custom/V8EventCustom.cpp
+++ b/WebCore/bindings/v8/custom/V8EventCustom.cpp
@@ -43,6 +43,7 @@
#include "V8DeviceMotionEvent.h"
#include "V8DeviceOrientationEvent.h"
#include "V8ErrorEvent.h"
+#include "V8HashChangeEvent.h"
#include "V8IDBErrorEvent.h"
#include "V8IDBSuccessEvent.h"
#include "V8KeyboardEvent.h"
@@ -120,6 +121,8 @@ v8::Handle<v8::Value> toV8(Event* impl)
#endif
return toV8(static_cast<UIEvent*>(impl));
}
+ if (impl->isHashChangeEvent())
+ return toV8(static_cast<HashChangeEvent*>(impl));
if (impl->isMutationEvent())
return toV8(static_cast<MutationEvent*>(impl));
if (impl->isOverflowEvent())