| 1 | /* |
| 2 | * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * 1. Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * 2. Redistributions in binary form must reproduce the above copyright |
| 10 | * notice, this list of conditions and the following disclaimer in the |
| 11 | * documentation and/or other materials provided with the distribution. |
| 12 | * |
| 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
| 14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
| 17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 23 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | #ifndef WKBundlePageEditorClient_h |
| 27 | #define WKBundlePageEditorClient_h |
| 28 | |
| 29 | #include <WebKit/WKBase.h> |
| 30 | |
| 31 | enum { |
| 32 | kWKInsertActionTyped = 0, |
| 33 | kWKInsertActionPasted = 1, |
| 34 | kWKInsertActionDropped = 2 |
| 35 | }; |
| 36 | typedef uint32_t WKInsertActionType; |
| 37 | |
| 38 | enum { |
| 39 | kWKAffinityUpstream, |
| 40 | kWKAffinityDownstream |
| 41 | }; |
| 42 | typedef uint32_t WKAffinityType; |
| 43 | |
| 44 | enum { |
| 45 | WKInputFieldActionTypeMoveUp, |
| 46 | WKInputFieldActionTypeMoveDown, |
| 47 | WKInputFieldActionTypeCancel, |
| 48 | WKInputFieldActionTypeInsertTab, |
| 49 | WKInputFieldActionTypeInsertBacktab, |
| 50 | WKInputFieldActionTypeInsertNewline, |
| 51 | WKInputFieldActionTypeInsertDelete |
| 52 | }; |
| 53 | typedef uint32_t WKInputFieldActionType; |
| 54 | |
| 55 | typedef bool (*WKBundlePageShouldBeginEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); |
| 56 | typedef bool (*WKBundlePageShouldEndEditingCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); |
| 57 | typedef bool (*WKBundlePageShouldInsertNodeCallback)(WKBundlePageRef page, WKBundleNodeHandleRef node, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); |
| 58 | typedef bool (*WKBundlePageShouldInsertTextCallback)(WKBundlePageRef page, WKStringRef string, WKBundleRangeHandleRef rangeToReplace, WKInsertActionType action, const void* clientInfo); |
| 59 | typedef bool (*WKBundlePageShouldDeleteRangeCallback)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); |
| 60 | typedef bool (*WKBundlePageShouldChangeSelectedRange)(WKBundlePageRef page, WKBundleRangeHandleRef fromRange, WKBundleRangeHandleRef toRange, WKAffinityType affinity, bool stillSelecting, const void* clientInfo); |
| 61 | typedef bool (*WKBundlePageShouldApplyStyle)(WKBundlePageRef page, WKBundleCSSStyleDeclarationRef style, WKBundleRangeHandleRef range, const void* clientInfo); |
| 62 | typedef void (*WKBundlePageEditingNotification)(WKBundlePageRef page, WKStringRef notificationName, const void* clientInfo); |
| 63 | typedef void (*WKBundlePageWillWriteToPasteboard)(WKBundlePageRef page, WKBundleRangeHandleRef range, const void* clientInfo); |
| 64 | typedef void (*WKBundlePageGetPasteboardDataForRange)(WKBundlePageRef page, WKBundleRangeHandleRef range, WKArrayRef* pasteboardTypes, WKArrayRef* pasteboardData, const void* clientInfo); |
| 65 | typedef WKStringRef (*)(WKBundlePageRef, WKDataRef resourceData, WKStringRef mimeType, const void* clientInfo); |
| 66 | typedef void (*WKBundlePageDidWriteToPasteboard)(WKBundlePageRef page, const void* clientInfo); |
| 67 | typedef bool (*WKBundlePagePerformTwoStepDrop)(WKBundlePageRef page, WKBundleNodeHandleRef fragment, WKBundleRangeHandleRef destination, bool isMove, const void* clientInfo); |
| 68 | |
| 69 | typedef struct WKBundlePageEditorClientBase { |
| 70 | int version; |
| 71 | const void * clientInfo; |
| 72 | } WKBundlePageEditorClientBase; |
| 73 | |
| 74 | typedef struct WKBundlePageEditorClientV0 { |
| 75 | WKBundlePageEditorClientBase base; |
| 76 | |
| 77 | // Version 0. |
| 78 | WKBundlePageShouldBeginEditingCallback shouldBeginEditing; |
| 79 | WKBundlePageShouldEndEditingCallback shouldEndEditing; |
| 80 | WKBundlePageShouldInsertNodeCallback shouldInsertNode; |
| 81 | WKBundlePageShouldInsertTextCallback shouldInsertText; |
| 82 | WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; |
| 83 | WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; |
| 84 | WKBundlePageShouldApplyStyle shouldApplyStyle; |
| 85 | WKBundlePageEditingNotification didBeginEditing; |
| 86 | WKBundlePageEditingNotification didEndEditing; |
| 87 | WKBundlePageEditingNotification didChange; |
| 88 | WKBundlePageEditingNotification didChangeSelection; |
| 89 | } WKBundlePageEditorClientV0; |
| 90 | |
| 91 | typedef struct WKBundlePageEditorClientV1 { |
| 92 | WKBundlePageEditorClientBase base; |
| 93 | |
| 94 | // Version 0. |
| 95 | WKBundlePageShouldBeginEditingCallback shouldBeginEditing; |
| 96 | WKBundlePageShouldEndEditingCallback shouldEndEditing; |
| 97 | WKBundlePageShouldInsertNodeCallback shouldInsertNode; |
| 98 | WKBundlePageShouldInsertTextCallback shouldInsertText; |
| 99 | WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; |
| 100 | WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; |
| 101 | WKBundlePageShouldApplyStyle shouldApplyStyle; |
| 102 | WKBundlePageEditingNotification didBeginEditing; |
| 103 | WKBundlePageEditingNotification didEndEditing; |
| 104 | WKBundlePageEditingNotification didChange; |
| 105 | WKBundlePageEditingNotification didChangeSelection; |
| 106 | |
| 107 | // Version 1. |
| 108 | WKBundlePageWillWriteToPasteboard willWriteToPasteboard; |
| 109 | WKBundlePageGetPasteboardDataForRange getPasteboardDataForRange; |
| 110 | WKBundlePageDidWriteToPasteboard didWriteToPasteboard; |
| 111 | WKBundlePagePerformTwoStepDrop performTwoStepDrop; |
| 112 | } WKBundlePageEditorClientV1; |
| 113 | |
| 114 | typedef struct WKBundlePageEditorClientV2 { |
| 115 | WKBundlePageEditorClientBase base; |
| 116 | |
| 117 | // Version 0. |
| 118 | WKBundlePageShouldBeginEditingCallback shouldBeginEditing; |
| 119 | WKBundlePageShouldEndEditingCallback shouldEndEditing; |
| 120 | WKBundlePageShouldInsertNodeCallback shouldInsertNode; |
| 121 | WKBundlePageShouldInsertTextCallback shouldInsertText; |
| 122 | WKBundlePageShouldDeleteRangeCallback shouldDeleteRange; |
| 123 | WKBundlePageShouldChangeSelectedRange shouldChangeSelectedRange; |
| 124 | WKBundlePageShouldApplyStyle shouldApplyStyle; |
| 125 | WKBundlePageEditingNotification didBeginEditing; |
| 126 | WKBundlePageEditingNotification didEndEditing; |
| 127 | WKBundlePageEditingNotification didChange; |
| 128 | WKBundlePageEditingNotification didChangeSelection; |
| 129 | |
| 130 | // Version 1. |
| 131 | WKBundlePageWillWriteToPasteboard willWriteToPasteboard; |
| 132 | WKBundlePageGetPasteboardDataForRange getPasteboardDataForRange; |
| 133 | WKBundlePageDidWriteToPasteboard didWriteToPasteboard; |
| 134 | WKBundlePagePerformTwoStepDrop performTwoStepDrop; |
| 135 | |
| 136 | // Version 2. |
| 137 | WKBundlePageReplacementURLForResource replacementURLForResource; |
| 138 | } WKBundlePageEditorClientV2; |
| 139 | |
| 140 | #endif // WKBundlePageEditorClient_h |
| 141 | |