HTMLAttachmentElement.h [plain text]
#pragma once
#if ENABLE(ATTACHMENT_ELEMENT)
#include "AttachmentTypes.h"
#include "HTMLElement.h"
namespace WebCore {
class AttachmentDataReader;
class File;
class HTMLImageElement;
class HTMLVideoElement;
class RenderAttachment;
class SharedBuffer;
class HTMLAttachmentElement final : public HTMLElement {
WTF_MAKE_ISO_ALLOCATED(HTMLAttachmentElement);
public:
static Ref<HTMLAttachmentElement> create(const QualifiedName&, Document&);
WEBCORE_EXPORT URL blobURL() const;
WEBCORE_EXPORT File* file() const;
enum class UpdateDisplayAttributes { No, Yes };
void setFile(RefPtr<File>&&, UpdateDisplayAttributes = UpdateDisplayAttributes::No);
String uniqueIdentifier() const { return m_uniqueIdentifier; }
void setUniqueIdentifier(const String& uniqueIdentifier) { m_uniqueIdentifier = uniqueIdentifier; }
WEBCORE_EXPORT void updateDisplayMode(AttachmentDisplayMode);
WEBCORE_EXPORT void updateFileWithData(Ref<SharedBuffer>&& data, std::optional<String>&& newContentType = std::nullopt, std::optional<String>&& newFilename = std::nullopt);
InsertedIntoAncestorResult insertedIntoAncestor(InsertionType, ContainerNode&) final;
void removedFromAncestor(RemovalType, ContainerNode&) final;
WEBCORE_EXPORT String attachmentTitle() const;
String attachmentType() const;
String attachmentPath() const;
RenderAttachment* attachmentRenderer() const;
WEBCORE_EXPORT void requestInfo(Function<void(const AttachmentInfo&)>&& callback);
void destroyReader(AttachmentDataReader&);
private:
HTMLAttachmentElement(const QualifiedName&, Document&);
virtual ~HTMLAttachmentElement();
RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
Ref<HTMLImageElement> ensureInnerImage();
Ref<HTMLVideoElement> ensureInnerVideo();
RefPtr<HTMLImageElement> innerImage() const;
RefPtr<HTMLVideoElement> innerVideo() const;
void populateShadowRootIfNecessary();
void invalidateShadowRootChildrenIfNecessary();
AttachmentDisplayMode defaultDisplayMode() const
{
return AttachmentDisplayMode::AsIcon;
}
bool shouldSelectOnMouseDown() final {
#if PLATFORM(IOS)
return false;
#else
return true;
#endif
}
bool canContainRangeEndPoint() const final { return false; }
void parseAttribute(const QualifiedName&, const AtomicString&) final;
RefPtr<File> m_file;
Vector<std::unique_ptr<AttachmentDataReader>> m_attachmentReaders;
String m_uniqueIdentifier;
};
}
#endif // ENABLE(ATTACHMENT_ELEMENT)