Rename NoEventDispatchAssertion to ScriptDisallowedScope
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 01:10:32 +0000 (01:10 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 22 Dec 2017 01:10:32 +0000 (01:10 +0000)
https://bugs.webkit.org/show_bug.cgi?id=181102

Reviewed by Zalan Bujtas.

Renamed the class.

* WebCore.xcodeproj/project.pbxproj:
* bindings/js/ScriptController.cpp:
(WebCore::ScriptController::canExecuteScripts):
* dom/ContainerNode.cpp:
(WebCore::ContainerNode::removeAllChildrenWithScriptAssertion):
(WebCore::ContainerNode::removeNodeWithScriptAssertion):
(WebCore::executeNodeInsertionWithScriptAssertion):
(WebCore::ContainerNode::removeDetachedChildren):
(WebCore::ContainerNode::insertBeforeCommon):
(WebCore::ContainerNode::appendChildCommon):
(WebCore::ContainerNode::removeBetween):
(WebCore::dispatchChildInsertionEvents):
(WebCore::dispatchChildRemovalEvents):
* dom/ContainerNodeAlgorithms.cpp:
(WebCore::notifyChildNodeInserted):
(WebCore::notifyChildNodeRemoved):
* dom/Document.cpp:
(WebCore::Document::resolveStyle):
(WebCore::isSafeToUpdateStyleOrLayout):
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::nodeChildrenWillBeRemoved):
(WebCore::Document::nodeWillBeRemoved):
(WebCore::Document::dispatchWindowEvent):
(WebCore::Document::dispatchWindowLoadEvent):
(WebCore::Document::applyPendingXSLTransformsTimerFired):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::attachAttributeNodeIfNeeded):
(WebCore::Element::setAttributeNode):
(WebCore::Element::setAttributeNodeNS):
(WebCore::Element::dispatchFocusInEvent):
(WebCore::Element::dispatchFocusOutEvent):
* dom/ElementIteratorAssertions.h:
(WebCore::ElementIteratorAssertions::ElementIteratorAssertions):
* dom/EventDispatcher.cpp:
(WebCore::EventDispatcher::dispatchEvent):
* dom/EventTarget.cpp:
(WebCore::EventTarget::fireEventListeners):
* dom/NoEventDispatchAssertion.h: Removed.
* dom/Node.cpp:
(WebCore::Node::dispatchSubtreeModifiedEvent):
(WebCore::Node::dispatchDOMActivateEvent):
* dom/ScriptDisallowedScope.h: Copied from Source/WebCore/dom/NoEventDispatchAssertion.h.
(WebCore::ScriptDisallowedScope::ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::~ScriptDisallowedScope):
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
(WebCore::ScriptDisallowedScope::InMainThread::isScriptAllowed):
(WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion): Deleted.
(WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion): Deleted.
(WebCore::NoEventDispatchAssertion::isEventAllowedInMainThread): Deleted.
(WebCore::NoEventDispatchAssertion::InMainThread::InMainThread): Deleted.
(WebCore::NoEventDispatchAssertion::InMainThread::~InMainThread): Deleted.
(WebCore::NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree): Deleted.
(WebCore::NoEventDispatchAssertion::InMainThread::isEventAllowed): Deleted.
(WebCore::NoEventDispatchAssertion::EventAllowedScope::EventAllowedScope): Deleted.
(WebCore::NoEventDispatchAssertion::EventAllowedScope::~EventAllowedScope): Deleted.
(WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNode): Deleted.
(WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNodeInternal): Deleted.
(WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::DisableAssertionsInScope): Deleted.
(WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::~DisableAssertionsInScope): Deleted.
* dom/ScriptElement.cpp:
(WebCore::ScriptElement::executeClassicScript):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension):
(WebCore::ScriptExecutionContext::suspendActiveDOMObjects):
(WebCore::ScriptExecutionContext::resumeActiveDOMObjects):
(WebCore::ScriptExecutionContext::stopActiveDOMObjects):
* history/CachedPage.cpp:
(WebCore::CachedPage::restore):
* history/PageCache.cpp:
(WebCore::PageCache::addIfCacheable):
* html/HTMLElement.cpp:
(WebCore::textToFragment):
(WebCore::HTMLElement::setInnerText):
* html/HTMLMediaElement.cpp:
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::setInnerTextValue):
* html/track/VTTCue.cpp:
(WebCore::VTTCue::createCueRenderingTree):
(WebCore::VTTCue::updateDisplayTree):
(WebCore::VTTCue::removeDisplayTree):
* loader/FormSubmission.cpp:
* loader/cache/CachedSVGFont.cpp:
(WebCore::CachedSVGFont::ensureCustomFontData):
* page/LayoutContext.cpp:
(WebCore::LayoutContext::layout):
* rendering/RenderFrameBase.cpp:
(WebCore::RenderFrameBase::performLayoutWithFlattening):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::scrollRectToVisible):
* svg/SVGTRefElement.cpp:
(WebCore::SVGTRefElement::updateReferencedText):
* svg/SVGUseElement.cpp:
(WebCore::SVGUseElement::clearShadowTree):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::draw):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@226251 268f45cc-cd09-0410-ab3c-d52691b4dbfc

28 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/ScriptController.cpp
Source/WebCore/dom/ContainerNode.cpp
Source/WebCore/dom/ContainerNodeAlgorithms.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Element.cpp
Source/WebCore/dom/ElementIteratorAssertions.h
Source/WebCore/dom/EventDispatcher.cpp
Source/WebCore/dom/EventTarget.cpp
Source/WebCore/dom/Node.cpp
Source/WebCore/dom/ScriptDisallowedScope.h [moved from Source/WebCore/dom/NoEventDispatchAssertion.h with 90% similarity]
Source/WebCore/dom/ScriptElement.cpp
Source/WebCore/dom/ScriptExecutionContext.cpp
Source/WebCore/history/CachedPage.cpp
Source/WebCore/history/PageCache.cpp
Source/WebCore/html/HTMLElement.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLTextFormControlElement.cpp
Source/WebCore/html/track/VTTCue.cpp
Source/WebCore/loader/FormSubmission.cpp
Source/WebCore/loader/cache/CachedSVGFont.cpp
Source/WebCore/page/LayoutContext.cpp
Source/WebCore/rendering/RenderFrameBase.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/svg/SVGTRefElement.cpp
Source/WebCore/svg/SVGUseElement.cpp
Source/WebCore/svg/graphics/SVGImage.cpp

