Eliminate isMainThread() checks in most call sites of NoEventDispatchAssertion
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2017 21:56:30 +0000 (21:56 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Nov 2017 21:56:30 +0000 (21:56 +0000)
commit3a6550313f57f3cbfcbd4ed7e03e8ca633fa75a5
tree7eefdf01e0d9273921c7acd3db59573b71f86b70
parentebe7c9a3a935b5f3ad59340d929f4a1d98274a89
Eliminate isMainThread() checks in most call sites of NoEventDispatchAssertion
https://bugs.webkit.org/show_bug.cgi?id=179161

Reviewed by Zalan Bujtas.

Introduced NoEventDispatchAssertion::InMainThread which bypasses the expensive isMainThread() check
in order to turn NoEventDispatchAssertion into a release assertion in a separate patch.

Also removed instances of NoEventDispatchAssertion in notifyChildNodeInserted and notifyChildNodeRemoved
and asserted that the caller has instantiated NoEventDispatchAssertion instead.

No new tests since there should be no behavioral changes.

* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::canExecuteScripts):
* dom/Attr.cpp:
* dom/CharacterData.cpp:
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeAllChildrenWithScriptAssertion):
(WebCore::ContainerNode::removeNodeWithScriptAssertion):
(WebCore::executeNodeInsertionWithScriptAssertion):
(WebCore::ContainerNode::removeDetachedChildren): Instantiated NoEventDispatchAssertion::InMainThread
so that notifyChildNodeRemoved would be called inside NoEventDispatchAssertion.
(WebCore::ContainerNode::insertBeforeCommon):
(WebCore::ContainerNode::appendChildCommon):
(WebCore::ContainerNode::removeBetween):
(WebCore::dispatchChildInsertionEvents):
(WebCore::dispatchChildRemovalEvents):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::notifyChildNodeInserted): Assert that the caller has instantiated NoEventDispatchAssertion.
(WebCore::notifyChildNodeRemoved): Ditto.
* dom/Document.cpp:
(WebCore::Document::resolveStyle):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::nodeChildrenWillBeRemoved):
(WebCore::Document::nodeWillBeRemoved):
(WebCore::Document::dispatchWindowEvent): Replaced RELEASE_ASSERT with ASSERT_WITH_SECURITY_IMPLICATION
for clarity since NoEventDispatchAssertion::isEventAllowedInMainThread() always returns true in release
builds right now.
(WebCore::Document::dispatchWindowLoadEvent): Ditto.
(WebCore::Document::applyPendingXSLTransformsTimerFired): Use ASSERT_WITH_SECURITY_IMPLICATION instead
of regular ASSERT.
* dom/Element.cpp:
(WebCore::Element::addShadowRoot): Instantiate NoEventDispatchAssertion::InMainThread to call
notifyChildNodeInserted will it.
(WebCore::Element::attachAttributeNodeIfNeeded):
(WebCore::Element::setAttributeNode): Fixed the indentation.
(WebCore::Element::setAttributeNodeNS): Ditto.
(WebCore::Element::dispatchFocusInEvent):
(WebCore::Element::dispatchFocusOutEvent):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):
* dom/NoEventDispatchAssertion.h:
(WebCore::NoEventDispatchAssertion::isEventDispatchAllowedInSubtree): Moved to InMainThread.
(WebCore::NoEventDispatchAssertion::InMainThread): Added.
(WebCore::NoEventDispatchAssertion::InMainThread::InMainThread): Assert that we're in the main thread
instead of exiting early.
(WebCore::NoEventDispatchAssertion::InMainThread::~InMainThread): Ditto.
(WebCore::NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree): Moved here.
(WebCore::NoEventDispatchAssertion::InMainThread::isEventAllowed):
* dom/Node.cpp:
(WebCore::Node::dispatchSubtreeModifiedEvent):
(WebCore::Node::dispatchDOMActivateEvent):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension):
(WebCore::ScriptExecutionContext::suspendActiveDOMObjects):
(WebCore::ScriptExecutionContext::resumeActiveDOMObjects):
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
* history/PageCache.cpp:
(WebCore::PageCache::addIfCacheable):
* page/LayoutContext.cpp:
(WebCore::LayoutContext::layout):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224356 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/dom/Attr.cpp
Source/WebCore/dom/CharacterData.cpp
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/NoEventDispatchAssertion.h
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/PageCache.cpp
Source/WebCore/page/LayoutContext.cpp
Source/WebCore/rendering/RenderLayer.cpp