#ifndef InsertionPoint_h
#define InsertionPoint_h
#include "HTMLContentSelector.h"
#include "HTMLElement.h"
#include "HTMLNames.h"
#include <wtf/Forward.h>
namespace WebCore {
class InsertionPoint : public HTMLElement {
public:
virtual ~InsertionPoint();
const HTMLContentSelectionList* selections() const { return &m_selections; }
bool hasSelection() const { return m_selections.first(); }
bool isShadowBoundary() const;
bool isActive() const;
virtual const AtomicString& select() const = 0;
virtual bool isSelectValid() const = 0;
virtual bool doesSelectFromHostChildren() const = 0;
virtual void attach();
virtual void detach();
virtual bool isInsertionPoint() const OVERRIDE { return true; }
ShadowRoot* assignedFrom() const;
protected:
InsertionPoint(const QualifiedName&, Document*);
virtual bool rendererIsNeeded(const NodeRenderingContext&) OVERRIDE;
private:
void distributeHostChildren(ShadowTree*);
void clearDistribution(ShadowTree*);
void attachDistributedNode();
void assignShadowRoot(ShadowRoot*);
void clearAssignment(ShadowRoot*);
HTMLContentSelectionList m_selections;
};
inline bool isInsertionPoint(const Node* node)
{
if (!node)
return true;
if (node->isHTMLElement() && toHTMLElement(node)->isInsertionPoint())
return true;
return false;
}
inline InsertionPoint* toInsertionPoint(Node* node)
{
ASSERT(isInsertionPoint(node));
return static_cast<InsertionPoint*>(node);
}
inline const InsertionPoint* toInsertionPoint(const Node* node)
{
ASSERT(isInsertionPoint(node));
return static_cast<const InsertionPoint*>(node);
}
inline bool isShadowBoundary(Node* node)
{
if (!isInsertionPoint(node))
return false;
return toInsertionPoint(node)->isShadowBoundary();
}
}
#endif // InsertionPoint_h