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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/CustomElementCallbackInvocation.h ('k') | Source/core/dom/CustomElementCallbackQueue.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/CustomElementCallbackInvocation.cpp
diff --git a/Source/core/dom/CustomElementCallbackQueue.h b/Source/core/dom/CustomElementCallbackInvocation.cpp
similarity index 51%
copy from Source/core/dom/CustomElementCallbackQueue.h
copy to Source/core/dom/CustomElementCallbackInvocation.cpp
index 236297d9f02c76b6a143bd90e70d10ad205be5e6..3b6aab9befaf419897f181b78258a1c9b330a3ec 100644
--- a/Source/core/dom/CustomElementCallbackQueue.h
+++ b/Source/core/dom/CustomElementCallbackInvocation.cpp
@@ -28,48 +28,57 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef CustomElementCallbackQueue_h
-#define CustomElementCallbackQueue_h
+#include "config.h"
+#include "core/dom/CustomElementCallbackInvocation.h"
#include "core/dom/CustomElementLifecycleCallbacks.h"
-#include "wtf/PassOwnPtr.h"
-#include "wtf/PassRefPtr.h"
-#include "wtf/RefPtr.h"
-#include "wtf/Vector.h"
namespace WebCore {
-class CustomElementCallbackQueue {
- WTF_MAKE_NONCOPYABLE(CustomElementCallbackQueue);
+class AttributeChangedInvocation : public CustomElementCallbackInvocation {
public:
- static PassOwnPtr<CustomElementCallbackQueue> create(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
+ AttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue);
- typedef int ElementQueue;
- ElementQueue owner() { return m_owner; }
- void setOwner(ElementQueue newOwner)
- {
- // ElementCallbackQueues only migrate towards the top of the
- // processing stack.
- ASSERT(newOwner >= m_owner);
- m_owner = newOwner;
- }
-
- typedef CustomElementLifecycleCallbacks::CallbackType Invocation;
- void append(const Invocation& invocation) { m_queue.append(invocation); }
+private:
+ virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE;
- void processInElementQueue(ElementQueue);
+ AtomicString m_name;
+ AtomicString m_oldValue;
+ AtomicString m_newValue;
+};
+class CreatedInvocation : public CustomElementCallbackInvocation {
+public:
+ CreatedInvocation() { }
private:
- CustomElementCallbackQueue(PassRefPtr<CustomElementLifecycleCallbacks>, PassRefPtr<Element>);
- void dispatch(const Invocation&);
-
- RefPtr<CustomElementLifecycleCallbacks> m_callbacks;
- RefPtr<Element> m_element;
- Vector<Invocation> m_queue;
- ElementQueue m_owner;
- size_t m_index;
+ virtual void dispatch(CustomElementLifecycleCallbacks*, Element*) OVERRIDE;
};
+PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createCreatedInvocation()
+{
+ return adoptPtr(new CreatedInvocation());
+}
+
+PassOwnPtr<CustomElementCallbackInvocation> CustomElementCallbackInvocation::createAttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
+{
+ return adoptPtr(new AttributeChangedInvocation(name, oldValue, newValue));
+}
+
+AttributeChangedInvocation::AttributeChangedInvocation(const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue)
+ : m_name(name)
+ , m_oldValue(oldValue)
+ , m_newValue(newValue)
+{
+}
+
+void AttributeChangedInvocation::dispatch(CustomElementLifecycleCallbacks* callbacks, Element* element)
+{
+ callbacks->attributeChanged(element, m_name, m_oldValue, m_newValue);
+}
+
+void CreatedInvocation::dispatch(CustomElementLifecycleCallbacks* callbacks, Element* element)
+{
+ callbacks->created(element);
}
-#endif // CustomElementCallbackQueue_h
+} // namespace WebCore
« 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