Changeset 206964 in webkit
- Timestamp:
- Oct 8, 2016 8:46:39 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r206963 r206964 1 2016-10-08 Chris Dumez <cdumez@apple.com> 2 3 Update CustomEvent to stop using legacy [ConstructorTemplate=Event] 4 https://bugs.webkit.org/show_bug.cgi?id=163174 5 6 Reviewed by Darin Adler. 7 8 Update existing layout test to reflect minor behavior change. 9 10 * fast/events/constructors/custom-event-constructor-expected.txt: 11 * fast/events/constructors/custom-event-constructor.html: 12 1 13 2016-10-08 Chris Dumez <cdumez@apple.com> 2 14 -
trunk/LayoutTests/fast/events/constructors/custom-event-constructor-expected.txt
r186955 r206964 14 14 PASS new CustomEvent('eventType', { detail: detailObject }).detail is detailObject 15 15 PASS new CustomEvent('eventType', { detail: document }).detail is document 16 PASS new CustomEvent('eventType', { detail: undefined }).detail is undefined16 PASS new CustomEvent('eventType', { detail: undefined }).detail is null 17 17 PASS new CustomEvent('eventType', { detail: null }).detail is null 18 18 PASS new CustomEvent('eventType', { get detail() { return true; } }).detail is true -
trunk/LayoutTests/fast/events/constructors/custom-event-constructor.html
r186955 r206964 33 33 34 34 // Detail is undefined. 35 shouldBe ("new CustomEvent('eventType', { detail: undefined }).detail", "undefined");35 shouldBeNull("new CustomEvent('eventType', { detail: undefined }).detail"); 36 36 37 37 // Detail is null. 38 shouldBe ("new CustomEvent('eventType', { detail: null }).detail", "null");38 shouldBeNull("new CustomEvent('eventType', { detail: null }).detail"); 39 39 40 40 // Detail is a getter. -
trunk/Source/WebCore/ChangeLog
r206963 r206964 1 2016-10-08 Chris Dumez <cdumez@apple.com> 2 3 Update CustomEvent to stop using legacy [ConstructorTemplate=Event] 4 https://bugs.webkit.org/show_bug.cgi?id=163174 5 6 Reviewed by Darin Adler. 7 8 Update CustomEvent to stop using legacy [ConstructorTemplate=Event] and 9 use an actual constructor instead, like in the specification: 10 - https://dom.spec.whatwg.org/#interface-customevent 11 12 There is a very minor behavior change when explictly passing undefined 13 as detail value in CustomEventInit. We used to initialize detail to 14 undefined but we now initialize it to null instead, which is its default 15 value. The new behavior matches the one of Chrome and Firefox. 16 17 * bindings/scripts/CodeGeneratorJS.pm: 18 (GenerateDefaultValue): 19 (GenerateDictionaryImplementationContent): 20 * bindings/scripts/test/JS/JSTestObj.cpp: 21 (WebCore::convertDictionary<TestObj::Dictionary>): 22 * bindings/scripts/test/TestObj.idl: 23 * dom/CustomEvent.cpp: 24 (WebCore::CustomEvent::CustomEvent): 25 * dom/CustomEvent.h: 26 * dom/CustomEvent.idl: 27 * dom/Document.cpp: 28 (WebCore::Document::createEvent): 29 * dom/Event.cpp: 30 (WebCore::Event::Event): 31 * dom/Event.h: 32 1 33 2016-10-08 Chris Dumez <cdumez@apple.com> 2 34 -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r206963 r206964 983 983 $value = $className . "::" . $enumerationValueName; 984 984 } 985 $value = "nullptr" if $value eq "null"; 985 if ($value eq "null") { 986 $value = $member->type eq "any" ? "jsNull()" : "nullptr"; 987 } 986 988 $value = "jsUndefined()" if $value eq "undefined"; 987 989 … … 1090 1092 my @sortedMembers = sort { $a->name cmp $b->name } @{$dictionary->members}; 1091 1093 foreach my $member (@sortedMembers) { 1092 $member->default("undefined") if $member->type eq "any" ; # Use undefined as default value for member of type 'any'.1094 $member->default("undefined") if $member->type eq "any" and !defined($member->default); # Use undefined as default value for member of type 'any' unless specified otherwise. 1093 1095 1094 1096 my $type = $member->type; -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r206960 r206964 489 489 } else 490 490 anyValue = jsUndefined(); 491 JSValue anyValueWithNullDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "anyValueWithNullDefault")); 492 JSC::JSValue anyValueWithNullDefault; 493 if (!anyValueWithNullDefaultValue.isUndefined()) { 494 anyValueWithNullDefault = convert<JSC::JSValue>(state, anyValueWithNullDefaultValue); 495 RETURN_IF_EXCEPTION(throwScope, Nullopt); 496 } else 497 anyValueWithNullDefault = jsNull(); 491 498 JSValue booleanWithDefaultValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "booleanWithDefault")); 492 499 bool booleanWithDefault; … … 683 690 } else 684 691 unsignedLargeIntegerWithDefault = 0; 685 return TestObj::Dictionary { WTFMove(enumerationValueWithoutDefault), WTFMove(enumerationValueWithDefault), WTFMove(enumerationValueWithEmptyStringDefault), WTFMove(stringWithDefault), WTFMove(stringWithoutDefault), WTFMove(booleanWithDefault), WTFMove(booleanWithoutDefault), WTFMove(sequenceOfStrings), WTFMove(restrictedDouble), WTFMove(unrestrictedDouble), WTFMove(restrictedDoubleWithDefault), WTFMove(unrestrictedDoubleWithDefault), WTFMove(restrictedFloat), WTFMove(unrestrictedFloat), WTFMove(restrictedFloatWithDefault), WTFMove(unrestrictedFloatWithDefault), WTFMove(smallIntegerClamped), WTFMove(smallIntegerWithDefault), WTFMove(smallUnsignedIntegerEnforcedRange), WTFMove(smallUnsignedIntegerWithDefault), WTFMove(integer), WTFMove(integerWithDefault), WTFMove(unsignedInteger), WTFMove(unsignedIntegerWithDefault), WTFMove(largeInteger), WTFMove(largeIntegerWithDefault), WTFMove(unsignedLargeInteger), WTFMove(unsignedLargeIntegerWithDefault), WTFMove(nullableNode), WTFMove(anyValue), WTFMove(any TypedefValue), dictionaryMember.value() };692 return TestObj::Dictionary { WTFMove(enumerationValueWithoutDefault), WTFMove(enumerationValueWithDefault), WTFMove(enumerationValueWithEmptyStringDefault), WTFMove(stringWithDefault), WTFMove(stringWithoutDefault), WTFMove(booleanWithDefault), WTFMove(booleanWithoutDefault), WTFMove(sequenceOfStrings), WTFMove(restrictedDouble), WTFMove(unrestrictedDouble), WTFMove(restrictedDoubleWithDefault), WTFMove(unrestrictedDoubleWithDefault), WTFMove(restrictedFloat), WTFMove(unrestrictedFloat), WTFMove(restrictedFloatWithDefault), WTFMove(unrestrictedFloatWithDefault), WTFMove(smallIntegerClamped), WTFMove(smallIntegerWithDefault), WTFMove(smallUnsignedIntegerEnforcedRange), WTFMove(smallUnsignedIntegerWithDefault), WTFMove(integer), WTFMove(integerWithDefault), WTFMove(unsignedInteger), WTFMove(unsignedIntegerWithDefault), WTFMove(largeInteger), WTFMove(largeIntegerWithDefault), WTFMove(unsignedLargeInteger), WTFMove(unsignedLargeIntegerWithDefault), WTFMove(nullableNode), WTFMove(anyValue), WTFMove(anyValueWithNullDefault), WTFMove(anyTypedefValue), dictionaryMember.value() }; 686 693 } 687 694 -
trunk/Source/WebCore/bindings/scripts/test/TestObj.idl
r206960 r206964 460 460 Node? nullableNode = null; 461 461 any anyValue; 462 any anyValueWithNullDefault = null; 462 463 AnyTypedef anyTypedefValue; 463 464 TestDictionaryThatShouldTolerateNull dictionaryMember; -
trunk/Source/WebCore/dom/CustomEvent.cpp
r204288 r206964 32 32 namespace WebCore { 33 33 34 CustomEvent::CustomEvent() 34 CustomEvent::CustomEvent(IsTrusted isTrusted) 35 : Event(isTrusted) 35 36 { 36 37 } 37 38 38 CustomEvent::CustomEvent( const AtomicString& type, const CustomEventInit& initializer)39 : Event(type, initializer )40 , m_detail( initializer.detail)39 CustomEvent::CustomEvent(JSC::ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted) 40 : Event(type, initializer, isTrusted) 41 , m_detail(state.vm(), initializer.detail) 41 42 { 42 43 } -
trunk/Source/WebCore/dom/CustomEvent.h
r202023 r206964 33 33 namespace WebCore { 34 34 35 struct CustomEventInit : public EventInit {36 Deprecated::ScriptValue detail;37 };38 39 35 class CustomEvent final : public Event { 40 36 public: 41 37 virtual ~CustomEvent(); 42 38 43 static Ref<CustomEvent> create ForBindings()39 static Ref<CustomEvent> create(IsTrusted isTrusted = IsTrusted::No) 44 40 { 45 return adoptRef(*new CustomEvent );41 return adoptRef(*new CustomEvent(isTrusted)); 46 42 } 47 43 48 static Ref<CustomEvent> createForBindings(const AtomicString& type, const CustomEventInit& initializer) 44 struct Init : public EventInit { 45 Init(bool bubbles, bool cancelable, bool composed, JSC::JSValue detail) 46 : EventInit(bubbles, cancelable, composed) 47 , detail(detail) 48 { } 49 50 JSC::JSValue detail; 51 }; 52 53 static Ref<CustomEvent> create(JSC::ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No) 49 54 { 50 return adoptRef(*new CustomEvent( type, initializer));55 return adoptRef(*new CustomEvent(state, type, initializer, isTrusted)); 51 56 } 52 57 … … 60 65 61 66 private: 62 CustomEvent( );63 CustomEvent( const AtomicString& type, const CustomEventInit& initializer);67 CustomEvent(IsTrusted); 68 CustomEvent(JSC::ExecState&, const AtomicString& type, const Init& initializer, IsTrusted); 64 69 65 70 Deprecated::ScriptValue m_detail; // FIXME: Why is it OK to use a strong reference here? What prevents a reference cycle? -
trunk/Source/WebCore/dom/CustomEvent.idl
r203734 r206964 25 25 26 26 // Introduced in DOM Level 3: 27 // FIXME: This should be exposed to workers as well. 27 28 [ 28 ConstructorTemplate=Event, 29 Constructor(DOMString type, optional CustomEventInit eventInitDict), 30 ConstructorCallWith=ScriptState, 29 31 ] interface CustomEvent : Event { 30 [ InitializedByEventConstructor,CustomGetter] readonly attribute any detail;32 [CustomGetter] readonly attribute any detail; 31 33 32 34 [CallWith=ScriptState] void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any detail); 33 35 }; 36 37 dictionary CustomEventInit : EventInit { 38 any detail = null; 39 }; -
trunk/Source/WebCore/dom/Document.cpp
r206960 r206964 4130 4130 4131 4131 if (equalLettersIgnoringASCIICase(type, "customevent")) 4132 return CustomEvent::create ForBindings();4132 return CustomEvent::create(); 4133 4133 if (equalLettersIgnoringASCIICase(type, "event") || equalLettersIgnoringASCIICase(type, "events") || equalLettersIgnoringASCIICase(type, "htmlevents")) 4134 4134 return Event::createForBindings(); -
trunk/Source/WebCore/dom/Event.cpp
r206963 r206964 32 32 namespace WebCore { 33 33 34 Event::Event() 35 : m_createTime(convertSecondsToDOMTimeStamp(currentTime())) 34 Event::Event(IsTrusted isTrusted) 35 : m_isTrusted(isTrusted == IsTrusted::Yes) 36 , m_createTime(convertSecondsToDOMTimeStamp(currentTime())) 36 37 { 37 38 } -
trunk/Source/WebCore/dom/Event.h
r206963 r206964 191 191 192 192 protected: 193 Event( );193 Event(IsTrusted = IsTrusted::No); 194 194 WEBCORE_EXPORT Event(const AtomicString& type, bool canBubble, bool cancelable); 195 195 Event(const AtomicString& type, bool canBubble, bool cancelable, double timestamp);
Note: See TracChangeset
for help on using the changeset viewer.