Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(643)

Unified Diff: Source/core/dom/EventTarget.cpp

Issue 22564003: Refactoring: Get rid of isDocument() check in EventTarget. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Applied the rename. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/EventTarget.h ('k') | Source/core/dom/ScriptExecutionContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/EventTarget.cpp
diff --git a/Source/core/dom/EventTarget.cpp b/Source/core/dom/EventTarget.cpp
index 233fd701603c29d73a41f6330a47ea94537e1114..db4032152b38c8c78206f0b42599858ce018126c 100644
--- a/Source/core/dom/EventTarget.cpp
+++ b/Source/core/dom/EventTarget.cpp
@@ -68,6 +68,13 @@ DOMWindow* EventTarget::toDOMWindow()
return 0;
}
+inline DOMWindow* EventTarget::executingWindow()
+{
+ if (ScriptExecutionContext* context = scriptExecutionContext())
+ return context->executingWindow();
+ return 0;
+}
+
bool EventTarget::addEventListener(const AtomicString& eventType, PassRefPtr<EventListener> listener, bool useCapture)
{
EventTargetData* d = ensureEventTargetData();
@@ -203,17 +210,14 @@ bool EventTarget::fireEventListeners(Event* event)
}
if (!prefixedTypeName.isEmpty()) {
- ScriptExecutionContext* context = scriptExecutionContext();
- if (context && context->isDocument()) {
- Document* document = toDocument(context);
- if (document->domWindow()) {
- if (listenerPrefixedVector)
- if (listenerUnprefixedVector)
- UseCounter::count(document->domWindow(), UseCounter::PrefixedAndUnprefixedTransitionEndEvent);
- else
- UseCounter::count(document->domWindow(), UseCounter::PrefixedTransitionEndEvent);
- else if (listenerUnprefixedVector)
- UseCounter::count(document->domWindow(), UseCounter::UnprefixedTransitionEndEvent);
+ if (DOMWindow* executingWindow = this->executingWindow()) {
+ if (listenerPrefixedVector) {
+ if (listenerUnprefixedVector)
+ UseCounter::count(executingWindow, UseCounter::PrefixedAndUnprefixedTransitionEndEvent);
+ else
+ UseCounter::count(executingWindow, UseCounter::PrefixedTransitionEndEvent);
+ } else if (listenerUnprefixedVector) {
+ UseCounter::count(executingWindow, UseCounter::UnprefixedTransitionEndEvent);
}
}
}
@@ -231,12 +235,10 @@ void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
// index |size|, so iterating up to (but not including) |size| naturally excludes
// new event listeners.
- ScriptExecutionContext* context = scriptExecutionContext();
- if (context && context->isDocument() && event->type() == eventNames().beforeunloadEvent) {
- Document* document = toDocument(context);
- if (DOMWindow* domWindow = document->domWindow()) {
- if (domWindow != domWindow->top())
- UseCounter::count(domWindow, UseCounter::SubFrameBeforeUnloadFired);
+ if (event->type() == eventNames().beforeunloadEvent) {
+ if (DOMWindow* executingWindow = this->executingWindow()) {
+ if (executingWindow->top())
+ UseCounter::count(executingWindow, UseCounter::SubFrameBeforeUnloadFired);
}
}
@@ -269,11 +271,8 @@ void EventTarget::fireEventListeners(Event* event, EventTargetData* d, EventList
}
d->firingEventIterators->removeLast();
if (userEventWasHandled) {
- ScriptExecutionContext* context = scriptExecutionContext();
- if (context && context->isDocument()) {
- Document* document = toDocument(context);
- document->resetLastHandledUserGestureTimestamp();
- }
+ if (ScriptExecutionContext* context = scriptExecutionContext())
+ context->userEventWasHandled();
}
}
« no previous file with comments | « Source/core/dom/EventTarget.h ('k') | Source/core/dom/ScriptExecutionContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698