# Copyright (C) 2010-2016 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1.  Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
# 2.  Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

messages -> WebPageProxy {
    # UI messages
    CreateNewPage(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::ResourceRequest request, struct WebCore::WindowFeatures windowFeatures, struct WebKit::NavigationActionData navigationActionData) -> (uint64_t newPageID, struct WebKit::WebPageCreationParameters newPageParameters) Delayed
    ShowPage()
    ClosePage(bool stopResponsivenessTimer)
    RunJavaScriptAlert(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, String message) -> () Delayed
    RunJavaScriptConfirm(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, String message) -> (bool result) Delayed
    RunJavaScriptPrompt(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, String message, String defaultValue) -> (String result) Delayed
    MouseDidMoveOverElement(struct WebKit::WebHitTestResultData hitTestResultData, uint32_t modifiers, WebKit::UserData userData)

#if ENABLE(NETSCAPE_PLUGIN_API)
    UnavailablePluginButtonClicked(uint32_t pluginUnavailabilityReason, String mimeType, String pluginURLString, String pluginspageAttributeURLString, String frameURLString, String pageURLString)
#endif // ENABLE(NETSCAPE_PLUGIN_API)
#if ENABLE(WEBGL)
    WebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
    ResolveWebGLPolicyForURL(String url) -> (uint32_t loadPolicy)
#endif // ENABLE(WEBGL)
    DidChangeViewportProperties(struct WebCore::ViewportAttributes attributes)
    DidReceiveEvent(uint32_t type, bool handled)
    StopResponsivenessTimer()
#if !PLATFORM(IOS)
    SetCursor(WebCore::Cursor cursor)
    SetCursorHiddenUntilMouseMoves(bool hiddenUntilMouseMoves)
#endif
    SetStatusText(String statusText)
    SetToolTip(String toolTip)
    SetFocus(bool focused)
    TakeFocus(uint32_t direction)
    FocusedFrameChanged(uint64_t frameID)
    FrameSetLargestFrameChanged(uint64_t frameID)
    SetRenderTreeSize(uint64_t treeSize)
    SetToolbarsAreVisible(bool toolbarsAreVisible)
    GetToolbarsAreVisible() -> (bool toolbarsAreVisible)
    SetMenuBarIsVisible(bool menuBarIsVisible);
    GetMenuBarIsVisible() -> (bool menuBarIsVisible);
    SetStatusBarIsVisible(bool statusBarIsVisible)
    GetStatusBarIsVisible() -> (bool statusBarIsVisible)
    SetIsResizable(bool isResizable)
    GetIsResizable() -> (bool isResizable)
    SetWindowFrame(WebCore::FloatRect windowFrame)
    GetWindowFrame() -> (WebCore::FloatRect windowFrame)
    ScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint)
    RootViewToScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame)

#if PLATFORM(COCOA)
    ShowValidationMessage(WebCore::IntRect anchorRect, String message)
    HideValidationMessage()
#endif

#if PLATFORM(IOS)
    AccessibilityScreenToRootView(WebCore::IntPoint screenPoint) -> (WebCore::IntPoint windowPoint)
    RootViewToAccessibilityScreen(WebCore::IntRect rect) -> (WebCore::IntRect screenFrame)
#endif

    RunBeforeUnloadConfirmPanel(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, String message) -> (bool shouldClose) Delayed
    PageDidScroll()
    RunOpenPanel(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, struct WebCore::FileChooserSettings parameters)
    PrintFrame(uint64_t frameID) -> ()
    RunModal()
    NotifyScrollerThumbIsVisibleInRect(WebCore::IntRect scrollerThumb)
    RecommendedScrollbarStyleDidChange(int32_t newStyle)
    DidChangeScrollbarsForMainFrame(bool hasHorizontalScrollbar, bool hasVerticalScrollbar)
    DidChangeScrollOffsetPinningForMainFrame(bool pinnedToLeftSide, bool pinnedToRightSide, bool pinnedToTopSide, bool pinnedToBottomSide)
    DidChangePageCount(unsigned pageCount)
    PageExtendedBackgroundColorDidChange(WebCore::Color backgroundColor)
