diff --git a/engine/bindings/core/v8/Dictionary.cpp b/engine/bindings/core/v8/Dictionary.cpp index 5105a830f43268c998910849c7368dd6e5cdc407..da2fab13a696bb88dad7325d1f946fc0a106d491 100644 --- a/engine/bindings/core/v8/Dictionary.cpp +++ b/engine/bindings/core/v8/Dictionary.cpp @@ -34,7 +34,6 @@ #include "bindings/core/v8/V8Element.h" #include "bindings/core/v8/V8EventTarget.h" #include "bindings/core/v8/V8MediaKeyError.h" -#include "bindings/core/v8/V8MessagePort.h" #include "bindings/core/v8/V8Path2D.h" #include "bindings/core/v8/V8VoidCallback.h" #include "bindings/core/v8/V8Window.h" diff --git a/engine/bindings/core/v8/Dictionary.h b/engine/bindings/core/v8/Dictionary.h index 573932f2c83d587d339bb7e0409fb94809438061..82ab6cc0c86e160b6e353a0d4fa0d992682d5c26 100644 --- a/engine/bindings/core/v8/Dictionary.h +++ b/engine/bindings/core/v8/Dictionary.h @@ -32,7 +32,6 @@ #include "bindings/core/v8/ScriptValue.h" #include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8BindingMacros.h" -#include "core/dom/MessagePort.h" #include "core/events/EventListener.h" #include "wtf/HashMap.h" #include "wtf/HashSet.h" diff --git a/engine/bindings/core/v8/DictionaryHelperForCore.cpp b/engine/bindings/core/v8/DictionaryHelperForCore.cpp index 16ffd86af68f8a30fc83e86b7b61c6ae9ca1206a..a3e8f953d4d76628e7fceaf28d48b1b5f6e5e1a6 100644 --- a/engine/bindings/core/v8/DictionaryHelperForCore.cpp +++ b/engine/bindings/core/v8/DictionaryHelperForCore.cpp @@ -34,7 +34,6 @@ #include "bindings/core/v8/V8Element.h" #include "bindings/core/v8/V8EventTarget.h" #include "bindings/core/v8/V8MediaKeyError.h" -#include "bindings/core/v8/V8MessagePort.h" #include "bindings/core/v8/V8Path2D.h" #include "bindings/core/v8/V8VoidCallback.h" #include "bindings/core/v8/V8Window.h" @@ -261,22 +260,6 @@ bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, RefP return true; } -template <> -bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, MessagePortArray& value) -{ - v8::Local v8Value; - if (!dictionary.get(key, v8Value)) - return false; - - ASSERT(dictionary.isolate()); - ASSERT(dictionary.isolate() == v8::Isolate::GetCurrent()); - if (blink::isUndefinedOrNull(v8Value)) - return true; - bool success = false; - value = toRefPtrWillBeMemberNativeArray(v8Value, key, dictionary.isolate(), &success); - return success; -} - template <> bool DictionaryHelper::get(const Dictionary& dictionary, const String& key, HashSet& value) { @@ -608,16 +591,4 @@ template bool DictionaryHelper::convert(const Dictionary&, Dictionary::Conversio template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember& value); template bool DictionaryHelper::convert(const Dictionary&, Dictionary::ConversionContext&, const String& key, RefPtrWillBeMember& value); -template <> -bool DictionaryHelper::convert(const Dictionary& dictionary, Dictionary::ConversionContext& context, const String& key, MessagePortArray& value) -{ - Dictionary::ConversionContextScope scope(context); - - v8::Local v8Value; - if (!dictionary.get(key, v8Value)) - return true; - - return DictionaryHelper::get(dictionary, key, value); -} - } // namespace blink diff --git a/engine/bindings/core/v8/PostMessage.h b/engine/bindings/core/v8/PostMessage.h deleted file mode 100644 index eaed55e9f712379fb893c13959a72696a9bc59f1..0000000000000000000000000000000000000000 --- a/engine/bindings/core/v8/PostMessage.h +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef PostMessage_h -#define PostMessage_h - -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/SerializedScriptValue.h" -#include "bindings/core/v8/V8Binding.h" -#include "bindings/core/v8/V8BindingMacros.h" -#include "core/dom/MessagePort.h" -#include "wtf/ArrayBuffer.h" -#include - -namespace blink { - -class ExecutionContext; - -// FIXME: This should be auto-generated by a code generator template. -template -void postMessageMethodCommon(const char* interfaceName, Type* instance, const v8::FunctionCallbackInfo& info) -{ - ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage", interfaceName, info.Holder(), info.GetIsolate()); - MessagePortArray ports; - ArrayBufferArray arrayBuffers; - if (info.Length() > 1) { - const int transferablesArgIndex = 1; - if (!SerializedScriptValue::extractTransferables(info[transferablesArgIndex], transferablesArgIndex, ports, arrayBuffers, exceptionState, info.GetIsolate())) { - exceptionState.throwIfNeeded(); - return; - } - } - RefPtr message = SerializedScriptValue::create(info[0], &ports, &arrayBuffers, exceptionState, info.GetIsolate()); - if (exceptionState.throwIfNeeded()) - return; - // FIXME: Only pass context/exceptionState if instance really requires it. - ExecutionContext* context = currentExecutionContext(info.GetIsolate()); - instance->postMessage(context, message.release(), &ports, exceptionState); - exceptionState.throwIfNeeded(); -} - -} // namespace blink - -#endif // PostMessage_h diff --git a/engine/bindings/core/v8/SerializedScriptValue.cpp b/engine/bindings/core/v8/SerializedScriptValue.cpp index 2178accd53722676d0685f962249a3460c81fcdd..55e3137ddc08fe0857c06e2129993d8e5ddd5060 100644 --- a/engine/bindings/core/v8/SerializedScriptValue.cpp +++ b/engine/bindings/core/v8/SerializedScriptValue.cpp @@ -34,7 +34,6 @@ #include "bindings/core/v8/ExceptionState.h" #include "bindings/core/v8/V8Binding.h" #include "bindings/core/v8/V8ImageData.h" -#include "bindings/core/v8/V8MessagePort.h" #include "bindings/core/v8/custom/V8ArrayBufferCustom.h" #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" #include "bindings/core/v8/custom/V8DataViewCustom.h" @@ -48,7 +47,6 @@ #include "bindings/core/v8/custom/V8Uint8ArrayCustom.h" #include "bindings/core/v8/custom/V8Uint8ClampedArrayCustom.h" #include "core/dom/ExceptionCode.h" -#include "core/dom/MessagePort.h" #include "core/html/ImageData.h" #include "core/html/canvas/DataView.h" #include "platform/SharedBuffer.h" @@ -183,7 +181,6 @@ enum SerializationTag { Int32Tag = 'I', // value:ZigZag-encoded int32 -> Integer Uint32Tag = 'U', // value:uint32_t -> Integer DateTag = 'D', // value:double -> Date (ref) - MessagePortTag = 'M', // index:int -> MessagePort. Fills the result with transferred MessagePort. NumberTag = 'N', // value:double -> Number ImageDataTag = '#', // width:uint32_t, height:uint32_t, pixelDataLength:uint32_t, data:byte[pixelDataLength] -> ImageData (ref) ObjectTag = '{', // numProperties:uint32_t -> pops the last object from the open stack; @@ -437,12 +434,6 @@ public: doWriteUint32(static_cast(flags)); } - void writeTransferredMessagePort(uint32_t index) - { - append(MessagePortTag); - doWriteUint32(index); - } - void writeTransferredArrayBuffer(uint32_t index) { append(ArrayBufferTransferTag); @@ -616,15 +607,6 @@ private: unsigned m_position; }; -static v8::Handle toV8Object(MessagePort* impl, v8::Handle creationContext, v8::Isolate* isolate) -{ - if (!impl) - return v8::Handle(); - v8::Handle wrapper = toV8(impl, creationContext, isolate); - ASSERT(wrapper->IsObject()); - return wrapper.As(); -} - static v8::Handle toV8Object(ArrayBuffer* impl, v8::Handle creationContext, v8::Isolate* isolate) { if (!impl) @@ -644,7 +626,7 @@ public: JSException }; - Serializer(Writer& writer, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, v8::TryCatch& tryCatch, ScriptState* scriptState) + Serializer(Writer& writer, ArrayBufferArray* arrayBuffers, v8::TryCatch& tryCatch, ScriptState* scriptState) : m_scriptState(scriptState) , m_writer(writer) , m_tryCatch(tryCatch) @@ -654,10 +636,6 @@ public: { ASSERT(!tryCatch.HasCaught()); v8::Handle creationContext = m_scriptState->context()->Global(); - if (messagePorts) { - for (size_t i = 0; i < messagePorts->size(); i++) - m_transferredMessagePorts.set(toV8Object(messagePorts->at(i).get(), creationContext, isolate()), i); - } if (arrayBuffers) { for (size_t i = 0; i < arrayBuffers->size(); i++) { v8::Handle v8ArrayBuffer = toV8Object(arrayBuffers->at(i).get(), creationContext, isolate()); @@ -1104,7 +1082,6 @@ private: String m_errorMessage; typedef V8ObjectMap ObjectPool; ObjectPool m_objectPool; - ObjectPool m_transferredMessagePorts; ObjectPool m_transferredArrayBuffers; uint32_t m_nextObjectReference; }; @@ -1151,13 +1128,6 @@ Serializer::StateBase* Serializer::doSerialize(v8::Handle value, Stat return writeAndGreyArrayBufferView(value.As(), next); } else if (value->IsString()) { writeString(value); - } else if (V8MessagePort::hasInstance(value, isolate())) { - uint32_t messagePortIndex; - if (m_transferredMessagePorts.tryGet(value.As(), &messagePortIndex)) { - m_writer.writeTransferredMessagePort(messagePortIndex); - } else { - return handleError(DataCloneError, "A MessagePort could not be cloned.", next); - } } else if (V8ArrayBuffer::hasInstance(value, isolate()) && m_transferredArrayBuffers.tryGet(value.As(), &arrayBufferIndex)) { return writeTransferredArrayBuffer(value, arrayBufferIndex, next); } else { @@ -1202,7 +1172,6 @@ public: virtual uint32_t objectReferenceCount() = 0; virtual void pushObjectReference(const v8::Handle&) = 0; virtual bool tryGetObjectFromObjectReference(uint32_t reference, v8::Handle*) = 0; - virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle*) = 0; virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle*) = 0; virtual bool newSparseArray(uint32_t length) = 0; virtual bool newDenseArray(uint32_t length) = 0; @@ -1397,16 +1366,6 @@ public: return false; return true; } - case MessagePortTag: { - if (!m_version) - return false; - uint32_t index; - if (!doReadUint32(&index)) - return false; - if (!creator.tryGetTransferredMessagePort(index, value)) - return false; - break; - } case ArrayBufferTransferTag: { if (!m_version) return false; @@ -1763,9 +1722,8 @@ typedef Vector ArrayBufferContentsArray; class Deserializer FINAL : public CompositeCreator { public: - Deserializer(Reader& reader, MessagePortArray* messagePorts, ArrayBufferContentsArray* arrayBufferContents) + Deserializer(Reader& reader, ArrayBufferContentsArray* arrayBufferContents) : m_reader(reader) - , m_transferredMessagePorts(messagePorts) , m_arrayBufferContents(arrayBufferContents) , m_arrayBuffers(arrayBufferContents ? arrayBufferContents->size() : 0) , m_version(0) @@ -1882,17 +1840,6 @@ public: m_objectPool.append(object); } - virtual bool tryGetTransferredMessagePort(uint32_t index, v8::Handle* object) OVERRIDE - { - if (!m_transferredMessagePorts) - return false; - if (index >= m_transferredMessagePorts->size()) - return false; - v8::Handle creationContext = m_reader.scriptState()->context()->Global(); - *object = toV8(m_transferredMessagePorts->at(index).get(), creationContext, m_reader.scriptState()->isolate()); - return true; - } - virtual bool tryGetTransferredArrayBuffer(uint32_t index, v8::Handle* object) OVERRIDE { if (!m_arrayBufferContents) @@ -1991,7 +1938,6 @@ private: Vector > m_stack; Vector > m_objectPool; Vector m_openCompositeReferenceStack; - RawPtrWillBeMember m_transferredMessagePorts; ArrayBufferContentsArray* m_arrayBufferContents; Vector > m_arrayBuffers; uint32_t m_version; @@ -1999,21 +1945,21 @@ private: } // namespace -PassRefPtr SerializedScriptValue::create(v8::Handle value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate) +PassRefPtr SerializedScriptValue::create(v8::Handle value, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate) { - return adoptRef(new SerializedScriptValue(value, messagePorts, arrayBuffers, exceptionState, isolate)); + return adoptRef(new SerializedScriptValue(value, arrayBuffers, exceptionState, isolate)); } PassRefPtr SerializedScriptValue::createAndSwallowExceptions(v8::Handle value, v8::Isolate* isolate) { TrackExceptionState exceptionState; - return adoptRef(new SerializedScriptValue(value, 0, 0, exceptionState, isolate)); + return adoptRef(new SerializedScriptValue(value, 0, exceptionState, isolate)); } PassRefPtr SerializedScriptValue::create(const ScriptValue& value, ExceptionState& exceptionState, v8::Isolate* isolate) { ASSERT(isolate->InContext()); - return adoptRef(new SerializedScriptValue(value.v8Value(), 0, 0, exceptionState, isolate)); + return adoptRef(new SerializedScriptValue(value.v8Value(), 0, exceptionState, isolate)); } PassRefPtr SerializedScriptValue::createFromWire(const String& data) @@ -2137,7 +2083,7 @@ PassOwnPtr SerializedScriptValu return contents.release(); } -SerializedScriptValue::SerializedScriptValue(v8::Handle value, MessagePortArray* messagePorts, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate) +SerializedScriptValue::SerializedScriptValue(v8::Handle value, ArrayBufferArray* arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate) : m_externallyAllocatedMemory(0) { Writer writer; @@ -2145,7 +2091,7 @@ SerializedScriptValue::SerializedScriptValue(v8::Handle value, Messag String errorMessage; { v8::TryCatch tryCatch; - Serializer serializer(writer, messagePorts, arrayBuffers, tryCatch, ScriptState::current(isolate)); + Serializer serializer(writer, arrayBuffers, tryCatch, ScriptState::current(isolate)); status = serializer.serialize(value); if (status == Serializer::JSException) { // If there was a JS exception thrown, re-throw it. @@ -2178,12 +2124,12 @@ SerializedScriptValue::SerializedScriptValue(const String& wireData) m_data = wireData.isolatedCopy(); } -v8::Handle SerializedScriptValue::deserialize(MessagePortArray* messagePorts) +v8::Handle SerializedScriptValue::deserialize() { - return deserialize(v8::Isolate::GetCurrent(), messagePorts); + return deserialize(v8::Isolate::GetCurrent()); } -v8::Handle SerializedScriptValue::deserialize(v8::Isolate* isolate, MessagePortArray* messagePorts) +v8::Handle SerializedScriptValue::deserialize(v8::Isolate* isolate) { if (!m_data.impl()) return v8::Null(isolate); @@ -2194,7 +2140,7 @@ v8::Handle SerializedScriptValue::deserialize(v8::Isolate* isolate, M // information stored in m_data isn't even encoded in UTF-16. Instead, // unicode characters are encoded as UTF-8 with two code units per UChar. Reader reader(reinterpret_cast(m_data.impl()->characters16()), 2 * m_data.length(), ScriptState::current(isolate)); - Deserializer deserializer(reader, messagePorts, m_arrayBufferContentsArray.get()); + Deserializer deserializer(reader, m_arrayBufferContentsArray.get()); // deserialize() can run arbitrary script (e.g., setters), which could result in |this| being destroyed. // Holding a RefPtr ensures we are alive (along with our internal data) throughout the operation. @@ -2202,65 +2148,6 @@ v8::Handle SerializedScriptValue::deserialize(v8::Isolate* isolate, M return deserializer.deserialize(); } -bool SerializedScriptValue::extractTransferables(v8::Local value, int argumentIndex, MessagePortArray& ports, ArrayBufferArray& arrayBuffers, ExceptionState& exceptionState, v8::Isolate* isolate) -{ - if (isUndefinedOrNull(value)) { - ports.resize(0); - arrayBuffers.resize(0); - return true; - } - - uint32_t length = 0; - if (value->IsArray()) { - v8::Local array = v8::Local::Cast(value); - length = array->Length(); - } else if (toV8Sequence(value, length, isolate).IsEmpty()) { - exceptionState.throwTypeError(ExceptionMessages::notAnArrayTypeArgumentOrValue(argumentIndex + 1)); - return false; - } - - v8::Local transferrables = v8::Local::Cast(value); - - // Validate the passed array of transferrables. - for (unsigned i = 0; i < length; ++i) { - v8::Local transferrable = transferrables->Get(i); - // Validation of non-null objects, per HTML5 spec 10.3.3. - if (isUndefinedOrNull(transferrable)) { - exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " is an untransferable " + (transferrable->IsUndefined() ? "'undefined'" : "'null'") + " value."); - return false; - } - // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. - if (V8MessagePort::hasInstance(transferrable, isolate)) { - RefPtrWillBeRawPtr port = V8MessagePort::toNative(v8::Handle::Cast(transferrable)); - // Check for duplicate MessagePorts. - if (ports.contains(port)) { - exceptionState.throwDOMException(DataCloneError, "Message port at index " + String::number(i) + " is a duplicate of an earlier port."); - return false; - } - ports.append(port.release()); - } else if (V8ArrayBuffer::hasInstance(transferrable, isolate)) { - RefPtr arrayBuffer = V8ArrayBuffer::toNative(v8::Handle::Cast(transferrable)); - if (arrayBuffers.contains(arrayBuffer)) { - exceptionState.throwDOMException(DataCloneError, "ArrayBuffer at index " + String::number(i) + " is a duplicate of an earlier ArrayBuffer."); - return false; - } - arrayBuffers.append(arrayBuffer.release()); - } else { - exceptionState.throwDOMException(DataCloneError, "Value at index " + String::number(i) + " does not have a transferable type."); - return false; - } - } - return true; -} - -void SerializedScriptValue::registerMemoryAllocatedWithCurrentScriptContext() -{ - if (m_externallyAllocatedMemory) - return; - m_externallyAllocatedMemory = static_cast(m_data.length()); - v8::Isolate::GetCurrent()->AdjustAmountOfExternalAllocatedMemory(m_externallyAllocatedMemory); -} - SerializedScriptValue::~SerializedScriptValue() { // If the allocated memory was not registered before, then this class is likely diff --git a/engine/bindings/core/v8/SerializedScriptValue.h b/engine/bindings/core/v8/SerializedScriptValue.h index 94bfe7edd91baa25448913a59da794f8677be80f..c7477f9f04de2d0e9d06146a2c32299dfb9dfc6b 100644 --- a/engine/bindings/core/v8/SerializedScriptValue.h +++ b/engine/bindings/core/v8/SerializedScriptValue.h @@ -46,9 +46,7 @@ class ArrayBufferContents; namespace blink { class ExceptionState; -class MessagePort; -typedef WillBeHeapVector, 1> MessagePortArray; typedef Vector, 1> ArrayBufferArray; class SerializedScriptValue FINAL : public ThreadSafeRefCounted { @@ -69,7 +67,7 @@ public: // be thrown using v8::ThrowException(), and sets |didThrow|. In this case // the caller must not invoke any V8 operations until control returns to // V8. When serialization is successful, |didThrow| is false. - static PassRefPtr create(v8::Handle, MessagePortArray*, ArrayBufferArray*, ExceptionState&, v8::Isolate*); + static PassRefPtr create(v8::Handle, ArrayBufferArray*, ExceptionState&, v8::Isolate*); static PassRefPtr createFromWire(const String&); static PassRefPtr createFromWireBytes(const Vector&); static PassRefPtr create(const String&); @@ -87,20 +85,8 @@ public: // Deserializes the value (in the current context). Returns a null value in // case of failure. - v8::Handle deserialize(MessagePortArray* = 0); - v8::Handle deserialize(v8::Isolate*, MessagePortArray* = 0); - - // Helper function which pulls the values out of a JS sequence and into a MessagePortArray. - // Also validates the elements per sections 4.1.13 and 4.1.15 of the WebIDL spec and section 8.3.3 - // of the HTML5 spec and generates exceptions as appropriate. - // Returns true if the array was filled, or false if the passed value was not of an appropriate type. - static bool extractTransferables(v8::Local, int, MessagePortArray&, ArrayBufferArray&, ExceptionState&, v8::Isolate*); - - // Informs the V8 about external memory allocated and owned by this object. Large values should contribute - // to GC counters to eventually trigger a GC, otherwise flood of postMessage() can cause OOM. - // Ok to invoke multiple times (only adds memory once). - // The memory registration is revoked automatically in destructor. - void registerMemoryAllocatedWithCurrentScriptContext(); + v8::Handle deserialize(); + v8::Handle deserialize(v8::Isolate*); private: enum StringDataMode { @@ -110,7 +96,7 @@ private: typedef Vector ArrayBufferContentsArray; SerializedScriptValue(); - SerializedScriptValue(v8::Handle, MessagePortArray*, ArrayBufferArray*, ExceptionState&, v8::Isolate*); + SerializedScriptValue(v8::Handle, ArrayBufferArray*, ExceptionState&, v8::Isolate*); explicit SerializedScriptValue(const String& wireData); static PassOwnPtr transferArrayBuffers(ArrayBufferArray&, ExceptionState&, v8::Isolate*); diff --git a/engine/bindings/core/v8/custom/V8HistoryCustom.cpp b/engine/bindings/core/v8/custom/V8HistoryCustom.cpp index bf5ded0be86e8877d94c8ecf67d411821528eef7..35d267df0f0f1183f415dbd99b95d02d16d7a5c3 100644 --- a/engine/bindings/core/v8/custom/V8HistoryCustom.cpp +++ b/engine/bindings/core/v8/custom/V8HistoryCustom.cpp @@ -62,7 +62,7 @@ void V8History::stateAttributeGetterCustom(const v8::PropertyCallbackInfo& info) { ExceptionState exceptionState(ExceptionState::ExecutionContext, "pushState", "History", info.Holder(), info.GetIsolate()); - RefPtr historyState = SerializedScriptValue::create(info[0], 0, 0, exceptionState, info.GetIsolate()); + RefPtr historyState = SerializedScriptValue::create(info[0], 0, exceptionState, info.GetIsolate()); if (exceptionState.throwIfNeeded()) return; diff --git a/engine/bindings/core/v8/custom/V8MessageChannelCustom.cpp b/engine/bindings/core/v8/custom/V8MessageChannelCustom.cpp deleted file mode 100644 index 30534ee9dcc728738fa72ac99f7fe04763426315..0000000000000000000000000000000000000000 --- a/engine/bindings/core/v8/custom/V8MessageChannelCustom.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2009 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 "bindings/core/v8/V8MessageChannel.h" - -#include "bindings/core/v8/V8Binding.h" -#include "bindings/core/v8/V8HiddenValue.h" -#include "bindings/core/v8/V8MessagePort.h" -#include "core/dom/MessageChannel.h" -#include "wtf/RefPtr.h" - -namespace blink { - -void V8MessageChannel::constructorCustom(const v8::FunctionCallbackInfo& info) -{ - ExecutionContext* context = currentExecutionContext(info.GetIsolate()); - - RefPtrWillBeRawPtr obj = MessageChannel::create(context); - - v8::Local wrapper = info.Holder(); - - // Create references from the MessageChannel wrapper to the two - // MessagePort wrappers to make sure that the MessagePort wrappers - // stay alive as long as the MessageChannel wrapper is around. - V8HiddenValue::setHiddenValue(info.GetIsolate(), wrapper, V8HiddenValue::port1(info.GetIsolate()), toV8(obj->port1(), info.Holder(), info.GetIsolate())); - V8HiddenValue::setHiddenValue(info.GetIsolate(), wrapper, V8HiddenValue::port2(info.GetIsolate()), toV8(obj->port2(), info.Holder(), info.GetIsolate())); - - V8DOMWrapper::associateObjectWithWrapper(obj.release(), &wrapperTypeInfo, wrapper, info.GetIsolate()); - info.GetReturnValue().Set(wrapper); -} - -} // namespace blink diff --git a/engine/bindings/core/v8/custom/V8MessageEventCustom.cpp b/engine/bindings/core/v8/custom/V8MessageEventCustom.cpp deleted file mode 100644 index a3a47ac915b8612faf7cb421fad3644a7ca72605..0000000000000000000000000000000000000000 --- a/engine/bindings/core/v8/custom/V8MessageEventCustom.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Copyright (C) 2009 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 "bindings/core/v8/V8MessageEvent.h" - -#include "bindings/core/v8/SerializedScriptValue.h" -#include "bindings/core/v8/V8Binding.h" -#include "bindings/core/v8/V8HiddenValue.h" -#include "bindings/core/v8/V8MessagePort.h" -#include "bindings/core/v8/V8Window.h" -#include "bindings/core/v8/custom/V8ArrayBufferCustom.h" -#include "core/events/MessageEvent.h" - -namespace blink { - -// Ensures a wrapper is created for the data to return now so that V8 knows how -// much memory is used via the wrapper. To keep the wrapper alive, it's set to -// the wrapper of the MessageEvent as a hidden value. -static void ensureWrapperCreatedAndAssociated(MessageEvent* eventImpl, v8::Handle eventWrapper, v8::Isolate* isolate) -{ - switch (eventImpl->dataType()) { - case MessageEvent::DataTypeScriptValue: - case MessageEvent::DataTypeSerializedScriptValue: - break; - case MessageEvent::DataTypeString: { - String stringValue = eventImpl->dataAsString(); - V8HiddenValue::setHiddenValue(isolate, eventWrapper, V8HiddenValue::stringData(isolate), v8String(isolate, stringValue)); - break; - } - case MessageEvent::DataTypeArrayBuffer: - V8HiddenValue::setHiddenValue(isolate, eventWrapper, V8HiddenValue::arrayBufferData(isolate), toV8(eventImpl->dataAsArrayBuffer(), eventWrapper, isolate)); - break; - } -} - -v8::Handle wrap(MessageEvent* impl, v8::Handle creationContext, v8::Isolate* isolate) -{ - ASSERT(impl); - ASSERT(!DOMDataStore::containsWrapper(impl, isolate)); - v8::Handle wrapper = V8MessageEvent::createWrapper(impl, creationContext, isolate); - ensureWrapperCreatedAndAssociated(impl, wrapper, isolate); - return wrapper; -} - -void V8MessageEvent::dataAttributeGetterCustom(const v8::PropertyCallbackInfo& info) -{ - MessageEvent* event = V8MessageEvent::toNative(info.Holder()); - - v8::Handle result; - switch (event->dataType()) { - case MessageEvent::DataTypeScriptValue: { - result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate())); - if (result.IsEmpty()) { - if (!event->dataAsSerializedScriptValue()) { - // If we're in an isolated world and the event was created in the main world, - // we need to find the 'data' property on the main world wrapper and clone it. - v8::Local mainWorldData = V8HiddenValue::getHiddenValueFromMainWorldWrapper(info.GetIsolate(), event, V8HiddenValue::data(info.GetIsolate())); - if (!mainWorldData.IsEmpty()) - event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(mainWorldData, info.GetIsolate())); - } - if (event->dataAsSerializedScriptValue()) - result = event->dataAsSerializedScriptValue()->deserialize(info.GetIsolate()); - else - result = v8::Null(info.GetIsolate()); - } - break; - } - - case MessageEvent::DataTypeSerializedScriptValue: - if (SerializedScriptValue* serializedValue = event->dataAsSerializedScriptValue()) { - MessagePortArray ports = event->ports(); - result = serializedValue->deserialize(info.GetIsolate(), &ports); - } else { - result = v8::Null(info.GetIsolate()); - } - break; - - case MessageEvent::DataTypeString: { - result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::stringData(info.GetIsolate())); - if (result.IsEmpty()) { - String stringValue = event->dataAsString(); - result = v8String(info.GetIsolate(), stringValue); - } - break; - } - - case MessageEvent::DataTypeArrayBuffer: - result = V8HiddenValue::getHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::arrayBufferData(info.GetIsolate())); - if (result.IsEmpty()) - result = toV8(event->dataAsArrayBuffer(), info.Holder(), info.GetIsolate()); - break; - } - - // Overwrite the data attribute so it returns the cached result in future invocations. - // This custom getter handler will not be called again. - v8::PropertyAttribute dataAttr = static_cast(v8::DontDelete | v8::ReadOnly); - info.Holder()->ForceSet(v8AtomicString(info.GetIsolate(), "data"), result, dataAttr); - v8SetReturnValue(info, result); -} - -void V8MessageEvent::initMessageEventMethodCustom(const v8::FunctionCallbackInfo& info) -{ - MessageEvent* event = V8MessageEvent::toNative(info.Holder()); - TOSTRING_VOID(V8StringResource<>, typeArg, info[0]); - TONATIVE_VOID(bool, canBubbleArg, info[1]->BooleanValue()); - TONATIVE_VOID(bool, cancelableArg, info[2]->BooleanValue()); - v8::Handle dataArg = info[3]; - TOSTRING_VOID(V8StringResource<>, originArg, info[4]); - TOSTRING_VOID(V8StringResource<>, lastEventIdArg, info[5]); - LocalDOMWindow* sourceArg = toDOMWindow(info[6], info.GetIsolate()); - OwnPtrWillBeRawPtr portArray = nullptr; - const int portArrayIndex = 7; - if (!isUndefinedOrNull(info[portArrayIndex])) { - portArray = adoptPtrWillBeNoop(new MessagePortArray); - bool success = false; - *portArray = toRefPtrWillBeMemberNativeArray(info[portArrayIndex], portArrayIndex + 1, info.GetIsolate(), &success); - if (!success) - return; - } - event->initMessageEvent(typeArg, canBubbleArg, cancelableArg, originArg, lastEventIdArg, sourceArg, portArray.release()); - - if (!dataArg.IsEmpty()) { - V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder(), V8HiddenValue::data(info.GetIsolate()), dataArg); - if (DOMWrapperWorld::current(info.GetIsolate()).isIsolatedWorld()) - event->setSerializedData(SerializedScriptValue::createAndSwallowExceptions(dataArg, info.GetIsolate())); - } -} - -} // namespace blink diff --git a/engine/bindings/core/v8/custom/V8MessagePortCustom.cpp b/engine/bindings/core/v8/custom/V8MessagePortCustom.cpp deleted file mode 100644 index 228b3a2580c445fba80f58874b80443c41513c3d..0000000000000000000000000000000000000000 --- a/engine/bindings/core/v8/custom/V8MessagePortCustom.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2009, 2011 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 "bindings/core/v8/V8MessagePort.h" - -#include "bindings/core/v8/PostMessage.h" -#include "bindings/core/v8/V8Binding.h" - -namespace blink { - -// FIXME: This stub should be replaced by generated code. -void V8MessagePort::postMessageMethodCustom(const v8::FunctionCallbackInfo& info) -{ - postMessageMethodCommon("MessagePort", V8MessagePort::toNative(info.Holder()), info); -} - -} // namespace blink diff --git a/engine/bindings/core/v8/custom/V8WindowCustom.cpp b/engine/bindings/core/v8/custom/V8WindowCustom.cpp index 198df69b32427f8f3bc922449daddcae1a958cc7..cc051eb382b8de38950cc1d0198d688a3fce8d18 100644 --- a/engine/bindings/core/v8/custom/V8WindowCustom.cpp +++ b/engine/bindings/core/v8/custom/V8WindowCustom.cpp @@ -45,7 +45,6 @@ #include "bindings/core/v8/V8HiddenValue.h" #include "bindings/core/v8/V8Node.h" #include "core/dom/ExceptionCode.h" -#include "core/dom/MessagePort.h" #include "core/dom/Element.h" #include "core/dom/Node.h" #include "core/frame/DOMTimer.h" diff --git a/engine/bindings/core/v8/custom/custom.gypi b/engine/bindings/core/v8/custom/custom.gypi index 159499bb5e3a2edab7147edc3ceaf822e60a30da..e91796fe4ac432c5aba2eee74e0f0d952d6068da 100644 --- a/engine/bindings/core/v8/custom/custom.gypi +++ b/engine/bindings/core/v8/custom/custom.gypi @@ -30,9 +30,6 @@ 'V8Int32ArrayCustom.h', 'V8Int8ArrayCustom.h', 'V8LocationCustom.cpp', - 'V8MessageChannelCustom.cpp', - 'V8MessageEventCustom.cpp', - 'V8MessagePortCustom.cpp', 'V8MutationObserverCustom.cpp', 'V8NodeCustom.cpp', 'V8PopStateEventCustom.cpp', diff --git a/engine/bindings/core/v8/v8.gypi b/engine/bindings/core/v8/v8.gypi index b04ea1f67bc29a974aab7c803062a5104c554468..8fe8e46d6a46fd22e535417e066bcc1c903b4729 100644 --- a/engine/bindings/core/v8/v8.gypi +++ b/engine/bindings/core/v8/v8.gypi @@ -39,7 +39,6 @@ 'ExceptionStatePlaceholder.cpp', 'ExceptionStatePlaceholder.h', 'Nullable.h', - 'PostMessage.h', 'RetainedDOMInfo.cpp', 'RetainedDOMInfo.h', 'RetainedObjectInfo.h', diff --git a/engine/bindings/templates/methods.cpp b/engine/bindings/templates/methods.cpp index c244456ed125fde3d3ee7d8c0ecc36ee73750063..3c925f131b75bf27bbc80a1e8c6c8f2397cdd040 100644 --- a/engine/bindings/templates/methods.cpp +++ b/engine/bindings/templates/methods.cpp @@ -175,7 +175,7 @@ if (!std::isnan({{argument.name}}NativeValue)) IDL integer types have same internal C++ type (int or unsigned) #} {{argument.name}} = clampTo<{{argument.idl_type}}>({{argument.name}}NativeValue); {% elif argument.idl_type == 'SerializedScriptValue' %} -{{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, 0, exceptionState, info.GetIsolate()); +{{argument.name}} = SerializedScriptValue::create(info[{{argument.index}}], 0, exceptionState, info.GetIsolate()); if (exceptionState.hadException()) { {{throw_from_exception_state(method)}}; return; diff --git a/engine/core/core.gni b/engine/core/core.gni index 57702c326de25cc6d9dba1e29114923ab76a5cee..1f395065aa92927c15f4ebfff4314e73567b003d 100644 --- a/engine/core/core.gni +++ b/engine/core/core.gni @@ -415,9 +415,6 @@ sky_core_files = [ "dom/ExecutionContext.h", "dom/IncrementLoadEventDelayCount.cpp", "dom/IncrementLoadEventDelayCount.h", - "dom/MessageChannel.cpp", - "dom/MessageChannel.h", - "dom/MessagePort.cpp", "dom/Microtask.cpp", "dom/Microtask.h", "dom/MutationCallback.h", @@ -651,8 +648,6 @@ sky_core_files = [ "events/GestureEvent.h", "events/HashChangeEvent.h", "events/KeyboardEvent.cpp", - "events/MessageEvent.cpp", - "events/MessageEvent.h", "events/MouseEvent.cpp", "events/MouseRelatedEvent.cpp", "events/NodeEventContext.cpp", @@ -1280,8 +1275,6 @@ core_idl_files = get_path_info([ "dom/Document.idl", "dom/DocumentFragment.idl", "dom/Element.idl", - "dom/MessageChannel.idl", - "dom/MessagePort.idl", "dom/MutationObserver.idl", "dom/MutationRecord.idl", "dom/NamedNodeMap.idl", @@ -1305,7 +1298,6 @@ core_idl_files = get_path_info([ "events/FocusEvent.idl", "events/HashChangeEvent.idl", "events/KeyboardEvent.idl", - "events/MessageEvent.idl", "events/MouseEvent.idl", "events/OverflowEvent.idl", "events/PageTransitionEvent.idl", @@ -1427,7 +1419,6 @@ core_event_idl_files = get_path_info([ "events/FocusEvent.idl", "events/HashChangeEvent.idl", "events/KeyboardEvent.idl", - "events/MessageEvent.idl", "events/MouseEvent.idl", "events/OverflowEvent.idl", "events/PageTransitionEvent.idl", diff --git a/engine/core/dom/MessageChannel.cpp b/engine/core/dom/MessageChannel.cpp deleted file mode 100644 index eb82673d3a0ae517e895122fb49b4a0ae02120d4..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessageChannel.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "core/dom/MessageChannel.h" - -#include "core/dom/MessagePort.h" -#include "public/platform/Platform.h" -#include "public/platform/WebMessagePortChannel.h" - -namespace blink { - -DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MessageChannel); - -static void createChannel(MessagePort* port1, MessagePort* port2) -{ - WebMessagePortChannel* channel1; - WebMessagePortChannel* channel2; - Platform::current()->createMessageChannel(&channel1, &channel2); - ASSERT(channel1 && channel2); - - // Now entangle the proxies with the appropriate local ports. - port1->entangle(adoptPtr(channel2)); - port2->entangle(adoptPtr(channel1)); -} - -MessageChannel::MessageChannel(ExecutionContext* context) - : m_port1(MessagePort::create(*context)) - , m_port2(MessagePort::create(*context)) -{ - ScriptWrappable::init(this); - createChannel(m_port1.get(), m_port2.get()); -} - -void MessageChannel::trace(Visitor* visitor) -{ - visitor->trace(m_port1); - visitor->trace(m_port2); -} - -} // namespace blink diff --git a/engine/core/dom/MessageChannel.h b/engine/core/dom/MessageChannel.h deleted file mode 100644 index 6dd7cc75f60a88463383b7cf43e358fd44382960..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessageChannel.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -#ifndef MessageChannel_h -#define MessageChannel_h - -#include "bindings/core/v8/ScriptWrappable.h" -#include "platform/heap/Handle.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" -#include "wtf/RefPtr.h" - -namespace blink { - -class MessagePort; -class ExecutionContext; - -class MessageChannel FINAL : public RefCountedWillBeGarbageCollected, public ScriptWrappable { - DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(MessageChannel); - DEFINE_WRAPPERTYPEINFO(); -public: - static PassRefPtrWillBeRawPtr create(ExecutionContext* context) - { - return adoptRefWillBeNoop(new MessageChannel(context)); - } - - MessagePort* port1() const { return m_port1.get(); } - MessagePort* port2() const { return m_port2.get(); } - - void trace(Visitor*); - -private: - explicit MessageChannel(ExecutionContext*); - - RefPtrWillBeMember m_port1; - RefPtrWillBeMember m_port2; -}; - -} // namespace blink - -#endif // MessageChannel_h diff --git a/engine/core/dom/MessageChannel.idl b/engine/core/dom/MessageChannel.idl deleted file mode 100644 index 4ef92cb72e02d99e9596240ad9eb29c6ed8436a9..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessageChannel.idl +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2008, 2010 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -[ - CustomConstructor, - WillBeGarbageCollected -] interface MessageChannel { - readonly attribute MessagePort port1; - readonly attribute MessagePort port2; -}; - diff --git a/engine/core/dom/MessagePort.cpp b/engine/core/dom/MessagePort.cpp deleted file mode 100644 index ca5d525adf7cff51e4312ed15240890ced01b422..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessagePort.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "core/dom/MessagePort.h" - -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/ExceptionStatePlaceholder.h" -#include "bindings/core/v8/SerializedScriptValue.h" -#include "core/dom/ExceptionCode.h" -#include "core/dom/ExecutionContext.h" -#include "core/events/MessageEvent.h" -#include "core/frame/LocalDOMWindow.h" -#include "public/platform/WebString.h" -#include "wtf/Functional.h" -#include "wtf/text/AtomicString.h" - -namespace blink { - -PassRefPtrWillBeRawPtr MessagePort::create(ExecutionContext& executionContext) -{ - RefPtrWillBeRawPtr port = adoptRefWillBeNoop(new MessagePort(executionContext)); - port->suspendIfNeeded(); - return port.release(); -} - -MessagePort::MessagePort(ExecutionContext& executionContext) - : ActiveDOMObject(&executionContext) - , m_started(false) - , m_closed(false) - , m_weakFactory(this) -{ - ScriptWrappable::init(this); -} - -MessagePort::~MessagePort() -{ - close(); -} - -void MessagePort::postMessage(ExecutionContext*, PassRefPtr message, const MessagePortArray* ports, ExceptionState& exceptionState) -{ - if (!isEntangled()) - return; - ASSERT(executionContext()); - ASSERT(m_entangledChannel); - - OwnPtr channels; - // Make sure we aren't connected to any of the passed-in ports. - if (ports) { - for (unsigned i = 0; i < ports->size(); ++i) { - MessagePort* dataPort = (*ports)[i].get(); - if (dataPort == this) { - exceptionState.throwDOMException(DataCloneError, "Port at index " + String::number(i) + " contains the source port."); - return; - } - } - channels = MessagePort::disentanglePorts(ports, exceptionState); - if (exceptionState.hadException()) - return; - } - - WebString messageString = message->toWireString(); - OwnPtr webChannels = toWebMessagePortChannelArray(channels.release()); - m_entangledChannel->postMessage(messageString, webChannels.leakPtr()); -} - -// static -PassOwnPtr MessagePort::toWebMessagePortChannelArray(PassOwnPtr channels) -{ - OwnPtr webChannels; - if (channels && channels->size()) { - webChannels = adoptPtr(new WebMessagePortChannelArray(channels->size())); - for (size_t i = 0; i < channels->size(); ++i) - (*webChannels)[i] = (*channels)[i].leakPtr(); - } - return webChannels.release(); -} - -// static -PassOwnPtrWillBeRawPtr MessagePort::toMessagePortArray(ExecutionContext* context, const WebMessagePortChannelArray& webChannels) -{ - OwnPtrWillBeRawPtr ports = nullptr; - if (!webChannels.isEmpty()) { - OwnPtr channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); - for (size_t i = 0; i < webChannels.size(); ++i) - (*channels)[i] = adoptPtr(webChannels[i]); - ports = MessagePort::entanglePorts(*context, channels.release()); - } - return ports.release(); -} - -PassOwnPtr MessagePort::disentangle() -{ - ASSERT(m_entangledChannel); - m_entangledChannel->setClient(0); - return m_entangledChannel.release(); -} - -// Invoked to notify us that there are messages available for this port. -// This code may be called from another thread, and so should not call any non-threadsafe APIs (i.e. should not call into the entangled channel or access mutable variables). -void MessagePort::messageAvailable() -{ - callOnMainThread(bind(&MessagePort::dispatchMessages, m_weakFactory.createWeakPtr())); -} - -void MessagePort::start() -{ - // Do nothing if we've been cloned or closed. - if (!isEntangled()) - return; - - ASSERT(executionContext()); - if (m_started) - return; - - m_started = true; - messageAvailable(); -} - -void MessagePort::close() -{ - if (isEntangled()) - m_entangledChannel->setClient(0); - m_closed = true; -} - -void MessagePort::entangle(PassOwnPtr remote) -{ - // Only invoked to set our initial entanglement. - ASSERT(!m_entangledChannel); - ASSERT(executionContext()); - - m_entangledChannel = remote; - m_entangledChannel->setClient(this); -} - -const AtomicString& MessagePort::interfaceName() const -{ - return EventTargetNames::MessagePort; -} - -static bool tryGetMessageFrom(WebMessagePortChannel& webChannel, RefPtr& message, OwnPtr& channels) -{ - WebString messageString; - WebMessagePortChannelArray webChannels; - if (!webChannel.tryGetMessage(&messageString, webChannels)) - return false; - - if (webChannels.size()) { - channels = adoptPtr(new MessagePortChannelArray(webChannels.size())); - for (size_t i = 0; i < webChannels.size(); ++i) - (*channels)[i] = adoptPtr(webChannels[i]); - } - message = SerializedScriptValue::createFromWire(messageString); - return true; -} - -void MessagePort::dispatchMessages() -{ - // Messages for contexts that are not fully active get dispatched too, but JSAbstractEventListener::handleEvent() doesn't call handlers for these. - // The HTML5 spec specifies that any messages sent to a document that is not fully active should be dropped, so this behavior is OK. - if (!started()) - return; - - RefPtr message; - OwnPtr channels; - while (m_entangledChannel && tryGetMessageFrom(*m_entangledChannel, message, channels)) { - OwnPtrWillBeRawPtr ports = MessagePort::entanglePorts(*executionContext(), channels.release()); - RefPtrWillBeRawPtr evt = MessageEvent::create(ports.release(), message.release()); - - dispatchEvent(evt.release(), ASSERT_NO_EXCEPTION); - } -} - -bool MessagePort::hasPendingActivity() const -{ - // The spec says that entangled message ports should always be treated as if they have a strong reference. - // We'll also stipulate that the queue needs to be open (if the app drops its reference to the port before start()-ing it, then it's not really entangled as it's unreachable). - return m_started && isEntangled(); -} - -PassOwnPtr MessagePort::disentanglePorts(const MessagePortArray* ports, ExceptionState& exceptionState) -{ - if (!ports || !ports->size()) - return nullptr; - - // HashSet used to efficiently check for duplicates in the passed-in array. - HashSet portSet; - - // Walk the incoming array - if there are any duplicate ports, or null ports or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec). - for (unsigned i = 0; i < ports->size(); ++i) { - MessagePort* port = (*ports)[i].get(); - if (!port || port->isNeutered() || portSet.contains(port)) { - String type; - if (!port) - type = "null"; - else if (port->isNeutered()) - type = "already neutered"; - else - type = "a duplicate"; - exceptionState.throwDOMException(DataCloneError, "Port at index " + String::number(i) + " is " + type + "."); - return nullptr; - } - portSet.add(port); - } - - // Passed-in ports passed validity checks, so we can disentangle them. - OwnPtr portArray = adoptPtr(new MessagePortChannelArray(ports->size())); - for (unsigned i = 0; i < ports->size(); ++i) - (*portArray)[i] = (*ports)[i]->disentangle(); - return portArray.release(); -} - -PassOwnPtrWillBeRawPtr MessagePort::entanglePorts(ExecutionContext& context, PassOwnPtr channels) -{ - if (!channels || !channels->size()) - return nullptr; - - OwnPtrWillBeRawPtr portArray = adoptPtrWillBeNoop(new MessagePortArray(channels->size())); - for (unsigned i = 0; i < channels->size(); ++i) { - RefPtrWillBeRawPtr port = MessagePort::create(context); - port->entangle((*channels)[i].release()); - (*portArray)[i] = port.release(); - } - return portArray.release(); -} - -} // namespace blink diff --git a/engine/core/dom/MessagePort.h b/engine/core/dom/MessagePort.h deleted file mode 100644 index f83a80a590920ae4eb941b186b88b5dfd301a4b1..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessagePort.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (C) 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -#ifndef MessagePort_h -#define MessagePort_h - -#include "core/dom/ActiveDOMObject.h" -#include "core/events/EventListener.h" -#include "core/events/EventTarget.h" -#include "public/platform/WebMessagePortChannel.h" -#include "public/platform/WebMessagePortChannelClient.h" -#include "wtf/OwnPtr.h" -#include "wtf/PassOwnPtr.h" -#include "wtf/PassRefPtr.h" -#include "wtf/RefCounted.h" -#include "wtf/RefPtr.h" -#include "wtf/Vector.h" -#include "wtf/WeakPtr.h" - -namespace blink { - -class ExceptionState; -class MessagePort; -class ExecutionContext; -class SerializedScriptValue; - -// The overwhelmingly common case is sending a single port, so handle that efficiently with an inline buffer of size 1. -typedef WillBeHeapVector, 1> MessagePortArray; - -// Not to be confused with WebMessagePortChannelArray; this one uses Vector and OwnPtr instead of WebVector and raw pointers. -typedef Vector, 1> MessagePortChannelArray; - -class MessagePort FINAL : public RefCountedWillBeGarbageCollectedFinalized - , public ActiveDOMObject - , public EventTargetWithInlineData - , public WebMessagePortChannelClient { - DEFINE_WRAPPERTYPEINFO(); - REFCOUNTED_EVENT_TARGET(MessagePort); - WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(MessagePort); -public: - static PassRefPtrWillBeRawPtr create(ExecutionContext&); - virtual ~MessagePort(); - - void postMessage(ExecutionContext*, PassRefPtr message, const MessagePortArray*, ExceptionState&); - - void start(); - void close(); - - void entangle(PassOwnPtr); - PassOwnPtr disentangle(); - - static PassOwnPtr toWebMessagePortChannelArray(PassOwnPtr); - static PassOwnPtrWillBeRawPtr toMessagePortArray(ExecutionContext*, const WebMessagePortChannelArray&); - - // Returns 0 if there is an exception, or if the passed-in array is 0/empty. - static PassOwnPtr disentanglePorts(const MessagePortArray*, ExceptionState&); - - // Returns 0 if the passed array is 0/empty. - static PassOwnPtrWillBeRawPtr entanglePorts(ExecutionContext&, PassOwnPtr); - - bool started() const { return m_started; } - - virtual const AtomicString& interfaceName() const OVERRIDE; - virtual ExecutionContext* executionContext() const OVERRIDE { return ActiveDOMObject::executionContext(); } - virtual MessagePort* toMessagePort() OVERRIDE { return this; } - - // ActiveDOMObject implementation. - virtual bool hasPendingActivity() const OVERRIDE; - virtual void stop() OVERRIDE { close(); } - - void setOnmessage(PassRefPtr listener) - { - setAttributeEventListener(EventTypeNames::message, listener); - start(); - } - EventListener* onmessage() { return getAttributeEventListener(EventTypeNames::message); } - - // A port starts out its life entangled, and remains entangled until it is closed or is cloned. - bool isEntangled() const { return !m_closed && !isNeutered(); } - - // A port gets neutered when it is transferred to a new owner via postMessage(). - bool isNeutered() const { return !m_entangledChannel; } - -private: - explicit MessagePort(ExecutionContext&); - - // WebMessagePortChannelClient implementation. - virtual void messageAvailable() OVERRIDE; - void dispatchMessages(); - - OwnPtr m_entangledChannel; - - bool m_started; - bool m_closed; - - WeakPtrFactory m_weakFactory; -}; - -} // namespace blink - -#endif // MessagePort_h diff --git a/engine/core/dom/MessagePort.idl b/engine/core/dom/MessagePort.idl deleted file mode 100644 index 77d8652d2d66e303aeccf2414d9a1d5d51b4b0c8..0000000000000000000000000000000000000000 --- a/engine/core/dom/MessagePort.idl +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2008 Apple Inc. All Rights Reserved. - * Copyright (C) 2011 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -[ - ActiveDOMObject, - WillBeGarbageCollected -] interface MessagePort : EventTarget { - [Custom, RaisesException] void postMessage(any message, optional sequence transfer); - - void start(); - void close(); - - // event handler attributes - attribute EventHandler onmessage; -}; diff --git a/engine/core/events/CustomEvent.h b/engine/core/events/CustomEvent.h index ece5719ac247811ba5f95a9fe96be7ed15004cc8..ce53ba36ab9e638c714ab2e173fb306b1ff09a21 100644 --- a/engine/core/events/CustomEvent.h +++ b/engine/core/events/CustomEvent.h @@ -26,6 +26,7 @@ #ifndef CustomEvent_h #define CustomEvent_h +#include "bindings/core/v8/SerializedScriptValue.h" #include "core/events/Event.h" namespace blink { diff --git a/engine/core/events/EventTarget.cpp b/engine/core/events/EventTarget.cpp index 08f090fa63682119dc5810a7d1a02e78d02f305e..17f7b0b4ea16e4c49d6a89b5717545f1f9621080 100644 --- a/engine/core/events/EventTarget.cpp +++ b/engine/core/events/EventTarget.cpp @@ -76,11 +76,6 @@ LocalDOMWindow* EventTarget::toDOMWindow() return 0; } -MessagePort* EventTarget::toMessagePort() -{ - return 0; -} - inline LocalDOMWindow* EventTarget::executingWindow() { if (ExecutionContext* context = executionContext()) diff --git a/engine/core/events/EventTarget.h b/engine/core/events/EventTarget.h index 3872cd814daccc11d10acc1792db10b5b9783dfc..4ed90b8f42e34ef5f33581634f3add404d7455c8 100644 --- a/engine/core/events/EventTarget.h +++ b/engine/core/events/EventTarget.h @@ -42,7 +42,6 @@ namespace blink { class LocalDOMWindow; class Event; class ExceptionState; -class MessagePort; class Node; struct FiringEventIterator { @@ -106,7 +105,6 @@ public: virtual Node* toNode(); virtual LocalDOMWindow* toDOMWindow(); - virtual MessagePort* toMessagePort(); // FIXME: first 2 args to addEventListener and removeEventListener should // be required (per spec), but throwing TypeError breaks legacy content. diff --git a/engine/core/events/EventTargetFactory.in b/engine/core/events/EventTargetFactory.in index 410a80290b3dddf479b99d28100ed456c8d81c86..109d3f84bd1208b034ced72b7a745ddb5b701b08 100644 --- a/engine/core/events/EventTargetFactory.in +++ b/engine/core/events/EventTargetFactory.in @@ -3,7 +3,6 @@ namespace="EventTarget" core/animation/AnimationPlayer core/css/FontFaceSet core/css/MediaQueryList -core/dom/MessagePort core/dom/Node core/html/MediaController core/html/ime/InputMethodContext diff --git a/engine/core/events/MessageEvent.cpp b/engine/core/events/MessageEvent.cpp deleted file mode 100644 index bed429dce7715363a72811fa38bc3dd0eca5cc45..0000000000000000000000000000000000000000 --- a/engine/core/events/MessageEvent.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (C) 2007 Henry Mason (hmason@mac.com) - * Copyright (C) 2003, 2005, 2006, 2007, 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 "core/events/MessageEvent.h" - -#include "bindings/core/v8/ExceptionMessages.h" -#include "bindings/core/v8/ExceptionState.h" -#include "bindings/core/v8/custom/V8ArrayBufferCustom.h" - -namespace blink { - -static inline bool isValidSource(EventTarget* source) -{ - return !source || source->toDOMWindow() || source->toMessagePort(); -} - -MessageEventInit::MessageEventInit() -{ -} - -MessageEvent::MessageEvent() - : m_dataType(DataTypeScriptValue) -{ - ScriptWrappable::init(this); -} - -MessageEvent::MessageEvent(const AtomicString& type, const MessageEventInit& initializer) - : Event(type, initializer) - , m_dataType(DataTypeScriptValue) - , m_origin(initializer.origin) - , m_lastEventId(initializer.lastEventId) - , m_source(isValidSource(initializer.source.get()) ? initializer.source : nullptr) - , m_ports(adoptPtrWillBeNoop(new MessagePortArray(initializer.ports))) -{ - ScriptWrappable::init(this); - ASSERT(isValidSource(m_source.get())); -} - -MessageEvent::MessageEvent(const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtrWillBeRawPtr ports) - : Event(EventTypeNames::message, false, false) - , m_dataType(DataTypeScriptValue) - , m_origin(origin) - , m_lastEventId(lastEventId) - , m_source(source) - , m_ports(ports) -{ - ScriptWrappable::init(this); - ASSERT(isValidSource(m_source.get())); -} - -MessageEvent::MessageEvent(PassRefPtr data, const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtrWillBeRawPtr ports) - : Event(EventTypeNames::message, false, false) - , m_dataType(DataTypeSerializedScriptValue) - , m_dataAsSerializedScriptValue(data) - , m_origin(origin) - , m_lastEventId(lastEventId) - , m_source(source) - , m_ports(ports) -{ - ScriptWrappable::init(this); - if (m_dataAsSerializedScriptValue) - m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext(); - ASSERT(isValidSource(m_source.get())); -} - -MessageEvent::MessageEvent(PassRefPtr data, const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtr channels) - : Event(EventTypeNames::message, false, false) - , m_dataType(DataTypeSerializedScriptValue) - , m_dataAsSerializedScriptValue(data) - , m_origin(origin) - , m_lastEventId(lastEventId) - , m_source(source) - , m_channels(channels) -{ - ScriptWrappable::init(this); - if (m_dataAsSerializedScriptValue) - m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext(); - ASSERT(isValidSource(m_source.get())); -} - -MessageEvent::MessageEvent(const String& data, const String& origin) - : Event(EventTypeNames::message, false, false) - , m_dataType(DataTypeString) - , m_dataAsString(data) - , m_origin(origin) -{ - ScriptWrappable::init(this); -} - -MessageEvent::MessageEvent(PassRefPtr data, const String& origin) - : Event(EventTypeNames::message, false, false) - , m_dataType(DataTypeArrayBuffer) - , m_dataAsArrayBuffer(data) - , m_origin(origin) -{ - ScriptWrappable::init(this); -} - -MessageEvent::~MessageEvent() -{ -} - -PassRefPtrWillBeRawPtr MessageEvent::create(const AtomicString& type, const MessageEventInit& initializer, ExceptionState& exceptionState) -{ - if (initializer.source.get() && !isValidSource(initializer.source.get())) { - exceptionState.throwTypeError("The optional 'source' property is neither a Window nor MessagePort."); - return nullptr; - } - return adoptRefWillBeNoop(new MessageEvent(type, initializer)); -} - -void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& origin, const String& lastEventId, LocalDOMWindow* source, PassOwnPtrWillBeRawPtr ports) -{ - if (dispatched()) - return; - - initEvent(type, canBubble, cancelable); - - m_dataType = DataTypeScriptValue; - m_origin = origin; - m_lastEventId = lastEventId; - m_source = source; - m_ports = ports; -} - -void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr data, const String& origin, const String& lastEventId, LocalDOMWindow* source, PassOwnPtrWillBeRawPtr ports) -{ - if (dispatched()) - return; - - initEvent(type, canBubble, cancelable); - - m_dataType = DataTypeSerializedScriptValue; - m_dataAsSerializedScriptValue = data; - m_origin = origin; - m_lastEventId = lastEventId; - m_source = source; - m_ports = ports; - - if (m_dataAsSerializedScriptValue) - m_dataAsSerializedScriptValue->registerMemoryAllocatedWithCurrentScriptContext(); -} - -const AtomicString& MessageEvent::interfaceName() const -{ - return EventNames::MessageEvent; -} - -void MessageEvent::entangleMessagePorts(ExecutionContext* context) -{ - m_ports = MessagePort::entanglePorts(*context, m_channels.release()); -} - -void MessageEvent::trace(Visitor* visitor) -{ - visitor->trace(m_source); -#if ENABLE(OILPAN) - visitor->trace(m_ports); -#endif - Event::trace(visitor); -} - -v8::Handle MessageEvent::wrap(v8::Handle creationContext, v8::Isolate* isolate) -{ - v8::Handle wrapper = Event::wrap(creationContext, isolate); - - switch (dataType()) { - case MessageEvent::DataTypeScriptValue: - case MessageEvent::DataTypeSerializedScriptValue: - break; - case MessageEvent::DataTypeString: - V8HiddenValue::setHiddenValue(isolate, wrapper, V8HiddenValue::stringData(isolate), v8String(isolate, dataAsString())); - break; - case MessageEvent::DataTypeArrayBuffer: - V8HiddenValue::setHiddenValue(isolate, wrapper, V8HiddenValue::arrayBufferData(isolate), toV8(dataAsArrayBuffer(), wrapper, isolate)); - break; - } - - return wrapper; -} - -} // namespace blink diff --git a/engine/core/events/MessageEvent.h b/engine/core/events/MessageEvent.h deleted file mode 100644 index 4b4d832f97a7182119b21e90ffdefa737a722fad..0000000000000000000000000000000000000000 --- a/engine/core/events/MessageEvent.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (C) 2007 Henry Mason (hmason@mac.com) - * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -#ifndef MessageEvent_h -#define MessageEvent_h - -#include "bindings/core/v8/SerializedScriptValue.h" -#include "core/events/Event.h" -#include "core/events/EventTarget.h" -#include "core/dom/MessagePort.h" -#include "core/frame/LocalDOMWindow.h" -#include "wtf/ArrayBuffer.h" - -namespace blink { - -struct MessageEventInit : public EventInit { - MessageEventInit(); - - String origin; - String lastEventId; - RefPtrWillBeMember source; - MessagePortArray ports; -}; - -class MessageEvent FINAL : public Event { - DEFINE_WRAPPERTYPEINFO(); -public: - static PassRefPtrWillBeRawPtr create() - { - return adoptRefWillBeNoop(new MessageEvent); - } - static PassRefPtrWillBeRawPtr create(PassOwnPtrWillBeRawPtr ports, const String& origin = String(), const String& lastEventId = String(), PassRefPtrWillBeRawPtr source = nullptr) - { - return adoptRefWillBeNoop(new MessageEvent(origin, lastEventId, source, ports)); - } - static PassRefPtrWillBeRawPtr create(PassOwnPtrWillBeRawPtr ports, PassRefPtr data, const String& origin = String(), const String& lastEventId = String(), PassRefPtrWillBeRawPtr source = nullptr) - { - return adoptRefWillBeNoop(new MessageEvent(data, origin, lastEventId, source, ports)); - } - static PassRefPtrWillBeRawPtr create(PassOwnPtr channels, PassRefPtr data, const String& origin = String(), const String& lastEventId = String(), PassRefPtrWillBeRawPtr source = nullptr) - { - return adoptRefWillBeNoop(new MessageEvent(data, origin, lastEventId, source, channels)); - } - static PassRefPtrWillBeRawPtr create(const String& data, const String& origin = String()) - { - return adoptRefWillBeNoop(new MessageEvent(data, origin)); - } - static PassRefPtrWillBeRawPtr create(PassRefPtr data, const String& origin = String()) - { - return adoptRefWillBeNoop(new MessageEvent(data, origin)); - } - static PassRefPtrWillBeRawPtr create(const AtomicString& type, const MessageEventInit& initializer, ExceptionState&); - virtual ~MessageEvent(); - - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& origin, const String& lastEventId, LocalDOMWindow* source, PassOwnPtrWillBeRawPtr); - void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr data, const String& origin, const String& lastEventId, LocalDOMWindow* source, PassOwnPtrWillBeRawPtr); - - const String& origin() const { return m_origin; } - const String& lastEventId() const { return m_lastEventId; } - EventTarget* source() const { return m_source.get(); } - MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); } - MessagePortChannelArray* channels() const { return m_channels ? m_channels.get() : 0; } - - virtual const AtomicString& interfaceName() const OVERRIDE; - - enum DataType { - DataTypeScriptValue, - DataTypeSerializedScriptValue, - DataTypeString, - DataTypeArrayBuffer - }; - DataType dataType() const { return m_dataType; } - SerializedScriptValue* dataAsSerializedScriptValue() const { ASSERT(m_dataType == DataTypeScriptValue || m_dataType == DataTypeSerializedScriptValue); return m_dataAsSerializedScriptValue.get(); } - String dataAsString() const { ASSERT(m_dataType == DataTypeString); return m_dataAsString; } - ArrayBuffer* dataAsArrayBuffer() const { ASSERT(m_dataType == DataTypeArrayBuffer); return m_dataAsArrayBuffer.get(); } - - void setSerializedData(PassRefPtr data) - { - ASSERT(!m_dataAsSerializedScriptValue); - m_dataAsSerializedScriptValue = data; - } - - void entangleMessagePorts(ExecutionContext*); - - virtual void trace(Visitor*) OVERRIDE; - - virtual v8::Handle wrap(v8::Handle creationContext, v8::Isolate*) OVERRIDE; - -private: - MessageEvent(); - MessageEvent(const AtomicString&, const MessageEventInit&); - MessageEvent(const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtrWillBeRawPtr); - MessageEvent(PassRefPtr data, const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtrWillBeRawPtr); - MessageEvent(PassRefPtr data, const String& origin, const String& lastEventId, PassRefPtrWillBeRawPtr source, PassOwnPtr); - - MessageEvent(const String& data, const String& origin); - MessageEvent(PassRefPtr data, const String& origin); - - DataType m_dataType; - RefPtr m_dataAsSerializedScriptValue; - String m_dataAsString; - RefPtr m_dataAsArrayBuffer; - String m_origin; - String m_lastEventId; - RefPtrWillBeMember m_source; - // m_ports are the MessagePorts in an engtangled state, and m_channels are - // the MessageChannels in a disentangled state. Only one of them can be - // non-empty at a time. entangleMessagePorts() moves between the states. - OwnPtrWillBeMember m_ports; - OwnPtr m_channels; -}; - -} // namespace blink - -#endif // MessageEvent_h diff --git a/engine/core/events/MessageEvent.idl b/engine/core/events/MessageEvent.idl deleted file mode 100644 index ae8f4437e30f815ddbd65ca46638bffb78b4a5a5..0000000000000000000000000000000000000000 --- a/engine/core/events/MessageEvent.idl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2007 Henry Mason - * Copyright (C) 2011 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: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. 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. - * - * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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. - * - */ - -[ - EventConstructor, - RaisesException=Constructor, - Custom=Wrap, -] interface MessageEvent : Event { - [InitializedByEventConstructor] readonly attribute DOMString origin; - [InitializedByEventConstructor] readonly attribute DOMString lastEventId; - [InitializedByEventConstructor] readonly attribute EventTarget? source; // May be a Window or a MessagePort - [InitializedByEventConstructor, Custom=Getter] readonly attribute any data; - [InitializedByEventConstructor] readonly attribute MessagePort[] ports; - [Custom, MeasureAs=InitMessageEvent] void initMessageEvent([Default=Undefined] optional DOMString typeArg, - [Default=Undefined] optional boolean canBubbleArg, - [Default=Undefined] optional boolean cancelableArg, - [Default=Undefined] optional any dataArg, - [Default=Undefined] optional DOMString originArg, - [Default=Undefined] optional DOMString lastEventIdArg, - [Default=Undefined] optional Window sourceArg, - [Default=Undefined] optional MessagePort[] messagePorts); -}; diff --git a/engine/core/frame/LocalDOMWindow.cpp b/engine/core/frame/LocalDOMWindow.cpp index 23b63cc738fc293071fa706ab7022affe2a10302..ec0b93616e9567800ad7250f2fbcd2fe27295635 100644 --- a/engine/core/frame/LocalDOMWindow.cpp +++ b/engine/core/frame/LocalDOMWindow.cpp @@ -50,7 +50,6 @@ #include "core/events/DOMWindowEventQueue.h" #include "core/events/EventListener.h" #include "core/events/HashChangeEvent.h" -#include "core/events/MessageEvent.h" #include "core/events/PageTransitionEvent.h" #include "core/events/PopStateEvent.h" #include "core/frame/Console.h" diff --git a/engine/core/frame/LocalDOMWindow.h b/engine/core/frame/LocalDOMWindow.h index 3ddc049d6cc696ce0c161ce5b8fe4be7fec7248e..b18ed31083828b6a6bc8668932a93ca4afaf2d76 100644 --- a/engine/core/frame/LocalDOMWindow.h +++ b/engine/core/frame/LocalDOMWindow.h @@ -28,6 +28,7 @@ #define LocalDOMWindow_h #include "bindings/core/v8/Dictionary.h" +#include "bindings/core/v8/SerializedScriptValue.h" #include "core/events/EventTarget.h" #include "core/frame/DOMWindowBase64.h" #include "core/frame/FrameDestructionObserver.h" @@ -64,7 +65,6 @@ class IDBFactory; class LocalFrame; class Location; class MediaQueryList; -class MessageEvent; class Node; class Page; class RequestAnimationFrameCallback; @@ -74,8 +74,6 @@ class ScriptCallStack; class SerializedScriptValue; class StyleMedia; -typedef WillBeHeapVector, 1> MessagePortArray; - enum PageshowEventPersistence { PageshowEventNotPersisted = 0, PageshowEventPersisted = 1 diff --git a/engine/core/frame/Window.idl b/engine/core/frame/Window.idl index 15fd0b1574e484e42f8a098f30f545a6b8d966ad..5daac653f0af98655839d9947a72ea965720a64f 100644 --- a/engine/core/frame/Window.idl +++ b/engine/core/frame/Window.idl @@ -132,21 +132,6 @@ [Custom, NotEnumerable] getter Window (DOMString name); }; -// http://www.whatwg.org/specs/web-apps/current-work/#transferable-objects -// -// Expressing the Transferable typedef in IDL depends on http://crbug.com/240176. -// The postMessage() methods taking a Transferable array argument have custom -// binding code that is able to handle the Transferables that we currently -// recognize. To be able to declare a postMessage() signature that matches -// the implementation, we provide a Transferable typedef but with an -// incomplete type. -// -// FIXME: make this typedef accurate once enough of http://crbug.com/240176 -// is in place. -// FIXME: consider putting this typedef in an .idl file containing spec-wide -// utility type definitions. -typedef MessagePort Transferable; - Window implements WindowBase64; Window implements WindowEventHandlers; Window implements WindowTimers; diff --git a/engine/core/loader/FrameLoaderClient.h b/engine/core/loader/FrameLoaderClient.h index 773d1292bd22031fbb909b346a7ae7420c5610a5..dd9c9e7afcb8b0f620dcef379f249c86aac942f6 100644 --- a/engine/core/loader/FrameLoaderClient.h +++ b/engine/core/loader/FrameLoaderClient.h @@ -52,7 +52,6 @@ namespace blink { class IntSize; class KURL; class LocalFrame; - class MessageEvent; class Page; class ResourceError; class ResourceHandle; diff --git a/engine/public/platform/Platform.h b/engine/public/platform/Platform.h index d542900c23d6c1f9df43f86ad985aee2d5e48d3f..e4dadb48f31837f44b1ce4f09eae75f2397f68a7 100644 --- a/engine/public/platform/Platform.h +++ b/engine/public/platform/Platform.h @@ -60,7 +60,6 @@ class WebFlingAnimator; class WebGestureCurveTarget; class WebGestureCurve; class WebGraphicsContext3DProvider; -class WebMessagePortChannel; class WebMimeRegistry; class WebPublicSuffixList; class WebSandboxSupport; @@ -169,14 +168,6 @@ public: // See comments on ImageDecoder::m_maxDecodedBytes. virtual size_t maxDecodedImageBytes() { return noDecodedImageByteLimit; } - - // Message Ports ------------------------------------------------------- - - // Creates a Message Port Channel pair. This can be called on any thread. - // The returned objects should only be used on the thread they were created on. - virtual void createMessageChannel(WebMessagePortChannel** channel1, WebMessagePortChannel** channel2) { *channel1 = 0; *channel2 = 0; } - - // Network ------------------------------------------------------------- // Returns a new WebURLLoader instance. diff --git a/engine/public/platform/WebMessagePortChannel.h b/engine/public/platform/WebMessagePortChannel.h deleted file mode 100644 index 6fce4e7a8831b443b2d5b3458cf91b181e717b58..0000000000000000000000000000000000000000 --- a/engine/public/platform/WebMessagePortChannel.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef WebMessagePortChannel_h -#define WebMessagePortChannel_h - -#include "WebCommon.h" -#include "WebVector.h" - -namespace blink { - -class WebMessagePortChannelClient; -class WebString; - -typedef WebVector WebMessagePortChannelArray; - -// Provides an interface to a Message Port Channel implementation. The object owns itself and -// is signalled that its not needed anymore with the destroy() call. -class WebMessagePortChannel { -public: - virtual void setClient(WebMessagePortChannelClient*) = 0; - virtual void destroy() = 0; - // Callee receives ownership of the passed vector. - // FIXME: Blob refs should be passed to maintain ref counts. crbug.com/351753 - virtual void postMessage(const WebString&, WebMessagePortChannelArray*) = 0; - virtual bool tryGetMessage(WebString*, WebMessagePortChannelArray&) = 0; - -protected: - ~WebMessagePortChannel() { } -}; - -} // namespace blink - -#if INSIDE_BLINK - -namespace WTF { - -template struct OwnedPtrDeleter; -template<> struct OwnedPtrDeleter { - static void deletePtr(blink::WebMessagePortChannel* channel) - { - if (channel) - channel->destroy(); - } -}; - -} // namespace WTF - -#endif // INSIDE_BLINK - -#endif // WebMessagePortChannel_h diff --git a/engine/public/platform/WebMessagePortChannelClient.h b/engine/public/platform/WebMessagePortChannelClient.h deleted file mode 100644 index 9389338bc37d6c01d478ca50332773e55574cf69..0000000000000000000000000000000000000000 --- a/engine/public/platform/WebMessagePortChannelClient.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2009 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. - */ - -#ifndef WebMessagePortChannelClient_h -#define WebMessagePortChannelClient_h - -namespace blink { - -// Provides an interface for users of WebMessagePortChannel to be notified -// when messages are available. -class WebMessagePortChannelClient { -public: - // Alerts that new messages have arrived, which are retrieved by calling - // WebMessagePortChannel::tryGetMessage. Note that this may be called - // on any thread. - virtual void messageAvailable() = 0; - -protected: - ~WebMessagePortChannelClient() { } -}; - -} // namespace blink - -#endif diff --git a/engine/public/web/WebDOMEvent.h b/engine/public/web/WebDOMEvent.h index 63bbb09a2927e7d955abae9ffd95c1c56cb8fde2..27056555b65a2c07db741a1ff51b568f306e1df1 100644 --- a/engine/public/web/WebDOMEvent.h +++ b/engine/public/web/WebDOMEvent.h @@ -83,7 +83,6 @@ public: BLINK_EXPORT bool isCompositionEvent() const; BLINK_EXPORT bool isDragEvent() const; BLINK_EXPORT bool isClipboardEvent() const; - BLINK_EXPORT bool isMessageEvent() const; BLINK_EXPORT bool isWheelEvent() const; BLINK_EXPORT bool isBeforeTextInsertedEvent() const; BLINK_EXPORT bool isOverflowEvent() const; diff --git a/engine/public/web/WebDOMMessageEvent.h b/engine/public/web/WebDOMMessageEvent.h deleted file mode 100644 index 5d8dc08f73a5d6a729e17d0366f1b32066982eb6..0000000000000000000000000000000000000000 --- a/engine/public/web/WebDOMMessageEvent.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2011 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. - */ -#ifndef WebDOMMessageEvent_h -#define WebDOMMessageEvent_h - -#include "../platform/WebMessagePortChannel.h" -#include "WebDOMEvent.h" -#include "WebSerializedScriptValue.h" - -#if BLINK_IMPLEMENTATION -#include "core/events/Event.h" -#include "core/events/MessageEvent.h" -#endif - -namespace blink { - -class WebFrame; -class WebString; - -class WebDOMMessageEvent : public WebDOMEvent { -public: - WebDOMMessageEvent() { } - BLINK_EXPORT void initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMessagePortChannelArray& channels = WebMessagePortChannelArray()); - - BLINK_EXPORT WebSerializedScriptValue data() const; - BLINK_EXPORT WebString origin() const; - - BLINK_EXPORT WebMessagePortChannelArray releaseChannels(); - -#if BLINK_IMPLEMENTATION - explicit WebDOMMessageEvent(const PassRefPtrWillBeRawPtr& e) : WebDOMEvent(e) { } -#endif -}; - -} // namespace blink - -#endif diff --git a/engine/public/web/WebFrame.h b/engine/public/web/WebFrame.h index 01f08c9f9a4017cc8727630636f8eeb0fa95e003..451c570530faf2627f13e960af4d2c0d76520642 100644 --- a/engine/public/web/WebFrame.h +++ b/engine/public/web/WebFrame.h @@ -36,7 +36,6 @@ #include "WebNode.h" #include "WebURLLoaderOptions.h" #include "public/platform/WebCanvas.h" -#include "public/platform/WebMessagePortChannel.h" #include "public/platform/WebPrivateOwnPtr.h" #include "public/platform/WebReferrerPolicy.h" #include "public/platform/WebURL.h" diff --git a/engine/public/web/WebFrameClient.h b/engine/public/web/WebFrameClient.h index 4ca5ced87c1c9b805e5e792c761f70d7cfeef89c..693fc67f80d30276dad62e237107d7ce44bf5cb1 100644 --- a/engine/public/web/WebFrameClient.h +++ b/engine/public/web/WebFrameClient.h @@ -33,7 +33,6 @@ #include "../platform/WebColor.h" #include "WebAXObject.h" -#include "WebDOMMessageEvent.h" #include "WebFrame.h" #include "WebIconURL.h" #include "WebNavigationPolicy.h" diff --git a/engine/web/BUILD.gn b/engine/web/BUILD.gn index fba458d4a9f9f18959a03d608108cf1750471ad8..1e3317f3089d0c44f2f0f869929d3e1c2c59cdcc 100644 --- a/engine/web/BUILD.gn +++ b/engine/web/BUILD.gn @@ -72,7 +72,6 @@ component("web") { "WebDOMCustomEvent.cpp", "WebDOMError.cpp", "WebDOMEvent.cpp", - "WebDOMMessageEvent.cpp", "WebDOMMouseEvent.cpp", "WebDOMProgressEvent.cpp", "WebDOMResourceProgressEvent.cpp", diff --git a/engine/web/FrameLoaderClientImpl.cpp b/engine/web/FrameLoaderClientImpl.cpp index acfb8a0e1953f65f2ef423da9c5492b5c8fb111d..06740dcdb2e03078aa9d0ebc500115485d37c425 100644 --- a/engine/web/FrameLoaderClientImpl.cpp +++ b/engine/web/FrameLoaderClientImpl.cpp @@ -34,7 +34,6 @@ #include "bindings/core/v8/ScriptController.h" #include "core/dom/Document.h" -#include "core/events/MessageEvent.h" #include "core/events/MouseEvent.h" #include "core/frame/FrameView.h" #include "core/frame/Settings.h" diff --git a/engine/web/WebDOMEvent.cpp b/engine/web/WebDOMEvent.cpp index e4ebeb8c34d85a37bc44497fe781db3bd295d7cb..11966c8aa785492614ef5d7dea0540f593550b19 100644 --- a/engine/web/WebDOMEvent.cpp +++ b/engine/web/WebDOMEvent.cpp @@ -147,12 +147,6 @@ bool WebDOMEvent::isClipboardEvent() const return m_private->isClipboardEvent(); } -bool WebDOMEvent::isMessageEvent() const -{ - ASSERT(m_private.get()); - return m_private->hasInterface(EventNames::MessageEvent); -} - bool WebDOMEvent::isWheelEvent() const { ASSERT(m_private.get()); diff --git a/engine/web/WebDOMMessageEvent.cpp b/engine/web/WebDOMMessageEvent.cpp deleted file mode 100644 index 0e76871d536bf89e9aab8c6b19cc3b07492f8c5c..0000000000000000000000000000000000000000 --- a/engine/web/WebDOMMessageEvent.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2011 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 "public/web/WebDOMMessageEvent.h" - -#include "bindings/core/v8/SerializedScriptValue.h" -#include "core/dom/Document.h" -#include "core/dom/MessagePort.h" -#include "core/events/MessageEvent.h" -#include "core/frame/LocalDOMWindow.h" -#include "public/platform/WebString.h" -#include "public/web/WebFrame.h" -#include "public/web/WebSerializedScriptValue.h" -#include "web/WebLocalFrameImpl.h" - -namespace blink { - -void WebDOMMessageEvent::initMessageEvent(const WebString& type, bool canBubble, bool cancelable, const WebSerializedScriptValue& messageData, const WebString& origin, const WebFrame* sourceFrame, const WebString& lastEventId, const WebMessagePortChannelArray& webChannels) -{ - ASSERT(m_private.get()); - ASSERT(isMessageEvent()); - LocalDOMWindow* window = 0; - if (sourceFrame) - window = toWebLocalFrameImpl(sourceFrame)->frame()->domWindow(); - OwnPtrWillBeRawPtr ports = nullptr; - if (sourceFrame) - ports = MessagePort::toMessagePortArray(window->document(), webChannels); - unwrap()->initMessageEvent(type, canBubble, cancelable, messageData, origin, lastEventId, window, ports.release()); -} - -WebSerializedScriptValue WebDOMMessageEvent::data() const -{ - return WebSerializedScriptValue(constUnwrap()->dataAsSerializedScriptValue()); -} - -WebString WebDOMMessageEvent::origin() const -{ - return WebString(constUnwrap()->origin()); -} - -WebMessagePortChannelArray WebDOMMessageEvent::releaseChannels() -{ - MessagePortChannelArray* channels = constUnwrap()->channels(); - WebMessagePortChannelArray webChannels(channels ? channels->size() : 0); - if (channels) { - for (size_t i = 0; i < channels->size(); ++i) - webChannels[i] = (*channels)[i].leakPtr(); - } - return webChannels; -} - -} // namespace blink diff --git a/engine/web/WebLocalFrameImpl.cpp b/engine/web/WebLocalFrameImpl.cpp index bc07f9eaf8034b89b402bf241067adcb20f0f50b..440ea93bfbeaa2f76ea3af3c2d6b60be19cafec5 100644 --- a/engine/web/WebLocalFrameImpl.cpp +++ b/engine/web/WebLocalFrameImpl.cpp @@ -81,7 +81,6 @@ #include "bindings/core/v8/V8GCController.h" #include "bindings/core/v8/V8PerIsolateData.h" #include "core/dom/Document.h" -#include "core/dom/MessagePort.h" #include "core/dom/Node.h" #include "core/dom/NodeTraversal.h" #include "core/dom/shadow/ShadowRoot.h" diff --git a/engine/web/WebSerializedScriptValue.cpp b/engine/web/WebSerializedScriptValue.cpp index 6211274913ae7051d8e464bb33587b463df3d176..4ffd3fb47fe9ea72b1e081e730b0c67d05a4c4b8 100644 --- a/engine/web/WebSerializedScriptValue.cpp +++ b/engine/web/WebSerializedScriptValue.cpp @@ -45,7 +45,7 @@ WebSerializedScriptValue WebSerializedScriptValue::fromString(const WebString& s WebSerializedScriptValue WebSerializedScriptValue::serialize(v8::Handle value) { TrackExceptionState exceptionState; - WebSerializedScriptValue serializedValue = SerializedScriptValue::create(value, 0, 0, exceptionState, v8::Isolate::GetCurrent()); + WebSerializedScriptValue serializedValue = SerializedScriptValue::create(value, 0, exceptionState, v8::Isolate::GetCurrent()); if (exceptionState.hadException()) return createInvalid(); return serializedValue;