| 1 | /* |
| 2 | * Copyright (C) 2014-2018 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 | #pragma once |
| 27 | |
| 28 | #include "ArgumentCoders.h" |
| 29 | #include <WebCore/AutocapitalizeTypes.h> |
| 30 | #include <WebCore/Autofill.h> |
| 31 | #include <WebCore/Color.h> |
| 32 | #include <WebCore/GraphicsLayer.h> |
| 33 | #include <WebCore/InputMode.h> |
| 34 | #include <WebCore/IntRect.h> |
| 35 | #include <wtf/URL.h> |
| 36 | #include <wtf/text/WTFString.h> |
| 37 | |
| 38 | namespace WebKit { |
| 39 | |
| 40 | enum class InputType { |
| 41 | None, |
| 42 | ContentEditable, |
| 43 | Text, |
| 44 | Password, |
| 45 | TextArea, |
| 46 | Search, |
| 47 | Email, |
| 48 | URL, |
| 49 | Phone, |
| 50 | Number, |
| 51 | NumberPad, |
| 52 | Date, |
| 53 | DateTime, |
| 54 | DateTimeLocal, |
| 55 | Month, |
| 56 | Week, |
| 57 | Time, |
| 58 | Select, |
| 59 | Drawing, |
| 60 | #if ENABLE(INPUT_TYPE_COLOR) |
| 61 | Color |
| 62 | #endif |
| 63 | }; |
| 64 | |
| 65 | #if PLATFORM(IOS_FAMILY) |
| 66 | struct OptionItem { |
| 67 | OptionItem() { } |
| 68 | |
| 69 | OptionItem(const OptionItem& item) |
| 70 | : text(item.text) |
| 71 | , isGroup(item.isGroup) |
| 72 | , isSelected(item.isSelected) |
| 73 | , disabled(item.disabled) |
| 74 | , parentGroupID(item.parentGroupID) |
| 75 | { |
| 76 | } |
| 77 | |
| 78 | OptionItem(const String& text, bool isGroup, int parentID, bool selected, bool disabled) |
| 79 | : text(text) |
| 80 | , isGroup(isGroup) |
| 81 | , isSelected(selected) |
| 82 | , disabled(disabled) |
| 83 | , parentGroupID(parentID) |
| 84 | { |
| 85 | } |
| 86 | String text; |
| 87 | bool isGroup { false }; |
| 88 | bool isSelected { false }; |
| 89 | bool disabled { false }; |
| 90 | int parentGroupID { 0 }; |
| 91 | |
| 92 | void encode(IPC::Encoder&) const; |
| 93 | static Optional<OptionItem> decode(IPC::Decoder&); |
| 94 | }; |
| 95 | |
| 96 | using FocusedElementIdentifier = uint64_t; |
| 97 | |
| 98 | struct FocusedElementInformation { |
| 99 | WebCore::IntRect elementRect; |
| 100 | WebCore::IntPoint lastInteractionLocation; |
| 101 | double minimumScaleFactor { -INFINITY }; |
| 102 | double maximumScaleFactor { INFINITY }; |
| 103 | double maximumScaleFactorIgnoringAlwaysScalable { INFINITY }; |
| 104 | double nodeFontSize { 0 }; |
| 105 | bool hasNextNode { false }; |
| 106 | WebCore::IntRect nextNodeRect; |
| 107 | bool hasPreviousNode { false }; |
| 108 | WebCore::IntRect previousNodeRect; |
| 109 | bool isAutocorrect { false }; |
| 110 | bool isRTL { false }; |
| 111 | bool isMultiSelect { false }; |
| 112 | bool isReadOnly {false }; |
| 113 | bool allowsUserScaling { false }; |
| 114 | bool allowsUserScalingIgnoringAlwaysScalable { false }; |
| 115 | bool insideFixedPosition { false }; |
| 116 | AutocapitalizeType autocapitalizeType { AutocapitalizeTypeDefault }; |
| 117 | InputType elementType { InputType::None }; |
| 118 | WebCore::InputMode inputMode { WebCore::InputMode::Unspecified }; |
| 119 | String formAction; |
| 120 | Vector<OptionItem> selectOptions; |
| 121 | int selectedIndex { -1 }; |
| 122 | String value; |
| 123 | double valueAsNumber { 0 }; |
| 124 | String title; |
| 125 | bool acceptsAutofilledLoginCredentials { false }; |
| 126 | bool isAutofillableUsernameField { false }; |
| 127 | URL representingPageURL; |
| 128 | WebCore::AutofillFieldName autofillFieldName { WebCore::AutofillFieldName::None }; |
| 129 | String placeholder; |
| 130 | String label; |
| 131 | String ariaLabel; |
| 132 | WebCore::GraphicsLayer::EmbeddedViewID embeddedViewID; |
| 133 | #if ENABLE(DATALIST_ELEMENT) |
| 134 | bool hasSuggestions { false }; |
| 135 | #if ENABLE(INPUT_TYPE_COLOR) |
| 136 | Vector<WebCore::Color> suggestedColors; |
| 137 | #endif |
| 138 | #endif |
| 139 | bool shouldSynthesizeKeyEventsForUndoAndRedo { false }; |
| 140 | |
| 141 | FocusedElementIdentifier focusedElementIdentifier { 0 }; |
| 142 | |
| 143 | void encode(IPC::Encoder&) const; |
| 144 | static bool decode(IPC::Decoder&, FocusedElementInformation&); |
| 145 | }; |
| 146 | #endif |
| 147 | |
| 148 | } |
| 149 | |