Title: [123193] trunk
Revision
123193
Author
commit-qu...@webkit.org
Date
2012-07-20 01:28:37 -0700 (Fri, 20 Jul 2012)

Log Message

Show or hide <dialog> depending on the open attribute
https://bugs.webkit.org/show_bug.cgi?id=90931

Patch by Matt Falkenhagen <fal...@chromium.org> on 2012-07-20
Reviewed by Kent Tamura.

Source/WebCore:

Test: fast/dom/HTMLDialogElement/dialog-open.html

* css/html.css: Add CSS for dialog. This is copied verbatim from the HTML5 spec: http://www.whatwg.org/specs/web-apps/current-work/#flow-content-1
(dialog:not([open])):
(dialog):
* html/HTMLDialogElement.cpp:
(WebCore::HTMLDialogElement::close): Set open to false, to hide the dialog.
(WebCore::HTMLDialogElement::show): Set open to true, to show the dialog.
(WebCore):
(WebCore::HTMLDialogElement::isPresentationAttribute): Make openAttr a presentation attribute, to work around bug 91058
* html/HTMLDialogElement.h:
(HTMLDialogElement):
* html/HTMLDialogElement.idl:

LayoutTests:

* fast/dom/HTMLDialogElement/dialog-open-expected.txt: Added.
* fast/dom/HTMLDialogElement/dialog-open.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (123192 => 123193)


--- trunk/LayoutTests/ChangeLog	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/LayoutTests/ChangeLog	2012-07-20 08:28:37 UTC (rev 123193)
@@ -1,3 +1,13 @@
+2012-07-20  Matt Falkenhagen  <fal...@chromium.org>
+
+        Show or hide <dialog> depending on the open attribute
+        https://bugs.webkit.org/show_bug.cgi?id=90931
+
+        Reviewed by Kent Tamura.
+
+        * fast/dom/HTMLDialogElement/dialog-open-expected.txt: Added.
+        * fast/dom/HTMLDialogElement/dialog-open.html: Added.
+
 2012-07-20  Shinya Kawanaka  <shin...@chromium.org>
 
         Needs pseudo id to point the inner element of an img elemnet for styling

Added: trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open-expected.txt (0 => 123193)


--- trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open-expected.txt	2012-07-20 08:28:37 UTC (rev 123193)
@@ -0,0 +1,13 @@
+Tests that dialog is visible after show() is called and not visible after close() is called. bug 90931
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS computedStyle.getPropertyValue('display') is 'none'
+PASS computedStyle.getPropertyValue('display') is 'block'
+PASS computedStyle.getPropertyValue('display') is 'none'
+PASS dialog.close(); threw exception Error: INVALID_STATE_ERR: DOM Exception 11.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open.html (0 => 123193)


--- trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLDialogElement/dialog-open.html	2012-07-20 08:28:37 UTC (rev 123193)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+if (window.internals)
+    internals.settings.setDialogElementEnabled(true);
+</script>
+</head>
+<body>
+<dialog id="mydialog">It's my dialog.</dialog>
+<script>
+description("Tests that dialog is visible after show() is called and not visible after close() is called. bug 90931");
+
+dialog = document.getElementById('mydialog');
+computedStyle = window.getComputedStyle(dialog, null);
+shouldBe("computedStyle.getPropertyValue('display')", "'none'");
+
+dialog.show();
+computedStyle = window.getComputedStyle(dialog, null);
+shouldBe("computedStyle.getPropertyValue('display')", "'block'");
+
+dialog.close();
+computedStyle = window.getComputedStyle(dialog, null);
+
+shouldBe("computedStyle.getPropertyValue('display')", "'none'");
+shouldThrow('dialog.close();', "'Error: INVALID_STATE_ERR: DOM Exception 11'");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (123192 => 123193)


