Commit 807e2360 authored by haraken@chromium.org's avatar haraken@chromium.org

Rename NoEventDispatchAssertion to EventDispatchForbiddenScope and move it to platform/

This is for consistency with ScriptForbiddenScope,
which is often used with EventDispatchForbiddenScope.

Review URL: https://codereview.chromium.org/446063007

git-svn-id: svn://svn.chromium.org/blink/trunk@180236 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b9313b4c
......@@ -41,12 +41,12 @@
#include "bindings/core/v8/V8Window.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/frame/ConsoleTypes.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/csp/ContentSecurityPolicy.h"
#include "core/inspector/ScriptCallStack.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/TraceEvent.h"
#include "public/platform/Platform.h"
#include "wtf/RefPtr.h"
......@@ -133,13 +133,13 @@ static void messageHandlerInMainThread(v8::Handle<v8::Message> message, v8::Hand
}
if (scriptState->world().isPrivateScriptIsolatedWorld()) {
// We allow a private script to dispatch error events even in a NoEventDispatchAssertion scope.
// We allow a private script to dispatch error events even in a EventDispatchForbiddenScope scope.
// Without having this ability, it's hard to debug the private script because syntax errors
// in the private script are not reported to console (the private script just crashes silently).
// Allowing error events in private scripts is safe because error events don't propagate to
// other isolated worlds (which means that the error events won't fire any event listeners
// in user's scripts).
NoEventDispatchAssertion::AllowUserAgentEvents allowUserAgentEvents;
EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;
enteredWindow->document()->reportException(event.release(), callStack, corsStatus);
} else {
enteredWindow->document()->reportException(event.release(), callStack, corsStatus);
......
......@@ -31,7 +31,6 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/FullscreenElementStack.h"
#include "core/dom/NameNodeList.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeChildRemovalTracker.h"
#include "core/dom/NodeRareData.h"
#include "core/dom/NodeRenderStyle.h"
......@@ -51,6 +50,7 @@
#include "core/rendering/RenderText.h"
#include "core/rendering/RenderTheme.h"
#include "core/rendering/RenderView.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/ScriptForbiddenScope.h"
namespace blink {
......@@ -61,7 +61,7 @@ static void dispatchChildInsertionEvents(Node&);
static void dispatchChildRemovalEvents(Node&);
#if ENABLE(ASSERT)
unsigned NoEventDispatchAssertion::s_count = 0;
unsigned EventDispatchForbiddenScope::s_count = 0;
#endif
static void collectChildrenAndRemoveFromOldParent(Node& node, NodeVector& nodes, ExceptionState& exceptionState)
......@@ -256,7 +256,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::insertBefore(PassRefPtrWillBeRawPtr<
void ContainerNode::insertBeforeCommon(Node& nextChild, Node& newChild)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
ASSERT(!newChild.parentNode()); // Use insertBefore if you need to handle reparenting (and want DOM mutation events).
......@@ -402,7 +402,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::replaceChild(PassRefPtrWillBeRawPtr<
// Add child before "next".
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
if (next)
insertBeforeCommon(*next, child);
else
......@@ -577,7 +577,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::removeChild(PassRefPtrWillBeRawPtr<N
void ContainerNode::removeBetween(Node* previousChild, Node* nextChild, Node& oldChild)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ASSERT(oldChild.parentNode() == this);
......@@ -661,7 +661,7 @@ void ContainerNode::removeChildren()
HTMLFrameOwnerElement::UpdateSuspendScope suspendWidgetHierarchyUpdates;
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
removedChildren.reserveInitialCapacity(countChildren());
......@@ -731,7 +731,7 @@ PassRefPtrWillBeRawPtr<Node> ContainerNode::appendChild(PassRefPtrWillBeRawPtr<N
break;
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
treeScope().adoptIfNeeded(child);
......@@ -758,7 +758,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
document().adoptNode(newChild.get(), ASSERT_NO_EXCEPTION);
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
treeScope().adoptIfNeeded(*newChild);
......@@ -772,7 +772,7 @@ void ContainerNode::parserAppendChild(PassRefPtrWillBeRawPtr<Node> newChild)
void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
ASSERT(!root.isShadowRoot());
InspectorInstrumentation::didInsertDOMNode(&root);
......@@ -794,7 +794,7 @@ void ContainerNode::notifyNodeInserted(Node& root, ChildrenChangeSource source)
void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInsertionNotificationTargets)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
......@@ -812,7 +812,7 @@ void ContainerNode::notifyNodeInsertedInternal(Node& root, NodeVector& postInser
void ContainerNode::notifyNodeRemoved(Node& root)
{
ScriptForbiddenScope forbidScript;
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
Document& document = root.document();
for (Node* node = &root; node; node = NodeTraversal::next(*node, &root)) {
......@@ -1135,7 +1135,7 @@ static void dispatchChildInsertionEvents(Node& child)
if (child.isInShadowTree())
return;
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
RefPtrWillBeRawPtr<Node> c(child);
RefPtrWillBeRawPtr<Document> document(child.document());
......@@ -1157,7 +1157,7 @@ static void dispatchChildRemovalEvents(Node& child)
return;
}
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
InspectorInstrumentation::willRemoveDOMNode(&child);
......
......@@ -73,7 +73,6 @@
#include "core/dom/ExecutionContextTask.h"
#include "core/dom/MainThreadTaskRunner.h"
#include "core/dom/MutationObserver.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeChildRemovalTracker.h"
#include "core/dom/NodeFilter.h"
#include "core/dom/NodeIterator.h"
......@@ -183,6 +182,7 @@
#include "core/xml/XSLTProcessor.h"
#include "core/xml/parser/XMLDocumentParser.h"
#include "platform/DateComponents.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/Language.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/ScriptForbiddenScope.h"
......@@ -3756,7 +3756,7 @@ void Document::updateRangesAfterNodeMovedToAnotherDocument(const Node& node)
void Document::nodeChildrenWillBeRemoved(ContainerNode& container)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
if (!m_ranges.isEmpty()) {
AttachedRangeSet::const_iterator end = m_ranges.end();
for (AttachedRangeSet::const_iterator it = m_ranges.begin(); it != end; ++it)
......
......@@ -57,7 +57,6 @@
#include "core/dom/MutationObserverInterestGroup.h"
#include "core/dom/MutationRecord.h"
#include "core/dom/NamedNodeMap.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeRenderStyle.h"
#include "core/dom/PresentationAttributeStyle.h"
#include "core/dom/PseudoElement.h"
......@@ -105,6 +104,7 @@
#include "core/rendering/compositing/RenderLayerCompositor.h"
#include "core/svg/SVGDocumentExtensions.h"
#include "core/svg/SVGElement.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "platform/scroll/ScrollableArea.h"
......@@ -2175,14 +2175,14 @@ void Element::dispatchBlurEvent(Element* newFocusedElement)
void Element::dispatchFocusInEvent(const AtomicString& eventType, Element* oldFocusedElement)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
ASSERT(eventType == EventTypeNames::focusin || eventType == EventTypeNames::DOMFocusIn);
dispatchScopedEventDispatchMediator(FocusInEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document().domWindow(), 0, oldFocusedElement)));
}
void Element::dispatchFocusOutEvent(const AtomicString& eventType, Element* newFocusedElement)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
ASSERT(eventType == EventTypeNames::focusout || eventType == EventTypeNames::DOMFocusOut);
dispatchScopedEventDispatchMediator(FocusOutEventDispatchMediator::create(FocusEvent::create(eventType, true, false, document().domWindow(), 0, newFocusedElement)));
}
......
......@@ -45,7 +45,6 @@
#include "core/dom/ElementTraversal.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/LiveNodeList.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeRareData.h"
#include "core/dom/NodeRenderingTraversal.h"
#include "core/dom/NodeTraversal.h"
......@@ -87,6 +86,7 @@
#include "core/rendering/FlowThreadController.h"
#include "core/rendering/RenderBox.h"
#include "core/svg/graphics/SVGImage.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/Partitions.h"
#include "platform/TraceEvent.h"
#include "platform/TracedValue.h"
......@@ -2118,7 +2118,7 @@ void Node::dispatchSubtreeModifiedEvent()
if (isInShadowTree())
return;
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
if (!document().hasListenerType(Document::DOMSUBTREEMODIFIED_LISTENER))
return;
......@@ -2128,7 +2128,7 @@ void Node::dispatchSubtreeModifiedEvent()
bool Node::dispatchDOMActivateEvent(int detail, PassRefPtrWillBeRawPtr<Event> underlyingEvent)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
RefPtrWillBeRawPtr<UIEvent> event = UIEvent::create(EventTypeNames::DOMActivate, true, true, document().domWindow(), detail);
event->setUnderlyingEvent(underlyingEvent);
dispatchScopedEvent(event);
......
......@@ -29,12 +29,12 @@
#include "core/css/StyleSheetList.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/shadow/ContentDistribution.h"
#include "core/html/HTMLContentElement.h"
#include "core/html/HTMLShadowElement.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/ScriptForbiddenScope.h"
namespace blink {
......@@ -144,7 +144,7 @@ ElementShadow::~ElementShadow()
ShadowRoot& ElementShadow::addShadowRoot(Element& shadowHost, ShadowRoot::ShadowRootType type)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
ScriptForbiddenScope forbidScript;
if (type == ShadowRoot::AuthorShadowRoot && (!youngestShadowRoot() || youngestShadowRoot()->type() == ShadowRoot::UserAgentShadowRoot))
......
......@@ -28,8 +28,8 @@
#include "core/editing/UndoStack.h"
#include "core/dom/ContainerNode.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/editing/UndoStep.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "wtf/TemporaryChange.h"
namespace blink {
......@@ -68,7 +68,7 @@ void UndoStack::registerRedoStep(PassRefPtrWillBeRawPtr<UndoStep> step)
void UndoStack::didUnloadFrame(const LocalFrame& frame)
{
NoEventDispatchAssertion assertNoEventDispatch;
EventDispatchForbiddenScope assertNoEventDispatch;
filterOutUndoSteps(m_undoStack, frame);
filterOutUndoSteps(m_redoStack, frame);
}
......
......@@ -27,7 +27,6 @@
#include "core/events/EventDispatcher.h"
#include "core/dom/ContainerNode.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/events/EventDispatchMediator.h"
#include "core/events/MouseEvent.h"
#include "core/events/ScopedEventQueue.h"
......@@ -35,6 +34,7 @@
#include "core/frame/FrameView.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/TraceEvent.h"
#include "wtf/RefPtr.h"
......@@ -43,7 +43,7 @@ namespace blink {
bool EventDispatcher::dispatchEvent(Node* node, PassRefPtrWillBeRawPtr<EventDispatchMediator> mediator)
{
TRACE_EVENT0("blink", "EventDispatcher::dispatchEvent");
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
if (!mediator->event())
return true;
EventDispatcher dispatcher(node, mediator->event());
......@@ -114,7 +114,7 @@ bool EventDispatcher::dispatch()
#endif
m_event->setTarget(EventPath::eventTargetRespectingTargetRules(m_node.get()));
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
ASSERT(m_event->target());
WindowEventContext windowEventContext(m_event.get(), m_node.get(), topNodeEventContext());
TRACE_EVENT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "EventDispatch", "data", InspectorEventDispatchEvent::data(*m_event));
......
......@@ -35,12 +35,12 @@
#include "bindings/core/v8/ExceptionState.h"
#include "bindings/core/v8/V8DOMActivityLogger.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/editing/Editor.h"
#include "core/events/Event.h"
#include "core/inspector/InspectorInstrumentation.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/frame/UseCounter.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "wtf/StdLibExtras.h"
#include "wtf/Vector.h"
......@@ -258,7 +258,7 @@ void EventTarget::countLegacyEvents(const AtomicString& legacyTypeName, EventLis
bool EventTarget::fireEventListeners(Event* event)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
ASSERT(event && !event->type().isEmpty());
EventTargetData* d = eventTargetData();
......
......@@ -48,7 +48,6 @@
#include "core/dom/Element.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContext.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/RequestAnimationFrameCallback.h"
#include "core/editing/Editor.h"
#include "core/events/DOMWindowEventQueue.h"
......@@ -96,6 +95,7 @@
#include "core/storage/StorageArea.h"
#include "core/storage/StorageNamespace.h"
#include "core/timing/Performance.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/PlatformScreen.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
......@@ -447,7 +447,7 @@ void LocalDOMWindow::enqueueDocumentEvent(PassRefPtrWillBeRawPtr<Event> event)
void LocalDOMWindow::dispatchWindowLoadEvent()
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
dispatchLoadEvent();
}
......@@ -1591,7 +1591,7 @@ void LocalDOMWindow::dispatchLoadEvent()
bool LocalDOMWindow::dispatchEvent(PassRefPtrWillBeRawPtr<Event> prpEvent, PassRefPtrWillBeRawPtr<EventTarget> prpTarget)
{
ASSERT(!NoEventDispatchAssertion::isEventDispatchForbidden());
ASSERT(!EventDispatchForbiddenScope::isEventDispatchForbidden());
RefPtrWillBeRawPtr<EventTarget> protect(this);
RefPtrWillBeRawPtr<Event> event = prpEvent;
......
......@@ -30,7 +30,6 @@
#include "core/svg/graphics/SVGImage.h"
#include "core/animation/AnimationTimeline.h"
#include "core/dom/NoEventDispatchAssertion.h"
#include "core/dom/NodeTraversal.h"
#include "core/dom/shadow/ComposedTreeWalker.h"
#include "core/frame/FrameView.h"
......@@ -46,6 +45,7 @@
#include "core/svg/SVGSVGElement.h"
#include "core/svg/animation/SMILTimeContainer.h"
#include "core/svg/graphics/SVGImageChromeClient.h"
#include "platform/EventDispatchForbiddenScope.h"
#include "platform/LengthFunctions.h"
#include "platform/TraceEvent.h"
#include "platform/geometry/IntRect.h"
......@@ -384,7 +384,7 @@ bool SVGImage::dataChanged(bool allDataReceived)
// actually allow script to run so it's fine to call into it. We allow this
// since it means an SVG data url can synchronously load like other image
// types.
NoEventDispatchAssertion::AllowUserAgentEvents allowUserAgentEvents;
EventDispatchForbiddenScope::AllowUserAgentEvents allowUserAgentEvents;
static FrameLoaderClient* dummyFrameLoaderClient = new EmptyFrameLoaderClient;
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef NoEventDispatchAssertion_h
#define NoEventDispatchAssertion_h
#ifndef EventDispatchForbiddenScope_h
#define EventDispatchForbiddenScope_h
#include "wtf/MainThread.h"
#include "wtf/TemporaryChange.h"
......@@ -12,16 +12,16 @@ namespace blink {
#if ENABLE(ASSERT)
class NoEventDispatchAssertion {
class EventDispatchForbiddenScope {
public:
NoEventDispatchAssertion()
EventDispatchForbiddenScope()
{
if (!isMainThread())
return;
++s_count;
}
~NoEventDispatchAssertion()
~EventDispatchForbiddenScope()
{
if (!isMainThread())
return;
......@@ -57,9 +57,9 @@ private:
#else
class NoEventDispatchAssertion {
class EventDispatchForbiddenScope {
public:
NoEventDispatchAssertion() { }
EventDispatchForbiddenScope() { }
class AllowUserAgentEvents {
public:
......@@ -71,4 +71,4 @@ public:
} // namespace blink
#endif // NoEventDispatchAssertion_h
#endif // EventDispatchForbiddenScope_h
......@@ -38,6 +38,7 @@
'Decimal.h',
'DragImage.cpp',
'DragImage.h',
'EventDispatchForbiddenScope.h',
'EventTracer.cpp',
'EventTracer.h',
'FileChooser.cpp',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment