Changeset 145340 in webkit


Ignore:
Timestamp:
Mar 10, 2013 11:13:05 PM (11 years ago)
Author:
falken@chromium.org
Message:

Implement inert subtrees needed for modal <dialog>
https://bugs.webkit.org/show_bug.cgi?id=110952

Reviewed by Hajime Morrita.

Source/WebCore:

This changes Node::disabled() to return true when a modal dialog is
open and the node is not in the dialog.

Reusing disabled for inertness is useful because then event
targeting and focus control automatically have the desired behavior:
inert nodes are skipped over.

Tests: fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events.html

fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html
fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events.html

  • dom/Document.h:

(WebCore::Document::activeModalDialog): Returns the topmost element in the top layer.
Since now the only elements in the top layer are modal dialogs, it is the active modal dialog.

  • dom/Node.cpp:

(WebCore):
(WebCore::Node::isInert): As per the spec, a node that is not an ancestor or descendant of the modal dialog is inert.
(WebCore::Node::disabled): Return false when inert.

  • dom/Node.h:
  • html/HTMLFormControlElement.cpp:

(WebCore::HTMLFormControlElement::disabled): Fall back to the superclass so inert is taken into account.

LayoutTests:

  • fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events-expected.txt: Added.
  • fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events.html: Added.
  • fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt: Added.
  • fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html: Added.
  • fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events-expected.txt: Added.
  • fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events.html: Added.
Location:
trunk
Files:
6 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r145338 r145340  
     12013-03-10  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Implement inert subtrees needed for modal <dialog>
     4        https://bugs.webkit.org/show_bug.cgi?id=110952
     5
     6        Reviewed by Hajime Morrita.
     7
     8        * fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events-expected.txt: Added.
     9        * fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events.html: Added.
     10        * fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events-expected.txt: Added.
     11        * fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html: Added.
     12        * fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events-expected.txt: Added.
     13        * fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events.html: Added.
     14
    1152013-03-10  Glenn Adams  <glenn@skynav.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r145338 r145340  
     12013-03-10  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Implement inert subtrees needed for modal <dialog>
     4        https://bugs.webkit.org/show_bug.cgi?id=110952
     5
     6        Reviewed by Hajime Morrita.
     7
     8        This changes Node::disabled() to return true when a modal dialog is
     9        open and the node is not in the dialog.
     10
     11        Reusing disabled for inertness is useful because then event
     12        targeting and focus control automatically have the desired behavior:
     13        inert nodes are skipped over.
     14
     15        Tests: fast/dom/HTMLDialogElement/closed-dialog-does-not-block-mouse-events.html
     16               fast/dom/HTMLDialogElement/modal-dialog-blocks-mouse-events.html
     17               fast/dom/HTMLDialogElement/non-modal-dialog-does-not-block-mouse-events.html
     18
     19        * dom/Document.h:
     20        (WebCore::Document::activeModalDialog): Returns the topmost element in the top layer.
     21        Since now the only elements in the top layer are modal dialogs, it is the active modal dialog.
     22        * dom/Node.cpp:
     23        (WebCore):
     24        (WebCore::Node::isInert): As per the spec, a node that is not an ancestor or descendant of the modal dialog is inert.
     25        (WebCore::Node::disabled): Return false when inert.
     26        * dom/Node.h:
     27        * html/HTMLFormControlElement.cpp:
     28        (WebCore::HTMLFormControlElement::disabled): Fall back to the superclass so inert is taken into account.
     29
    1302013-03-10  Glenn Adams  <glenn@skynav.com>
    231
  • trunk/Source/WebCore/dom/Document.h

    r145126 r145340  
    11801180    void removeFromTopLayer(Element*);
    11811181    const Vector<RefPtr<Element> >& topLayerElements() const { return m_topLayerElements; }
     1182    Element* activeModalDialog() const { return !m_topLayerElements.isEmpty() ? m_topLayerElements.last().get() : 0; }
    11821183#endif
    11831184
  • trunk/Source/WebCore/dom/Node.cpp

    r145296 r145340  
    903903}
    904904
     905#if ENABLE(DIALOG_ELEMENT)
     906bool Node::isInert() const
     907{
     908    Element* dialog = document()->activeModalDialog();
     909    return dialog && !containsIncludingShadowDOM(dialog) && !dialog->containsIncludingShadowDOM(this);
     910}
     911#endif
     912
    905913unsigned Node::nodeIndex() const
    906914{
     
    24472455bool Node::disabled() const
    24482456{
     2457#if ENABLE(DIALOG_ELEMENT)
     2458    if (isInert())
     2459        return true;
     2460#endif
    24492461    return false;
    24502462}
  • trunk/Source/WebCore/dom/Node.h

    r145021 r145340  
    415415    virtual Node* focusDelegate();
    416416
     417#if ENABLE(DIALOG_ELEMENT)
     418    bool isInert() const;
     419#endif
     420
    417421    enum UserSelectAllTreatment {
    418422        UserSelectAllDoesNotAffectEditability,
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r144949 r145340  
    282282    if (m_ancestorDisabledState == AncestorDisabledStateUnknown)
    283283        updateAncestorDisabledState();
    284     return m_ancestorDisabledState == AncestorDisabledStateDisabled;
     284    if (m_ancestorDisabledState == AncestorDisabledStateDisabled)
     285        return true;
     286    return HTMLElement::disabled();
    285287}
    286288
Note: See TracChangeset for help on using the changeset viewer.