193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)/*
293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved.
393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * Redistribution and use in source and binary forms, with or without
593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * modification, are permitted provided that the following conditions are
693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * met:
793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions of source code must retain the above copyright
993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * notice, this list of conditions and the following disclaimer.
1093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Redistributions in binary form must reproduce the above
1193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer
1293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * in the documentation and/or other materials provided with the
1393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * distribution.
1493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *     * Neither the name of Google Inc. nor the names of its
1593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * contributors may be used to endorse or promote products derived from
1693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * this software without specific prior written permission.
1793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) *
1893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2193ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2293ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2393ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2493ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2593ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2793ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2993ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles) */
3093ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
31e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#ifndef CustomElementLifecycleCallbacks_h
32e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#define CustomElementLifecycleCallbacks_h
33591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
34591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch#include "wtf/RefCounted.h"
35e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/text/AtomicString.h"
3693ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
37c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink {
3893ac45cfc74041c8ae536ce58a9534d46db2024eTorne (Richard Coles)
39591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochclass Element;
40591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
41e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochclass CustomElementLifecycleCallbacks : public RefCounted<CustomElementLifecycleCallbacks> {
42591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochpublic:
43e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch    virtual ~CustomElementLifecycleCallbacks() { }
44591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
45591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    enum CallbackType {
467242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        None                     = 0,
477242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        CreatedCallback          = 1 << 0,
487242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        AttachedCallback         = 1 << 1,
497242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        DetachedCallback         = 1 << 2,
507242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci        AttributeChangedCallback = 1 << 3
51591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch    };
52591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
537242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    bool hasCallback(CallbackType type) const { return m_callbackType & type; }
54aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch
55aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch    virtual void created(Element*) = 0;
56aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch    virtual void attached(Element*) = 0;
57aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch    virtual void detached(Element*) = 0;
58aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch    virtual void attributeChanged(Element*, const AtomicString& name, const AtomicString& oldValue, const AtomicString& newValue) = 0;
59aafa69cb17c9d6606c07663ade5f81388a2c5986Ben Murdoch
60e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdochprotected:
617242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    CustomElementLifecycleCallbacks(CallbackType type) : m_callbackType(type) { }
62591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
63591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdochprivate:
647242dc3dbeb210b5e876a3c42d1ec1a667fc621aPrimiano Tucci    CallbackType m_callbackType;
65591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch};
66591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
67591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch}
68591b958dee2cf159d33a0b931e6231072eaf38d5Ben Murdoch
69e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#endif // CustomElementLifecycleCallbacks_h
70