Title: [207514] trunk
Revision
207514
Author
cdu...@apple.com
Date
2016-10-18 19:03:07 -0700 (Tue, 18 Oct 2016)

Log Message

Changing details.open should cause a toggle event to be fired asynchronously
https://bugs.webkit.org/show_bug.cgi?id=163568

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/html/dom/interfaces-expected.txt:
Rebaseline W3C test now that more checks are passing.

* web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent-expected.txt: Added.
* web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html: Added.
* web-platform-tests/html/semantics/interactive-elements/the-details-element/w3c-import.log:
Import test coverage for the toggle event.

Source/WebCore:

Changing details.open should cause a toggle event to be fired asynchronously:
- https://html.spec.whatwg.org/#details-notification-task-steps

Firefox and Chrome implement this, we don't.

Test: imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html

* dom/EventNames.h:
* dom/GlobalEventHandlers.idl:
* html/HTMLAttributeNames.in:
* html/HTMLDetailsElement.cpp:
(WebCore::detailToggleEventSender):
(WebCore::HTMLDetailsElement::~HTMLDetailsElement):
(WebCore::HTMLDetailsElement::dispatchPendingEvent):
(WebCore::HTMLDetailsElement::parseAttribute):
* html/HTMLDetailsElement.h:
* html/HTMLElement.cpp:
(WebCore::HTMLElement::createEventHandlerNameMap):

LayoutTests:

Rebaseline existing test now that a new ontoggle attribute is exposed.

* js/dom/dom-static-property-for-in-iteration-expected.txt:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (207513 => 207514)


--- trunk/LayoutTests/ChangeLog	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/LayoutTests/ChangeLog	2016-10-19 02:03:07 UTC (rev 207514)
@@ -1,5 +1,16 @@
 2016-10-18  Chris Dumez  <cdu...@apple.com>
 
+        Changing details.open should cause a toggle event to be fired asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=163568
+
+        Reviewed by Darin Adler.
+
+        Rebaseline existing test now that a new ontoggle attribute is exposed.
+
+        * js/dom/dom-static-property-for-in-iteration-expected.txt:
+
+2016-10-18  Chris Dumez  <cdu...@apple.com>
+
         Provide better form validation messages
         https://bugs.webkit.org/show_bug.cgi?id=163584
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (207513 => 207514)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-10-19 02:03:07 UTC (rev 207514)
@@ -1,5 +1,20 @@
 2016-10-18  Chris Dumez  <cdu...@apple.com>
 
+        Changing details.open should cause a toggle event to be fired asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=163568
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent-expected.txt: Added.
+        * web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html: Added.
+        * web-platform-tests/html/semantics/interactive-elements/the-details-element/w3c-import.log:
+        Import test coverage for the toggle event.
+
+2016-10-18  Chris Dumez  <cdu...@apple.com>
+
         Leverage new union type support for HTMLSelectElement.add() / HTMLOptionsCollection.add()
         https://bugs.webkit.org/show_bug.cgi?id=163608
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (207513 => 207514)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-10-19 02:03:07 UTC (rev 207514)
@@ -114,7 +114,7 @@
 PASS Document interface: attribute onsubmit 
 PASS Document interface: attribute onsuspend 
 PASS Document interface: attribute ontimeupdate 
-FAIL Document interface: attribute ontoggle assert_true: The prototype object must have a property "ontoggle" expected true got false
+PASS Document interface: attribute ontoggle 
 PASS Document interface: attribute onvolumechange 
 PASS Document interface: attribute onwaiting 
 FAIL Document interface: attribute oncopy assert_true: property is not enumerable expected true got false
@@ -300,7 +300,7 @@
 PASS Document interface: iframe.contentDocument must inherit property "onsubmit" with the proper type (144) 
 PASS Document interface: iframe.contentDocument must inherit property "onsuspend" with the proper type (145) 
 PASS Document interface: iframe.contentDocument must inherit property "ontimeupdate" with the proper type (146) 
-FAIL Document interface: iframe.contentDocument must inherit property "ontoggle" with the proper type (147) assert_inherits: property "ontoggle" not found in prototype chain
+PASS Document interface: iframe.contentDocument must inherit property "ontoggle" with the proper type (147) 
 PASS Document interface: iframe.contentDocument must inherit property "onvolumechange" with the proper type (148) 
 PASS Document interface: iframe.contentDocument must inherit property "onwaiting" with the proper type (149) 
 PASS Document interface: iframe.contentDocument must inherit property "oncopy" with the proper type (150) 
