2 * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2010 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "HTMLDivElement.h"
35 #include "RenderBlockFlow.h"
36 #include <wtf/Forward.h>
40 class HTMLInputElement;
44 class SliderThumbElement final : public HTMLDivElement {
46 static Ref<SliderThumbElement> create(Document&);
48 void setPositionFromValue();
49 void dragFrom(const LayoutPoint&);
50 HTMLInputElement* hostInput() const;
51 void setPositionFromPoint(const LayoutPoint&);
53 #if ENABLE(IOS_TOUCH_EVENTS)
54 void handleTouchEvent(TouchEvent&);
57 void disabledAttributeChanged();
60 SliderThumbElement(Document&);
62 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
64 Ref<Element> cloneElementWithoutAttributesAndChildren(Document&) override;
65 bool isDisabledFormControl() const override;
66 bool matchesReadWritePseudoClass() const override;
67 Element* focusDelegate() override;
69 void defaultEventHandler(Event&) override;
70 bool willRespondToMouseMoveEvents() override;
71 bool willRespondToMouseClickEvents() override;
74 #if ENABLE(IOS_TOUCH_EVENTS)
75 void didAttachRenderers() override;
77 void willDetachRenderers() override;
79 std::optional<ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) override;
80 const AtomicString& shadowPseudoId() const override;
85 #if ENABLE(IOS_TOUCH_EVENTS)
86 unsigned exclusiveTouchIdentifier() const;
87 void setExclusiveTouchIdentifier(unsigned);
88 void clearExclusiveTouchIdentifier();
90 void handleTouchStart(TouchEvent&);
91 void handleTouchMove(TouchEvent&);
92 void handleTouchEndAndCancel(TouchEvent&);
94 bool shouldAcceptTouchEvents();
95 void registerForTouchEvents();
96 void unregisterForTouchEvents();
99 AtomicString m_shadowPseudoId;
102 #if ENABLE(IOS_TOUCH_EVENTS)
103 // FIXME: Currently it is safe to use 0, but this may need to change
104 // if touch identifiers change in the future and can be 0.
105 static const unsigned NoIdentifier = 0;
106 unsigned m_exclusiveTouchIdentifier;
107 bool m_isRegisteredAsTouchEventListener;
111 inline Ref<SliderThumbElement> SliderThumbElement::create(Document& document)
113 return adoptRef(*new SliderThumbElement(document));
116 // --------------------------------
118 class RenderSliderThumb final : public RenderBlockFlow {
120 RenderSliderThumb(SliderThumbElement&, RenderStyle&&);
121 void updateAppearance(const RenderStyle* parentStyle);
124 bool isSliderThumb() const override;
127 // --------------------------------
129 class SliderContainerElement final : public HTMLDivElement {
131 static Ref<SliderContainerElement> create(Document&);
134 SliderContainerElement(Document&);
135 RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) override;
136 std::optional<ElementStyle> resolveCustomStyle(const RenderStyle&, const RenderStyle*) override;
137 const AtomicString& shadowPseudoId() const override;
138 bool isSliderContainerElement() const override { return true; }
140 AtomicString m_shadowPseudoId;
143 } // namespace WebCore
145 SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SliderContainerElement)
146 static bool isType(const WebCore::Element& element) { return element.isSliderContainerElement(); }
147 static bool isType(const WebCore::Node& node) { return is<WebCore::Element>(node) && isType(downcast<WebCore::Element>(node)); }
148 SPECIALIZE_TYPE_TRAITS_END()