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

Unified Diff: Source/core/testing/Internals.cpp

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: One more unneeded include. Created 6 years, 8 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/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/testing/Internals.cpp
diff --git a/Source/core/testing/Internals.cpp b/Source/core/testing/Internals.cpp
index e9924031defc0d5b15614b1367dc9b26e53b37ff..b9309caa253bfc1a37acd8dfb9de0f446bd2e5c9 100644
--- a/Source/core/testing/Internals.cpp
+++ b/Source/core/testing/Internals.cpp
@@ -57,6 +57,7 @@
#include "core/dom/DocumentMarker.h"
#include "core/dom/DocumentMarkerController.h"
#include "core/dom/Element.h"
+#include "core/dom/EventHandlerRegistry.h"
#include "core/dom/ExceptionCode.h"
#include "core/dom/FullscreenElementStack.h"
#include "core/dom/NodeRenderStyle.h"
@@ -1278,6 +1279,18 @@ unsigned Internals::activeDOMObjectCount(Document* document, ExceptionState& exc
return document->activeDOMObjectCount();
}
+static unsigned eventHandlerCount(Document& document, EventHandlerRegistry::EventHandlerClass handlerClass)
+{
+ EventHandlerRegistry* registry = EventHandlerRegistry::from(document);
+ unsigned count = 0;
+ const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass);
+ if (targets) {
+ for (EventTargetSet::const_iterator iter = targets->begin(); iter != targets->end(); ++iter)
+ count += iter->value;
+ }
+ return count;
+}
+
unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& exceptionState)
{
if (!document) {
@@ -1288,6 +1301,16 @@ unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e
return WheelController::from(*document)->wheelEventHandlerCount();
}
+unsigned Internals::scrollEventHandlerCount(Document* document, ExceptionState& exceptionState)
+{
+ if (!document) {
+ exceptionState.throwDOMException(InvalidAccessError, "No context document is available.");
+ return 0;
+ }
+
+ return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent);
+}
+
unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& exceptionState)
{
if (!document) {
« no previous file with comments | « Source/core/testing/Internals.h ('k') | Source/core/testing/Internals.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698