#include "config.h"
#include "PseudoElement.h"
#include "CSSAnimationController.h"
#include "ContentData.h"
#include "InspectorInstrumentation.h"
#include "RenderElement.h"
#include "RenderImage.h"
#include "RenderQuote.h"
#include "StyleResolver.h"
namespace WebCore {
const QualifiedName& pseudoElementTagName()
{
static NeverDestroyed<QualifiedName> name(nullAtom(), "<pseudo>", nullAtom());
return name;
}
String PseudoElement::pseudoElementNameForEvents(PseudoId pseudoId)
{
static NeverDestroyed<const String> after(MAKE_STATIC_STRING_IMPL("::after"));
static NeverDestroyed<const String> before(MAKE_STATIC_STRING_IMPL("::before"));
switch (pseudoId) {
case AFTER:
return after;
case BEFORE:
return before;
default:
return emptyString();
}
}
PseudoElement::PseudoElement(Element& host, PseudoId pseudoId)
: Element(pseudoElementTagName(), host.document(), CreatePseudoElement)
, m_hostElement(&host)
, m_pseudoId(pseudoId)
{
ASSERT(pseudoId == BEFORE || pseudoId == AFTER);
setHasCustomStyleResolveCallbacks();
}
PseudoElement::~PseudoElement()
{
ASSERT(!m_hostElement);
}
Ref<PseudoElement> PseudoElement::create(Element& host, PseudoId pseudoId)
{
auto pseudoElement = adoptRef(*new PseudoElement(host, pseudoId));
InspectorInstrumentation::pseudoElementCreated(host.document().page(), pseudoElement.get());
return pseudoElement;
}
void PseudoElement::clearHostElement()
{
InspectorInstrumentation::pseudoElementDestroyed(document().page(), *this);
if (auto* frame = document().frame())
frame->animation().cancelAnimations(*this);
m_hostElement = nullptr;
}
bool PseudoElement::rendererIsNeeded(const RenderStyle& style)
{
return pseudoElementRendererIsNeeded(&style);
}
}