2010-12-09 Ryosuke Niwa <rniwa@webkit.org>
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 05:08:04 +0000 (05:08 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 Dec 2010 05:08:04 +0000 (05:08 +0000)
commit715fbf3d8c956a9f77b851246403fe722aeebdf0
tree791eb0ba41d343cb8de58efac297e467add39e5e
parentf01c79c6a6c3d6877497cc28c3750df9c67427c7
2010-12-09  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Ojan Vafai.

        Implemented DOM mutations events as scoped events. A scoped event is an event whose
        dispatch is done via ScopedEventQueue. The behavior of the queue is controlled by
        EventQueueScope objects (RAII idiom), which increments and decrements the scoping level
        on its constructor and destructor respectively.

        When the scoping level is 0 (initial level), scoped events are dispatched as soon as
        they are enqueued and act like synchronous events. When the scoping level is greater than 0,
        however, events are queued in ScopedEventQueue and their dispatches are delayed until
        the scoping level goes back to 0 (by the destruction of EventQueueScope).

        DOMSubtreeModified, DOMNodeInserted, DOMNodeRemoved, DOMNodeRemovedFromDocument,
        DOMNodeInsertedIntoDocument, DOMFocusIn, DOMFocusOut, focusin, and focusout are treated as
        scoped events, and a scope object is instantiated in EditCommand::apply to delay dispatches
        of the events until the completion of each call of EditCommand::doApply.

        Test: fast/events/mutation/execCommands.html

        * Android.mk: Added ScopedEventQueue.cpp.
        * CMakeLists.txt: Ditto.
        * WebCore.pro: Ditto.
        * GNUmakefile.am: Added ScopedEventQueue.cpp and ScopedEventQueue.h.
        * WebCore.gypi:  Ditto.
        * WebCore.vcproj/project.vcproj: Ditto.
        * WebCore.xcodeproj/project.pbxproj: Ditto.
        * dom/ContainerNode.cpp:
        (WebCore::dispatchChildInsertionEvents): Calls dispatchScopedEvent.
        (WebCore::dispatchChildRemovalEvents): Ditto.
        * dom/DOMAllInOne.cpp: Added ScopedEventQueue.cpp.
        * dom/Element.cpp:
        (WebCore::Element::dispatchAttrRemovalEvent): Ditto.
        (WebCore::Element::dispatchAttrAdditionEvent): Ditto.
        * dom/Node.cpp:
        (WebCore::Node::dispatchScopedEvent): Added.
        (WebCore::Node::dispatchSubtreeModifiedEvent): Calls dispatchScopedEvent.
        * dom/Node.h:
        * dom/ScopedEventQueue.cpp: Added.
        (WebCore::ScopedEventQueue::initialize): Added.
        (WebCore::ScopedEventQueue::enqueueEvent): Added.
        (WebCore::ScopedEventQueue::dispatchAllEvents): Added.
        (WebCore::ScopedEventQueue::dispatchEvent): Added.
        (WebCore::ScopedEventQueue::instance): Added.
        (WebCore::ScopedEventQueue::incrementScopingLevel): Added.
        (WebCore::ScopedEventQueue::decrementScopingLevel): Added.
        * dom/ScopedEventQueue.h: Added.
        (WebCore::ScopedEventQueue::~ScopedEventQueue): Added.
        (WebCore::ScopedEventQueue::ScopedEventQueue): Added.
        (WebCore::EventQueueScope::EventQueueScope): Added.
        (WebCore::EventQueueScope::~EventQueueScope): Added.
        * editing/EditCommand.cpp:
        (WebCore::EditCommand::apply): Instantiates EventQueueScope.
2010-12-09  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Ojan Vafai.

        Added a test to ensure no DOM mutation events are fired while execCommand is in progress.

        * fast/events/crash-on-mutate-during-drop.html: DOMNodeInserted is fired after BR is detached
        from the document, and can't be observed. Modify the DOM when text node is inserted.
        * fast/events/mutation: Added.
        * fast/events/mutation/execCommands.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@73684 268f45cc-cd09-0410-ab3c-d52691b4dbfc
20 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/crash-on-mutate-during-drop.html
LayoutTests/fast/events/scoped/editing-commands-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/scoped/editing-commands.html [new file with mode: 0644]
WebCore/Android.mk
WebCore/CMakeLists.txt
WebCore/ChangeLog
WebCore/GNUmakefile.am
WebCore/WebCore.gypi
WebCore/WebCore.pro
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/dom/ContainerNode.cpp
WebCore/dom/DOMAllInOne.cpp
WebCore/dom/Element.cpp
WebCore/dom/Node.cpp
WebCore/dom/Node.h
WebCore/dom/ScopedEventQueue.cpp [new file with mode: 0644]
WebCore/dom/ScopedEventQueue.h [new file with mode: 0644]
WebCore/editing/EditCommand.cpp