#if ENABLE(NETSCAPE_PLUGIN_API)
    DidFailToInitializePlugin(String mimeType, String frameURLString, String pageURLString)
    DidBlockInsecurePluginVersion(String mimeType, String pluginURLString, String frameURLString, String pageURLString, bool replacementObscured)
#endif // ENABLE(NETSCAPE_PLUGIN_API)
    SetCanShortCircuitHorizontalWheelEvents(bool canShortCircuitHorizontalWheelEvents)

    DidChangeContentSize(WebCore::IntSize newSize)

#if ENABLE(INPUT_TYPE_COLOR)
    ShowColorPicker(WebCore::Color initialColor, WebCore::IntRect elementRect);
    SetColorPickerColor(WebCore::Color color);
    EndColorPicker();
#endif

    # Policy messages
    DecidePolicyForResponseSync(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, WebCore::ResourceResponse response, WebCore::ResourceRequest request, bool canShowMIMEType, uint64_t listenerID, WebKit::UserData userData) -> (uint64_t policyAction, WebKit::DownloadID downloadID) Delayed
    DecidePolicyForNavigationAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, struct WebKit::NavigationActionData navigationActionData, uint64_t originatingFrameID, struct WebCore::SecurityOriginData originatingFrameSecurityOrigin, WebCore::ResourceRequest originalRequest, WebCore::ResourceRequest request, uint64_t listenerID, WebKit::UserData userData) -> (uint64_t newNavigationID, uint64_t policyAction, WebKit::DownloadID downloadID, struct WebKit::WebsitePolicies websitePolicies) Delayed
    DecidePolicyForNewWindowAction(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, struct WebKit::NavigationActionData navigationActionData, WebCore::ResourceRequest request, String frameName, uint64_t listenerID, WebKit::UserData userData)
    UnableToImplementPolicy(uint64_t frameID, WebCore::ResourceError error, WebKit::UserData userData)

    # Progress messages
    DidChangeProgress(double value)
    DidFinishProgress()
    DidStartProgress()

    SetNetworkRequestsInProgress(bool networkRequestsInProgress)

    # Frame lifetime messages
    DidCreateMainFrame(uint64_t frameID)
    DidCreateSubframe(uint64_t frameID)

    # Frame load messages
    DidStartProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, String unreachableURL, WebKit::UserData userData)
    DidReceiveServerRedirectForProvisionalLoadForFrame(uint64_t frameID, uint64_t navigationID, String url, WebKit::UserData userData)
    DidChangeProvisionalURLForFrame(uint64_t frameID, uint64_t navigationID, String url)
    DidFailProvisionalLoadForFrame(uint64_t frameID, struct WebCore::SecurityOriginData frameSecurityOrigin, uint64_t navigationID, String provisionalURL, WebCore::ResourceError error, WebKit::UserData userData)
    DidCommitLoadForFrame(uint64_t frameID, uint64_t navigationID, String mimeType, bool hasCustomContentProvider, uint32_t loadType, WebCore::CertificateInfo certificateInfo, bool containsPluginDocument, std::optional<WebCore::HasInsecureContent> forcedHasInsecureContent, WebKit::UserData userData)
    DidFailLoadForFrame(uint64_t frameID, uint64_t navigationID, WebCore::ResourceError error, WebKit::UserData userData)
    DidFinishDocumentLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
    DidFinishLoadForFrame(uint64_t frameID, uint64_t navigationID, WebKit::UserData userData)
    DidFirstLayoutForFrame(uint64_t frameID, WebKit::UserData userData)
    DidFirstVisuallyNonEmptyLayoutForFrame(uint64_t frameID, WebKit::UserData userData)
    DidReachLayoutMilestone(uint32_t type)
    DidReceiveTitleForFrame(uint64_t frameID, String title, WebKit::UserData userData)
    DidDisplayInsecureContentForFrame(uint64_t frameID, WebKit::UserData userData)
    DidRunInsecureContentForFrame(uint64_t frameID, WebKit::UserData userData)
    DidDetectXSSForFrame(uint64_t frameID, WebKit::UserData userData)
    DidSameDocumentNavigationForFrame(uint64_t frameID, uint64_t navigationID, uint32_t type, String url, WebKit::UserData userData)
    DidChangeMainDocument(uint64_t frameID);
    DidDestroyNavigation(uint64_t navigationID)

    HasInsecureContent() -> (enum WebCore::HasInsecureContent hasInsecureContent)

    MainFramePluginHandlesPageScaleGestureDidChange(bool mainFramePluginHandlesPageScaleGesture)

    FrameDidBecomeFrameSet(uint64_t frameID, bool value)

    # History client messages.
    DidNavigateWithNavigationData(struct WebKit::WebNavigationDataStore store, uint64_t frameID)
    DidPerformClientRedirect(String sourceURLString, String destinationURLString, uint64_t frameID)
    DidPerformServerRedirect(String sourceURLString, String destinationURLString, uint64_t frameID)
    DidUpdateHistoryTitle(String title, String url, uint64_t frameID)

    # Custom representations
    DidFinishLoadingDataForCustomContentProvider(String suggestedFilename, IPC::DataReference data)

    # Forms messages
    WillSubmitForm(uint64_t frameID, uint64_t sourceFrameID, Vector<std::pair<String, String>> textFieldValues, uint64_t listenerID, WebKit::UserData userData)

    # Callback messages
    VoidCallback(uint64_t callbackID)
    DataCallback(IPC::DataReference resultData, uint64_t callbackID)
    ImageCallback(WebKit::ShareableBitmap::Handle bitmapHandle, uint64_t callbackID)
    StringCallback(String resultString, uint64_t callbackID)
    InvalidateStringCallback(uint64_t callbackID)
    ScriptValueCallback(IPC::DataReference resultData, bool hadException, struct WebCore::ExceptionDetails details, uint64_t callbackID)
    ComputedPagesCallback(Vector<WebCore::IntRect> pageRects, double totalScaleFactorForPrinting, uint64_t callbackID)
    ValidateCommandCallback(String command, bool isEnabled, int32_t state, uint64_t callbackID)
    EditingRangeCallback(struct WebKit::EditingRange range, uint64_t callbackID)
    UnsignedCallback(uint64_t result, uint64_t callbackID)
    RectForCharacterRangeCallback(WebCore::IntRect rect, struct WebKit::EditingRange actualRange, uint64_t callbackID)
