diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSMessagePortCustom.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/js/JSMessagePortCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSMessagePortCustom.cpp | 78 |
1 files changed, 3 insertions, 75 deletions
diff --git a/Source/WebCore/bindings/js/JSMessagePortCustom.cpp b/Source/WebCore/bindings/js/JSMessagePortCustom.cpp index 33ed4dc3a..b168cf22f 100644 --- a/Source/WebCore/bindings/js/JSMessagePortCustom.cpp +++ b/Source/WebCore/bindings/js/JSMessagePortCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008, 2009 Apple Inc. All Rights Reserved. + * Copyright (C) 2008-2009, 2016 Apple Inc. All Rights Reserved. * Copyright (C) 2011 Google Inc. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,87 +27,15 @@ #include "config.h" #include "JSMessagePort.h" -#include "Event.h" -#include "ExceptionCode.h" -#include "Frame.h" -#include "JSDOMGlobalObject.h" -#include "JSEvent.h" -#include "JSEventListener.h" -#include "JSMessagePortCustom.h" -#include "MessagePort.h" -#include <runtime/Error.h> -#include <runtime/JSArrayBuffer.h> -#include <wtf/text/AtomicString.h> - using namespace JSC; namespace WebCore { -void JSMessagePort::visitChildren(JSCell* cell, SlotVisitor& visitor) +void JSMessagePort::visitAdditionalChildren(SlotVisitor& visitor) { - JSMessagePort* thisObject = jsCast<JSMessagePort*>(cell); - ASSERT_GC_OBJECT_INHERITS(thisObject, info()); - COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag); - ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren()); - Base::visitChildren(thisObject, visitor); - // If we have a locally entangled port, we can directly mark it as reachable. Ports that are remotely entangled are marked in-use by markActiveObjectsForContext(). - if (MessagePort* port = thisObject->m_impl->locallyEntangledPort()) + if (MessagePort* port = wrapped().locallyEntangledPort()) visitor.addOpaqueRoot(port); - - thisObject->m_impl->visitJSEventListeners(visitor); -} - -JSC::JSValue JSMessagePort::postMessage(JSC::ExecState* exec) -{ - return handlePostMessage(exec, &impl()); -} - -void fillMessagePortArray(JSC::ExecState* exec, JSC::JSValue value, MessagePortArray& portArray, ArrayBufferArray& arrayBuffers) -{ - // Convert from the passed-in JS array-like object to 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. - if (value.isUndefinedOrNull()) { - portArray.resize(0); - arrayBuffers.resize(0); - return; - } - - // Validation of sequence types, per WebIDL spec 4.1.13. - unsigned length = 0; - JSObject* object = toJSSequence(exec, value, length); - if (exec->hadException()) - return; - - for (unsigned i = 0 ; i < length; ++i) { - JSValue value = object->get(exec, i); - if (exec->hadException()) - return; - // Validation of non-null objects, per HTML5 spec 10.3.3. - if (value.isUndefinedOrNull()) { - setDOMException(exec, INVALID_STATE_ERR); - return; - } - - // Validation of Objects implementing an interface, per WebIDL spec 4.1.15. - RefPtr<MessagePort> port = toMessagePort(value); - if (port) { - // Check for duplicate ports. - if (portArray.contains(port)) { - setDOMException(exec, INVALID_STATE_ERR); - return; - } - portArray.append(port.release()); - } else { - RefPtr<ArrayBuffer> arrayBuffer = toArrayBuffer(value); - if (arrayBuffer) - arrayBuffers.append(arrayBuffer); - else { - throwTypeError(exec); - return; - } - } - } } } // namespace WebCore |