source: webkit/trunk/Source/WebCore/rendering/RenderSlider.cpp

Last change on this file was 294728, checked in by [email protected], 3 years ago

Remove RenderSliderThumb
https://bugs.webkit.org/show_bug.cgi?id=240794

Reviewed by Antti Koivisto.

Test: imported/w3c/web-platform-tests/css/css-ui/appearance-cssom-001.html

  • Source/WebCore/html/shadow/SliderThumbElement.cpp:

(WebCore::SliderThumbElement::resolveCustomStyle):
(WebCore::SliderContainerElement::resolveCustomStyle):
(WebCore::RenderSliderThumb::RenderSliderThumb): Deleted.
(WebCore::RenderSliderThumb::updateAppearance): Deleted.
(WebCore::RenderSliderThumb::isSliderThumb const): Deleted.
(WebCore::SliderThumbElement::createElementRenderer): Deleted.

  • Source/WebCore/html/shadow/SliderThumbElement.h:
  • Source/WebCore/rendering/RenderObject.h:

(WebCore::RenderObject::isSlider const):
(WebCore::RenderObject::isSliderThumb const): Deleted.

  • Source/WebCore/rendering/RenderSlider.cpp:

(WebCore::RenderSlider::layout): Deleted.

  • Source/WebCore/rendering/RenderSlider.h:

Canonical link: https://commits.webkit.org/250906@main

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1/*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 *
19 */
20
21#include "config.h"
22#include "RenderSlider.h"
23
24#include "CSSPropertyNames.h"
25#include "Document.h"
26#include "Event.h"
27#include "Frame.h"
28#include "HTMLInputElement.h"
29#include "HTMLNames.h"
30#include "HTMLParserIdioms.h"
31#include "MouseEvent.h"
32#include "Node.h"
33#include "RenderLayer.h"
34#include "RenderTheme.h"
35#include "RenderView.h"
36#include "ShadowRoot.h"
37#include "SliderThumbElement.h"
38#include "StepRange.h"
39#include "StyleResolver.h"
40#include <wtf/IsoMallocInlines.h>
41#include <wtf/MathExtras.h>
42#include <wtf/StackStats.h>
43
44namespace WebCore {
45
46WTF_MAKE_ISO_ALLOCATED_IMPL(RenderSlider);
47
48const int RenderSlider::defaultTrackLength = 129;
49
50RenderSlider::RenderSlider(HTMLInputElement& element, RenderStyle&& style)
51 : RenderFlexibleBox(element, WTFMove(style))
52{
53 // We assume RenderSlider works only with <input type=range>.
54 ASSERT(element.isRangeControl());
55}
56
57RenderSlider::~RenderSlider() = default;
58
59HTMLInputElement& RenderSlider::element() const
60{
61 return downcast<HTMLInputElement>(nodeForNonAnonymous());
62}
63
64LayoutUnit RenderSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode) const
65{
66 // FIXME: Patch this function for writing-mode.
67 return height() + marginTop();
68}
69
70void RenderSlider::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
71{
72 if (shouldApplySizeContainment())
73 return;
74 maxLogicalWidth = defaultTrackLength * style().effectiveZoom();
75 if (!style().width().isPercentOrCalculated())
76 minLogicalWidth = maxLogicalWidth;
77}
78
79void RenderSlider::computePreferredLogicalWidths()
80{
81 m_minPreferredLogicalWidth = 0;
82 m_maxPreferredLogicalWidth = 0;
83
84 if (style().width().isFixed() && style().width().value() > 0)
85 m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style().width());
86 else
87 computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
88
89 RenderBox::computePreferredLogicalWidths(style().minWidth(), style().maxWidth(), horizontalBorderAndPaddingExtent());
90
91 setPreferredLogicalWidthsDirty(false);
92}
93
94bool RenderSlider::inDragMode() const
95{
96 return element().sliderThumbElement()->active();
97}
98
99double RenderSlider::valueRatio() const
100{
101 auto& element = this->element();
102
103 auto min = element.minimum();
104 auto max = element.maximum();
105 auto value = element.valueAsNumber();
106
107 if (max <= min)
108 return 0;
109 return (value - min) / (max - min);
110}
111
112} // namespace WebCore
Note: See TracBrowser for help on using the repository browser.