HTMLPictureElement.cpp [plain text]
#include "config.h"
#include "HTMLPictureElement.h"
#include "ElementChildIterator.h"
#include "HTMLAnchorElement.h"
#include "HTMLImageElement.h"
#include "ImageLoader.h"
#include "Logging.h"
#include "RuntimeEnabledFeatures.h"
#include <wtf/IsoMallocInlines.h>
namespace WebCore {
WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLPictureElement);
HTMLPictureElement::HTMLPictureElement(const QualifiedName& tagName, Document& document)
: HTMLElement(tagName, document)
{
}
HTMLPictureElement::~HTMLPictureElement()
{
}
void HTMLPictureElement::didMoveToNewDocument(Document& oldDocument, Document& newDocument)
{
HTMLElement::didMoveToNewDocument(oldDocument, newDocument);
sourcesChanged();
}
Ref<HTMLPictureElement> HTMLPictureElement::create(const QualifiedName& tagName, Document& document)
{
return adoptRef(*new HTMLPictureElement(tagName, document));
}
void HTMLPictureElement::sourcesChanged()
{
for (auto& element : childrenOfType<HTMLImageElement>(*this))
element.selectImageSource(RelevantMutation::Yes);
}
#if USE(SYSTEM_PREVIEW)
bool HTMLPictureElement::isSystemPreviewImage()
{
if (!RuntimeEnabledFeatures::sharedFeatures().systemPreviewEnabled())
return false;
auto* parent = parentElement();
if (!is<HTMLAnchorElement>(parent))
return false;
return downcast<HTMLAnchorElement>(parent)->isSystemPreviewLink();
}
#endif
}