OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2010 Google Inc. All Rights Reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 #include "config.h" | 27 #include "config.h" |
28 #include "DocumentEventQueue.h" | 28 #include "DocumentEventQueue.h" |
29 | 29 |
30 #include "DOMWindow.h" | 30 #include "DOMWindow.h" |
31 #include "Document.h" | 31 #include "Document.h" |
32 #include "Event.h" | 32 #include "Event.h" |
33 #include "EventNames.h" | 33 #include "EventNames.h" |
34 #include "ScriptExecutionContext.h" | 34 #include "ScriptExecutionContext.h" |
35 #include "SuspendableTimer.h" | 35 #include "SuspendableTimer.h" |
36 #include "WebCoreMemoryInstrumentation.h" | |
37 #include <wtf/MemoryInstrumentationHashSet.h> | |
38 #include <wtf/MemoryInstrumentationListHashSet.h> | |
39 | 36 |
40 namespace WebCore { | 37 namespace WebCore { |
41 | 38 |
42 class DocumentEventQueueTimer : public SuspendableTimer { | 39 class DocumentEventQueueTimer : public SuspendableTimer { |
43 WTF_MAKE_NONCOPYABLE(DocumentEventQueueTimer); | 40 WTF_MAKE_NONCOPYABLE(DocumentEventQueueTimer); |
44 public: | 41 public: |
45 DocumentEventQueueTimer(DocumentEventQueue* eventQueue, ScriptExecutionConte
xt* context) | 42 DocumentEventQueueTimer(DocumentEventQueue* eventQueue, ScriptExecutionConte
xt* context) |
46 : SuspendableTimer(context) | 43 : SuspendableTimer(context) |
47 , m_eventQueue(eventQueue) { } | 44 , m_eventQueue(eventQueue) { } |
48 | 45 |
49 virtual void reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const OVE
RRIDE | |
50 { | |
51 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); | |
52 SuspendableTimer::reportMemoryUsage(memoryObjectInfo); | |
53 info.addWeakPointer(m_eventQueue); | |
54 } | |
55 | |
56 private: | 46 private: |
57 virtual void fired() { m_eventQueue->pendingEventTimerFired(); } | 47 virtual void fired() { m_eventQueue->pendingEventTimerFired(); } |
58 DocumentEventQueue* m_eventQueue; | 48 DocumentEventQueue* m_eventQueue; |
59 }; | 49 }; |
60 | 50 |
61 PassRefPtr<DocumentEventQueue> DocumentEventQueue::create(ScriptExecutionContext
* context) | 51 PassRefPtr<DocumentEventQueue> DocumentEventQueue::create(ScriptExecutionContext
* context) |
62 { | 52 { |
63 return adoptRef(new DocumentEventQueue(context)); | 53 return adoptRef(new DocumentEventQueue(context)); |
64 } | 54 } |
65 | 55 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 bool canBubble = targetType == ScrollEventDocumentTarget; | 88 bool canBubble = targetType == ScrollEventDocumentTarget; |
99 RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubbl
e, false /* non cancelleable */); | 89 RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubbl
e, false /* non cancelleable */); |
100 | 90 |
101 if (!m_nodesWithQueuedScrollEvents.add(target.get()).isNewEntry) | 91 if (!m_nodesWithQueuedScrollEvents.add(target.get()).isNewEntry) |
102 return; | 92 return; |
103 | 93 |
104 scrollEvent->setTarget(target); | 94 scrollEvent->setTarget(target); |
105 enqueueEvent(scrollEvent.release()); | 95 enqueueEvent(scrollEvent.release()); |
106 } | 96 } |
107 | 97 |
108 void DocumentEventQueue::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) c
onst | |
109 { | |
110 MemoryClassInfo info(memoryObjectInfo, this, WebCoreMemoryTypes::DOM); | |
111 info.addMember(m_pendingEventTimer, "pendingEventTimer"); | |
112 info.addMember(m_queuedEvents, "queuedEvents"); | |
113 info.addMember(m_nodesWithQueuedScrollEvents, "nodesWithQueuedScrollEvents")
; | |
114 } | |
115 | |
116 bool DocumentEventQueue::cancelEvent(Event* event) | 98 bool DocumentEventQueue::cancelEvent(Event* event) |
117 { | 99 { |
118 bool found = m_queuedEvents.contains(event); | 100 bool found = m_queuedEvents.contains(event); |
119 m_queuedEvents.remove(event); | 101 m_queuedEvents.remove(event); |
120 if (m_queuedEvents.isEmpty()) | 102 if (m_queuedEvents.isEmpty()) |
121 m_pendingEventTimer->stop(); | 103 m_pendingEventTimer->stop(); |
122 return found; | 104 return found; |
123 } | 105 } |
124 | 106 |
125 void DocumentEventQueue::close() | 107 void DocumentEventQueue::close() |
(...skipping 30 matching lines...) Expand all Loading... |
156 void DocumentEventQueue::dispatchEvent(PassRefPtr<Event> event) | 138 void DocumentEventQueue::dispatchEvent(PassRefPtr<Event> event) |
157 { | 139 { |
158 EventTarget* eventTarget = event->target(); | 140 EventTarget* eventTarget = event->target(); |
159 if (eventTarget->toDOMWindow()) | 141 if (eventTarget->toDOMWindow()) |
160 eventTarget->toDOMWindow()->dispatchEvent(event, 0); | 142 eventTarget->toDOMWindow()->dispatchEvent(event, 0); |
161 else | 143 else |
162 eventTarget->dispatchEvent(event); | 144 eventTarget->dispatchEvent(event); |
163 } | 145 } |
164 | 146 |
165 } | 147 } |
OLD | NEW |