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

Side by Side Diff: Source/core/dom/CustomElementCallbackQueue.cpp

Issue 18167006: Implement Custom Elements' entered and left document callbacks. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Feedback. Created 7 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 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 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/dom/CustomElementCallbackQueue.h" 32 #include "core/dom/CustomElementCallbackQueue.h"
33 33
34 #include "core/dom/Element.h" 34 #include "core/dom/Element.h"
35 35
36 namespace WebCore { 36 namespace WebCore {
37 37
38 PassOwnPtr<CustomElementCallbackQueue> CustomElementCallbackQueue::create(PassRe fPtr<CustomElementLifecycleCallbacks> callbacks, PassRefPtr<Element> element) 38 PassOwnPtr<CustomElementCallbackQueue> CustomElementCallbackQueue::create(PassRe fPtr<Element> element)
39 { 39 {
40 return adoptPtr(new CustomElementCallbackQueue(callbacks, element)); 40 return adoptPtr(new CustomElementCallbackQueue(element));
41 } 41 }
42 42
43 CustomElementCallbackQueue::CustomElementCallbackQueue(PassRefPtr<CustomElementL ifecycleCallbacks> callbacks, PassRefPtr<Element> element) 43 CustomElementCallbackQueue::CustomElementCallbackQueue(PassRefPtr<Element> eleme nt)
44 : m_callbacks(callbacks) 44 : m_element(element)
45 , m_element(element)
46 , m_owner(-1) 45 , m_owner(-1)
47 , m_index(0) 46 , m_index(0)
48 { 47 {
49 } 48 }
50 49
51 void CustomElementCallbackQueue::processInElementQueue(ElementQueue caller) 50 void CustomElementCallbackQueue::processInElementQueue(ElementQueue caller)
52 { 51 {
53 for (; m_index < m_queue.size() && owner() == caller; m_index++) { 52 while (m_index < m_queue.size() && owner() == caller) {
54 // dispatch() may cause recursion which steals this callback 53 // dispatch() may cause recursion which steals this callback
55 // queue and reenters processInQueue. owner() == caller 54 // queue and reenters processInQueue. owner() == caller
56 // detects this recursion and cedes processing. 55 // detects this recursion and cedes processing.
57 m_queue[m_index]->dispatch(m_callbacks.get(), m_element.get()); 56 m_queue[m_index++]->dispatch(m_element.get());
58 } 57 }
59 58
60 if (owner() == caller && m_index == m_queue.size()) { 59 if (owner() == caller && m_index == m_queue.size()) {
61 // This processInQueue exhausted the queue; shrink it. 60 // This processInQueue exhausted the queue; shrink it.
62 m_index = 0; 61 m_index = 0;
63 m_queue.resize(0); 62 m_queue.resize(0);
64 m_owner = -1; 63 m_owner = -1;
65 } 64 }
66 } 65 }
67 66
68 } // namespace WebCore 67 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementCallbackQueue.h ('k') | Source/core/dom/CustomElementLifecycleCallbacks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698