#if PLATFORM(MAC)
    AttributedStringForCharacterRangeCallback(struct WebKit::AttributedString string, struct WebKit::EditingRange actualRange, uint64_t callbackID)
    FontAtSelectionCallback(String fontName, double fontSize, bool selectioHasMultipleFonts, uint64_t callbackID)
#endif
#if PLATFORM(IOS)
    GestureCallback(WebCore::IntPoint point, uint32_t gestureType, uint32_t gestureState, uint32_t flags, uint64_t callbackID)
    TouchesCallback(WebCore::IntPoint point, uint32_t touches, uint32_t flags, uint64_t callbackID)
    AutocorrectionDataCallback(Vector<WebCore::FloatRect> textRects, String fontName, double fontSize, uint64_t traits, uint64_t callbackID)
    AutocorrectionContextCallback(String beforeText, String markedText, String selectedText, String afterText, uint64_t location, uint64_t length, uint64_t callbackID)
    SelectionContextCallback(String selectedText, String beforeText, String afterText, uint64_t callbackID)
    InterpretKeyEvent(struct WebKit::EditorState state, bool isCharEvent) -> (bool handled)
    DidReceivePositionInformation(struct WebKit::InteractionInformationAtPosition information)
    SaveImageToLibrary(WebKit::SharedMemory::Handle handle, uint64_t size)
    DidUpdateBlockSelectionWithTouch(uint32_t touch, uint32_t flags, float growThreshold, float shrinkThreshold)
    ShowPlaybackTargetPicker(bool hasVideo, WebCore::IntRect elementRect)
    CommitPotentialTapFailed()
    DidNotHandleTapAsClick(WebCore::IntPoint point)
    DidCompleteSyntheticClick()
    DisableDoubleTapGesturesDuringTapIfNecessary(uint64_t requestID)
    DrawToPDFCallback(IPC::DataReference pdfData, uint64_t callbackID)
    SelectionRectsCallback(Vector<WebCore::SelectionRect> selectionRects, uint64_t callbackID);
#endif
#if ENABLE(DATA_DETECTION)
    SetDataDetectionResult(struct WebKit::DataDetectionResult dataDetectionResult)
