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

Side by Side Diff: Source/core/testing/Internals.cpp

Issue 206603002: Add EventHandlerRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase harder. 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * Copyright (C) 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 #include "core/css/resolver/StyleResolver.h" 50 #include "core/css/resolver/StyleResolver.h"
51 #include "core/css/resolver/StyleResolverStats.h" 51 #include "core/css/resolver/StyleResolverStats.h"
52 #include "core/css/resolver/ViewportStyleResolver.h" 52 #include "core/css/resolver/ViewportStyleResolver.h"
53 #include "core/dom/ClientRect.h" 53 #include "core/dom/ClientRect.h"
54 #include "core/dom/ClientRectList.h" 54 #include "core/dom/ClientRectList.h"
55 #include "core/dom/DOMStringList.h" 55 #include "core/dom/DOMStringList.h"
56 #include "core/dom/Document.h" 56 #include "core/dom/Document.h"
57 #include "core/dom/DocumentMarker.h" 57 #include "core/dom/DocumentMarker.h"
58 #include "core/dom/DocumentMarkerController.h" 58 #include "core/dom/DocumentMarkerController.h"
59 #include "core/dom/Element.h" 59 #include "core/dom/Element.h"
60 #include "core/dom/EventHandlerRegistry.h"
60 #include "core/dom/ExceptionCode.h" 61 #include "core/dom/ExceptionCode.h"
61 #include "core/dom/FullscreenElementStack.h" 62 #include "core/dom/FullscreenElementStack.h"
62 #include "core/dom/NodeRenderStyle.h" 63 #include "core/dom/NodeRenderStyle.h"
63 #include "core/dom/PseudoElement.h" 64 #include "core/dom/PseudoElement.h"
64 #include "core/dom/Range.h" 65 #include "core/dom/Range.h"
65 #include "core/dom/StaticNodeList.h" 66 #include "core/dom/StaticNodeList.h"
66 #include "core/dom/TreeScope.h" 67 #include "core/dom/TreeScope.h"
67 #include "core/dom/ViewportDescription.h" 68 #include "core/dom/ViewportDescription.h"
68 #include "core/dom/WheelController.h"
69 #include "core/dom/shadow/ComposedTreeWalker.h" 69 #include "core/dom/shadow/ComposedTreeWalker.h"
70 #include "core/dom/shadow/ElementShadow.h" 70 #include "core/dom/shadow/ElementShadow.h"
71 #include "core/dom/shadow/SelectRuleFeatureSet.h" 71 #include "core/dom/shadow/SelectRuleFeatureSet.h"
72 #include "core/dom/shadow/ShadowRoot.h" 72 #include "core/dom/shadow/ShadowRoot.h"
73 #include "core/editing/Editor.h" 73 #include "core/editing/Editor.h"
74 #include "core/editing/PlainTextRange.h" 74 #include "core/editing/PlainTextRange.h"
75 #include "core/editing/SpellCheckRequester.h" 75 #include "core/editing/SpellCheckRequester.h"
76 #include "core/editing/SpellChecker.h" 76 #include "core/editing/SpellChecker.h"
77 #include "core/editing/SurroundingText.h" 77 #include "core/editing/SurroundingText.h"
78 #include "core/editing/TextIterator.h" 78 #include "core/editing/TextIterator.h"
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 unsigned Internals::activeDOMObjectCount(Document* document, ExceptionState& exc eptionState) 1271 unsigned Internals::activeDOMObjectCount(Document* document, ExceptionState& exc eptionState)
1272 { 1272 {
1273 if (!document) { 1273 if (!document) {
1274 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available."); 1274 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available.");
1275 return 0; 1275 return 0;
1276 } 1276 }
1277 1277
1278 return document->activeDOMObjectCount(); 1278 return document->activeDOMObjectCount();
1279 } 1279 }
1280 1280
1281 static unsigned eventHandlerCount(Document& document, EventHandlerRegistry::Even tHandlerClass handlerClass)
1282 {
1283 EventHandlerRegistry* registry = EventHandlerRegistry::from(document);
1284 unsigned count = registry->externalEventHandlerCount(handlerClass);
1285 const EventTargetSet* targets = registry->eventHandlerTargets(handlerClass);
1286 if (targets) {
1287 for (EventTargetSet::const_iterator iter = targets->begin(); iter != tar gets->end(); ++iter)
1288 count += iter->value;
1289 }
1290 return count;
1291 }
1292
1281 unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e xceptionState) 1293 unsigned Internals::wheelEventHandlerCount(Document* document, ExceptionState& e xceptionState)
1282 { 1294 {
1283 if (!document) { 1295 if (!document) {
1284 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available."); 1296 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available.");
1285 return 0; 1297 return 0;
1286 } 1298 }
1287 1299
1288 return WheelController::from(*document)->wheelEventHandlerCount(); 1300 return eventHandlerCount(*document, EventHandlerRegistry::WheelEvent);
1301 }
1302
1303 unsigned Internals::scrollEventHandlerCount(Document* document, ExceptionState& exceptionState)
1304 {
1305 if (!document) {
1306 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available.");
1307 return 0;
1308 }
1309
1310 return eventHandlerCount(*document, EventHandlerRegistry::ScrollEvent);
1289 } 1311 }
1290 1312
1291 unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& e xceptionState) 1313 unsigned Internals::touchEventHandlerCount(Document* document, ExceptionState& e xceptionState)
1292 { 1314 {
1293 if (!document) { 1315 if (!document) {
1294 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available."); 1316 exceptionState.throwDOMException(InvalidAccessError, "No context documen t is available.");
1295 return 0; 1317 return 0;
1296 } 1318 }
1297 1319
1298 const TouchEventTargetSet* touchHandlers = document->touchEventTargets(); 1320 return eventHandlerCount(*document, EventHandlerRegistry::TouchEvent);
1299 if (!touchHandlers)
1300 return 0;
1301
1302 unsigned count = 0;
1303 for (TouchEventTargetSet::const_iterator iter = touchHandlers->begin(); iter != touchHandlers->end(); ++iter)
1304 count += iter->value;
1305 return count;
1306 } 1321 }
1307 1322
1308 static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, Gra phicsLayer* graphicsLayer, String* layerType) 1323 static RenderLayer* findRenderLayerForGraphicsLayer(RenderLayer* searchRoot, Gra phicsLayer* graphicsLayer, String* layerType)
1309 { 1324 {
1310 if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot-> compositedLayerMapping()->mainGraphicsLayer()) 1325 if (searchRoot->hasCompositedLayerMapping() && graphicsLayer == searchRoot-> compositedLayerMapping()->mainGraphicsLayer())
1311 return searchRoot; 1326 return searchRoot;
1312 1327
1313 GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot ->scrollableArea()->layerForScrolling() : 0; 1328 GraphicsLayer* layerForScrolling = searchRoot->scrollableArea() ? searchRoot ->scrollableArea()->layerForScrolling() : 0;
1314 if (graphicsLayer == layerForScrolling) { 1329 if (graphicsLayer == layerForScrolling) {
1315 *layerType = "scrolling"; 1330 *layerType = "scrolling";
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2457 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength) 2472 String Internals::textSurroundingNode(Node* node, int x, int y, unsigned long ma xLength)
2458 { 2473 {
2459 if (!node) 2474 if (!node)
2460 return String(); 2475 return String();
2461 blink::WebPoint point(x, y); 2476 blink::WebPoint point(x, y);
2462 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength); 2477 SurroundingText surroundingText(VisiblePosition(node->renderer()->positionFo rPoint(static_cast<IntPoint>(point))), maxLength);
2463 return surroundingText.content(); 2478 return surroundingText.content();
2464 } 2479 }
2465 2480
2466 } 2481 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698