@@ -548,7 +548,7 @@
 PASS Document interface: new Document() must inherit property "onsubmit" with the proper type (144) 
 PASS Document interface: new Document() must inherit property "onsuspend" with the proper type (145) 
 PASS Document interface: new Document() must inherit property "ontimeupdate" with the proper type (146) 
-FAIL Document interface: new Document() must inherit property "ontoggle" with the proper type (147) assert_inherits: property "ontoggle" not found in prototype chain
+PASS Document interface: new Document() must inherit property "ontoggle" with the proper type (147) 
 PASS Document interface: new Document() must inherit property "onvolumechange" with the proper type (148) 
 PASS Document interface: new Document() must inherit property "onwaiting" with the proper type (149) 
 PASS Document interface: new Document() must inherit property "oncopy" with the proper type (150) 
@@ -796,7 +796,7 @@
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onsubmit" with the proper type (144) 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onsuspend" with the proper type (145) 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "ontimeupdate" with the proper type (146) 
-FAIL Document interface: document.implementation.createDocument(null, "", null) must inherit property "ontoggle" with the proper type (147) assert_inherits: property "ontoggle" not found in prototype chain
+PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "ontoggle" with the proper type (147) 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onvolumechange" with the proper type (148) 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "onwaiting" with the proper type (149) 
 PASS Document interface: document.implementation.createDocument(null, "", null) must inherit property "oncopy" with the proper type (150) 
@@ -1013,7 +1013,7 @@
 PASS HTMLElement interface: attribute onsubmit 
 PASS HTMLElement interface: attribute onsuspend 
 PASS HTMLElement interface: attribute ontimeupdate 
-FAIL HTMLElement interface: attribute ontoggle assert_true: The prototype object must have a property "ontoggle" expected true got false
+PASS HTMLElement interface: attribute ontoggle 
 PASS HTMLElement interface: attribute onvolumechange 
 PASS HTMLElement interface: attribute onwaiting 
 FAIL HTMLElement interface: attribute oncopy assert_own_property: expected property "oncopy" missing
@@ -1098,7 +1098,7 @@
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "onsubmit" with the proper type (72) 
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "onsuspend" with the proper type (73) 
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "ontimeupdate" with the proper type (74) 
-FAIL HTMLElement interface: document.createElement("noscript") must inherit property "ontoggle" with the proper type (75) assert_inherits: property "ontoggle" not found in prototype chain
+PASS HTMLElement interface: document.createElement("noscript") must inherit property "ontoggle" with the proper type (75) 
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "onvolumechange" with the proper type (76) 
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "onwaiting" with the proper type (77) 
 PASS HTMLElement interface: document.createElement("noscript") must inherit property "oncopy" with the proper type (78) 
@@ -5032,7 +5032,7 @@
 PASS Window interface: attribute onsubmit 
 PASS Window interface: attribute onsuspend 
 PASS Window interface: attribute ontimeupdate 
-FAIL Window interface: attribute ontoggle assert_own_property: The global object must have a property "ontoggle" expected property "ontoggle" missing
+PASS Window interface: attribute ontoggle 
 PASS Window interface: attribute onvolumechange 
 PASS Window interface: attribute onwaiting 
 FAIL Window interface: attribute onafterprint assert_own_property: The global object must have a property "onafterprint" expected property "onafterprint" missing
@@ -5159,7 +5159,7 @@
 PASS Window interface: window must inherit property "onsubmit" with the proper type (92) 
 PASS Window interface: window must inherit property "onsuspend" with the proper type (93) 
 PASS Window interface: window must inherit property "ontimeupdate" with the proper type (94) 
