#pragma once
#include "ViewSnapshotStore.h"
#include <WebCore/BackForwardItemIdentifier.h>
#include <WebCore/FloatRect.h>
#include <WebCore/FrameLoaderTypes.h>
#include <WebCore/IntRect.h>
#include <WebCore/SerializedScriptValue.h>
#include <wtf/Optional.h>
#include <wtf/URL.h>
#include <wtf/Vector.h>
#include <wtf/text/WTFString.h>
namespace IPC {
class Decoder;
class Encoder;
}
namespace WebKit {
bool isValidEnum(WebCore::ShouldOpenExternalURLsPolicy);
struct HTTPBody {
struct Element {
void encode(IPC::Encoder&) const;
static Optional<Element> decode(IPC::Decoder&);
enum class Type {
Data,
File,
Blob,
};
Type type = Type::Data;
Vector<char> data;
String filePath;
int64_t fileStart;
Optional<int64_t> fileLength;
Optional<WallTime> expectedFileModificationTime;
String blobURLString;
};
void encode(IPC::Encoder&) const;
static bool decode(IPC::Decoder&, HTTPBody&);
String contentType;
Vector<Element> elements;
};
struct FrameState {
void encode(IPC::Encoder&) const;
static Optional<FrameState> decode(IPC::Decoder&);
String urlString;
String originalURLString;
String referrer;
String target;
Vector<String> documentState;
Optional<Vector<uint8_t>> stateObjectData;
int64_t documentSequenceNumber { 0 };
int64_t itemSequenceNumber { 0 };
WebCore::IntPoint scrollPosition;
bool shouldRestoreScrollPosition { true };
float pageScaleFactor { 0 };
Optional<HTTPBody> httpBody;
#if PLATFORM(IOS_FAMILY)
WebCore::FloatRect exposedContentRect;
WebCore::IntRect unobscuredContentRect;
WebCore::FloatSize minimumLayoutSizeInScrollViewCoordinates;
WebCore::IntSize contentSize;
bool scaleIsInitial { false };
WebCore::FloatBoxExtent obscuredInsets;
#endif
Vector<FrameState> children;
bool isDestructed { false };
~FrameState() { isDestructed = true; }
};
struct PageState {
void encode(IPC::Encoder&) const;
static bool decode(IPC::Decoder&, PageState&);
String title;
FrameState mainFrameState;
WebCore::ShouldOpenExternalURLsPolicy shouldOpenExternalURLsPolicy { WebCore::ShouldOpenExternalURLsPolicy::ShouldNotAllow };
RefPtr<WebCore::SerializedScriptValue> sessionStateObject;
};
struct BackForwardListItemState {
void encode(IPC::Encoder&) const;
static Optional<BackForwardListItemState> decode(IPC::Decoder&);
WebCore::BackForwardItemIdentifier identifier;
PageState pageState;
#if PLATFORM(COCOA) || PLATFORM(GTK)
RefPtr<ViewSnapshot> snapshot;
#endif
bool hasCachedPage { false };
};
struct BackForwardListState {
void encode(IPC::Encoder&) const;
static Optional<BackForwardListState> decode(IPC::Decoder&);
Vector<BackForwardListItemState> items;
Optional<uint32_t> currentIndex;
};
struct SessionState {
BackForwardListState backForwardListState;
uint64_t renderTreeSize;
URL provisionalURL;
};
}