1/*
2 * Copyright (C) 2006, 2008, 2010, 2014 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27#pragma once
28
29#include "HTMLDivElement.h"
30#include <wtf/Forward.h>
31
32namespace WebCore {
33
34class RenderTextControlInnerBlock;
35
36class TextControlInnerContainer final : public HTMLDivElement {
37 WTF_MAKE_ISO_ALLOCATED(TextControlInnerContainer);
38public:
39 static Ref<TextControlInnerContainer> create(Document&);
40protected:
41 TextControlInnerContainer(Document&);
42 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
43 Optional<ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;
44};
45
46class TextControlInnerElement final : public HTMLDivElement {
47 WTF_MAKE_ISO_ALLOCATED(TextControlInnerElement);
48public:
49 static Ref<TextControlInnerElement> create(Document&);
50
51protected:
52 TextControlInnerElement(Document&);
53 Optional<ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;
54
55private:
56 bool isMouseFocusable() const override { return false; }
57};
58
59class TextControlInnerTextElement final : public HTMLDivElement {
60 WTF_MAKE_ISO_ALLOCATED(TextControlInnerTextElement);
61public:
62 static Ref<TextControlInnerTextElement> create(Document&);
63
64 void defaultEventHandler(Event&) override;
65
66 RenderTextControlInnerBlock* renderer() const;
67
68private:
69 TextControlInnerTextElement(Document&);
70 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
71 Optional<ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;
72 bool isMouseFocusable() const override { return false; }
73 bool isTextControlInnerTextElement() const override { return true; }
74};
75
76class TextControlPlaceholderElement final : public HTMLDivElement {
77 WTF_MAKE_ISO_ALLOCATED(TextControlPlaceholderElement);
78public:
79 static Ref<TextControlPlaceholderElement> create(Document&);
80
81private:
82 TextControlPlaceholderElement(Document&);
83
84 Optional<ElementStyle> resolveCustomStyle(const RenderStyle& parentStyle, const RenderStyle* shadowHostStyle) override;
85};
86
87class SearchFieldResultsButtonElement final : public HTMLDivElement {
88 WTF_MAKE_ISO_ALLOCATED(SearchFieldResultsButtonElement);
89public:
90 static Ref<SearchFieldResultsButtonElement> create(Document&);
91
92 void defaultEventHandler(Event&) override;
93#if !PLATFORM(IOS_FAMILY)
94 bool willRespondToMouseClickEvents() override;
95#endif
96
97private:
98 SearchFieldResultsButtonElement(Document&);
99 bool isMouseFocusable() const override { return false; }
100};
101
102class SearchFieldCancelButtonElement final : public HTMLDivElement {
103 WTF_MAKE_ISO_ALLOCATED(SearchFieldCancelButtonElement);
104public:
105 static Ref<SearchFieldCancelButtonElement> create(Document&);
106
107 void defaultEventHandler(Event&) override;
108#if !PLATFORM(IOS_FAMILY)
109 bool willRespondToMouseClickEvents() override;
110#endif
111
112private:
113 SearchFieldCancelButtonElement(Document&);
114 bool isMouseFocusable() const override { return false; }
115};
116
117} // namespace WebCore
118
119SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::TextControlInnerTextElement)
120 static bool isType(const WebCore::HTMLElement& element) { return element.isTextControlInnerTextElement(); }
121 static bool isType(const WebCore::Node& node) { return is<WebCore::HTMLElement>(node) && isType(downcast<WebCore::HTMLElement>(node)); }
122SPECIALIZE_TYPE_TRAITS_END()
123