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

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

Issue 124003003: Add ascii() / latin1() / utf8() methods to AtomicString to avoid having to call string() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 11 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
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org) 2 * Copyright (C) 2012 Victor Carbune (victor@rosedu.org)
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 } 49 }
50 50
51 bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event) 51 bool GenericEventQueue::enqueueEvent(PassRefPtr<Event> event)
52 { 52 {
53 if (m_isClosed) 53 if (m_isClosed)
54 return false; 54 return false;
55 55
56 if (event->target() == m_owner) 56 if (event->target() == m_owner)
57 event->setTarget(0); 57 event->setTarget(0);
58 58
59 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge t(), "type", event->type().string().ascii()); 59 TRACE_EVENT_ASYNC_BEGIN1("event", "GenericEventQueue:enqueueEvent", event.ge t(), "type", event->type().ascii());
60 m_pendingEvents.append(event); 60 m_pendingEvents.append(event);
61 61
62 if (!m_timer.isActive()) 62 if (!m_timer.isActive())
63 m_timer.startOneShot(0); 63 m_timer.startOneShot(0);
64 64
65 return true; 65 return true;
66 } 66 }
67 67
68 bool GenericEventQueue::cancelEvent(Event* event) 68 bool GenericEventQueue::cancelEvent(Event* event)
69 { 69 {
70 bool found = m_pendingEvents.contains(event); 70 bool found = m_pendingEvents.contains(event);
71 71
72 if (found) { 72 if (found) {
73 m_pendingEvents.remove(m_pendingEvents.find(event)); 73 m_pendingEvents.remove(m_pendingEvents.find(event));
74 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().string().ascii(), "status", "cancelled"); 74 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii(), "status", "cancelled");
75 } 75 }
76 76
77 if (m_pendingEvents.isEmpty()) 77 if (m_pendingEvents.isEmpty())
78 m_timer.stop(); 78 m_timer.stop();
79 79
80 return found; 80 return found;
81 } 81 }
82 82
83 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*) 83 void GenericEventQueue::timerFired(Timer<GenericEventQueue>*)
84 { 84 {
85 ASSERT(!m_timer.isActive()); 85 ASSERT(!m_timer.isActive());
86 ASSERT(!m_pendingEvents.isEmpty()); 86 ASSERT(!m_pendingEvents.isEmpty());
87 87
88 Vector<RefPtr<Event> > pendingEvents; 88 Vector<RefPtr<Event> > pendingEvents;
89 m_pendingEvents.swap(pendingEvents); 89 m_pendingEvents.swap(pendingEvents);
90 90
91 RefPtr<EventTarget> protect(m_owner); 91 RefPtr<EventTarget> protect(m_owner);
92 for (size_t i = 0; i < pendingEvents.size(); ++i) { 92 for (size_t i = 0; i < pendingEvents.size(); ++i) {
93 Event* event = pendingEvents[i].get(); 93 Event* event = pendingEvents[i].get();
94 EventTarget* target = event->target() ? event->target() : m_owner; 94 EventTarget* target = event->target() ? event->target() : m_owner;
95 CString type(event->type().string().ascii()); 95 CString type(event->type().ascii());
96 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type); 96 TRACE_EVENT_ASYNC_STEP_INTO1("event", "GenericEventQueue:enqueueEvent", event, "dispatch", "type", type);
97 target->dispatchEvent(pendingEvents[i].release()); 97 target->dispatchEvent(pendingEvents[i].release());
98 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type); 98 TRACE_EVENT_ASYNC_END1("event", "GenericEventQueue:enqueueEvent", event, "type", type);
99 } 99 }
100 } 100 }
101 101
102 void GenericEventQueue::close() 102 void GenericEventQueue::close()
103 { 103 {
104 m_isClosed = true; 104 m_isClosed = true;
105 cancelAllEvents(); 105 cancelAllEvents();
106 } 106 }
107 107
108 void GenericEventQueue::cancelAllEvents() 108 void GenericEventQueue::cancelAllEvents()
109 { 109 {
110 m_timer.stop(); 110 m_timer.stop();
111 111
112 for (size_t i = 0; i < m_pendingEvents.size(); ++i) { 112 for (size_t i = 0; i < m_pendingEvents.size(); ++i) {
113 Event* event = m_pendingEvents[i].get(); 113 Event* event = m_pendingEvents[i].get();
114 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().string().ascii(), "status", "cancelled"); 114 TRACE_EVENT_ASYNC_END2("event", "GenericEventQueue:enqueueEvent", event, "type", event->type().ascii(), "status", "cancelled");
115 } 115 }
116 m_pendingEvents.clear(); 116 m_pendingEvents.clear();
117 } 117 }
118 118
119 bool GenericEventQueue::hasPendingEvents() const 119 bool GenericEventQueue::hasPendingEvents() const
120 { 120 {
121 return m_pendingEvents.size(); 121 return m_pendingEvents.size();
122 } 122 }
123 123
124 } 124 }
OLDNEW
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698