index 89e2acd..f20fa7f 100644 (file)
@@ -1,3 +1,109 @@
+2017-12-21  Ryosuke Niwa  <rniwa@webkit.org>
+
+        Rename NoEventDispatchAssertion to ScriptDisallowedScope
+        https://bugs.webkit.org/show_bug.cgi?id=181102
+
+        Reviewed by Zalan Bujtas.
+
+        Renamed the class.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/ScriptController.cpp:
+        (WebCore::ScriptController::canExecuteScripts):
+        * dom/ContainerNode.cpp:
+        (WebCore::ContainerNode::removeAllChildrenWithScriptAssertion):
+        (WebCore::ContainerNode::removeNodeWithScriptAssertion):
+        (WebCore::executeNodeInsertionWithScriptAssertion):
+        (WebCore::ContainerNode::removeDetachedChildren):
+        (WebCore::ContainerNode::insertBeforeCommon):
+        (WebCore::ContainerNode::appendChildCommon):
+        (WebCore::ContainerNode::removeBetween):
+        (WebCore::dispatchChildInsertionEvents):
+        (WebCore::dispatchChildRemovalEvents):
+        * dom/ContainerNodeAlgorithms.cpp:
+        (WebCore::notifyChildNodeInserted):
+        (WebCore::notifyChildNodeRemoved):
+        * dom/Document.cpp:
+        (WebCore::Document::resolveStyle):
+        (WebCore::isSafeToUpdateStyleOrLayout):
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::nodeChildrenWillBeRemoved):
+        (WebCore::Document::nodeWillBeRemoved):
+        (WebCore::Document::dispatchWindowEvent):
+        (WebCore::Document::dispatchWindowLoadEvent):
+        (WebCore::Document::applyPendingXSLTransformsTimerFired):
+        * dom/Element.cpp:
+        (WebCore::Element::addShadowRoot):
+        (WebCore::Element::attachAttributeNodeIfNeeded):
+        (WebCore::Element::setAttributeNode):
+        (WebCore::Element::setAttributeNodeNS):
+        (WebCore::Element::dispatchFocusInEvent):
+        (WebCore::Element::dispatchFocusOutEvent):
+        * dom/ElementIteratorAssertions.h:
+        (WebCore::ElementIteratorAssertions::ElementIteratorAssertions):
+        * dom/EventDispatcher.cpp:
+        (WebCore::EventDispatcher::dispatchEvent):
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::fireEventListeners):
+        * dom/NoEventDispatchAssertion.h: Removed.
+        * dom/Node.cpp:
+        (WebCore::Node::dispatchSubtreeModifiedEvent):
+        (WebCore::Node::dispatchDOMActivateEvent):
+        * dom/ScriptDisallowedScope.h: Copied from Source/WebCore/dom/NoEventDispatchAssertion.h.
+        (WebCore::ScriptDisallowedScope::ScriptDisallowedScope):
+        (WebCore::ScriptDisallowedScope::~ScriptDisallowedScope):
+        (WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
+        (WebCore::ScriptDisallowedScope::InMainThread::isScriptAllowed):
+        (WebCore::NoEventDispatchAssertion::NoEventDispatchAssertion): Deleted.
+        (WebCore::NoEventDispatchAssertion::~NoEventDispatchAssertion): Deleted.
+        (WebCore::NoEventDispatchAssertion::isEventAllowedInMainThread): Deleted.
+        (WebCore::NoEventDispatchAssertion::InMainThread::InMainThread): Deleted.
+        (WebCore::NoEventDispatchAssertion::InMainThread::~InMainThread): Deleted.
+        (WebCore::NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree): Deleted.
+        (WebCore::NoEventDispatchAssertion::InMainThread::isEventAllowed): Deleted.
+        (WebCore::NoEventDispatchAssertion::EventAllowedScope::EventAllowedScope): Deleted.
+        (WebCore::NoEventDispatchAssertion::EventAllowedScope::~EventAllowedScope): Deleted.
+        (WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNode): Deleted.
+        (WebCore::NoEventDispatchAssertion::EventAllowedScope::isAllowedNodeInternal): Deleted.
+        (WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::DisableAssertionsInScope): Deleted.
+        (WebCore::NoEventDispatchAssertion::DisableAssertionsInScope::~DisableAssertionsInScope): Deleted.
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElement::executeClassicScript):
+        * dom/ScriptExecutionContext.cpp:
+        (WebCore::ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension):
+        (WebCore::ScriptExecutionContext::suspendActiveDOMObjects):
+        (WebCore::ScriptExecutionContext::resumeActiveDOMObjects):
+        (WebCore::ScriptExecutionContext::stopActiveDOMObjects):
+        * history/CachedPage.cpp:
+        (WebCore::CachedPage::restore):
+        * history/PageCache.cpp:
+        (WebCore::PageCache::addIfCacheable):
+        * html/HTMLElement.cpp:
+        (WebCore::textToFragment):
+        (WebCore::HTMLElement::setInnerText):
+        * html/HTMLMediaElement.cpp:
+        * html/HTMLTextFormControlElement.cpp:
+        (WebCore::HTMLTextFormControlElement::setInnerTextValue):
+        * html/track/VTTCue.cpp:
+        (WebCore::VTTCue::createCueRenderingTree):
+        (WebCore::VTTCue::updateDisplayTree):
+        (WebCore::VTTCue::removeDisplayTree):
+        * loader/FormSubmission.cpp:
+        * loader/cache/CachedSVGFont.cpp:
+        (WebCore::CachedSVGFont::ensureCustomFontData):
+        * page/LayoutContext.cpp:
+        (WebCore::LayoutContext::layout):
+        * rendering/RenderFrameBase.cpp:
+        (WebCore::RenderFrameBase::performLayoutWithFlattening):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::scrollRectToVisible):
+        * svg/SVGTRefElement.cpp:
+        (WebCore::SVGTRefElement::updateReferencedText):
+        * svg/SVGUseElement.cpp:
+        (WebCore::SVGUseElement::clearShadowTree):
+        * svg/graphics/SVGImage.cpp:
+        (WebCore::SVGImage::draw):
+
 2017-12-21  Maciej Stachowiak  <mjs@apple.com>
 
         Update Service Workers status to Supported in Preview
index fd6db00..d6ab5f9 100644 (file)
                E462A4A1113E71BE004A4220 /* IntPointHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E462A4A0113E71BE004A4220 /* IntPointHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E46A2B1E17CA76B1000DBCD8 /* ElementChildIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               E46B41F91CB24E70008F11DE /* NoEventDispatchAssertion.h in Headers */ = {isa = PBXBuildFile; fileRef = E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               E46B41F91CB24E70008F11DE /* ScriptDisallowedScope.h in Headers */ = {isa = PBXBuildFile; fileRef = E46B41F81CB24E70008F11DE /* ScriptDisallowedScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E46C794B1F13E82B00F371E1 /* StyleInvalidationFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = E4A1822F1F13BE5800FEF698 /* StyleInvalidationFunctions.h */; };
                E47127CB163438AE00ED6F5A /* StyleInvalidator.h in Headers */ = {isa = PBXBuildFile; fileRef = E47A97CF163059FC005DCD99 /* StyleInvalidator.h */; };
                E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = E4778B7E115A581A00B5D372 /* JSCustomEvent.h */; };
                E462A4A0113E71BE004A4220 /* IntPointHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntPointHash.h; sourceTree = "<group>"; };
                E46A2B1B17CA65B9000DBCD8 /* TypedElementDescendantIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypedElementDescendantIterator.h; sourceTree = "<group>"; };
                E46A2B1D17CA76B1000DBCD8 /* ElementChildIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ElementChildIterator.h; sourceTree = "<group>"; };
-               E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NoEventDispatchAssertion.h; sourceTree = "<group>"; };
+               E46B41F81CB24E70008F11DE /* ScriptDisallowedScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptDisallowedScope.h; sourceTree = "<group>"; };
                E4778B7D115A581A00B5D372 /* JSCustomEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCustomEvent.cpp; sourceTree = "<group>"; };
                E4778B7E115A581A00B5D372 /* JSCustomEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCustomEvent.h; sourceTree = "<group>"; };
                E47A3AC21C5EABBE00CCBFA7 /* StyleSharingResolver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleSharingResolver.cpp; sourceTree = "<group>"; };
                                E43105B716750F0C00DB2FB8 /* NodeTraversal.cpp */,
                                E43105BA16750F1600DB2FB8 /* NodeTraversal.h */,
                                9382AAB10D8C386100F357A6 /* NodeWithIndex.h */,
