Changeset 123193 in webkit


Ignore:
Timestamp:
Jul 20, 2012 1:28:37 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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

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

Source/WebCore:

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

(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.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r123192 r123193  
     12012-07-20  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Show or hide <dialog> depending on the open attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=90931
     5
     6        Reviewed by Kent Tamura.
     7
     8        * fast/dom/HTMLDialogElement/dialog-open-expected.txt: Added.
     9        * fast/dom/HTMLDialogElement/dialog-open.html: Added.
     10
    1112012-07-20  Shinya Kawanaka  <shinyak@chromium.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r123192 r123193  
     12012-07-20  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Show or hide <dialog> depending on the open attribute
     4        https://bugs.webkit.org/show_bug.cgi?id=90931
     5
     6        Reviewed by Kent Tamura.
     7
     8        Test: fast/dom/HTMLDialogElement/dialog-open.html
     9
     10        * 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
     11        (dialog:not([open])):
     12        (dialog):
     13        * html/HTMLDialogElement.cpp:
     14        (WebCore::HTMLDialogElement::close): Set open to false, to hide the dialog.
     15        (WebCore::HTMLDialogElement::show): Set open to true, to show the dialog.
     16        (WebCore):
     17        (WebCore::HTMLDialogElement::isPresentationAttribute): Make openAttr a presentation attribute, to work around bug 91058
     18        * html/HTMLDialogElement.h:
     19        (HTMLDialogElement):
     20        * html/HTMLDialogElement.idl:
     21
    1222012-07-20  Shinya Kawanaka  <shinyak@chromium.org>
    223
  • trunk/Source/WebCore/css/html.css

    r122824 r123193  
    141141}
    142142
     143#if defined(ENABLE_DIALOG_ELEMENT) && ENABLE_DIALOG_ELEMENT
     144dialog:not([open]) { display: none; }
     145dialog {
     146    position: absolute;
     147    left: 0; right: 0;
     148    margin: auto;
     149    border: solid;
     150    padding: 1em;
     151    background: white;
     152    color: black;
     153}
     154#endif
     155
    143156/* heading elements */
    144157
  • trunk/Source/WebCore/html/HTMLDialogElement.cpp

    r122195 r123193  
    2929#if ENABLE(DIALOG_ELEMENT)
    3030
     31#include "ExceptionCode.h"
     32
    3133namespace WebCore {
    3234
     
    4446}
    4547
    46 void HTMLDialogElement::close()
     48void HTMLDialogElement::close(ExceptionCode& ec)
    4749{
    48     // FIXME: Implement.
     50    if (!fastHasAttribute(openAttr)) {
     51        ec = INVALID_STATE_ERR;
     52        return;
     53    }
     54    setBooleanAttribute(openAttr, false);
    4955}
    5056
    5157void HTMLDialogElement::show()
    5258{
    53     // FIXME: Implement.
     59    if (fastHasAttribute(openAttr))
     60        return;
     61    setBooleanAttribute(openAttr, true);
     62}
     63
     64bool HTMLDialogElement::isPresentationAttribute(const QualifiedName& name) const
     65{
     66    // FIXME: Workaround for <https://bugs.webkit.org/show_bug.cgi?id=91058>: modifying an attribute for which there is an attribute selector
     67    // in html.css sometimes does not trigger a style recalc.
     68    if (name == openAttr)
     69        return true;
     70
     71    return HTMLElement::isPresentationAttribute(name);
    5472}
    5573
  • trunk/Source/WebCore/html/HTMLDialogElement.h

    r122195 r123193  
    4040    static PassRefPtr<HTMLDialogElement> create(const QualifiedName&, Document*);
    4141
    42     void close();
     42    void close(ExceptionCode&);
    4343    void show();
    4444
    4545private:
    4646    HTMLDialogElement(const QualifiedName&, Document*);
     47
     48    virtual bool isPresentationAttribute(const QualifiedName&) const OVERRIDE;
    4749};
    4850
  • trunk/Source/WebCore/html/HTMLDialogElement.idl

    r122195 r123193  
    3030    ] HTMLDialogElement : HTMLElement {
    3131        attribute [Reflect] boolean open;
    32         void close();
     32        void close() raises(DOMException);
    3333        void show();
    3434    };
Note: See TracChangeset for help on using the changeset viewer.