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

Side by Side Diff: Source/core/events/DOMWindowEventQueue.cpp

Issue 216523002: Oilpan: Replace most of RefPtrs for Event objects with oilpan's transition types (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
OLDNEW
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 : m_pendingEventTimer(adoptPtr(new DOMWindowEventQueueTimer(this, context))) 55 : m_pendingEventTimer(adoptPtr(new DOMWindowEventQueueTimer(this, context)))
56 , m_isClosed(false) 56 , m_isClosed(false)
57 { 57 {
58 m_pendingEventTimer->suspendIfNeeded(); 58 m_pendingEventTimer->suspendIfNeeded();
59 } 59 }
60 60
61 DOMWindowEventQueue::~DOMWindowEventQueue() 61 DOMWindowEventQueue::~DOMWindowEventQueue()
62 { 62 {
63 } 63 }
64 64
65 bool DOMWindowEventQueue::enqueueEvent(PassRefPtr<Event> event) 65 bool DOMWindowEventQueue::enqueueEvent(PassRefPtrWillBeRawPtr<Event> event)
66 { 66 {
67 if (m_isClosed) 67 if (m_isClosed)
68 return false; 68 return false;
69 69
70 ASSERT(event->target()); 70 ASSERT(event->target());
71 bool wasAdded = m_queuedEvents.add(event).isNewEntry; 71 bool wasAdded = m_queuedEvents.add(event).isNewEntry;
72 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. 72 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
73 73
74 if (!m_pendingEventTimer->isActive()) 74 if (!m_pendingEventTimer->isActive())
75 m_pendingEventTimer->startOneShot(0, FROM_HERE); 75 m_pendingEventTimer->startOneShot(0, FROM_HERE);
76 76
77 return true; 77 return true;
78 } 78 }
79 79
80 bool DOMWindowEventQueue::cancelEvent(Event* event) 80 bool DOMWindowEventQueue::cancelEvent(Event* event)
81 { 81 {
82 ListHashSet<RefPtr<Event>, 16>::iterator it = m_queuedEvents.find(event); 82 ListHashSet<RefPtrWillBePersistent<Event>, 16>::iterator it = m_queuedEvents .find(event);
83 bool found = it != m_queuedEvents.end(); 83 bool found = it != m_queuedEvents.end();
84 if (found) 84 if (found)
85 m_queuedEvents.remove(it); 85 m_queuedEvents.remove(it);
86 if (m_queuedEvents.isEmpty()) 86 if (m_queuedEvents.isEmpty())
87 m_pendingEventTimer->stop(); 87 m_pendingEventTimer->stop();
88 return found; 88 return found;
89 } 89 }
90 90
91 void DOMWindowEventQueue::close() 91 void DOMWindowEventQueue::close()
92 { 92 {
93 m_isClosed = true; 93 m_isClosed = true;
94 m_pendingEventTimer->stop(); 94 m_pendingEventTimer->stop();
95 m_queuedEvents.clear(); 95 m_queuedEvents.clear();
96 } 96 }
97 97
98 void DOMWindowEventQueue::pendingEventTimerFired() 98 void DOMWindowEventQueue::pendingEventTimerFired()
99 { 99 {
100 ASSERT(!m_pendingEventTimer->isActive()); 100 ASSERT(!m_pendingEventTimer->isActive());
101 ASSERT(!m_queuedEvents.isEmpty()); 101 ASSERT(!m_queuedEvents.isEmpty());
102 102
103 // Insert a marker for where we should stop. 103 // Insert a marker for where we should stop.
104 ASSERT(!m_queuedEvents.contains(nullptr)); 104 ASSERT(!m_queuedEvents.contains(nullptr));
105 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry; 105 bool wasAdded = m_queuedEvents.add(nullptr).isNewEntry;
106 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list. 106 ASSERT_UNUSED(wasAdded, wasAdded); // It should not have already been in the list.
107 107
108 RefPtr<DOMWindowEventQueue> protector(this); 108 RefPtr<DOMWindowEventQueue> protector(this);
109 109
110 while (!m_queuedEvents.isEmpty()) { 110 while (!m_queuedEvents.isEmpty()) {
111 ListHashSet<RefPtr<Event>, 16>::iterator iter = m_queuedEvents.begin(); 111 ListHashSet<RefPtrWillBePersistent<Event>, 16>::iterator iter = m_queued Events.begin();
112 RefPtr<Event> event = *iter; 112 RefPtrWillBeRawPtr<Event> event = *iter;
113 m_queuedEvents.remove(iter); 113 m_queuedEvents.remove(iter);
114 if (!event) 114 if (!event)
115 break; 115 break;
116 dispatchEvent(event.get()); 116 dispatchEvent(event.get());
117 } 117 }
118 } 118 }
119 119
120 void DOMWindowEventQueue::dispatchEvent(PassRefPtr<Event> event) 120 void DOMWindowEventQueue::dispatchEvent(PassRefPtrWillBeRawPtr<Event> event)
121 { 121 {
122 EventTarget* eventTarget = event->target(); 122 EventTarget* eventTarget = event->target();
123 if (eventTarget->toDOMWindow()) 123 if (eventTarget->toDOMWindow())
124 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr); 124 eventTarget->toDOMWindow()->dispatchEvent(event, nullptr);
125 else 125 else
126 eventTarget->dispatchEvent(event); 126 eventTarget->dispatchEvent(event);
127 } 127 }
128 128
129 } 129 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698