-                               E46B41F81CB24E70008F11DE /* NoEventDispatchAssertion.h */,
                                8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */,
                                7C6752BA1B06E82000C279CB /* NonElementParentNode.idl */,
                                1A0D57340A5C77FE007EDD4C /* OverflowEvent.cpp */,
                                A84D82BF11D3474800972990 /* ScriptableDocumentParser.h */,
                                4998AECF13FB224D0090B1AA /* ScriptedAnimationController.cpp */,
                                4998AED013FB224D0090B1AA /* ScriptedAnimationController.h */,
+                               E46B41F81CB24E70008F11DE /* ScriptDisallowedScope.h */,
                                08A484750E5272C500C3FE76 /* ScriptElement.cpp */,
                                08A484760E5272C500C3FE76 /* ScriptElement.h */,
                                E3E4E2A51E3B16FC0023BB8A /* ScriptElementCachedScriptFetcher.cpp */,
                                63D7B32D0E78CD3F00F7617C /* NodeRenderStyle.h in Headers */,
                                E43105BB16750F1600DB2FB8 /* NodeTraversal.h in Headers */,
                                9382AAB40D8C386100F357A6 /* NodeWithIndex.h in Headers */,
-                               E46B41F91CB24E70008F11DE /* NoEventDispatchAssertion.h in Headers */,
+                               E46B41F91CB24E70008F11DE /* ScriptDisallowedScope.h in Headers */,
                                312C0C41146DC6CC0016C911 /* Notification.h in Headers */,
                                33503C9A10179A74003B47E1 /* NotificationClient.h in Headers */,
                                3128CA6B147331630074C72A /* NotificationController.h in Headers */,
index c6ea0c5..e12957e 100644 (file)
 #include "ModuleFetchFailureKind.h"
 #include "ModuleFetchParameters.h"
 #include "NP_jsobject.h"
-#include "NoEventDispatchAssertion.h"
 #include "Page.h"
 #include "PageConsoleClient.h"
 #include "PageGroup.h"
 #include "PluginViewBase.h"
 #include "RuntimeApplicationChecks.h"
+#include "ScriptDisallowedScope.h"
 #include "ScriptSourceCode.h"
 #include "ScriptableDocumentParser.h"
 #include "Settings.h"