-FAIL Window interface: window must inherit property "ontoggle" with the proper type (95) assert_own_property: expected property "ontoggle" missing
+PASS Window interface: window must inherit property "ontoggle" with the proper type (95) 
 PASS Window interface: window must inherit property "onvolumechange" with the proper type (96) 
 PASS Window interface: window must inherit property "onwaiting" with the proper type (97) 
 FAIL Window interface: window must inherit property "onafterprint" with the proper type (98) assert_own_property: expected property "onafterprint" missing

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent-expected.txt (0 => 207514)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent-expected.txt	2016-10-19 02:03:07 UTC (rev 207514)
@@ -0,0 +1,24 @@
+
+PASS Adding open to 'details' should fire a toggle event at the 'details' element 
+PASS Removing open from 'details' should fire a toggle event at the 'details' element 
+PASS Adding open to 'details' (display:none) should fire a toggle event at the 'details' element 
+PASS Adding open from 'details' (no children) should fire a toggle event at the 'details' element 
+PASS Calling open twice on 'details' fires only one toggle event 
+PASS Calling setAttribute('open', '') to 'details' should fire a toggle event at the 'details' element 
+PASS Calling removeAttribute('open') to 'details' should fire a toggle event at the 'details' element 
+PASS Setting open=true to opened 'details' element should not fire a toggle event at the 'details' element 
+PASS Setting open=false to closed 'details' element should not fire a toggle event at the 'details' element 
+PASS Adding open to 'details' (not in the document) should fire a toggle event at the 'details' element 
+Lorem ipsum
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+Lorem ipsum
+Lorem ipsum
+Lorem ipsum
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+Lorem ipsum
+Lorem ipsum
+Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
+
+Lorem ipsum

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html (0 => 207514)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html	2016-10-19 02:03:07 UTC (rev 207514)
@@ -0,0 +1,157 @@
+<!DOCTYPE html>
+<meta charset=utf-8>
+<title>The details element</title>
+<link rel="author" title="Denis Ah-Kang" href=""
+<link rel=help href=""
+<script src=""
+<script src=""
+<div id="log"></div>
+<details id=details1>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details2 open>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details3 style="display:none;">
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details4>
+</details>
+<details id=details6>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details7>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details8 open>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details9 open>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<details id=details10>
+  <summary>Lorem ipsum</summary>
+  <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
+</details>
+<script>
+  var t1 = async_test("Adding open to 'details' should fire a toggle event at the 'details' element"),
+  t2 = async_test("Removing open from 'details' should fire a toggle event at the 'details' element"),
+  t3 = async_test("Adding open to 'details' (display:none) should fire a toggle event at the 'details' element"),
+  t4 = async_test("Adding open from 'details' (no children) should fire a toggle event at the 'details' element"),
+  t6 = async_test("Calling open twice on 'details' fires only one toggle event"),
+  t7 = async_test("Calling setAttribute('open', '') to 'details' should fire a toggle event at the 'details' element"),
+  t8 = async_test("Calling removeAttribute('open') to 'details' should fire a toggle event at the 'details' element"),
+  t9 = async_test("Setting open=true to opened 'details' element should not fire a toggle event at the 'details' element"),
+  t10 = async_test("Setting open=false to closed 'details' element should not fire a toggle event at the 'details' element"),
+
+  details1 = document.getElementById('details1'),
+  details2 = document.getElementById('details2'),
+  details3 = document.getElementById('details3'),
+  details4 = document.getElementById('details4'),
+  details6 = document.getElementById('details6'),
+  details7 = document.getElementById('details7'),
+  details8 = document.getElementById('details8'),
+  details9 = document.getElementById('details9'),
+  details10 = document.getElementById('details10'),
+  loop=false;
+
+  function testEvent(evt) {
+    assert_true(evt.isTrusted, "event is trusted");
+    assert_false(evt.bubbles, "event doesn't bubble");
+    assert_false(evt.cancelable, "event is not cancelable");
+    assert_equals(Object.getPrototypeOf(evt), Event.prototype, "Prototype of toggle event is Event.prototype");
+  }
+
+  details1._ontoggle_ = t1.step_func_done(function(evt) {
+    assert_true(details1.open);
+    testEvent(evt)
+  });
+  details1.open = true; // opens details1
+
+  details2._ontoggle_ = t2.step_func_done(function(evt) {
+    assert_false(details2.open);
+    testEvent(evt);
+  });
+  details2.open = false; // closes details2
+
+  details3._ontoggle_ = t3.step_func_done(function(evt) {
+    assert_true(details3.open);
+    testEvent(evt);
+  });
+  details3.open = true; // opens details3
+
+  details4._ontoggle_ = t4.step_func_done(function(evt) {
+    assert_true(details4.open);
+    testEvent(evt);
+  });
+  details4.open = true; // opens details4
+
+  async_test(function(t) {
+    var details5 = document.createElement("details");
+    details5._ontoggle_ = t.step_func_done(function(evt) {
+      assert_true(details5.open);
+      testEvent(evt);
+    })
+    details5.open = true;
+  }, "Adding open to 'details' (not in the document) should fire a toggle event at the 'details' element");
+
+  details6.open = true;
+  details6.open = false;
+  details6._ontoggle_ = t6.step_func(function() {
+    if (loop) {
+      assert_unreached("toggle event fired twice");
+    } else {
+      loop = true;
+    }
+  });
+  setTimeout(t6.step_func(function() {
+    assert_true(loop);
+    t6.done();
+  }), 0);
+
+  details7._ontoggle_ = t7.step_func_done(function(evt) {
+    assert_true(details7.open);
+    testEvent(evt)
+  });
+  details7.setAttribute('open', ''); // opens details7
+
+  details8._ontoggle_ = t8.step_func_done(function(evt) {
+    assert_false(details8.open);
+    testEvent(evt)
+  });
+  details8.removeAttribute('open'); // closes details8
+
+  var toggleFiredOnDetails9 = false;
+  details9._ontoggle_ = t9.step_func_done(function(evt) {
+    if (toggleFiredOnDetails9) {
+      assert_unreached("toggle event fired twice on opened details element");
+    } else {
+      toggleFiredOnDetails9 = true;
+    }
+  });
+  // The toggle event should be fired once when declaring details9 with open
+  // attribute.
+  details9.open = true; // opens details9
+  setTimeout(t9.step_func(function() {
+    assert_true(details9.open);
+    assert_true(toggleFiredOnDetails9);
+    t9.done();
+  }), 0);
+
+  details10._ontoggle_ = t10.step_func_done(function(evt) {
+    assert_unreached("toggle event fired on closed details element");
+  });
+  details10.open = false; // closes details10
+  setTimeout(t10.step_func(function() {
+    assert_false(details10.open);
+    t10.done();
+  }), 0);
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/w3c-import.log (207513 => 207514)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/w3c-import.log	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/w3c-import.log	2016-10-19 02:03:07 UTC (rev 207514)
@@ -16,3 +16,4 @@
 ------------------------------------------------------------------------
 List of files:
 /LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/details.html
