Title: [279950] trunk
Revision
279950
Author
[email protected]
Date
2021-07-15 09:16:40 -0700 (Thu, 15 Jul 2021)

Log Message

<dialog> element: do not perform close() method steps when removing open attribute.
https://bugs.webkit.org/show_bug.cgi?id=227872

Reviewed by Chris Dumez.

Test: web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open.html

The close function now follows the steps at: https://html.spec.whatwg.org/multipage/interactive-elements.html#close-the-dialog

LayoutTests/imported/w3c:

* web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open-expected.txt:

Source/WebCore:

* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::show):
(WebCore::HTMLDialogElement::showModal):
(WebCore::HTMLDialogElement::close):
(WebCore::HTMLDialogElement::dispatchPendingEvent):
(WebCore::HTMLDialogElement::isOpen const): Deleted.
(WebCore::HTMLDialogElement::returnValue): Deleted.
(WebCore::HTMLDialogElement::setReturnValue): Deleted.
(WebCore::HTMLDialogElement::parseAttribute): Deleted.
(WebCore::HTMLDialogElement::isModal const): Deleted.
* html/HTMLDialogElement.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279949 => 279950)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-15 16:15:49 UTC (rev 279949)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-15 16:16:40 UTC (rev 279950)
@@ -1,5 +1,18 @@
 2021-07-15  Tim Nguyen  <[email protected]>
 
+        <dialog> element: do not perform close() method steps when removing open attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=227872
+
+        Reviewed by Chris Dumez.
+
+        Test: web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open.html
+
+        The close function now follows the steps at: https://html.spec.whatwg.org/multipage/interactive-elements.html#close-the-dialog
+
+        * web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open-expected.txt:
+
+2021-07-15  Tim Nguyen  <[email protected]>
+
         Re-import html/semantics/interactive-elements/the-dialog-element WPT
         https://bugs.webkit.org/show_bug.cgi?id=227986
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open-expected.txt (279949 => 279950)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open-expected.txt	2021-07-15 16:15:49 UTC (rev 279949)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open-expected.txt	2021-07-15 16:16:40 UTC (rev 279950)
@@ -4,5 +4,5 @@
 
 PASS On getting, the IDL open attribute must return true if the content open attribute is set, and false if it is absent.
 PASS On setting, the content open attribute must be removed if the IDL open attribute is set to false, and must be present if the IDL open attribute is set to true.
-FAIL On setting it to false, the close event should not be fired assert_unreached: close event should not be fired when just setting the open attribute Reached unreachable code
+PASS On setting it to false, the close event should not be fired
 

Modified: trunk/Source/WebCore/ChangeLog (279949 => 279950)


--- trunk/Source/WebCore/ChangeLog	2021-07-15 16:15:49 UTC (rev 279949)
+++ trunk/Source/WebCore/ChangeLog	2021-07-15 16:16:40 UTC (rev 279950)
@@ -1,3 +1,26 @@
+2021-07-15  Tim Nguyen  <[email protected]>
+
+        <dialog> element: do not perform close() method steps when removing open attribute.
+        https://bugs.webkit.org/show_bug.cgi?id=227872
+
+        Reviewed by Chris Dumez.
+
+        Test: web-platform-tests/html/semantics/interactive-elements/the-dialog-element/dialog-open.html
+
+        The close function now follows the steps at: https://html.spec.whatwg.org/multipage/interactive-elements.html#close-the-dialog
+
+        * html/HTMLDialogElement.cpp:
+        (WebCore::HTMLDialogElement::show):
+        (WebCore::HTMLDialogElement::showModal):
+        (WebCore::HTMLDialogElement::close):
+        (WebCore::HTMLDialogElement::dispatchPendingEvent):
+        (WebCore::HTMLDialogElement::isOpen const): Deleted.
+        (WebCore::HTMLDialogElement::returnValue): Deleted.
+        (WebCore::HTMLDialogElement::setReturnValue): Deleted.
+        (WebCore::HTMLDialogElement::parseAttribute): Deleted.
+        (WebCore::HTMLDialogElement::isModal const): Deleted.
+        * html/HTMLDialogElement.h:
+
 2021-07-15  Jer Noble  <[email protected]>
 
         REGRESSION (r279119?): [iOS] ASSERTION FAILED: !m_impl || !m_shouldEnableAssertions || m_impl->wasConstructedOnMainThread() == isMainThread() seen with 3 WebKitLegacy media API tests

Modified: trunk/Source/WebCore/html/HTMLDialogElement.cpp (279949 => 279950)