@@ -669,7 +669,7 @@ JSValue ScriptController::executeScriptInWorld(DOMWrapperWorld& world, const Str
 bool ScriptController::canExecuteScripts(ReasonForCallingCanExecuteScripts reason)
 {
     if (reason == AboutToExecuteScript)
-        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed() || !isInWebProcess());
+        RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
 
     if (m_frame.document() && m_frame.document()->isSandboxed(SandboxScripts)) {
         // FIXME: This message should be moved off the console once a solution to https://bugs.webkit.org/show_bug.cgi?id=103274 exists.
index 622dfe3..c4827ff 100644 (file)
@@ -44,7 +44,6 @@
 #include "LabelsNodeList.h"
 #include "MutationEvent.h"
 #include "NameNodeList.h"
-#include "NoEventDispatchAssertion.h"
 #include "NodeRareData.h"
 #include "NodeRenderStyle.h"
 #include "RadioNodeList.h"
@@ -58,6 +57,7 @@
 #include "SVGElement.h"
 #include "SVGNames.h"
 #include "SVGUseElement.h"
+#include "ScriptDisallowedScope.h"
 #include "SelectorQuery.h"
 #include "TemplateContentDocumentFragment.h"
 #include <algorithm>
@@ -70,9 +70,9 @@ static void dispatchChildRemovalEvents(Ref<Node>&);
 
 ChildNodesLazySnapshot* ChildNodesLazySnapshot::latestSnapshot;
 
-unsigned NoEventDispatchAssertion::s_count = 0;
+unsigned ScriptDisallowedScope::s_count = 0;
 #if !ASSERT_DISABLED
-NoEventDispatchAssertion::EventAllowedScope* NoEventDispatchAssertion::EventAllowedScope::s_currentScope = nullptr;
+ScriptDisallowedScope::EventAllowedScope* ScriptDisallowedScope::EventAllowedScope::s_currentScope = nullptr;
 #endif
 
 ALWAYS_INLINE NodeVector ContainerNode::removeAllChildrenWithScriptAssertion(ChildChangeSource source, DeferChildrenChanged deferChildrenChanged)
@@ -88,7 +88,7 @@ ALWAYS_INLINE NodeVector ContainerNode::removeAllChildrenWithScriptAssertion(Chi
         }
     } else {
         ASSERT(source == ContainerNode::ChildChangeSource::Parser);
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         if (UNLIKELY(document().hasMutationObserversOfType(MutationObserver::ChildList))) {
             ChildListMutationScope mutation(*this);
             for (auto& child : children)
@@ -99,7 +99,7 @@ ALWAYS_INLINE NodeVector ContainerNode::removeAllChildrenWithScriptAssertion(Chi
     disconnectSubframesIfNeeded(*this, DescendantsOnly);
 
     WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     document().nodeChildrenWillBeRemoved(*this);
 
@@ -119,11 +119,11 @@ ALWAYS_INLINE bool ContainerNode::removeNodeWithScriptAssertion(Node& childToRem
     Ref<Node> protectedChildToRemove(childToRemove);
     ASSERT_WITH_SECURITY_IMPLICATION(childToRemove.parentNode() == this);
     {
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         ChildListMutationScope(*this).willRemoveChild(childToRemove);
     }
 
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(childToRemove));
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(childToRemove));
     if (source == ContainerNode::ChildChangeSource::API) {
         childToRemove.notifyMutationObserversNodeWillDetach();
         dispatchChildRemovalEvents(protectedChildToRemove);
@@ -145,7 +145,7 @@ ALWAYS_INLINE bool ContainerNode::removeNodeWithScriptAssertion(Node& childToRem
     ChildChange change;
     {
         WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
         document().nodeWillBeRemoved(childToRemove);
 
@@ -163,7 +163,7 @@ ALWAYS_INLINE bool ContainerNode::removeNodeWithScriptAssertion(Node& childToRem
         change.source = source;
     }
 
-    // FIXME: Move childrenChanged into NoEventDispatchAssertion block.
+    // FIXME: Move childrenChanged into ScriptDisallowedScope block.
     childrenChanged(change);
 
     return true;
@@ -177,13 +177,13 @@ static ALWAYS_INLINE void executeNodeInsertionWithScriptAssertion(ContainerNode&
 {
     NodeVector postInsertionNotificationTargets;
     {
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         doNodeInsertion();
         ChildListMutationScope(containerNode).childAdded(child);
         postInsertionNotificationTargets = notifyChildNodeInserted(containerNode, child);
     }
 
-    // FIXME: Move childrenChanged into NoEventDispatchAssertion block.
+    // FIXME: Move childrenChanged into ScriptDisallowedScope block.
     if (replacedAllChildren == ReplacedAllChildren::Yes)
         containerNode.childrenChanged(ContainerNode::ChildChange { ContainerNode::AllChildrenReplaced, nullptr, nullptr, source });
     else {
@@ -195,7 +195,7 @@ static ALWAYS_INLINE void executeNodeInsertionWithScriptAssertion(ContainerNode&
         });
     }
 
-    ASSERT(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(child));
+    ASSERT(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(child));
     for (auto& target : postInsertionNotificationTargets)
         target->didFinishInsertingNode();
 
@@ -228,7 +228,7 @@ void ContainerNode::removeDetachedChildren()
             child->updateAncestorConnectedSubframeCountForRemoval();
     }
     // FIXME: We should be able to ASSERT(!attached()) here: https://bugs.webkit.org/show_bug.cgi?id=107801
-    NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
     removeDetachedChildrenInContainer(*this);
 }
 
@@ -403,7 +403,7 @@ ExceptionOr<void> ContainerNode::insertBefore(Node& newChild, Node* refChild)
 
 void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
 {
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle reparenting (and want DOM mutation events).
     ASSERT(!newChild.nextSibling());
@@ -428,7 +428,7 @@ void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
 
 void ContainerNode::appendChildCommon(Node& child)
 {
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     child.setParentNode(this);
 
@@ -567,7 +567,7 @@ void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& ol
 {
     InspectorInstrumentation::didRemoveDOMNode(oldChild.document(), oldChild);
 
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     ASSERT(oldChild.parentNode() == this);
 
@@ -766,7 +766,7 @@ static void dispatchChildInsertionEvents(Node& child)
     if (child.isInShadowTree())
         return;
 
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(child));
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(child));
 
     RefPtr<Node> c = &child;
     Ref<Document> document(child.document());
@@ -783,7 +783,7 @@ static void dispatchChildInsertionEvents(Node& child)
 
 static void dispatchChildRemovalEvents(Ref<Node>& child)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(child));
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(child));
     InspectorInstrumentation::willRemoveDOMNode(child->document(), child.get());
 
     if (child->isInShadowTree())
index 9180af2..fe8375a 100644 (file)
@@ -29,7 +29,7 @@
 #include "HTMLFrameOwnerElement.h"
 #include "HTMLTextAreaElement.h"
 #include "InspectorInstrumentation.h"
-#include "NoEventDispatchAssertion.h"
+#include "ScriptDisallowedScope.h"
 #include "ShadowRoot.h"
 #include "TypedElementDescendantIterator.h"
 
@@ -88,7 +88,7 @@ static void notifyNodeInsertedIntoTree(ContainerNode& parentOfInsertedTree, Node
 
 NodeVector notifyChildNodeInserted(ContainerNode& parentOfInsertedTree, Node& node)
 {
-    ASSERT(!NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT(!ScriptDisallowedScope::InMainThread::isScriptAllowed());
 
     InspectorInstrumentation::didInsertDOMNode(node.document(), node);
 
@@ -151,8 +151,8 @@ static void notifyNodeRemovedFromTree(ContainerNode& oldParentOfRemovedTree, Tre
 
 void notifyChildNodeRemoved(ContainerNode& oldParentOfRemovedTree, Node& child)
 {
-    // Assert that the caller of this function has an instance of NoEventDispatchAssertion.
-    ASSERT(!isMainThread() || !NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    // Assert that the caller of this function has an instance of ScriptDisallowedScope.
+    ASSERT(!isMainThread() || !ScriptDisallowedScope::InMainThread::isScriptAllowed());
     ContainerChildRemovalScope removalScope(oldParentOfRemovedTree, child);
 
     // Tree scope has changed if the container node from which "node" is removed is in a document or a shadow root.
index d4ebb07..a570f2c 100644 (file)
 #include "NavigationDisabler.h"
 #include "NavigationScheduler.h"
 #include "NestingLevelIncrementer.h"
-#include "NoEventDispatchAssertion.h"
+
 #include "NodeIterator.h"
 #include "NodeRareData.h"
 #include "NodeWithIndex.h"
 #include "SchemeRegistry.h"
 #include "ScopedEventQueue.h"
 #include "ScriptController.h"
+#include "ScriptDisallowedScope.h"
 #include "ScriptModuleLoader.h"
 #include "ScriptRunner.h"
 #include "ScriptSourceCode.h"
@@ -1806,7 +1807,7 @@ void Document::resolveStyle(ResolveStyleType type)
     // hits a null-dereference due to security code always assuming the document has a SecurityOrigin.
 
     {
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         styleScope().flushPendingUpdate();
         frameView.willRecalcStyle();
     }
@@ -1817,7 +1818,7 @@ void Document::resolveStyle(ResolveStyleType type)
     {
         Style::PostResolutionCallbackDisabler disabler(*this);
         WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates;
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
         m_inStyleRecalc = true;
 
@@ -1936,7 +1937,7 @@ bool Document::needsStyleRecalc() const
 
 inline bool static isSafeToUpdateStyleOrLayout(FrameView* frameView)
 {
-    bool isSafeToExecuteScript = NoEventDispatchAssertion::InMainThread::isEventAllowed();
+    bool isSafeToExecuteScript = ScriptDisallowedScope::InMainThread::isScriptAllowed();
     bool isInFrameFlattening = frameView && frameView->isInChildFrameWithFrameFlattening();
     return isSafeToExecuteScript || isInFrameFlattening || !isInWebProcess();
 }
@@ -1945,7 +1946,7 @@ bool Document::updateStyleIfNeeded()
 {
     RefPtr<FrameView> frameView = view();
     {
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         ASSERT(isMainThread());
         ASSERT(!frameView || !frameView->isPainting());
 
@@ -4121,7 +4122,7 @@ void Document::updateRangesAfterChildrenChanged(ContainerNode& container)
 
 void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
 {
-    ASSERT(!NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT(!ScriptDisallowedScope::InMainThread::isScriptAllowed());
 
     removeFocusedNodeOfSubtree(container, true /* amongChildrenOnly */);
     removeFocusNavigationNodeOfSubtree(container, true /* amongChildrenOnly */);
@@ -4154,7 +4155,7 @@ void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
 
 void Document::nodeWillBeRemoved(Node& node)
 {
-    ASSERT(!NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT(!ScriptDisallowedScope::InMainThread::isScriptAllowed());
 
     removeFocusedNodeOfSubtree(node);
     removeFocusNavigationNodeOfSubtree(node);
@@ -4298,7 +4299,7 @@ EventListener* Document::getWindowAttributeEventListener(const AtomicString& eve
 
 void Document::dispatchWindowEvent(Event& event, EventTarget* target)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     if (!m_domWindow)
         return;
     m_domWindow->dispatchEvent(event, target);
@@ -4306,7 +4307,7 @@ void Document::dispatchWindowEvent(Event& event, EventTarget* target)
 
 void Document::dispatchWindowLoadEvent()
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     if (!m_domWindow)
         return;
     m_domWindow->dispatchLoadEvent();
@@ -5141,7 +5142,7 @@ void Document::applyPendingXSLTransformsTimerFired()
         return;
 
     m_hasPendingXSLTransforms = false;
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     for (auto& processingInstruction : styleScope().collectXSLTransforms()) {
         ASSERT(processingInstruction->isXSL());
 
index 336f425..57ef69d 100644 (file)
@@ -75,7 +75,6 @@
 #include "MainFrame.h"
 #include "MutationObserverInterestGroup.h"
 #include "MutationRecord.h"
-#include "NoEventDispatchAssertion.h"
 #include "NodeRenderStyle.h"
 #include "PlatformWheelEvent.h"
 #include "PointerLockController.h"
@@ -91,6 +90,7 @@
 #include "SVGElement.h"
 #include "SVGNames.h"
 #include "SVGSVGElement.h"
+#include "ScriptDisallowedScope.h"
 #include "ScrollLatchingState.h"
 #include "SelectorQuery.h"
 #include "Settings.h"
@@ -1774,7 +1774,7 @@ void Element::addShadowRoot(Ref<ShadowRoot>&& newShadowRoot)
 
     ShadowRoot& shadowRoot = newShadowRoot;
     {
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         if (renderer())
             RenderTreeUpdater::tearDownRenderers(*this);
 
@@ -2149,7 +2149,7 @@ void Element::attachAttributeNodeIfNeeded(Attr& attrNode)
     if (attrNode.ownerElement() == this)
         return;
 
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     attrNode.attachToElement(*this);
     ensureAttrNodeListForElement(*this).append(&attrNode);
@@ -2167,7 +2167,7 @@ ExceptionOr<RefPtr<Attr>> Element::setAttributeNode(Attr& attrNode)
         return Exception { InUseAttributeError };
 
     {
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         synchronizeAllAttributes();
     }
 
@@ -2218,7 +2218,7 @@ ExceptionOr<RefPtr<Attr>> Element::setAttributeNodeNS(Attr& attrNode)
     auto attrNodeValue = attrNode.value();
     unsigned index = 0;
     {
-        NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         synchronizeAllAttributes();
         auto& elementData = ensureUniqueElementData();
 
@@ -2475,14 +2475,14 @@ void Element::blur()
 
 void Element::dispatchFocusInEvent(const AtomicString& eventType, RefPtr<Element>&& oldFocusedElement)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     ASSERT(eventType == eventNames().focusinEvent || eventType == eventNames().DOMFocusInEvent);
     dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, WTFMove(oldFocusedElement)));
 }
 
 void Element::dispatchFocusOutEvent(const AtomicString& eventType, RefPtr<Element>&& newFocusedElement)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     ASSERT(eventType == eventNames().focusoutEvent || eventType == eventNames().DOMFocusOutEvent);
     dispatchScopedEvent(FocusEvent::create(eventType, true, false, document().defaultView(), 0, WTFMove(newFocusedElement)));
 }
index 2d9df0b..393b351 100644 (file)
@@ -25,7 +25,7 @@
 
 #pragma once
 
-#include "NoEventDispatchAssertion.h"
+#include "ScriptDisallowedScope.h"
 
 namespace WebCore {
 
@@ -39,7 +39,7 @@ public:
 private:
     const Document* m_document;
     uint64_t m_initialDOMTreeVersion;
-    std::optional<NoEventDispatchAssertion> m_eventDispatchAssertion;
+    std::optional<ScriptDisallowedScope> m_eventDispatchAssertion;
 };
 
 // FIXME: No real point in doing these as inlines; they are for debugging and we usually turn off inlining in debug builds.
@@ -49,7 +49,7 @@ inline ElementIteratorAssertions::ElementIteratorAssertions(const Node* first)
     , m_initialDOMTreeVersion(first ? m_document->domTreeVersion() : 0)
 {
     if (first)
-        m_eventDispatchAssertion = NoEventDispatchAssertion();
+        m_eventDispatchAssertion = ScriptDisallowedScope();
 }
 
 inline bool ElementIteratorAssertions::domTreeHasMutated() const
index 1120a2c..40db9a9 100644 (file)
@@ -37,8 +37,8 @@
 #include "Logging.h"
 #include "MainFrame.h"
 #include "MouseEvent.h"
-#include "NoEventDispatchAssertion.h"
 #include "ScopedEventQueue.h"
+#include "ScriptDisallowedScope.h"
 #include "ShadowRoot.h"
 #include "TextEvent.h"
 #include "TouchEvent.h"
@@ -130,7 +130,7 @@ static bool shouldSuppressEventDispatchInDOM(Node& node, Event& event)
 
 void EventDispatcher::dispatchEvent(Node& node, Event& event)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(node));
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(node));
     
     LOG(Events, "EventDispatcher::dispatchEvent %s on node %s", event.type().string().utf8().data(), node.nodeName().utf8().data());
 
index 36b9eb3..6d9e58c 100644 (file)
@@ -37,8 +37,8 @@
 #include "HTMLBodyElement.h"
 #include "InspectorInstrumentation.h"
 #include "JSEventListener.h"
-#include "NoEventDispatchAssertion.h"
 #include "ScriptController.h"
+#include "ScriptDisallowedScope.h"
 #include "WebKitAnimationEvent.h"
 #include "WebKitTransitionEvent.h"
 #include <wtf/MainThread.h>
@@ -215,7 +215,7 @@ static const AtomicString& legacyType(const Event& event)
 
 void EventTarget::fireEventListeners(Event& event)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::isEventAllowedInMainThread());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::isEventAllowedInMainThread());
     ASSERT(event.isInitialized());
 
     auto* data = eventTargetData();
index e086c9f..48f3161 100644 (file)
@@ -52,7 +52,6 @@
 #include "KeyboardEvent.h"
 #include "Logging.h"
 #include "MutationEvent.h"
-#include "NoEventDispatchAssertion.h"
 #include "NodeRenderStyle.h"
 #include "ProcessingInstruction.h"
 #include "ProgressEvent.h"
@@ -62,6 +61,7 @@
 #include "RenderTextControl.h"
 #include "RenderView.h"
 #include "ScopedEventQueue.h"
+#include "ScriptDisallowedScope.h"
 #include "StorageEvent.h"
 #include "StyleResolver.h"
 #include "StyleSheetContents.h"
@@ -2335,7 +2335,7 @@ void Node::dispatchSubtreeModifiedEvent()
     if (isInShadowTree())
         return;
 
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventDispatchAllowedInSubtree(*this));
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(*this));
 
     if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER))
         return;
@@ -2348,7 +2348,7 @@ void Node::dispatchSubtreeModifiedEvent()
 
 void Node::dispatchDOMActivateEvent(Event& underlyingClickEvent)
 {
-    ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed());
+    ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed());
     int detail = is<UIEvent>(underlyingClickEvent) ? downcast<UIEvent>(underlyingClickEvent).detail() : 0;
     auto event = UIEvent::create(eventNames().DOMActivateEvent, true, true, document().defaultView(), detail);
     event->setUnderlyingEvent(&underlyingClickEvent);
similarity index 90%
rename from Source/WebCore/dom/NoEventDispatchAssertion.h
rename to Source/WebCore/dom/ScriptDisallowedScope.h
index 0429e83..c3fd578 100644 (file)
 
 namespace WebCore {
 
-class NoEventDispatchAssertion {
+class ScriptDisallowedScope {
 public:
-    // This variant is expensive. Use NoEventDispatchAssertion::InMainThread whenever possible.
-    NoEventDispatchAssertion()
+    // This variant is expensive. Use ScriptDisallowedScope::InMainThread whenever possible.
+    ScriptDisallowedScope()
     {
         if (!isMainThread())
             return;
         ++s_count;
     }
 
-    NoEventDispatchAssertion(const NoEventDispatchAssertion&)
-        : NoEventDispatchAssertion()
+    ScriptDisallowedScope(const ScriptDisallowedScope&)
+        : ScriptDisallowedScope()
     {
     }
 
-    ~NoEventDispatchAssertion()
+    ~ScriptDisallowedScope()
     {
         if (!isMainThread())
             return;
@@ -76,14 +76,14 @@ public:
         static bool isEventDispatchAllowedInSubtree(Node& node)
         {
 #if !ASSERT_DISABLED || ENABLE(SECURITY_ASSERTIONS)
-            return isEventAllowed() || EventAllowedScope::isAllowedNode(node);
+            return isScriptAllowed() || EventAllowedScope::isAllowedNode(node);
 #else
             UNUSED_PARAM(node);
             return true;
 #endif
         }
 
-        static bool isEventAllowed()
+        static bool isScriptAllowed()
         {
             ASSERT(isMainThread());
             return !s_count;
index b421815..b37ba4d 100644 (file)
 #include "LoadableClassicScript.h"
 #include "LoadableModuleScript.h"
 #include "MIMETypeRegistry.h"
-#include "NoEventDispatchAssertion.h"
 #include "PendingScript.h"
 #include "RuntimeApplicationChecks.h"
 #include "SVGScriptElement.h"
 #include "ScriptController.h"
+#include "ScriptDisallowedScope.h"
 #include "ScriptRunner.h"
 #include "ScriptSourceCode.h"
 #include "ScriptableDocumentParser.h"
@@ -362,7 +362,7 @@ bool ScriptElement::requestModuleScript(const TextPosition& scriptStartPosition)
 
 void ScriptElement::executeClassicScript(const ScriptSourceCode& sourceCode)
 {
-    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(NoEventDispatchAssertion::InMainThread::isEventAllowed() || !isInWebProcess());
+    RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(ScriptDisallowedScope::InMainThread::isScriptAllowed() || !isInWebProcess());
     ASSERT(m_alreadyStarted);
 
     if (sourceCode.isEmpty())
index 726f502..4a17155 100644 (file)
 #include "JSDOMWindow.h"
 #include "MessagePort.h"
 #include "Navigator.h"
-#include "NoEventDispatchAssertion.h"
 #include "PublicURLManager.h"
 #include "RejectedPromiseTracker.h"
 #include "ResourceRequest.h"
 #include "SWClientConnection.h"
 #include "SWContextManager.h"
 #include "SchemeRegistry.h"
+#include "ScriptDisallowedScope.h"
 #include "ScriptState.h"
 #include "ServiceWorker.h"
 #include "ServiceWorkerGlobalScope.h"
@@ -196,7 +196,7 @@ bool ScriptExecutionContext::canSuspendActiveDOMObjectsForDocumentSuspension(Vec
     // functions should not add new active DOM objects, nor execute arbitrary JavaScript.
     // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code
     // canSuspend functions so it will not happen!
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
     for (auto* activeDOMObject : m_activeDOMObjects) {
         if (!activeDOMObject->canSuspendForDocumentSuspension()) {
             canSuspend = false;
@@ -238,7 +238,7 @@ void ScriptExecutionContext::suspendActiveDOMObjects(ActiveDOMObject::ReasonForS
     // functions should not add new active DOM objects, nor execute arbitrary JavaScript.
     // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code
     // suspend functions so it will not happen!
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
     for (auto* activeDOMObject : m_activeDOMObjects)
         activeDOMObject->suspend(why);
 
@@ -267,7 +267,7 @@ void ScriptExecutionContext::resumeActiveDOMObjects(ActiveDOMObject::ReasonForSu
     // functions should not add new active DOM objects, nor execute arbitrary JavaScript.
     // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code
     // resume functions so it will not happen!
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
     for (auto* activeDOMObject : m_activeDOMObjects)
         activeDOMObject->resume();
 
@@ -294,7 +294,7 @@ void ScriptExecutionContext::stopActiveDOMObjects()
     // stop functions should not add new active DOM objects, nor execute arbitrary JavaScript.
     // An ASSERT_WITH_SECURITY_IMPLICATION or RELEASE_ASSERT will fire if this happens, but it's important to code stop functions
     // so it will not happen!
-    NoEventDispatchAssertion assertNoEventDispatch;
+    ScriptDisallowedScope scriptDisallowedScope;
     for (auto* activeDOMObject : possibleActiveDOMObjects) {
         // Check if this object was deleted already. If so, just skip it.
         // Calling contains on a possibly-already-deleted object is OK because we guarantee
index 20a9c4a..a07fdce 100644 (file)
 #include "HistoryController.h"
 #include "HistoryItem.h"
 #include "MainFrame.h"
-#include "NoEventDispatchAssertion.h"
 #include "Node.h"
 #include "Page.h"
 #include "PageTransitionEvent.h"
+#include "ScriptDisallowedScope.h"
 #include "Settings.h"
 #include "VisitedLinkState.h"
 #include <wtf/CurrentTime.h>
@@ -108,7 +108,7 @@ void CachedPage::restore(Page& page)
     {
         // Do not dispatch DOM events as their JavaScript listeners could cause the page to be put
         // into the page cache before we have finished restoring it from the page cache.
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
         m_cachedMainFrame->open();
     }
index 326f2e7..1cf8f31 100644 (file)
@@ -44,8 +44,8 @@
 #include "IgnoreOpensDuringUnloadCountIncrementer.h"
 #include "Logging.h"
 #include "MainFrame.h"
-#include "NoEventDispatchAssertion.h"
 #include "Page.h"
+#include "ScriptDisallowedScope.h"
 #include "Settings.h"
 #include "SubframeLoader.h"
 #include <wtf/MemoryPressureHandler.h>
@@ -423,7 +423,7 @@ void PageCache::addIfCacheable(HistoryItem& item, Page* page)
     setPageCacheState(*page, Document::InPageCache);
 
     // Make sure we no longer fire any JS events past this point.
-    NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+    ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
     item.m_cachedPage = std::make_unique<CachedPage>(*page);
     item.m_pruningReason = PruningReason::None;
index b1d5bb1..36985e9 100644 (file)
@@ -443,7 +443,7 @@ static Ref<DocumentFragment> textToFragment(Document& document, const String& te
     auto fragment = DocumentFragment::create(document);
 
     // It's safe to dispatch events on the new fragment since author scripts have no access to it yet.
-    NoEventDispatchAssertion::EventAllowedScope allowedScope(fragment);
+    ScriptDisallowedScope::EventAllowedScope allowedScope(fragment);
 
     for (unsigned start = 0, length = text.length(); start < length; ) {
         // Find next line break.
@@ -533,7 +533,7 @@ ExceptionOr<void> HTMLElement::setInnerText(const String& text)
     auto fragment = textToFragment(document(), text);
     // FIXME: This should use replaceAllChildren() once it accepts DocumentFragments as input.
     // It's safe to dispatch events on the new fragment since author scripts have no access to it yet.
-    NoEventDispatchAssertion::EventAllowedScope allowedScope(fragment.get());
+    ScriptDisallowedScope::EventAllowedScope allowedScope(fragment.get());
     return replaceChildrenWithFragment(*this, WTFMove(fragment));
 }
 
index bfcbe3e..c02aefe 100644 (file)
@@ -68,7 +68,6 @@
 #include "MediaQueryEvaluator.h"
 #include "MediaResourceLoader.h"
 #include "NetworkingContext.h"
-#include "NoEventDispatchAssertion.h"
 #include "Page.h"
 #include "PageGroup.h"
 #include "PlatformMediaSessionManager.h"
@@ -79,6 +78,7 @@
 #include "RenderView.h"
 #include "ResourceLoadInfo.h"
 #include "ScriptController.h"
+#include "ScriptDisallowedScope.h"
 #include "ScriptSourceCode.h"
 #include "SecurityOriginData.h"
 #include "SecurityPolicy.h"
index 8ade0c6..cd90629 100644 (file)
 #include "HTMLParserIdioms.h"
 #include "LayoutDisallowedScope.h"
 #include "Logging.h"
-#include "NoEventDispatchAssertion.h"
 #include "NodeTraversal.h"
 #include "Page.h"
 #include "RenderTextControlSingleLine.h"
 #include "RenderTheme.h"
+#include "ScriptDisallowedScope.h"
 #include "ShadowRoot.h"
 #include "Text.h"
 #include "TextControlInnerElements.h"
@@ -572,7 +572,7 @@ void HTMLTextFormControlElement::setInnerTextValue(const String& value)
 
         {
             // Events dispatched on the inner text element cannot execute arbitrary author scripts.
-            NoEventDispatchAssertion::EventAllowedScope allowedScope(*userAgentShadowRoot());
+            ScriptDisallowedScope::EventAllowedScope allowedScope(*userAgentShadowRoot());
 
             innerText->setInnerText(value);
 
index 044096e..2d9d730 100644 (file)
@@ -41,9 +41,9 @@
 #include "HTMLDivElement.h"
 #include "HTMLSpanElement.h"
 #include "Logging.h"
-#include "NoEventDispatchAssertion.h"
 #include "NodeTraversal.h"
 #include "RenderVTTCue.h"
+#include "ScriptDisallowedScope.h"
 #include "Text.h"
 #include "TextTrack.h"
 #include "TextTrackCueList.h"
@@ -530,7 +530,7 @@ RefPtr<DocumentFragment> VTTCue::createCueRenderingTree()
     auto clonedFragment = DocumentFragment::create(ownerDocument());
 
     // The cloned fragment is never exposed to author scripts so it's safe to dispatch events here.
-    NoEventDispatchAssertion::EventAllowedScope noEventDispatchAssertionDisabledForScope(clonedFragment);
+    ScriptDisallowedScope::EventAllowedScope allowedScope(clonedFragment);
 
     m_webVTTNodeTree->cloneChildNodes(clonedFragment);
     return WTFMove(clonedFragment);
@@ -788,7 +788,7 @@ void VTTCue::updateDisplayTree(const MediaTime& movieTime)
         return;
 
     // Mutating the VTT contents is safe because it's never exposed to author scripts.
-    NoEventDispatchAssertion::EventAllowedScope allowedScopeForCueHighlightBox(*m_cueHighlightBox);
+    ScriptDisallowedScope::EventAllowedScope allowedScopeForCueHighlightBox(*m_cueHighlightBox);
 
     // Clear the contents of the set.
     m_cueHighlightBox->removeChildren();
@@ -798,7 +798,7 @@ void VTTCue::updateDisplayTree(const MediaTime& movieTime)
     if (!referenceTree)
         return;
 
-    NoEventDispatchAssertion::EventAllowedScope allowedScopeForReferenceTree(*referenceTree);
+    ScriptDisallowedScope::EventAllowedScope allowedScopeForReferenceTree(*referenceTree);
 
     markFutureAndPastNodes(referenceTree.get(), startMediaTime(), movieTime);
     m_cueHighlightBox->appendChild(*referenceTree);
@@ -861,7 +861,7 @@ void VTTCue::removeDisplayTree()
         return;
 
     // The display tree is never exposed to author scripts so it's safe to dispatch events here.
-    NoEventDispatchAssertion::EventAllowedScope allowedScope(displayTreeInternal());
+    ScriptDisallowedScope::EventAllowedScope allowedScope(displayTreeInternal());
     displayTreeInternal().remove();
 }
 
index b312dd6..3aa6e56 100644 (file)
@@ -47,7 +47,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "HTMLParserIdioms.h"
-#include "NoEventDispatchAssertion.h"
+#include "ScriptDisallowedScope.h"
 #include "TextEncoding.h"
 #include <wtf/CurrentTime.h>
 
index a0ca86e..8f140d5 100644 (file)
 
 #include "FontDescription.h"
 #include "FontPlatformData.h"
-#include "NoEventDispatchAssertion.h"
 #include "SVGDocument.h"
 #include "SVGFontElement.h"
 #include "SVGFontFaceElement.h"
+#include "ScriptDisallowedScope.h"
 #include "SharedBuffer.h"
 #include "TextResourceDecoder.h"
 #include "TypedElementDescendantIterator.h"
@@ -75,7 +75,7 @@ bool CachedSVGFont::ensureCustomFontData(const AtomicString& remoteURI)
             m_externalSVGDocument = SVGDocument::create(nullptr, URL());
             auto decoder = TextResourceDecoder::create("application/xml");
 
-            NoEventDispatchAssertion::EventAllowedScope allowedScope(*m_externalSVGDocument);
+            ScriptDisallowedScope::EventAllowedScope allowedScope(*m_externalSVGDocument);
 
             m_externalSVGDocument->setContent(decoder->decodeAndFlush(m_data->data(), m_data->size()));
             sawError = decoder->sawError();
index 6dedeef..5de7d06 100644 (file)
@@ -33,9 +33,9 @@
 #include "InspectorInstrumentation.h"
 #include "LayoutState.h"
 #include "Logging.h"
-#include "NoEventDispatchAssertion.h"
 #include "RenderElement.h"
 #include "RenderView.h"
+#include "ScriptDisallowedScope.h"
 #include "Settings.h"
 
 #include <wtf/SetForScope.h>
@@ -175,7 +175,7 @@ void LayoutContext::layout()
     }
     {
         SetForScope<LayoutPhase> layoutPhase(m_layoutPhase, LayoutPhase::InRenderTreeLayout);
-        NoEventDispatchAssertion::InMainThread noEventDispatchAssertion;
+        ScriptDisallowedScope::InMainThread scriptDisallowedScope;
         SubtreeLayoutStateMaintainer subtreeLayoutStateMaintainer(subtreeLayoutRoot());
         RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
 #ifndef NDEBUG
index 525c736..b095d8e 100644 (file)
@@ -29,8 +29,8 @@
 #include "Frame.h"
 #include "FrameView.h"
 #include "HTMLFrameElementBase.h"
-#include "NoEventDispatchAssertion.h"
 #include "RenderView.h"
+#include "ScriptDisallowedScope.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
@@ -75,7 +75,7 @@ RenderView* RenderFrameBase::childRenderView() const
 void RenderFrameBase::performLayoutWithFlattening(bool hasFixedWidth, bool hasFixedHeight)
 {
     // FIXME: Refactor frame flattening code so that we don't need to disable assertions here.
-    NoEventDispatchAssertion::DisableAssertionsInScope scope;
+    ScriptDisallowedScope::DisableAssertionsInScope scope;
     if (!childRenderView())
         return;
 
index a7e42c3..25e13b4 100644 (file)
@@ -82,7 +82,6 @@
 #include "HitTestingTransformState.h"
 #include "Logging.h"
 #include "MainFrame.h"
-#include "NoEventDispatchAssertion.h"
 #include "OverflowEvent.h"
 #include "OverlapTestRequestClient.h"
 #include "Page.h"
 #include "RenderView.h"
 #include "SVGNames.h"
 #include "ScaleTransformOperation.h"
+#include "ScriptDisallowedScope.h"
 #include "ScrollAnimator.h"
 #include "Scrollbar.h"
 #include "ScrollbarTheme.h"
@@ -2587,7 +2587,7 @@ void RenderLayer::scrollRectToVisible(SelectionRevealMode revealMode, const Layo
 
             if (frameElementAndViewPermitScroll(frameElementBase, frameView)) {
                 // If this assertion fires we need to protect the ownerElement from being destroyed.
-                NoEventDispatchAssertion::InMainThread assertNoEventDispatch;
+                ScriptDisallowedScope::InMainThread scriptDisallowedScope;
 
                 LayoutRect viewRect = frameView.visibleContentRect(LegacyIOSDocumentVisibleRect);
                 LayoutRect exposeRect = getRectToExpose(viewRect, absoluteRect, insideFixed, alignX, alignY);
index 9f8312e..16fb9a1 100644 (file)
@@ -25,7 +25,6 @@
 #include "EventListener.h"
 #include "EventNames.h"
 #include "MutationEvent.h"
-#include "NoEventDispatchAssertion.h"
 #include "RenderSVGInline.h"
 #include "RenderSVGInlineText.h"
 #include "RenderSVGResource.h"
@@ -33,6 +32,7 @@
 #include "SVGDocument.h"
 #include "SVGDocumentExtensions.h"
 #include "SVGNames.h"
+#include "ScriptDisallowedScope.h"
 #include "StyleInheritedData.h"
 #include "Text.h"
 #include "XLinkNames.h"
@@ -146,7 +146,7 @@ void SVGTRefElement::updateReferencedText(Element* target)
 
     auto root = userAgentShadowRoot();
     ASSERT(root);
-    NoEventDispatchAssertion::EventAllowedScope allowedScope(*root);
+    ScriptDisallowedScope::EventAllowedScope allowedScope(*root);
     if (!root->firstChild())
         root->appendChild(Text::create(document(), textContent));
     else {
index 8ec87ea..0cea883 100644 (file)
 #include "ElementIterator.h"
 #include "Event.h"
 #include "EventNames.h"
-#include "NoEventDispatchAssertion.h"
 #include "RenderSVGResource.h"
 #include "RenderSVGTransformableContainer.h"
 #include "SVGDocumentExtensions.h"
 #include "SVGGElement.h"
 #include "SVGSVGElement.h"
 #include "SVGSymbolElement.h"
+#include "ScriptDisallowedScope.h"
 #include "ShadowRoot.h"
 #include "XLinkNames.h"
 
@@ -219,7 +219,7 @@ void SVGUseElement::clearShadowTree()
 {
     if (auto root = userAgentShadowRoot()) {
         // Safe because SVG use element's shadow tree is never used to fire synchronous events during layout or DOM mutations.
-        NoEventDispatchAssertion::EventAllowedScope scope(*root);
+        ScriptDisallowedScope::EventAllowedScope scope(*root);
         root->removeChildren();
     }
 }
index a481005..3d1162d 100644 (file)
@@ -43,7 +43,6 @@
 #include "JSDOMWindowBase.h"
 #include "LibWebRTCProvider.h"
 #include "MainFrame.h"
-#include "NoEventDispatchAssertion.h"
 #include "Page.h"
 #include "PageConfiguration.h"
 #include "RenderSVGRoot.h"
@@ -54,6 +53,7 @@
 #include "SVGImageClients.h"
 #include "SVGImageElement.h"
 #include "SVGSVGElement.h"
+#include "ScriptDisallowedScope.h"
 #include "Settings.h"
 #include "SocketProvider.h"
 #include <runtime/JSCInlines.h>
@@ -312,7 +312,7 @@ ImageDrawResult SVGImage::draw(GraphicsContext& context, const FloatRect& dstRec
     view->resize(containerSize());
 
     {
-        NoEventDispatchAssertion::DisableAssertionsInScope disabledScope;
+        ScriptDisallowedScope::DisableAssertionsInScope disabledScope;
         if (view->needsLayout())
             view->layoutContext().layout();
     }