#endif
#if PLATFORM(GTK)
    PrintFinishedCallback(WebCore::ResourceError error, uint64_t callbackID)
#endif
#if PLATFORM(COCOA)
    MachSendRightCallback(WebCore::MachSendRight sendRight, uint64_t callbackID)
#endif

    PageScaleFactorDidChange(double scaleFactor)
    PluginScaleFactorDidChange(double zoomFactor)
    PluginZoomFactorDidChange(double zoomFactor)

#if PLATFORM(GTK)
    # Support for connecting the Accessibility worlds of the UI and the Web processes
    BindAccessibilityTree(String plugID)

    SetInputMethodState(bool enabled);
#endif

    # BackForward messages
    BackForwardAddItem(uint64_t itemID)
    BackForwardGoToItem(uint64_t itemID) -> (WebKit::SandboxExtension::Handle sandboxExtensionHandle)
    BackForwardItemAtIndex(int32_t itemIndex) -> (uint64_t itemID)
    BackForwardBackListCount() -> (int32_t count)
    BackForwardForwardListCount() -> (int32_t count)
    BackForwardClear()
    WillGoToBackForwardListItem(uint64_t itemID, WebKit::UserData userData)

    # Undo/Redo messages
    RegisterEditCommandForUndo(uint64_t commandID, uint32_t editAction)
    ClearAllEditCommands()
    RegisterInsertionUndoGrouping()
    CanUndoRedo(uint32_t action) -> (bool result)
    ExecuteUndoRedo(uint32_t action) -> (bool result)

    # Diagnostic messages logging
    LogDiagnosticMessage(String message, String description, enum WebCore::ShouldSample shouldSample)
    LogDiagnosticMessageWithResult(String message, String description, uint32_t result, enum WebCore::ShouldSample shouldSample)
    LogDiagnosticMessageWithValue(String message, String description, double value, unsigned significantFigures, enum WebCore::ShouldSample shouldSample)
    LogDiagnosticMessageWithEnhancedPrivacy(String message, String description, enum WebCore::ShouldSample shouldSample)

    # Performance logging
    LogScrollingEvent(uint32_t eventType, MonotonicTime timestamp, uint64_t data)

    # Editor notifications
    EditorStateChanged(struct WebKit::EditorState editorState)
    CompositionWasCanceled()
    SetHasHadSelectionChangesFromUserInteraction(bool hasHadUserSelectionChanges)
    SetNeedsHiddenContentEditableQuirk(bool needsHiddenContentEditableQuirk)
    SetNeedsPlainTextQuirk(bool needsPlainTextQuirk)

    # Find messages
    DidCountStringMatches(String string, uint32_t matchCount)
    SetTextIndicator(struct WebCore::TextIndicatorData indicator, uint64_t lifetime)
    ClearTextIndicator()
    DidFindString(String string, Vector<WebCore::IntRect> matchRect, uint32_t matchCount, int32_t matchIndex, bool didWrapAround)
    DidFailToFindString(String string)
    DidFindStringMatches(String string, Vector<Vector<WebCore::IntRect>> matches, int32_t firstIndexAfterSelection)
    DidGetImageForFindMatch(WebKit::ShareableBitmap::Handle contentImageHandle, uint32_t matchIndex)

    # PopupMenu messages
    ShowPopupMenu(WebCore::IntRect rect, uint64_t textDirection, Vector<WebKit::WebPopupItem> items, int32_t selectedIndex, struct WebKit::PlatformPopupMenuData data)
    HidePopupMenu()

#if ENABLE(CONTEXT_MENUS)
    ShowContextMenu(WebKit::ContextMenuContextData contextMenuContextData, WebKit::UserData userData)
#endif

    # Authentication messages
    DidReceiveAuthenticationChallenge(uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)

    # Database messages
    ExceededDatabaseQuota(uint64_t frameID, String originIdentifier, String databaseName, String databaseDisplayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage) -> (uint64_t newQuota) Delayed

    # Application cache messages
    ReachedApplicationCacheOriginQuota(String originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded) -> (uint64_t newQuota) Delayed

    # Geolocation messages
    RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
    
