Diff
Modified: trunk/Source/WebCore/ChangeLog (134119 => 134120)
--- trunk/Source/WebCore/ChangeLog 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/ChangeLog 2012-11-09 23:27:22 UTC (rev 134120)
@@ -1,3 +1,29 @@
+2012-11-09 Sadrul Habib Chowdhury <[email protected]>
+
+ CustomEvent: Allow taking in a serialized value during initialization.
+ https://bugs.webkit.org/show_bug.cgi?id=101348
+
+ Reviewed by Adam Barth.
+
+ If a CustomEvent is initialized using a serialized value, then for each access
+ to |detail|, the value is deserialized first. This way, each world gets a different
+ deserialization.
+
+ * UseV8.cmake:
+ * WebCore.gypi:
+ * bindings/v8/V8HiddenPropertyName.h:
+ (WebCore):
+ * bindings/v8/custom/V8CustomEventCustom.cpp: Copied from Source/WebCore/bindings/v8/V8HiddenPropertyName.h.
+ (WebCore):
+ (WebCore::V8CustomEvent::detailAccessorGetter):
+ * dom/CustomEvent.cpp:
+ (WebCore::CustomEvent::initCustomEvent):
+ (WebCore):
+ * dom/CustomEvent.h:
+ (CustomEvent):
+ (WebCore::CustomEvent::serializedScriptValue):
+ * dom/CustomEvent.idl:
+
2012-11-09 Brady Eidson <[email protected]>
Implement WebResourceBuffer::isEmpty()
Modified: trunk/Source/WebCore/UseV8.cmake (134119 => 134120)
--- trunk/Source/WebCore/UseV8.cmake 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/UseV8.cmake 2012-11-09 23:27:22 UTC (rev 134120)
@@ -84,6 +84,7 @@
bindings/v8/custom/V8ClipboardCustom.cpp
bindings/v8/custom/V8ConsoleCustom.cpp
bindings/v8/custom/V8CoordinatesCustom.cpp
+ bindings/v8/custom/V8CustomEventCustom.cpp
bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp
bindings/v8/custom/V8CustomXPathNSResolver.cpp
bindings/v8/custom/V8DOMFormDataCustom.cpp
Modified: trunk/Source/WebCore/WebCore.gypi (134119 => 134120)
--- trunk/Source/WebCore/WebCore.gypi 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/WebCore.gypi 2012-11-09 23:27:22 UTC (rev 134120)
@@ -2343,6 +2343,7 @@
'bindings/v8/custom/V8ClipboardCustom.cpp',
'bindings/v8/custom/V8ConsoleCustom.cpp',
'bindings/v8/custom/V8CoordinatesCustom.cpp',
+ 'bindings/v8/custom/V8CustomEventCustom.cpp',
'bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp',
'bindings/v8/custom/V8CustomXPathNSResolver.cpp',
'bindings/v8/custom/V8CustomXPathNSResolver.h',
Modified: trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h (134119 => 134120)
--- trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h 2012-11-09 23:27:22 UTC (rev 134120)
@@ -37,6 +37,7 @@
#define V8_HIDDEN_PROPERTIES(V) \
V(attributeListener) \
+ V(detail) \
V(document) \
V(domStringMap) \
V(domTokenList) \
Copied: trunk/Source/WebCore/bindings/v8/custom/V8CustomEventCustom.cpp (from rev 134119, trunk/Source/WebCore/bindings/v8/V8HiddenPropertyName.h) (0 => 134120)
--- trunk/Source/WebCore/bindings/v8/custom/V8CustomEventCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/v8/custom/V8CustomEventCustom.cpp 2012-11-09 23:27:22 UTC (rev 134120)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2012 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 "V8CustomEvent.h"
+
+#include "BindingState.h"
+#include "ContextFeatures.h"
+#include "Dictionary.h"
+#include "ExceptionCode.h"
+#include "Frame.h"
+#include "RuntimeEnabledFeatures.h"
+#include "ScriptState.h"
+#include "ScriptValue.h"
+#include "V8Binding.h"
+#include "V8DOMWrapper.h"
+#include "V8Event.h"
+#include "V8HiddenPropertyName.h"
+
+namespace WebCore {
+
+v8::Handle<v8::Value> V8CustomEvent::detailAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
+{
+ INC_STATS("DOM.CustomEvent.detail._get");
+ CustomEvent* imp = V8CustomEvent::toNative(info.Holder());
+ SerializedScriptValue* serialized = imp->serializedScriptValue().get();
+ if (serialized) {
+ v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(V8HiddenPropertyName::detail());
+ if (value.IsEmpty()) {
+ value = serialized->deserialize();
+ info.Holder()->SetHiddenValue(V8HiddenPropertyName::detail(), value);
+ }
+ return value;
+ }
+ return imp->detail().v8Value();
+}
+
+} // namespace WebCore
Modified: trunk/Source/WebCore/dom/CustomEvent.cpp (134119 => 134120)
--- trunk/Source/WebCore/dom/CustomEvent.cpp 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/dom/CustomEvent.cpp 2012-11-09 23:27:22 UTC (rev 134120)
@@ -34,7 +34,6 @@
{
}
-
CustomEvent::CustomEvent()
{
}
@@ -51,6 +50,7 @@
void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail)
{
+ ASSERT(!m_serializedScriptValue.get());
if (dispatched())
return;
@@ -59,6 +59,19 @@
m_detail = detail;
}
+#if USE(V8)
+void CustomEvent::initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> serializedScriptValue)
+{
+ ASSERT(m_detail.hasNoValue());
+ if (dispatched())
+ return;
+
+ initEvent(type, canBubble, cancelable);
+
+ m_serializedScriptValue = serializedScriptValue;
+}
+#endif // USE(V8)
+
const AtomicString& CustomEvent::interfaceName() const
{
return eventNames().interfaceForCustomEvent;
Modified: trunk/Source/WebCore/dom/CustomEvent.h (134119 => 134120)
--- trunk/Source/WebCore/dom/CustomEvent.h 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/dom/CustomEvent.h 2012-11-09 23:27:22 UTC (rev 134120)
@@ -28,6 +28,7 @@
#include "Event.h"
#include "ScriptValue.h"
+#include "SerializedScriptValue.h"
namespace WebCore {
@@ -52,16 +53,21 @@
}
void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, const ScriptValue& detail);
+#if USE(V8)
+ void initCustomEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue>);
+#endif
virtual const AtomicString& interfaceName() const;
const ScriptValue& detail() const { return m_detail; }
+ PassRefPtr<SerializedScriptValue> serializedScriptValue() { return m_serializedScriptValue; }
private:
CustomEvent();
CustomEvent(const AtomicString& type, const CustomEventInit& initializer);
ScriptValue m_detail;
+ RefPtr<SerializedScriptValue> m_serializedScriptValue;
};
} // namespace WebCore
Modified: trunk/Source/WebCore/dom/CustomEvent.idl (134119 => 134120)
--- trunk/Source/WebCore/dom/CustomEvent.idl 2012-11-09 23:25:19 UTC (rev 134119)
+++ trunk/Source/WebCore/dom/CustomEvent.idl 2012-11-09 23:27:22 UTC (rev 134120)
@@ -28,7 +28,7 @@
[
ConstructorTemplate=Event
] interface CustomEvent : Event {
- [InitializedByEventConstructor] readonly attribute DOMObject detail;
+ [InitializedByEventConstructor, V8Custom] readonly attribute DOMObject detail;
void initCustomEvent(in [Optional=DefaultIsUndefined] DOMString typeArg,
in [Optional=DefaultIsUndefined] boolean canBubbleArg,