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

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

Issue 18789002: Implement Custom Elements' attributeChangedCallback. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Sync to tip. 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 10 matching lines...) Expand all
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
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 #ifndef CustomElementCallbackQueue_h 31 #include "config.h"
32 #define CustomElementCallbackQueue_h 32 #include "core/dom/CustomElementCallbackInvocation.h"
33 33
34 #include "core/dom/CustomElementLifecycleCallbacks.h" 34 #include "core/dom/CustomElementLifecycleCallbacks.h"
35 #include "wtf/PassOwnPtr.h"
36 #include "wtf/PassRefPtr.h"
37 #include "wtf/RefPtr.h"
38 #include "wtf/Vector.h"
39 35
40 namespace WebCore { 36 namespace WebCore {
41 37
42 class CustomElementCallbackQueue { 38 class AttributeChangedInvocation : public CustomElementCallbackInvocation {
43 WTF_MAKE_NONCOPYABLE(CustomElementCallbackQueue);
44 public: 39 public:
45 static PassOwnPtr<CustomElementCallbackQueue> create(PassRefPtr<CustomElemen tLifecycleCallbacks>, PassRefPtr<Element>); 40 AttributeChangedInvocation(const AtomicString& name, const AtomicString& old Value, const AtomicString& newValue);
46
47 typedef int ElementQueue;
48 ElementQueue owner() { return m_owner; }
49 void setOwner(ElementQueue newOwner)
50 {
51 // ElementCallbackQueues only migrate towards the top of the
52 // processing stack.
53 ASSERT(newOwner >= m_owner);
54 m_owner = newOwner;
55 }
56
57 typedef CustomElementLifecycleCallbacks::CallbackType Invocation;
58 void append(const Invocation& invocation) { m_queue.append(invocation); }
59
60 void processInElementQueue(ElementQueue);
61 41
62 private: 42 private:
63 CustomElementCallbackQueue(PassRefPtr<CustomElementLifecycleCallbacks>, Pass RefPtr<Element>); 43 virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE;
64 void dispatch(const Invocation&);
65 44
66 RefPtr<CustomElementLifecycleCallbacks> m_callbacks; 45 AtomicString m_name;
67 RefPtr<Element> m_element; 46 AtomicString m_oldValue;
68 Vector<Invocation> m_queue; 47 AtomicString m_newValue;
69 ElementQueue m_owner;
70 size_t m_index;
71 }; 48 };
72 49
50 class CreatedInvocation : public CustomElementCallbackInvocation {
51 public:
52 CreatedInvocation() { }
53 private:
54 virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE;
55 };
56
57 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre ateCreatedInvocation()
58 {
59 return adoptPtr(new CreatedInvocation());
73 } 60 }
74 61
75 #endif // CustomElementCallbackQueue_h 62 PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::cre ateAttributeChangedInvocation(const AtomicString& name, const AtomicString& oldV alue, const AtomicString& newValue)
63 {
64 return adoptPtr(new AttributeChangedInvocation(name, oldValue, newValue));
65 }
66
67 AttributeChangedInvocation::AttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
68 : m_name(name)
69 , m_oldValue(oldValue)
70 , m_newValue(newValue)
71 {
72 }
73
74 void AttributeChangedInvocation::dispatch(CustomElementLifecycleCallbacks* callb acks, Element* element)
75 {
76 callbacks->attributeChanged(element, m_name, m_oldValue, m_newValue);
77 }
78
79 void CreatedInvocation::dispatch(CustomElementLifecycleCallbacks* callbacks, Ele ment* element)
80 {
81 callbacks->created(element);
82 }
83
84 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/dom/CustomElementCallbackInvocation.h ('k') | Source/core/dom/CustomElementCallbackQueue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698