#if ENABLE(MEDIA_STREAM)
    # MediaSteam messages
    RequestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, struct WebCore::SecurityOriginData userMediaDocumentOriginIdentifier, struct WebCore::SecurityOriginData topLevelDocumentOriginIdentifier, struct WebCore::MediaConstraints audioConstraints, struct WebCore::MediaConstraints videoConstraints)
    EnumerateMediaDevicesForFrame(uint64_t userMediaID, uint64_t frameID, struct WebCore::SecurityOriginData userMediaDocumentOriginIdentifier, struct WebCore::SecurityOriginData topLevelDocumentOriginIdentifier)
#endif

    # Notification messages
    RequestNotificationPermission(uint64_t requestID, String originIdentifier)
    ShowNotification(String title, String body, String iconURL, String tag, String lang, enum WebCore::NotificationDirection dir, String originIdentifier, uint64_t notificationID)
    CancelNotification(uint64_t notificationID)
    ClearNotifications(Vector<uint64_t> notificationIDs)
    DidDestroyNotification(uint64_t notificationID)

    # Spelling and grammar messages
#if USE(UNIFIED_TEXT_CHECKING)  
    CheckTextOfParagraph(String text, uint64_t checkingTypes, int32_t insertionPoint) -> (Vector<WebCore::TextCheckingResult> results)
#endif
    CheckSpellingOfString(String text) -> (int32_t misspellingLocation, int32_t misspellingLength)
    CheckGrammarOfString(String text) -> (Vector<WebCore::GrammarDetail> results, int32_t badGrammarLocation, int32_t badGrammarLength)
    SpellingUIIsShowing() -> (bool isShowing)
    UpdateSpellingUIWithMisspelledWord(String misspelledWord)
    UpdateSpellingUIWithGrammarString(String badGrammarPhrase, struct WebCore::GrammarDetail grammarDetail)
    GetGuessesForWord(String word, String context, int32_t insertionPoint) -> (Vector<String> guesses)
    LearnWord(String word);
    IgnoreWord(String word);
    RequestCheckingOfString(uint64_t requestID, WebCore::TextCheckingRequestData request, int32_t insertionPoint)

    # Drag and drop messages
#if ENABLE(DRAG_SUPPORT)
    DidPerformDragControllerAction(uint64_t dragOperation, bool mouseIsOverFileInput, unsigned numberOfItemsToBeAccepted, WebCore::IntRect insertionRect)
    DidEndDragging();
#endif
#if PLATFORM(COCOA) && ENABLE(DRAG_SUPPORT)
    SetDragImage(WebCore::IntPoint clientPosition, WebKit::ShareableBitmap::Handle dragImage, std::optional<WebCore::TextIndicatorData> textIndicator, WebCore::FloatPoint dragImageAnchor, uint64_t action)
    SetPromisedDataForImage(String pasteboardName, WebKit::SharedMemory::Handle imageHandle, uint64_t imageSize, String filename, String extension, String title, String url, String visibleURL, WebKit::SharedMemory::Handle archiveHandle, uint64_t archiveSize)
#if ENABLE(ATTACHMENT_ELEMENT)
    SetPromisedDataForAttachment(String pasteboardName, String filename, String extension, String title, String url, String visibleURL)
#endif
#endif
#if PLATFORM(GTK) && ENABLE(DRAG_SUPPORT)
    StartDrag(struct WebKit::WebSelectionData selection, uint64_t dragOperation, WebKit::ShareableBitmap::Handle dragImage)
#endif

#if ENABLE(DATA_INTERACTION)
    DidPerformDataInteractionControllerOperation(bool handled)
    DidHandleStartDataInteractionRequest(bool started)
    DidConcludeEditDataInteraction(std::optional<WebCore::TextIndicatorData> textIndicator)
#endif

#if PLATFORM(COCOA)
    # Dictionary support.
    DidPerformDictionaryLookup(struct WebCore::DictionaryPopupInfo dictionaryPopupInfo)

    # Keyboard input support messages
    ExecuteSavedCommandBySelector(String selector) -> (bool handled)

    # Remote accessibility messages
    RegisterWebProcessAccessibilityToken(IPC::DataReference data)

    # Plug-in complex text input support messages
    PluginFocusOrWindowFocusChanged(uint64_t pluginComplexTextInputIdentifier, bool pluginHasFocusAndWindowHasFocus)
    SetPluginComplexTextInputState(uint64_t pluginComplexTextInputIdentifier, uint64_t complexTextInputState)

    # Speech messages
    GetIsSpeaking() -> (bool isSpeaking)
    Speak(String string)
    StopSpeaking()

    MakeFirstResponder()

    # Spotlight
    SearchWithSpotlight(String string)

    SearchTheWeb(String string)
