Changeset 223023 in webkit
- Timestamp:
- Oct 7, 2017, 4:44:45 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r223021 r223023 1 2017-10-07 Darin Adler <darin@apple.com> 2 3 Update Document.createEvent for recent DOM specification changes 4 https://bugs.webkit.org/show_bug.cgi?id=178052 5 6 Reviewed by Chris Dumez. 7 8 * web-platform-tests/dom/events/EventTarget-dispatchEvent-expected.txt: Updated to expect more tests to pass. 9 * web-platform-tests/dom/nodes/Document-createEvent-expected.txt: Ditto. 10 * web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt: Ditto. 11 1 12 2017-10-07 Andy Estes <aestes@apple.com> 2 13 -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-expected.txt
r220772 r223023 2 2 3 3 PASS Calling dispatchEvent(null). 4 FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (BeforeUnloadEvent). The operation is not supported. 4 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (BeforeUnloadEvent). 5 5 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (CompositionEvent). 6 6 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (CustomEvent). … … 10 10 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (Event). 11 11 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (Events). 12 FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (FocusEvent). The operation is not supported. 12 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (FocusEvent). 13 13 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (HashChangeEvent). 14 14 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (HTMLEvents). … … 18 18 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (MouseEvents). 19 19 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (StorageEvent). 20 FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (SVGEvents). The operation is not supported. 20 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (SVGEvents). 21 21 PASS If the event's initialized flag is not set, an InvalidStateError must be thrown (TextEvent). 22 22 FAIL If the event's initialized flag is not set, an InvalidStateError must be thrown (TouchEvent). The operation is not supported. -
trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Document-createEvent-expected.txt
r220772 r223023 1 1 2 FAIL BeforeUnloadEvent should be an alias for BeforeUnloadEvent. The operation is not supported. 3 FAIL createEvent('BeforeUnloadEvent') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 4 FAIL beforeunloadevent should be an alias for BeforeUnloadEvent. The operation is not supported. 5 FAIL createEvent('beforeunloadevent') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 6 FAIL BEFOREUNLOADEVENT should be an alias for BeforeUnloadEvent. The operation is not supported. 7 FAIL createEvent('BEFOREUNLOADEVENT') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 2 PASS BeforeUnloadEvent should be an alias for BeforeUnloadEvent. 3 PASS createEvent('BeforeUnloadEvent') should be initialized correctly. 4 PASS beforeunloadevent should be an alias for BeforeUnloadEvent. 5 PASS createEvent('beforeunloadevent') should be initialized correctly. 6 PASS BEFOREUNLOADEVENT should be an alias for BeforeUnloadEvent. 7 PASS createEvent('BEFOREUNLOADEVENT') should be initialized correctly. 8 8 PASS Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "BeforeUnloadEvents" 9 9 PASS CompositionEvent should be an alias for CompositionEvent. … … 54 54 PASS EVENTS should be an alias for Event. 55 55 PASS createEvent('EVENTS') should be initialized correctly. 56 FAIL FocusEvent should be an alias for FocusEvent. The operation is not supported. 57 FAIL createEvent('FocusEvent') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 58 FAIL focusevent should be an alias for FocusEvent. The operation is not supported. 59 FAIL createEvent('focusevent') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 60 FAIL FOCUSEVENT should be an alias for FocusEvent. The operation is not supported. 61 FAIL createEvent('FOCUSEVENT') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 56 PASS FocusEvent should be an alias for FocusEvent. 57 PASS createEvent('FocusEvent') should be initialized correctly. 58 PASS focusevent should be an alias for FocusEvent. 59 PASS createEvent('focusevent') should be initialized correctly. 60 PASS FOCUSEVENT should be an alias for FocusEvent. 61 PASS createEvent('FOCUSEVENT') should be initialized correctly. 62 62 PASS Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "FocusEvents" 63 63 PASS HashChangeEvent should be an alias for HashChangeEvent. … … 109 109 PASS createEvent('STORAGEEVENT') should be initialized correctly. 110 110 PASS Should throw NOT_SUPPORTED_ERR for pluralized legacy event interface "StorageEvents" 111 FAIL SVGEvents should be an alias for Event. The operation is not supported. 112 FAIL createEvent('SVGEvents') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 113 FAIL svgevents should be an alias for Event. The operation is not supported. 114 FAIL createEvent('svgevents') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 115 FAIL SVGEVENTS should be an alias for Event. The operation is not supported. 116 FAIL createEvent('SVGEVENTS') should be initialized correctly. undefined is not an object (evaluating 'ev.type') 111 PASS SVGEvents should be an alias for Event. 112 PASS createEvent('SVGEvents') should be initialized correctly. 113 PASS svgevents should be an alias for Event. 114 PASS createEvent('svgevents') should be initialized correctly. 115 PASS SVGEVENTS should be an alias for Event. 116 PASS createEvent('SVGEVENTS') should be initialized correctly. 117 117 FAIL TextEvent should be an alias for CompositionEvent. assert_equals: expected object "[object CompositionEventPrototype]" but got object "[object TextEventPrototype]" 118 118 PASS createEvent('TextEvent') should be initialized correctly. -
trunk/LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/unloading-documents/beforeunload-canceling-expected.txt
r215164 r223023 3 3 PASS Returning a string must not cancel the event: CustomEvent, cancelable 4 4 FAIL Returning false must not cancel the event, because it's coerced to the DOMString "false" which does not cancel CustomEvents: CustomEvent, cancelable assert_false: The event must not have been canceled expected false got true 5 FAIL Returning a string must not cancel the event: BeforeUnloadEvent with type "click", cancelable The operation is not supported. 5 PASS Returning a string must not cancel the event: BeforeUnloadEvent with type "click", cancelable 6 6 PASS Returning null with a real iframe unloading 7 7 PASS Returning undefined with a real iframe unloading -
trunk/Source/WebCore/ChangeLog
r223021 r223023 1 2017-10-07 Darin Adler <darin@apple.com> 2 3 Update Document.createEvent for recent DOM specification changes 4 https://bugs.webkit.org/show_bug.cgi?id=178052 5 6 Reviewed by Chris Dumez. 7 8 * dom/BeforeUnloadEvent.cpp: 9 (WebCore::BeforeUnloadEvent::BeforeUnloadEvent): Added a constructor for 10 createForBindings. 11 (WebCore::BeforeUnloadEvent::~BeforeUnloadEvent): Deleted. Just let the 12 compiler generate this. 13 * dom/BeforeUnloadEvent.h: Added createForBindings. Also made more things private. 14 15 * dom/Document.cpp: 16 (WebCore::Document::createEvent): Updated comments for clarity. Responding to 17 changes to the DOM specification, added support for "beforeunloadevent", "focusevent", 18 and "svgevents", moved "keyboardevents" and "popstateevent" into the list of strings 19 we should remove, and moved "compositionevent", "devicemotionevent", 20 "deviceorientationevent", "hashchangeevent", "storageevent", and "textevent" into 21 the list of strings we should keep. 22 23 * dom/Event.h: Added a virtual setRelatedTarget alongside the virtual relatedTarget 24 to allow us to clean up the code that manipulates it. 25 26 * dom/EventContext.cpp: 27 (WebCore::MouseOrFocusEventContext::handleLocalEvents const): Call the virtual 28 setRelatedTarget instead of doing a little type casting dance. 29 30 * dom/FocusEvent.h: Added createForBindings. Made more functions private and 31 changed setRelatedTarget into a private final override. 32 33 * dom/MouseEvent.h: Changed setRelatedTarget into a private final override. 34 1 35 2017-10-07 Andy Estes <aestes@apple.com> 2 36 -
trunk/Source/WebCore/dom/BeforeUnloadEvent.cpp
r165676 r223023 33 33 } 34 34 35 BeforeUnloadEvent::BeforeUnloadEvent(ForBindingsFlag) 36 { 37 } 38 35 39 bool BeforeUnloadEvent::isBeforeUnloadEvent() const 36 40 { … … 38 42 } 39 43 40 BeforeUnloadEvent::~BeforeUnloadEvent()41 {42 }43 44 44 } // namespace WebCore -
trunk/Source/WebCore/dom/BeforeUnloadEvent.h
r208179 r223023 3 3 * Copyright (C) 2001 Tobias Anton (anton@stud.fbi.fh-darmstadt.de) 4 4 * Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * Copyright (C) 2003 , 2004, 2005, 2006 Apple Inc.5 * Copyright (C) 2003-2017 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2013 Samsung Electronics 7 7 * … … 31 31 class BeforeUnloadEvent final : public Event { 32 32 public: 33 virtual ~BeforeUnloadEvent();34 35 33 static Ref<BeforeUnloadEvent> create() 36 34 { … … 38 36 } 39 37 38 static Ref<BeforeUnloadEvent> createForBindings() 39 { 40 return adoptRef(*new BeforeUnloadEvent { ForBindings }); 41 } 42 40 43 String returnValue() const { return m_returnValue; } 41 44 void setReturnValue(const String& returnValue) { m_returnValue = returnValue; } 42 45 43 EventInterface eventInterface() const override { return BeforeUnloadEventInterfaceType; } 46 private: 47 enum ForBindingsFlag { ForBindings }; 48 BeforeUnloadEvent(); 49 BeforeUnloadEvent(ForBindingsFlag); 44 50 45 private: 46 BeforeUnloadEvent(); 47 48 bool isBeforeUnloadEvent() const override; 51 EventInterface eventInterface() const final { return BeforeUnloadEventInterfaceType; } 52 bool isBeforeUnloadEvent() const final; 49 53 50 54 String m_returnValue; -
trunk/Source/WebCore/dom/Document.cpp
r222997 r223023 31 31 #include "AXObjectCache.h" 32 32 #include "Attr.h" 33 #include "BeforeUnloadEvent.h" 33 34 #include "CDATASection.h" 34 35 #include "CSSAnimationController.h" … … 65 66 #include "ExtensionStyleSheets.h" 66 67 #include "FocusController.h" 68 #include "FocusEvent.h" 67 69 #include "FontFaceSet.h" 68 70 #include "FormController.h" … … 4260 4262 ExceptionOr<Ref<Event>> Document::createEvent(const String& type) 4261 4263 { 4262 // Please do *not* add new event classes to this function unless they are 4263 // required for compatibility ofsome actual legacy web content.4264 // Please do *not* add new event classes to this function unless they are required 4265 // for compatibility with the DOM specification or some actual legacy web content. 4264 4266 4265 4267 // This mechanism is superceded by use of event constructors. … … 4269 4271 // <https://dom.spec.whatwg.org/#dom-document-createevent>. 4270 4272 4273 if (equalLettersIgnoringASCIICase(type, "beforeunloadevent")) 4274 return Ref<Event> { BeforeUnloadEvent::createForBindings() }; 4275 if (equalLettersIgnoringASCIICase(type, "compositionevent")) 4276 return Ref<Event> { CompositionEvent::createForBindings() }; 4271 4277 if (equalLettersIgnoringASCIICase(type, "customevent")) 4272 4278 return Ref<Event> { CustomEvent::create() }; 4273 if (equalLettersIgnoringASCIICase(type, "event") || equalLettersIgnoringASCIICase(type, "events") || equalLettersIgnoringASCIICase(type, "htmlevents") )4279 if (equalLettersIgnoringASCIICase(type, "event") || equalLettersIgnoringASCIICase(type, "events") || equalLettersIgnoringASCIICase(type, "htmlevents") || equalLettersIgnoringASCIICase(type, "svgevents")) 4274 4280 return Event::createForBindings(); 4275 if (equalLettersIgnoringASCIICase(type, "keyboardevent") || equalLettersIgnoringASCIICase(type, "keyboardevents")) 4281 if (equalLettersIgnoringASCIICase(type, "focusevent")) 4282 return Ref<Event> { FocusEvent::createForBindings() }; 4283 if (equalLettersIgnoringASCIICase(type, "hashchangeevent")) 4284 return Ref<Event> { HashChangeEvent::createForBindings() }; 4285 if (equalLettersIgnoringASCIICase(type, "keyboardevent")) 4276 4286 return Ref<Event> { KeyboardEvent::createForBindings() }; 4277 4287 if (equalLettersIgnoringASCIICase(type, "messageevent")) 4278 4288 return Ref<Event> { MessageEvent::createForBindings() }; 4289 if (equalLettersIgnoringASCIICase(type, "storageevent")) 4290 return Ref<Event> { StorageEvent::createForBindings() }; 4279 4291 if (equalLettersIgnoringASCIICase(type, "mouseevent") || equalLettersIgnoringASCIICase(type, "mouseevents")) 4280 4292 return Ref<Event> { MouseEvent::createForBindings() }; 4293 if (equalLettersIgnoringASCIICase(type, "textevent")) 4294 return Ref<Event> { TextEvent::createForBindings() }; // FIXME: HTML specification says this should create a CompositionEvent, not a TextEvent. 4281 4295 if (equalLettersIgnoringASCIICase(type, "uievent") || equalLettersIgnoringASCIICase(type, "uievents")) 4282 4296 return Ref<Event> { UIEvent::createForBindings() }; 4283 if (equalLettersIgnoringASCIICase(type, "popstateevent")) 4284 return Ref<Event> { PopStateEvent::createForBindings() }; 4285 4286 #if ENABLE(TOUCH_EVENTS) 4287 if (equalLettersIgnoringASCIICase(type, "touchevent")) 4288 return Ref<Event> { TouchEvent::createForBindings() }; 4289 #endif 4290 4291 // The following string comes from the SVG specifications 4292 // <http://www.w3.org/TR/SVG/script.html#InterfaceSVGZoomEvent> 4293 // <http://www.w3.org/TR/SVG2/interact.html#InterfaceSVGZoomEvent>. 4294 // However, since there is no provision for initializing the event once it is created, 4295 // there is no practical value in this feature. 4296 4297 if (equalLettersIgnoringASCIICase(type, "svgzoomevents")) 4298 return Ref<Event> { SVGZoomEvent::createForBindings() }; 4299 4300 // The following strings are for event classes where WebKit supplies an init function. 4301 // These strings are not part of the DOM specification and we would like to eliminate them. 4302 // However, we currently include these because we have concerns about backward compatibility. 4303 4304 // FIXME: For each of the strings below, prove there is no content depending on it and remove 4305 // both the string and the corresponding init function for that class. 4306 4307 if (equalLettersIgnoringASCIICase(type, "compositionevent")) 4308 return Ref<Event> { CompositionEvent::createForBindings() }; 4309 if (equalLettersIgnoringASCIICase(type, "hashchangeevent")) 4310 return Ref<Event> { HashChangeEvent::createForBindings() }; 4311 if (equalLettersIgnoringASCIICase(type, "mutationevent") || equalLettersIgnoringASCIICase(type, "mutationevents")) 4312 return Ref<Event> { MutationEvent::createForBindings() }; 4313 if (equalLettersIgnoringASCIICase(type, "overflowevent")) 4314 return Ref<Event> { OverflowEvent::createForBindings() }; 4315 if (equalLettersIgnoringASCIICase(type, "storageevent")) 4316 return Ref<Event> { StorageEvent::createForBindings() }; 4317 if (equalLettersIgnoringASCIICase(type, "textevent")) 4318 return Ref<Event> { TextEvent::createForBindings() }; 4319 if (equalLettersIgnoringASCIICase(type, "wheelevent")) 4320 return Ref<Event> { WheelEvent::createForBindings() }; 4321 4297 4298 // FIXME: Consider including support for these event classes even when device orientation 4299 // support is not enabled. 4322 4300 #if ENABLE(DEVICE_ORIENTATION) 4323 4301 if (equalLettersIgnoringASCIICase(type, "devicemotionevent")) … … 4326 4304 return Ref<Event> { DeviceOrientationEvent::createForBindings() }; 4327 4305 #endif 4306 4307 #if ENABLE(TOUCH_EVENTS) 4308 if (equalLettersIgnoringASCIICase(type, "touchevent")) 4309 return Ref<Event> { TouchEvent::createForBindings() }; 4310 #endif 4311 4312 // FIXME: Add support for "dragevent", which the DOM specification calls for. 4313 4314 // The following string comes from the SVG specification 4315 // <http://www.w3.org/TR/SVG/script.html#InterfaceSVGZoomEvent> 4316 // However, since there is no provision for initializing the event once it is created, 4317 // there is no practical value in this feature. 4318 // FIXME: Confirm there is no content depending on this and remove it. 4319 4320 if (equalLettersIgnoringASCIICase(type, "svgzoomevents")) 4321 return Ref<Event> { SVGZoomEvent::createForBindings() }; 4322 4323 // The following strings are not part of the DOM specification and we would like to eliminate them. 4324 // However, we currently include them until we resolve any issues with backward compatibility. 4325 // FIXME: For each of the strings below, confirm that there is no content depending on it and remove 4326 // the string, remove the createForBindings function, and also consider removing the corresponding 4327 // init function for that class. 4328 4329 if (equalLettersIgnoringASCIICase(type, "keyboardevents")) 4330 return Ref<Event> { KeyboardEvent::createForBindings() }; 4331 if (equalLettersIgnoringASCIICase(type, "mutationevent") || equalLettersIgnoringASCIICase(type, "mutationevents")) 4332 return Ref<Event> { MutationEvent::createForBindings() }; 4333 if (equalLettersIgnoringASCIICase(type, "overflowevent")) 4334 return Ref<Event> { OverflowEvent::createForBindings() }; 4335 if (equalLettersIgnoringASCIICase(type, "popstateevent")) 4336 return Ref<Event> { PopStateEvent::createForBindings() }; 4337 if (equalLettersIgnoringASCIICase(type, "wheelevent")) 4338 return Ref<Event> { WheelEvent::createForBindings() }; 4328 4339 4329 4340 return Exception { NotSupportedError }; -
trunk/Source/WebCore/dom/Event.h
r222392 r223023 169 169 170 170 virtual EventTarget* relatedTarget() const { return nullptr; } 171 virtual void setRelatedTarget(EventTarget&) { } 171 172 172 173 protected: -
trunk/Source/WebCore/dom/EventContext.cpp
r210216 r223023 76 76 void MouseOrFocusEventContext::handleLocalEvents(Event& event) const 77 77 { 78 ASSERT(is<MouseEvent>(event) || is<FocusEvent>(event)); 79 if (m_relatedTarget) { 80 if (is<MouseEvent>(event)) 81 downcast<MouseEvent>(event).setRelatedTarget(m_relatedTarget.get()); 82 else if (is<FocusEvent>(event)) 83 downcast<FocusEvent>(event).setRelatedTarget(m_relatedTarget.get()); 84 } 78 if (m_relatedTarget) 79 event.setRelatedTarget(*m_relatedTarget); 85 80 EventContext::handleLocalEvents(event); 86 81 } -
trunk/Source/WebCore/dom/FocusEvent.h
r208179 r223023 1 1 /* 2 2 * Copyright (C) 2013 Google Inc. All rights reserved. 3 * Copyright (C) 2017 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 40 41 } 41 42 43 static Ref<FocusEvent> createForBindings() 44 { 45 return adoptRef(*new FocusEvent); 46 } 47 42 48 struct Init : UIEventInit { 43 49 RefPtr<EventTarget> relatedTarget; … … 49 55 } 50 56 51 EventTarget* relatedTarget() const override { return m_relatedTarget.get(); } 52 void setRelatedTarget(RefPtr<EventTarget>&& relatedTarget) { m_relatedTarget = WTFMove(relatedTarget); } 53 54 EventInterface eventInterface() const override; 57 EventTarget* relatedTarget() const final { return m_relatedTarget.get(); } 55 58 56 59 private: 60 FocusEvent() = default; 57 61 FocusEvent(const AtomicString& type, bool canBubble, bool cancelable, DOMWindow*, int, RefPtr<EventTarget>&&); 58 62 FocusEvent(const AtomicString& type, const Init&, IsTrusted); 59 63 60 bool isFocusEvent() const override; 64 EventInterface eventInterface() const final; 65 bool isFocusEvent() const final; 66 67 void setRelatedTarget(EventTarget& relatedTarget) final { m_relatedTarget = &relatedTarget; } 61 68 62 69 RefPtr<EventTarget> m_relatedTarget; -
trunk/Source/WebCore/dom/MouseEvent.h
r222392 r223023 58 58 bool buttonDown() const { return m_buttonDown; } 59 59 EventTarget* relatedTarget() const final { return m_relatedTarget.get(); } 60 void setRelatedTarget(EventTarget* relatedTarget) { m_relatedTarget = relatedTarget; }61 60 double force() const { return m_force; } 62 61 void setForce(double force) { m_force = force; } … … 95 94 bool isDragEvent() const; 96 95 96 void setRelatedTarget(EventTarget& relatedTarget) final { m_relatedTarget = &relatedTarget; } 97 97 98 unsigned short m_button { 0 }; 98 99 unsigned short m_syntheticClickType { 0 };
Note:
See TracChangeset
for help on using the changeset viewer.