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

Side by Side Diff: Source/core/workers/WorkerEventQueue.cpp

Issue 1241613004: Rework dispatchEvent so it is consistent for isTrusted support. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Work around MSVC optimization bug Created 5 years, 5 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) 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 return adoptPtr(new EventDispatcherTask(event, eventQueue)); 66 return adoptPtr(new EventDispatcherTask(event, eventQueue));
67 } 67 }
68 68
69 ~EventDispatcherTask() override 69 ~EventDispatcherTask() override
70 { 70 {
71 if (m_event) 71 if (m_event)
72 m_eventQueue->removeEvent(m_event.get()); 72 m_eventQueue->removeEvent(m_event.get());
73 } 73 }
74 74
75 void dispatchEvent(ExecutionContext*, PassRefPtrWillBeRawPtr<Event> event) 75 void dispatchEvent(ExecutionContext*, PassRefPtrWillBeRawPtr<Event> prpEvent )
76 { 76 {
77 // Stash the event on the stack in a RefPtrWillBeRawPtr; trying to do th is
78 // in a single line causes an optimization bug with MSVC. MSVC generates code
79 // that passes the event arg (forcing PassRefPtrWillBeRawPtr to be relea sed)
80 // before the target is queried.
tkent 2015/07/16 00:22:03 Wow, nice detective work.
81 RefPtrWillBeRawPtr<Event> event = prpEvent;
77 event->target()->dispatchEvent(event); 82 event->target()->dispatchEvent(event);
78 } 83 }
79 84
80 virtual void performTask(ExecutionContext* context) 85 virtual void performTask(ExecutionContext* context)
81 { 86 {
82 if (m_isCancelled) 87 if (m_isCancelled)
83 return; 88 return;
84 m_eventQueue->removeEvent(m_event.get()); 89 m_eventQueue->removeEvent(m_event.get());
85 dispatchEvent(context, m_event); 90 dispatchEvent(context, m_event);
86 m_event.clear(); 91 m_event.clear();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 for (const auto& entry : m_eventTaskMap) { 144 for (const auto& entry : m_eventTaskMap) {
140 Event* event = entry.key.get(); 145 Event* event = entry.key.get();
141 EventDispatcherTask* task = entry.value; 146 EventDispatcherTask* task = entry.value;
142 InspectorInstrumentation::didRemoveEvent(event->target(), event); 147 InspectorInstrumentation::didRemoveEvent(event->target(), event);
143 task->cancel(); 148 task->cancel();
144 } 149 }
145 m_eventTaskMap.clear(); 150 m_eventTaskMap.clear();
146 } 151 }
147 152
148 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698