+/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html

Modified: trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt (207513 => 207514)


--- trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/LayoutTests/js/dom/dom-static-property-for-in-iteration-expected.txt	2016-10-19 02:03:07 UTC (rev 207514)
@@ -99,6 +99,7 @@
 PASS a["onsubmit"] is null
 PASS a["onsuspend"] is null
 PASS a["ontimeupdate"] is null
+PASS a["ontoggle"] is null
 PASS a["onvolumechange"] is null
 PASS a["onwaiting"] is null
 PASS a["tagName"] is A
@@ -109,7 +110,7 @@
 PASS a["prefix"] is null
 PASS a["localName"] is a
 PASS a["offsetLeft"] is 8
-PASS a["offsetTop"] is 1674
+PASS a["offsetTop"] is 1689
 PASS a["offsetWidth"] is 40
 PASS a["offsetHeight"] is 18
 PASS a["clientLeft"] is 0

Modified: trunk/Source/WebCore/ChangeLog (207513 => 207514)


--- trunk/Source/WebCore/ChangeLog	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/ChangeLog	2016-10-19 02:03:07 UTC (rev 207514)
@@ -1,3 +1,29 @@
+2016-10-18  Chris Dumez  <cdu...@apple.com>
+
+        Changing details.open should cause a toggle event to be fired asynchronously
+        https://bugs.webkit.org/show_bug.cgi?id=163568
+
+        Reviewed by Darin Adler.
+
+        Changing details.open should cause a toggle event to be fired asynchronously:
+        - https://html.spec.whatwg.org/#details-notification-task-steps
+
+        Firefox and Chrome implement this, we don't.
+
+        Test: imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-details-element/toggleEvent.html
+
+        * dom/EventNames.h:
+        * dom/GlobalEventHandlers.idl:
+        * html/HTMLAttributeNames.in:
+        * html/HTMLDetailsElement.cpp:
+        (WebCore::detailToggleEventSender):
+        (WebCore::HTMLDetailsElement::~HTMLDetailsElement):
+        (WebCore::HTMLDetailsElement::dispatchPendingEvent):
+        (WebCore::HTMLDetailsElement::parseAttribute):
+        * html/HTMLDetailsElement.h:
+        * html/HTMLElement.cpp:
+        (WebCore::HTMLElement::createEventHandlerNameMap):
+
 2016-10-18  Dave Hyatt  <hy...@apple.com>
 
         [CSS Parser] Enable basic parser testing.

Modified: trunk/Source/WebCore/dom/EventNames.h (207513 => 207514)


--- trunk/Source/WebCore/dom/EventNames.h	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/dom/EventNames.h	2016-10-19 02:03:07 UTC (rev 207514)
@@ -218,6 +218,7 @@
     macro(textInput) \
     macro(timeout) \
     macro(timeupdate) \
+    macro(toggle) \
     macro(tonechange) \
     macro(touchcancel) \
     macro(touchend) \

Modified: trunk/Source/WebCore/dom/GlobalEventHandlers.idl (207513 => 207514)


