Changeset 207381 in webkit
- Timestamp:
- Oct 15, 2016 2:52:09 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r207373 r207381 1 2016-10-15 Sam Weinig <sam@webkit.org> 2 3 MessageEvent's source property should be a (DOMWindow or MessagePort)? rather than a EventTarget? 4 https://bugs.webkit.org/show_bug.cgi?id=163475 5 6 Reviewed by Simon Fraser. 7 8 * fast/dom/message-port-deleted-by-accessor.html: 9 Switch source parameter to null to avoid accidental type error. 10 11 * fast/events/constructors/message-event-constructor-expected.txt: 12 * fast/events/constructors/message-event-constructor.html: 13 Update test expect a thrown type error, as is now expected, for non-window or MessagePort EventTargets. 14 1 15 2016-10-15 Antoine Quint <graouts@apple.com> 2 16 -
trunk/LayoutTests/fast/dom/message-port-deleted-by-accessor.html
r120792 r207381 10 10 event = document.createEvent("MessageEvent"); 11 11 12 event.initMessageEvent(0, 0, 0, 0, 0, 0, 0, [channel.port1, channel.port2]);12 event.initMessageEvent(0, 0, 0, 0, 0, 0, null, [channel.port1, channel.port2]); 13 13 14 14 Array.prototype.__defineSetter__(0, function() { 15 event.initMessageEvent(0, 0, 0, 0, 0, 0, 0, [ ]);15 event.initMessageEvent(0, 0, 0, 0, 0, 0, null, [ ]); 16 16 }); 17 17 -
trunk/LayoutTests/fast/events/constructors/message-event-constructor-expected.txt
r207150 r207381 63 63 PASS new MessageEvent('eventType', { ports: [channel.port1], source: channel.port1 }).source is channel.port1 64 64 PASS new MessageEvent('eventType', { source: test_object }).source threw exception TypeError: Type error. 65 PASS new MessageEvent('eventType', { source: document }).source is null66 PASS new MessageEvent('eventType', { source: document.body }).source is null65 PASS new MessageEvent('eventType', { source: document }).source threw exception TypeError: Type error. 66 PASS new MessageEvent('eventType', { source: document.body }).source threw exception TypeError: Type error. 67 67 PASS new MessageEvent('eventType', { source: undefined }).source is null 68 68 PASS new MessageEvent('eventType', { source: null }).source is null -
trunk/LayoutTests/fast/events/constructors/message-event-constructor.html
r207016 r207381 78 78 // Unacceptable source objects (not a Window or a MessagePort). 79 79 shouldThrowErrorName("new MessageEvent('eventType', { source: test_object }).source", "TypeError"); 80 should Be("new MessageEvent('eventType', { source: document }).source", "null");81 should Be("new MessageEvent('eventType', { source: document.body }).source", "null");80 shouldThrowErrorName("new MessageEvent('eventType', { source: document }).source", "TypeError"); 81 shouldThrowErrorName("new MessageEvent('eventType', { source: document.body }).source", "TypeError"); 82 82 shouldBe("new MessageEvent('eventType', { source: undefined }).source", "null"); 83 83 shouldBe("new MessageEvent('eventType', { source: null }).source", "null"); -
trunk/Source/WTF/ChangeLog
r207237 r207381 1 2016-10-15 Sam Weinig <sam@webkit.org> 2 3 MessageEvent's source property should be a (DOMWindow or MessagePort)? rather than a EventTarget? 4 https://bugs.webkit.org/show_bug.cgi?id=163475 5 6 Reviewed by Simon Fraser. 7 8 * wtf/Variant.h: 9 Add missing return statement that was tripping up some compilers. 10 1 11 2016-10-12 Ryan Haddad <ryanhaddad@apple.com> 2 12 -
trunk/Source/WTF/wtf/Variant.h
r204433 r207381 1945 1945 static constexpr typename __multi_visitor_return_type<_Visitor,_Variants...>::__type 1946 1946 __visit(_Visitor&,_Variants&& ...){ 1947 __throw_bad_variant_access<typename __multi_visitor_return_type<_Visitor,_Variants...>::__type>("Visiting of empty variant");1947 return __throw_bad_variant_access<typename __multi_visitor_return_type<_Visitor,_Variants...>::__type>("Visiting of empty variant"); 1948 1948 } 1949 1949 }; -
trunk/Source/WebCore/ChangeLog
r207380 r207381 1 2016-10-14 Sam Weinig <sam@webkit.org> 2 3 MessageEvent's source property should be a (DOMWindow or MessagePort)? rather than a EventTarget? 4 https://bugs.webkit.org/show_bug.cgi?id=163475 5 6 Reviewed by Simon Fraser. 7 8 Start fleshing out union support, starting with MessageEvent. 9 - Simplify things a bit for now by requiring interface types to use RefPtr<T> as their type when 10 used in sequences and unions. We should revisit this later, and see if we can use Ref<T> where 11 possible, but it causes complications for dictionaries, since they want a Ref<T> uninitialized. 12 13 * bindings/generic/IDLTypes.h: 14 Switch IDLInterface to use RefPtr<T> as its implementation type. 15 16 * bindings/js/JSDOMConvert.h: 17 (WebCore::Detail::VariadicConverterBase::convert): 18 - Remove isJSDOMWrapperType() optimization. It was not correct, due to not being able to detect window 19 and window shell, and not always an optimization, e.g. in the case of a single interface. 20 - Switch from JSC::jsDynamicCast<WrapperType*>() to WrapperType::toWrapped() which can be faster and 21 handles window and window shell correctly. 22 - Also fix an issue where we would wrongly assert that one interface had to match. 23 24 * bindings/js/JSDOMWrapper.h: 25 (WebCore::isJSDOMWrapperType): Deleted. 26 Remove unused predicate. 27 28 * bindings/scripts/IDLParser.pm: 29 (parseType): 30 Add missing support for nullable unions. 31 32 * bindings/scripts/test/JS/JSTestObj.cpp: 33 * bindings/scripts/test/TestObj.idl: 34 Add new tests for unions (both non-null and nullable) in dictionaries. 35 36 * dom/ContainerNode.cpp: 37 (WebCore::ContainerNode::append): 38 (WebCore::ContainerNode::prepend): 39 * dom/ContainerNode.h: 40 * dom/Node.cpp: 41 (WebCore::nodeSetPreTransformedFromNodeOrStringVector): 42 (WebCore::Node::convertNodesOrStringsIntoNode): 43 (WebCore::Node::before): 44 (WebCore::Node::after): 45 (WebCore::Node::replaceWith): 46 * dom/Node.h: 47 Add using declaration for NodeOrString and change it to use RefPtr<Node>. 48 49 * bindings/js/JSMessageEventCustom.cpp: 50 (WebCore::handleInitMessageEvent): 51 * dom/MessageEvent.cpp: 52 (WebCore::MessageEvent::MessageEvent): 53 (WebCore::MessageEvent::create): 54 (WebCore::MessageEvent::initMessageEvent): 55 (WebCore::MessageEvent::source): 56 (WebCore::isValidSource): Deleted. 57 * dom/MessageEvent.h: 58 * dom/MessageEvent.idl: 59 * page/DOMWindow.cpp: 60 (WebCore::PostMessageTimer::event): 61 Change MessageEvent's source to be a std::experimental::variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>. 62 For now, we only enforce this on setting, and leave the getter a EventTarget?, but that should not be 63 observable, and will rectified in subsequent patches. 64 1 65 2016-10-15 Chris Dumez <cdumez@apple.com> 2 66 -
trunk/Source/WebCore/bindings/generic/IDLTypes.h
r207150 r207381 85 85 struct IDLObject : IDLUnsupportedType { }; 86 86 87 template<typename T> struct IDLInterface : IDLType< std::reference_wrapper<T>> {87 template<typename T> struct IDLInterface : IDLType<RefPtr<T>> { 88 88 using RawType = T; 89 using NullableType = T*;89 using NullableType = RefPtr<T>; 90 90 }; 91 91 -
trunk/Source/WebCore/bindings/js/JSDOMConvert.h
r207277 r207381 516 516 // (FIXME: Add support for object and step 4.2) 517 517 if (brigand::any<TypeList, IsIDLInterface<brigand::_1>>::value) { 518 if (isJSDOMWrapperType(value)) { 519 Optional<ReturnType> returnValue; 520 brigand::for_each<InterfaceTypeList>([&](auto&& type) { 521 if (returnValue) 522 return; 523 524 using ImplementationType = typename WTF::RemoveCVAndReference<decltype(type)>::type::type::RawType; 525 using WrapperType = typename JSDOMWrapperConverterTraits<ImplementationType>::WrapperClass; 526 527 auto* castedValue = JSC::jsDynamicCast<WrapperType*>(value); 528 if (!castedValue) 529 return; 530 531 returnValue = ReturnType(castedValue->wrapped()); 532 }); 533 ASSERT(returnValue); 534 518 Optional<ReturnType> returnValue; 519 brigand::for_each<InterfaceTypeList>([&](auto&& type) { 520 if (returnValue) 521 return; 522 523 using ImplementationType = typename WTF::RemoveCVAndReference<decltype(type)>::type::type::RawType; 524 using WrapperType = typename JSDOMWrapperConverterTraits<ImplementationType>::WrapperClass; 525 526 auto* castedValue = WrapperType::toWrapped(value); 527 if (!castedValue) 528 return; 529 530 returnValue = ReturnType(castedValue); 531 }); 532 533 if (returnValue) 535 534 return WTFMove(returnValue.value()); 536 }537 535 } 538 536 … … 593 591 RETURN_IF_EXCEPTION(scope, Nullopt); 594 592 595 return result;593 return WTFMove(result); 596 594 } 597 595 }; … … 599 597 template<typename T> 600 598 struct VariadicConverterBase<IDLInterface<T>> { 601 using Item = typename IDLInterface<T>::ImplementationType;599 using Item = std::reference_wrapper<T>; 602 600 603 601 static Optional<Item> convert(JSC::ExecState& state, JSC::JSValue value) -
trunk/Source/WebCore/bindings/js/JSDOMWrapper.h
r207239 r207381 87 87 }; 88 88 89 ALWAYS_INLINE bool isJSDOMWrapperType(JSC::JSValue value)90 {91 if (UNLIKELY(!value.isCell()))92 return false;93 return value.asCell()->type() >= JSDOMWrapperType;94 }95 96 89 template<typename ImplementationClass> struct JSDOMWrapperConverterTraits; 97 90 -
trunk/Source/WebCore/bindings/js/JSMessageEventCustom.cpp
r206575 r207381 36 36 #include "JSDOMWindow.h" 37 37 #include "JSEventTarget.h" 38 #include "JSMessagePort.h" 38 39 #include "JSMessagePortCustom.h" 39 40 #include "MessageEvent.h" … … 113 114 const String originArg = valueToUSVString(&state, state.argument(4)); 114 115 const String lastEventIdArg = state.argument(5).toString(&state)->value(&state); 115 DOMWindow* sourceArg = JSDOMWindow::toWrapped(state.argument(6));116 auto sourceArg = convert<IDLNullable<IDLUnion<IDLInterface<DOMWindow>, IDLInterface<MessagePort>>>>(state, state.argument(6)); 116 117 std::unique_ptr<MessagePortArray> messagePorts; 117 118 std::unique_ptr<ArrayBufferArray> arrayBuffers; … … 126 127 127 128 MessageEvent& event = jsEvent->wrapped(); 128 event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, sourceArg, WTFMove(messagePorts));129 event.initMessageEvent(typeArg, canBubbleArg, cancelableArg, dataArg, originArg, lastEventIdArg, WTFMove(sourceArg), WTFMove(messagePorts)); 129 130 jsEvent->m_data.set(vm, jsEvent, dataArg.jsValue()); 130 131 return jsUndefined(); -
trunk/Source/WebCore/bindings/scripts/IDLParser.pm
r207378 r207381 1952 1952 my $next = $self->nextToken(); 1953 1953 if ($next->value() eq "(") { 1954 return $self->parseUnionType(); 1954 my $unionType = $self->parseUnionType(); 1955 $unionType->isNullable($self->parseNull()); 1956 return $unionType; 1955 1957 } 1956 1958 if ($next->type() == IdentifierToken || $next->value() =~ /$nextType_1/) { -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r207378 r207381 567 567 } else 568 568 result.nullableStringWithDefault = String(); 569 JSValue nullableUnionMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "nullableUnionMember")); 570 if (!nullableUnionMemberValue.isUndefined()) { 571 result.nullableUnionMember = convert<IDLNullable<IDLUnion<IDLLong, IDLInterface<Node>>>>(state, nullableUnionMemberValue); 572 RETURN_IF_EXCEPTION(throwScope, Nullopt); 573 } else 574 result.nullableUnionMember = Nullopt; 569 575 JSValue restrictedDoubleValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "restrictedDouble")); 570 576 if (!restrictedDoubleValue.isUndefined()) { … … 624 630 if (!stringWithoutDefaultValue.isUndefined()) { 625 631 result.stringWithoutDefault = convert<IDLDOMString>(state, stringWithoutDefaultValue); 632 RETURN_IF_EXCEPTION(throwScope, Nullopt); 633 } 634 JSValue unionMemberValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "unionMember")); 635 if (!unionMemberValue.isUndefined()) { 636 result.unionMember = convert<IDLUnion<IDLLong, IDLInterface<Node>>>(state, unionMemberValue); 626 637 RETURN_IF_EXCEPTION(throwScope, Nullopt); 627 638 } -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r207378 r207381 459 459 AnyTypedef anyTypedefValue; 460 460 TestDictionaryThatShouldTolerateNull dictionaryMember; 461 (long or Node) unionMember; 462 (long or Node)? nullableUnionMember = null; 461 463 }; 462 464 -
trunk/Source/WebCore/dom/ContainerNode.cpp
r206956 r207381 878 878 } 879 879 880 void ContainerNode::append(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)880 void ContainerNode::append(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 881 881 { 882 882 RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec); … … 887 887 } 888 888 889 void ContainerNode::prepend(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)889 void ContainerNode::prepend(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 890 890 { 891 891 RefPtr<Node> node = convertNodesOrStringsIntoNode(WTFMove(nodeOrStringVector), ec); -
trunk/Source/WebCore/dom/ContainerNode.h
r207013 r207381 101 101 WEBCORE_EXPORT Element* lastElementChild() const; 102 102 WEBCORE_EXPORT unsigned childElementCount() const; 103 void append(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);104 void prepend(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);103 void append(Vector<NodeOrString>&&, ExceptionCode&); 104 void prepend(Vector<NodeOrString>&&, ExceptionCode&); 105 105 106 106 bool ensurePreInsertionValidity(Node& newChild, Node* refChild, ExceptionCode&); -
trunk/Source/WebCore/dom/MessageEvent.cpp
r207016 r207381 30 30 31 31 #include "Blob.h" 32 #include "DOMWindow.h"33 32 #include "EventNames.h" 34 33 #include <runtime/JSCInlines.h> … … 38 37 using namespace JSC; 39 38 40 static inline bool isValidSource(EventTarget* source)41 {42 return !source || source->toDOMWindow() || source->isMessagePort();43 }44 45 39 inline MessageEvent::MessageEvent() 46 40 : m_dataType(DataTypeScriptValue) … … 48 42 } 49 43 50 inline MessageEvent::MessageEvent(ExecState& state, const AtomicString& type, constInit& initializer, IsTrusted isTrusted)44 inline MessageEvent::MessageEvent(ExecState& state, const AtomicString& type, Init& initializer, IsTrusted isTrusted) 51 45 : Event(type, initializer, isTrusted) 52 46 , m_dataType(DataTypeScriptValue) … … 54 48 , m_origin(initializer.origin) 55 49 , m_lastEventId(initializer.lastEventId) 56 , m_source( isValidSource(initializer.source.get()) ? initializer.source : nullptr)50 , m_source(WTFMove(initializer.source)) 57 51 , m_ports(std::make_unique<MessagePortArray>(initializer.ports)) 58 52 { 59 53 } 60 54 61 inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, EventTarget*source, std::unique_ptr<MessagePortArray> ports)55 inline MessageEvent::MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports) 62 56 : Event(eventNames().messageEvent, false, false) 63 57 , m_dataType(DataTypeSerializedScriptValue) … … 65 59 , m_origin(origin) 66 60 , m_lastEventId(lastEventId) 67 , m_source( source)61 , m_source(WTFMove(source)) 68 62 , m_ports(WTFMove(ports)) 69 63 { 70 ASSERT(isValidSource(source));71 64 } 72 65 … … 104 97 } 105 98 106 Ref<MessageEvent> MessageEvent::create(std::unique_ptr<MessagePortArray> ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, EventTarget*source)107 { 108 return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, source, WTFMove(ports)));99 Ref<MessageEvent> MessageEvent::create(std::unique_ptr<MessagePortArray> ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source) 100 { 101 return adoptRef(*new MessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports))); 109 102 } 110 103 … … 134 127 } 135 128 136 Ref<MessageEvent> MessageEvent::create(ExecState& state, const AtomicString& type, constInit& initializer, IsTrusted isTrusted)129 Ref<MessageEvent> MessageEvent::create(ExecState& state, const AtomicString& type, Init& initializer, IsTrusted isTrusted) 137 130 { 138 131 return adoptRef(*new MessageEvent(state, type, initializer, isTrusted)); … … 143 136 } 144 137 145 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow*source, std::unique_ptr<MessagePortArray> ports)138 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports) 146 139 { 147 140 if (dispatched()) … … 156 149 m_origin = origin; 157 150 m_lastEventId = lastEventId; 158 m_source = source;151 m_source = WTFMove(source); 159 152 m_ports = WTFMove(ports); 160 153 } 161 154 162 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow*source, std::unique_ptr<MessagePortArray> ports)155 void MessageEvent::initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray> ports) 163 156 { 164 157 if (dispatched()) … … 171 164 m_origin = origin; 172 165 m_lastEventId = lastEventId; 173 m_source = source;166 m_source = WTFMove(source); 174 167 m_ports = WTFMove(ports); 175 168 } 176 169 170 EventTarget* MessageEvent::source() const 171 { 172 if (!m_source) 173 return nullptr; 174 175 auto visitor = WTF::makeVisitor( 176 [](const RefPtr<DOMWindow>& window) -> EventTarget* { return const_cast<EventTarget*>(static_cast<const EventTarget*>(window.get())); }, 177 [](const RefPtr<MessagePort>& messagePort) -> EventTarget* { return const_cast<EventTarget*>(static_cast<const EventTarget*>(messagePort.get())); } 178 ); 179 180 return std::experimental::visit(visitor, m_source.value()); 181 } 182 177 183 RefPtr<SerializedScriptValue> MessageEvent::trySerializeData(ExecState* exec) 178 184 { -
trunk/Source/WebCore/dom/MessageEvent.h
r207016 r207381 28 28 #pragma once 29 29 30 #include "DOMWindow.h" 30 31 #include "Event.h" 31 32 #include "MessagePort.h" 32 33 #include "SerializedScriptValue.h" 33 34 #include <bindings/ScriptValue.h> 35 #include <wtf/Variant.h> 34 36 35 37 namespace WebCore { … … 37 39 class Blob; 38 40 41 using MessageEventSource = std::experimental::variant<RefPtr<DOMWindow>, RefPtr<MessagePort>>; 42 39 43 class MessageEvent final : public Event { 40 44 public: 41 static Ref<MessageEvent> create(std::unique_ptr<MessagePortArray>, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, EventTarget* source = nullptr);45 static Ref<MessageEvent> create(std::unique_ptr<MessagePortArray>, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, Optional<MessageEventSource>&& source = Nullopt); 42 46 static Ref<MessageEvent> create(const AtomicString& type, RefPtr<SerializedScriptValue>&&, const String& origin, const String& lastEventId); 43 47 static Ref<MessageEvent> create(const String& data, const String& origin = { }); … … 50 54 String origin; 51 55 String lastEventId; 52 RefPtr<EventTarget> source;56 Optional<MessageEventSource> source; 53 57 MessagePortArray ports; 54 58 }; 55 static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, constInit&, IsTrusted = IsTrusted::No);59 static Ref<MessageEvent> create(JSC::ExecState&, const AtomicString& type, Init&, IsTrusted = IsTrusted::No); 56 60 57 61 virtual ~MessageEvent(); 58 62 59 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, DOMWindow*source, std::unique_ptr<MessagePortArray>);60 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, DOMWindow*source, std::unique_ptr<MessagePortArray>);63 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, const Deprecated::ScriptValue& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>); 64 void initMessageEvent(const AtomicString& type, bool canBubble, bool cancelable, PassRefPtr<SerializedScriptValue> data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>); 61 65 62 66 const String& origin() const { return m_origin; } 63 67 const String& lastEventId() const { return m_lastEventId; } 64 EventTarget* source() const { return m_source.get(); }68 EventTarget* source() const; 65 69 MessagePortArray ports() const { return m_ports ? *m_ports : MessagePortArray(); } 66 70 … … 88 92 private: 89 93 MessageEvent(); 90 MessageEvent(JSC::ExecState&, const AtomicString&, constInit&, IsTrusted);91 MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, EventTarget*source, std::unique_ptr<MessagePortArray>);94 MessageEvent(JSC::ExecState&, const AtomicString&, Init&, IsTrusted); 95 MessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, Optional<MessageEventSource>&& source, std::unique_ptr<MessagePortArray>); 92 96 MessageEvent(const AtomicString& type, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId); 93 97 MessageEvent(const String& data, const String& origin); … … 104 108 String m_origin; 105 109 String m_lastEventId; 106 RefPtr<EventTarget> m_source;110 Optional<MessageEventSource> m_source; 107 111 std::unique_ptr<MessagePortArray> m_ports; 108 112 }; -
trunk/Source/WebCore/dom/MessageEvent.idl
r207016 r207381 2 2 * Copyright (C) 2007 Henry Mason <hmason@mac.com> 3 3 * Copyright (C) 2011 Google Inc. All rights reserved. 4 * Copyright (C) 2016 Apple Inc. All rights reserved. 4 5 * 5 6 * Redistribution and use in source and binary forms, with or without … … 33 34 readonly attribute USVString origin; 34 35 readonly attribute DOMString lastEventId; 35 readonly attribute EventTarget? source; // May be a DOMWindow or a MessagePort.36 readonly attribute EventTarget? source; 36 37 [CachedAttribute, CustomGetter] readonly attribute any data; 37 38 readonly attribute FrozenArray<MessagePort> ports; 38 39 39 40 [Custom] void initMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg, 40 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindowsourceArg,41 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg, 41 42 optional Array messagePorts); 42 43 43 44 [Custom] void webkitInitMessageEvent(optional DOMString typeArg, optional boolean canBubbleArg, optional boolean cancelableArg, 44 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional DOMWindowsourceArg,45 optional any dataArg, optional USVString originArg, optional DOMString lastEventIdArg, optional (DOMWindow or MessagePort)? sourceArg, 45 46 optional Array transferables); 46 47 }; … … 50 51 USVString origin = ""; 51 52 DOMString lastEventId = ""; 52 EventTarget? source = null;53 (DOMWindow or MessagePort)? source = null; 53 54 sequence<MessagePort> ports = []; 54 55 }; -
trunk/Source/WebCore/dom/Node.cpp
r207010 r207381 436 436 } 437 437 438 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>& vector)438 static HashSet<RefPtr<Node>> nodeSetPreTransformedFromNodeOrStringVector(const Vector<NodeOrString>& vector) 439 439 { 440 440 HashSet<RefPtr<Node>> nodeSet; 441 441 442 442 auto visitor = WTF::makeVisitor( 443 [&](const std::reference_wrapper<Node>& node) { nodeSet.add(const_cast<Node*>(&node.get())); },443 [&](const RefPtr<Node>& node) { nodeSet.add(const_cast<Node*>(node.get())); }, 444 444 [](const String&) { } 445 445 ); … … 469 469 } 470 470 471 RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)471 RefPtr<Node> Node::convertNodesOrStringsIntoNode(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 472 472 { 473 473 if (nodeOrStringVector.isEmpty()) … … 478 478 479 479 auto visitor = WTF::makeVisitor( 480 [&]( std::reference_wrapper<Node>& node) { nodes.uncheckedAppend(node); },480 [&](RefPtr<Node>& node) { nodes.uncheckedAppend(*node.get()); }, 481 481 [&](String& string) { nodes.uncheckedAppend(Text::create(document(), string)); } 482 482 ); … … 496 496 } 497 497 498 void Node::before(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)498 void Node::before(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 499 499 { 500 500 RefPtr<ContainerNode> parent = parentNode(); … … 517 517 } 518 518 519 void Node::after(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)519 void Node::after(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 520 520 { 521 521 RefPtr<ContainerNode> parent = parentNode(); … … 533 533 } 534 534 535 void Node::replaceWith(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&& nodeOrStringVector, ExceptionCode& ec)535 void Node::replaceWith(Vector<NodeOrString>&& nodeOrStringVector, ExceptionCode& ec) 536 536 { 537 537 RefPtr<ContainerNode> parent = parentNode(); -
trunk/Source/WebCore/dom/Node.h
r207013 r207381 63 63 64 64 const int nodeStyleChangeShift = 14; 65 66 using NodeOrString = std::experimental::variant<RefPtr<Node>, String>; 65 67 66 68 // SyntheticStyleChange means that we need to go through the entire style change logic even though … … 203 205 204 206 // From the ChildNode - https://dom.spec.whatwg.org/#childnode 205 void before(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);206 void after(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);207 void replaceWith(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);207 void before(Vector<NodeOrString>&&, ExceptionCode&); 208 void after(Vector<NodeOrString>&&, ExceptionCode&); 209 void replaceWith(Vector<NodeOrString>&&, ExceptionCode&); 208 210 WEBCORE_EXPORT void remove(ExceptionCode&); 209 211 … … 661 663 void updateAncestorsForStyleRecalc(); 662 664 663 RefPtr<Node> convertNodesOrStringsIntoNode(Vector< std::experimental::variant<std::reference_wrapper<Node>, String>>&&, ExceptionCode&);665 RefPtr<Node> convertNodesOrStringsIntoNode(Vector<NodeOrString>&&, ExceptionCode&); 664 666 665 667 private: -
trunk/Source/WebCore/page/DOMWindow.cpp
r207040 r207381 161 161 Ref<MessageEvent> event(ScriptExecutionContext& context) 162 162 { 163 return MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(m_channels)), WTFMove(m_message), m_origin, { }, m_source.ptr());163 return MessageEvent::create(MessagePort::entanglePorts(context, WTFMove(m_channels)), WTFMove(m_message), m_origin, { }, MessageEventSource(RefPtr<DOMWindow>(WTFMove(m_source)))); 164 164 } 165 165
Note: See TracChangeset
for help on using the changeset viewer.