#endif

#if USE(APPKIT)
    SubstitutionsPanelIsShowing() -> (bool isShowing)
#endif
#if USE(AUTOMATIC_TEXT_REPLACEMENT)
    toggleSmartInsertDelete()
    toggleAutomaticQuoteSubstitution()
    toggleAutomaticLinkDetection()
    toggleAutomaticDashSubstitution()
    toggleAutomaticTextReplacement()
#endif
#if PLATFORM(MAC)
    # Autocorrection messages
    ShowCorrectionPanel(int32_t panelType, WebCore::FloatRect boundingBoxOfReplacedString, String replacedString, String replacementString, Vector<String> alternativeReplacementStrings)
    DismissCorrectionPanel(int32_t reason)
    DismissCorrectionPanelSoon(int32_t reason) -> (String result)
    RecordAutocorrectionResponse(int32_t response, String replacedString, String replacementString);

    SetEditableElementIsFocused(bool editableElementIsFocused)
#endif

#if USE(DICTATION_ALTERNATIVES)
    ShowDictationAlternativeUI(WebCore::FloatRect boundingBoxOfDictatedText, uint64_t dictationContext)
    RemoveDictationAlternatives(uint64_t dictationContext)
    DictationAlternatives(uint64_t dictationContext) -> (Vector<String> alternatives)
#endif

#if PLUGIN_ARCHITECTURE(X11)
    # X11 windowed plugin messages
    CreatePluginContainer() -> (uint64_t windowID)
    WindowedPluginGeometryDidChange(WebCore::IntRect frameRect, WebCore::IntRect clipRect, uint64_t windowID)
    WindowedPluginVisibilityDidChange(bool isVisible, uint64_t windowID)
#endif

#if PLATFORM(IOS)
    DynamicViewportUpdateChangedTarget(double newTargetScale, WebCore::FloatPoint newScrollPosition, uint64_t dynamicViewportSizeUpdateID)
    CouldNotRestorePageState()
    RestorePageState(std::optional<WebCore::FloatPoint> scrollPosition, WebCore::FloatPoint scrollOrigin, WebCore::BoxExtent<float> obscuredInsetsOnSave, double scale)
    RestorePageCenterAndScale(std::optional<WebCore::FloatPoint> unobscuredCenter, double scale)
    DidGetTapHighlightGeometries(uint64_t requestID, WebCore::Color color, Vector<WebCore::FloatQuad> geometries, WebCore::IntSize topLeftRadius, WebCore::IntSize topRightRadius, WebCore::IntSize bottomLeftRadius, WebCore::IntSize bottomRightRadius)

    StartAssistingNode(struct WebKit::AssistedNodeInformation information, bool userIsInteracting, bool blurPreviousNode, WebKit::UserData userData)
    StopAssistingNode()
    OverflowScrollWillStartScroll()
    OverflowScrollDidEndScroll()
    ShowInspectorHighlight(struct WebCore::Highlight highlight)
    HideInspectorHighlight()

    ShowInspectorIndication()
    HideInspectorIndication()

    EnableInspectorNodeSearch()
    DisableInspectorNodeSearch()
#endif

    # Search popup menus
    SaveRecentSearches(String name, Vector<WebCore::RecentSearch> searchItems)
    LoadRecentSearches(String name) -> (Vector<WebCore::RecentSearch> result)

    SavePDFToFileInDownloadsFolder(String suggestedFilename, String originatingURLString, IPC::DataReference data)

#if PLATFORM(COCOA)
    SavePDFToTemporaryFolderAndOpenWithNativeApplication(String suggestedFilename, String originatingURLString, IPC::DataReference data, String pdfUUID)
    OpenPDFFromTemporaryFolderWithNativeApplication(String pdfUUID)
#endif

#if ENABLE(NETSCAPE_PLUGIN_API)
    FindPlugin(String mimeType, uint32_t processType, String urlString, String frameURLString, String pageURLString, bool allowOnlyApplicationPlugins) -> (uint64_t pluginProcessToken, String newMIMEType, uint32_t pluginLoadPolicy, String unavailabilityDescription)
