1/*
2 * Copyright (C) 2014 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 AssistedNodeInformation_h
27#define AssistedNodeInformation_h
28
29#include "ArgumentCoders.h"
30#include <WebCore/IntRect.h>
31#include <WebCore/WebAutocapitalize.h>
32#include <wtf/text/WTFString.h>
33
34namespace WebKit {
35
36enum class InputType {
37    None,
38    ContentEditable,
39    Text,
40    Password,
41    TextArea,
42    Search,
43    Email,
44    URL,
45    Phone,
46    Number,
47    NumberPad,
48    Date,
49    DateTime,
50    DateTimeLocal,
51    Month,
52    Week,
53    Time,
54    Select
55};
56
57#if PLATFORM(IOS)
58struct OptionItem {
59    OptionItem()
60        : isGroup(false)
61        , isSelected(false)
62        , disabled(false)
63        , parentGroupID(0)
64    {
65    }
66
67    OptionItem(const OptionItem& item)
68        : text(item.text)
69        , isGroup(item.isGroup)
70        , isSelected(item.isSelected)
71        , disabled(item.disabled)
72        , parentGroupID(item.parentGroupID)
73    {
74    }
75
76    OptionItem(const String& text, bool isGroup, int parentID, bool selected, bool disabled)
77        : text(text)
78        , isGroup(isGroup)
79        , isSelected(selected)
80        , disabled(disabled)
81        , parentGroupID(parentID)
82    {
83    }
84    String text;
85    bool isGroup;
86    bool isSelected;
87    bool disabled;
88    int parentGroupID;
89
90    void encode(IPC::ArgumentEncoder&) const;
91    static bool decode(IPC::ArgumentDecoder&, OptionItem&);
92};
93
94struct AssistedNodeInformation {
95    AssistedNodeInformation()
96        : minimumScaleFactor(-INFINITY)
97        , maximumScaleFactor(INFINITY)
98        , nodeFontSize(0)
99        , hasNextNode(false)
100        , hasPreviousNode(false)
101        , isAutocorrect(false)
102        , isMultiSelect(false)
103        , isReadOnly(false)
104        , allowsUserScaling(false)
105        , insideFixedPosition(false)
106        , autocapitalizeType(WebAutocapitalizeTypeDefault)
107        , elementType(InputType::None)
108        , selectedIndex(-1)
109        , valueAsNumber(0)
110    {
111    }
112
113    WebCore::IntRect elementRect;
114    WebCore::IntRect selectionRect;
115    double minimumScaleFactor;
116    double maximumScaleFactor;
117    double nodeFontSize;
118    bool hasNextNode;
119    bool hasPreviousNode;
120    bool isAutocorrect;
121    bool isMultiSelect;
122    bool isReadOnly;
123    bool allowsUserScaling;
124    bool insideFixedPosition;
125    WebAutocapitalizeType autocapitalizeType;
126    InputType elementType;
127    String formAction;
128    Vector<OptionItem> selectOptions;
129    int selectedIndex;
130    String value;
131    double valueAsNumber;
132    String title;
133
134    void encode(IPC::ArgumentEncoder&) const;
135    static bool decode(IPC::ArgumentDecoder&, AssistedNodeInformation&);
136};
137#endif
138
139}
140
141#endif // InteractionInformationAtPosition_h
142