EditableImageController.h [plain text]
#pragma once
#if HAVE(PENCILKIT)
#include "APIAttachment.h"
#include "MessageReceiver.h"
#include "WebPageProxy.h"
#include <WebCore/GraphicsLayer.h>
#include <wtf/Noncopyable.h>
#include <wtf/WeakObjCPtr.h>
#include <wtf/WeakPtr.h>
#include <wtf/text/WTFString.h>
OBJC_CLASS WKDrawingView;
namespace WebKit {
struct EditableImage {
RetainPtr<WKDrawingView> drawingView;
String attachmentID;
};
class EditableImageController : private IPC::MessageReceiver {
WTF_MAKE_NONCOPYABLE(EditableImageController);
public:
explicit EditableImageController(WebPageProxy&);
~EditableImageController();
void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
EditableImage* editableImage(WebCore::GraphicsLayer::EmbeddedViewID);
EditableImage& ensureEditableImage(WebCore::GraphicsLayer::EmbeddedViewID);
void invalidateAttachmentForEditableImage(WebCore::GraphicsLayer::EmbeddedViewID);
WebPageProxy::ShouldUpdateAttachmentAttributes willUpdateAttachmentAttributes(const API::Attachment&);
private:
void didCreateEditableImage(WebCore::GraphicsLayer::EmbeddedViewID);
void didDestroyEditableImage(WebCore::GraphicsLayer::EmbeddedViewID);
void associateWithAttachment(WebCore::GraphicsLayer::EmbeddedViewID, const String& attachmentID);
void loadStrokesFromAttachment(EditableImage&, const API::Attachment&);
WeakPtr<WebPageProxy> m_webPageProxy;
HashMap<WebCore::GraphicsLayer::EmbeddedViewID, std::unique_ptr<EditableImage>> m_editableImages;
};
}
#endif // HAVE(PENCILKIT)