Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / Source / core / layout / LayoutSlider.cpp
blob4684dc61c0c736e7a20e1734ac891e192bcb2a10
1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
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.
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.
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.
21 #include "config.h"
22 #include "core/layout/LayoutSlider.h"
24 #include "core/InputTypeNames.h"
25 #include "core/dom/shadow/ShadowRoot.h"
26 #include "core/html/HTMLInputElement.h"
27 #include "core/html/shadow/ShadowElementNames.h"
28 #include "core/html/shadow/SliderThumbElement.h"
29 #include "core/layout/LayoutSliderThumb.h"
30 #include "wtf/MathExtras.h"
32 using namespace::std;
34 namespace blink {
36 const int LayoutSlider::defaultTrackLength = 129;
38 LayoutSlider::LayoutSlider(HTMLInputElement* element)
39 : LayoutFlexibleBox(element)
41 // We assume LayoutSlider works only with <input type=range>.
42 ASSERT(element->type() == InputTypeNames::range);
45 LayoutSlider::~LayoutSlider()
49 int LayoutSlider::baselinePosition(FontBaseline, bool /*firstLine*/, LineDirectionMode, LinePositionMode linePositionMode) const
51 ASSERT(linePositionMode == PositionOnContainingLine);
52 // FIXME: Patch this function for writing-mode.
53 return size().height() + marginTop();
56 void LayoutSlider::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
58 maxLogicalWidth = defaultTrackLength * style()->effectiveZoom();
59 if (!style()->width().hasPercent())
60 minLogicalWidth = maxLogicalWidth;
63 inline SliderThumbElement* LayoutSlider::sliderThumbElement() const
65 return toSliderThumbElement(toElement(node())->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderThumb()));
68 void LayoutSlider::layout()
70 // FIXME: Find a way to cascade appearance.
71 // http://webkit.org/b/62535
72 LayoutBox* thumbBox = sliderThumbElement()->layoutBox();
73 if (thumbBox && thumbBox->isSliderThumb())
74 toLayoutSliderThumb(thumbBox)->updateAppearance(styleRef());
76 LayoutFlexibleBox::layout();
79 bool LayoutSlider::inDragMode() const
81 return sliderThumbElement()->active();
84 } // namespace blink