--- trunk/Source/WebCore/dom/GlobalEventHandlers.idl	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/dom/GlobalEventHandlers.idl	2016-10-19 02:03:07 UTC (rev 207514)
@@ -91,7 +91,7 @@
     attribute EventHandler onsubmit;
     attribute EventHandler onsuspend;
     attribute EventHandler ontimeupdate;
-    // attribute EventHandler ontoggle;
+    attribute EventHandler ontoggle;
     attribute EventHandler onvolumechange;
     attribute EventHandler onwaiting;
 

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (207513 => 207514)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2016-10-19 02:03:07 UTC (rev 207514)
@@ -266,6 +266,7 @@
 onsuspend
 onsubmit
 ontimeupdate
+ontoggle
 ontouchforcechange
 ontouchstart
 ontouchmove

Modified: trunk/Source/WebCore/html/HTMLDetailsElement.cpp (207513 => 207514)


--- trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.cpp	2016-10-19 02:03:07 UTC (rev 207514)
@@ -24,6 +24,8 @@
 #if ENABLE(DETAILS_ELEMENT)
 #include "AXObjectCache.h"
 #include "ElementIterator.h"
+#include "EventNames.h"
+#include "EventSender.h"
 #include "HTMLSlotElement.h"
 #include "HTMLSummaryElement.h"
 #include "LocalizedStrings.h"
@@ -38,6 +40,12 @@
 
 using namespace HTMLNames;
 
+static DetailEventSender& detailToggleEventSender()
+{
+    static NeverDestroyed<DetailEventSender> sharedToggleEventSender(eventNames().toggleEvent);
+    return sharedToggleEventSender;
+}
+
 static const AtomicString& summarySlotName()
 {
     static NeverDestroyed<AtomicString> summarySlot("summarySlot");
@@ -87,6 +95,11 @@
     ASSERT(hasTagName(detailsTag));
 }
 
+HTMLDetailsElement::~HTMLDetailsElement()
+{
+    detailToggleEventSender().cancelEvent(*this);
+}
+
 RenderPtr<RenderElement> HTMLDetailsElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
     return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
@@ -123,6 +136,12 @@
     return slot == m_summarySlot;
 }
 
+void HTMLDetailsElement::dispatchPendingEvent(DetailEventSender* eventSender)
+{
+    ASSERT_UNUSED(eventSender, eventSender == &detailToggleEventSender());
+    dispatchEvent(Event::create(eventNames().toggleEvent, false, false));
+}
+
 void HTMLDetailsElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
 {
     if (name == openAttr) {
@@ -135,6 +154,10 @@
                 root->appendChild(*m_defaultSlot);
             else
                 root->removeChild(*m_defaultSlot);
+
+            // https://html.spec.whatwg.org/#details-notification-task-steps.
+            detailToggleEventSender().cancelEvent(*this);
+            detailToggleEventSender().dispatchEventSoon(*this);
         }
     } else
         HTMLElement::parseAttribute(name, value);

Modified: trunk/Source/WebCore/html/HTMLDetailsElement.h (207513 => 207514)


--- trunk/Source/WebCore/html/HTMLDetailsElement.h	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/html/HTMLDetailsElement.h	2016-10-19 02:03:07 UTC (rev 207514)
@@ -27,13 +27,20 @@
 
 class HTMLSlotElement;
 
+template<typename T> class EventSender;
+typedef EventSender<HTMLDetailsElement> DetailEventSender;
+
 class HTMLDetailsElement final : public HTMLElement {
 public:
     static Ref<HTMLDetailsElement> create(const QualifiedName& tagName, Document&);
+    ~HTMLDetailsElement();
+
     void toggleOpen();
 
     bool isOpen() const { return m_isOpen; }
     bool isActiveSummary(const HTMLSummaryElement&) const;
+
+    void dispatchPendingEvent(DetailEventSender*);
     
 private:
     HTMLDetailsElement(const QualifiedName&, Document&);

Modified: trunk/Source/WebCore/html/HTMLElement.cpp (207513 => 207514)


--- trunk/Source/WebCore/html/HTMLElement.cpp	2016-10-19 01:06:45 UTC (rev 207513)
+++ trunk/Source/WebCore/html/HTMLElement.cpp	2016-10-19 02:03:07 UTC (rev 207514)
@@ -295,6 +295,7 @@
         &onsubmitAttr,
         &onsuspendAttr,
         &ontimeupdateAttr,
+        &ontoggleAttr,
         &ontouchcancelAttr,
         &ontouchendAttr,
         &ontouchforcechangeAttr,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to