--- trunk/Source/WebCore/html/HTMLDialogElement.cpp	2021-07-15 16:15:49 UTC (rev 279949)
+++ trunk/Source/WebCore/html/HTMLDialogElement.cpp	2021-07-15 16:16:40 UTC (rev 279950)
@@ -53,27 +53,12 @@
     dialogCloseEventSender().cancelEvent(*this);
 }
 
-bool HTMLDialogElement::isOpen() const
-{
-    return m_isOpen;
-}
-
-const String& HTMLDialogElement::returnValue()
-{
-    return m_returnValue;
-}
-
-void HTMLDialogElement::setReturnValue(String&& returnValue)
-{
-    m_returnValue = WTFMove(returnValue);
-}
-
 void HTMLDialogElement::show()
 {
     // If the element already has an open attribute, then return.
     if (isOpen())
         return;
-    
+
     setBooleanAttribute(openAttr, true);
 }
 
@@ -89,54 +74,41 @@
 
     setBooleanAttribute(openAttr, true);
 
-    document().addToTopLayer(*this);
     m_isModal = true;
 
+    // FIXME: Only add dialog to top layer if it's not already in it. (webkit.org/b/227907)
+    document().addToTopLayer(*this);
+
+    // FIXME: Add steps 8 & 9 from spec. (webkit.org/b/227537)
+
     return { };
 }
 
-void HTMLDialogElement::close(const String& returnValue)
+void HTMLDialogElement::close(const String& result)
 {
     if (!isOpen())
         return;
-    
+
     setBooleanAttribute(openAttr, false);
 
-    if (!returnValue.isNull())
-        m_returnValue = returnValue;
-}
+    m_isModal = false;
 
-void HTMLDialogElement::dispatchPendingEvent(DialogEventSender* eventSender)
-{
-    ASSERT_UNUSED(eventSender, eventSender == &dialogCloseEventSender());
-    dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
-}
+    if (!result.isNull())
+        m_returnValue = result;
 
-void HTMLDialogElement::parseAttribute(const QualifiedName& name, const AtomString& value)
-{
-    if (name == openAttr) {
-        bool oldValue = m_isOpen;
-        m_isOpen = !value.isNull();
+    // FIXME: Only remove dialog from top layer if it's inside it. (webkit.org/b/227907)
+    document().removeFromTopLayer(*this);
 
-        // Emit close event
-        if (oldValue != m_isOpen && !m_isOpen) {
-            if (m_isModal) {
-                document().removeFromTopLayer(*this);
-                m_isModal = false;
-            }
+    // FIXME: Add step 6 from spec. (webkit.org/b/227537)
 
-            dialogCloseEventSender().cancelEvent(*this);
-            dialogCloseEventSender().dispatchEventSoon(*this);
-        }
-        return;
-    }
-    
-    HTMLElement::parseAttribute(name, value);
+    dialogCloseEventSender().cancelEvent(*this);
+    dialogCloseEventSender().dispatchEventSoon(*this);
 }
 
-bool HTMLDialogElement::isModal() const
+void HTMLDialogElement::dispatchPendingEvent(DialogEventSender* eventSender)
 {
-    return m_isModal;
+    ASSERT_UNUSED(eventSender, eventSender == &dialogCloseEventSender());
+    dispatchEvent(Event::create(eventNames().closeEvent, Event::CanBubble::No, Event::IsCancelable::No));
 }
 
 }

Modified: trunk/Source/WebCore/html/HTMLDialogElement.h (279949 => 279950)


--- trunk/Source/WebCore/html/HTMLDialogElement.h	2021-07-15 16:15:49 UTC (rev 279949)
+++ trunk/Source/WebCore/html/HTMLDialogElement.h	2021-07-15 16:16:40 UTC (rev 279950)
@@ -37,12 +37,12 @@
 public:
     template<typename... Args> static Ref<HTMLDialogElement> create(Args&&... args) { return adoptRef(*new HTMLDialogElement(std::forward<Args>(args)...)); }
     ~HTMLDialogElement();
-    
-    bool isOpen() const;
 
-    const String& returnValue();
-    void setReturnValue(String&&);
+    bool isOpen() const { return hasAttribute(HTMLNames::openAttr); }
 
+    const String& returnValue() const { return m_returnValue; }
+    void setReturnValue(String&& value) { m_returnValue = WTFMove(value); }
+
     void show();
     ExceptionOr<void> showModal();
     void close(const String&);
@@ -49,16 +49,13 @@
 
     void dispatchPendingEvent(DialogEventSender*);
 
-    bool isModal() const;
+    bool isModal() const { return m_isModal; };
 
 private:
     HTMLDialogElement(const QualifiedName&, Document&);
 
-    void parseAttribute(const QualifiedName&, const AtomString&) final;
-
     String m_returnValue;
     bool m_isModal { false };
-    bool m_isOpen { false };
 };
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to