#endif

    DidUpdateActivityState()

    DidSaveToPageCache()

#if ENABLE(SUBTLE_CRYPTO)
    WrapCryptoKey(Vector<uint8_t> key) -> (bool succeeded, Vector<uint8_t> wrappedKey)
    UnwrapCryptoKey(Vector<uint8_t> wrappedKey) -> (bool succeeded, Vector<uint8_t> key)
#endif


#if ENABLE(TELEPHONE_NUMBER_DETECTION)
#if PLATFORM(MAC)
    ShowTelephoneNumberMenu(String telephoneNumber, WebCore::IntPoint point)
#endif
#endif

#if USE(QUICK_LOOK)
    DidStartLoadForQuickLookDocumentInMainFrame(String fileName, String uti)
    DidFinishLoadForQuickLookDocumentInMainFrame(WebKit::QuickLookDocumentData data)
    DidRequestPasswordForQuickLookDocumentInMainFrame(String fileName)
#endif

#if ENABLE(CONTENT_FILTERING)
    ContentFilterDidBlockLoadForFrame(WebCore::ContentFilterUnblockHandler unblockHandler, uint64_t frameID)
#endif

    IsPlayingMediaDidChange(unsigned state, uint64_t sourceElementID)
    HandleAutoplayEvent(enum WebCore::AutoplayEvent event, OptionSet<WebCore::AutoplayEventFlags> flags)

#if ENABLE(MEDIA_SESSION)
    HasMediaSessionWithActiveMediaElementsDidChange(bool state)
    MediaSessionMetadataDidChange(WebCore::MediaSessionMetadata metadata);
    FocusedContentMediaElementDidChange(uint64_t elementID)
#endif

#if PLATFORM(MAC)
    DidPerformImmediateActionHitTest(struct WebKit::WebHitTestResultData result, bool contentPreventsDefault, WebKit::UserData userData)
#endif
    HandleMessage(String messageName, WebKit::UserData messageBody) WantsConnection
    HandleSynchronousMessage(String messageName, WebKit::UserData messageBody) -> (WebKit::UserData returnData) WantsConnection

    HandleAutoFillButtonClick(WebKit::UserData userData);

#if ENABLE(WIRELESS_PLAYBACK_TARGET) && !PLATFORM(IOS)
    AddPlaybackTargetPickerClient(uint64_t contextId)
    RemovePlaybackTargetPickerClient(uint64_t contextId)
    ShowPlaybackTargetPicker(uint64_t clientId, WebCore::FloatRect pickerLocation, bool hasVideo)
    PlaybackTargetPickerClientStateDidChange(uint64_t contextId, unsigned mediaState)
    SetMockMediaPlaybackTargetPickerEnabled(bool enabled)
    SetMockMediaPlaybackTargetPickerState(String name, unsigned pickerState)
#endif

#if ENABLE(POINTER_LOCK)
    RequestPointerLock()
    RequestPointerUnlock()
#endif

    ImageOrMediaDocumentSizeChanged(WebCore::IntSize newSize)

    UseFixedLayoutDidChange(bool useFixedLayout)
    FixedLayoutSizeDidChange(WebCore::IntSize fixedLayoutSize)

#if ENABLE(VIDEO) && USE(GSTREAMER)
    RequestInstallMissingMediaPlugins(String details, String description)
#endif

    DidRestoreScrollPosition()

    GetLoadDecisionForIcon(struct WebCore::LinkIcon icon, uint64_t callbackID)
    FinishedLoadingIcon(uint64_t callbackIdentifier, IPC::DataReference data);

#if PLATFORM(MAC)
    DidHandleAcceptedCandidate()
#endif

#if PLATFORM(COCOA)
    HandleActiveNowPlayingSessionInfoResponse(bool hasActiveSession, String title, double duration, double elapsedTime)
#endif

    SetIsUsingHighPerformanceWebGL(bool isUsingHighPerformanceWebGL)

    StartURLSchemeTask(uint64_t loaderIdentifier, uint64_t resourceIdentifier, WebCore::ResourceRequest request)
    StopURLSchemeTask(uint64_t loaderIdentifier, uint64_t resourceIdentifier)
}