--- trunk/Source/WebCore/ChangeLog	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/Source/WebCore/ChangeLog	2012-07-20 08:28:37 UTC (rev 123193)
@@ -1,3 +1,24 @@
+2012-07-20  Matt Falkenhagen  <fal...@chromium.org>
+
+        Show or hide <dialog> depending on the open attribute
+        https://bugs.webkit.org/show_bug.cgi?id=90931
+
+        Reviewed by Kent Tamura.
+
+        Test: fast/dom/HTMLDialogElement/dialog-open.html
+
+        * css/html.css: Add CSS for dialog. This is copied verbatim from the HTML5 spec: http://www.whatwg.org/specs/web-apps/current-work/#flow-content-1
+        (dialog:not([open])):
+        (dialog):
+        * html/HTMLDialogElement.cpp:
+        (WebCore::HTMLDialogElement::close): Set open to false, to hide the dialog.
+        (WebCore::HTMLDialogElement::show): Set open to true, to show the dialog.
+        (WebCore):
+        (WebCore::HTMLDialogElement::isPresentationAttribute): Make openAttr a presentation attribute, to work around bug 91058
+        * html/HTMLDialogElement.h:
+        (HTMLDialogElement):
+        * html/HTMLDialogElement.idl:
+
 2012-07-20  Shinya Kawanaka  <shin...@chromium.org>
 
         Needs pseudo id to point the inner element of an img elemnet for styling

Modified: trunk/Source/WebCore/css/html.css (123192 => 123193)


--- trunk/Source/WebCore/css/html.css	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/Source/WebCore/css/html.css	2012-07-20 08:28:37 UTC (rev 123193)
@@ -140,6 +140,19 @@
     display: inline
 }
 
+#if defined(ENABLE_DIALOG_ELEMENT) && ENABLE_DIALOG_ELEMENT
+dialog:not([open]) { display: none; }
+dialog {
+    position: absolute;
+    left: 0; right: 0;
+    margin: auto;
+    border: solid;
+    padding: 1em;
+    background: white;
+    color: black;
+}
+#endif
+
 /* heading elements */
 
 h1 {

Modified: trunk/Source/WebCore/html/HTMLDialogElement.cpp (123192 => 123193)


--- trunk/Source/WebCore/html/HTMLDialogElement.cpp	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/Source/WebCore/html/HTMLDialogElement.cpp	2012-07-20 08:28:37 UTC (rev 123193)
@@ -28,6 +28,8 @@
 
 #if ENABLE(DIALOG_ELEMENT)
 
+#include "ExceptionCode.h"
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -43,16 +45,32 @@
     return adoptRef(new HTMLDialogElement(tagName, document));
 }
 
-void HTMLDialogElement::close()
+void HTMLDialogElement::close(ExceptionCode& ec)
 {
-    // FIXME: Implement.
+    if (!fastHasAttribute(openAttr)) {
+        ec = INVALID_STATE_ERR;
+        return;
+    }
+    setBooleanAttribute(openAttr, false);
 }
 
 void HTMLDialogElement::show()
 {
-    // FIXME: Implement.
+    if (fastHasAttribute(openAttr))
+        return;
+    setBooleanAttribute(openAttr, true);
 }
 
+bool HTMLDialogElement::isPresentationAttribute(const QualifiedName& name) const
+{
+    // FIXME: Workaround for <https://bugs.webkit.org/show_bug.cgi?id=91058>: modifying an attribute for which there is an attribute selector
+    // in html.css sometimes does not trigger a style recalc.
+    if (name == openAttr)
+        return true;
+
+    return HTMLElement::isPresentationAttribute(name);
 }
 
+}
+
 #endif

Modified: trunk/Source/WebCore/html/HTMLDialogElement.h (123192 => 123193)


--- trunk/Source/WebCore/html/HTMLDialogElement.h	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/Source/WebCore/html/HTMLDialogElement.h	2012-07-20 08:28:37 UTC (rev 123193)
@@ -39,11 +39,13 @@
 public:
     static PassRefPtr<HTMLDialogElement> create(const QualifiedName&, Document*);
 
-    void close();
+    void close(ExceptionCode&);
     void show();
 
 private:
     HTMLDialogElement(const QualifiedName&, Document*);
+
+    virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLDialogElement.idl (123192 => 123193)


--- trunk/Source/WebCore/html/HTMLDialogElement.idl	2012-07-20 08:06:36 UTC (rev 123192)
+++ trunk/Source/WebCore/html/HTMLDialogElement.idl	2012-07-20 08:28:37 UTC (rev 123193)
@@ -29,7 +29,7 @@
         Conditional=DIALOG_ELEMENT
     ] HTMLDialogElement : HTMLElement {
         attribute [Reflect] boolean open;
-        void close();
+        void close() raises(DOMException);
         void show();
     };
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to