This source file includes following definitions.
- baselinePosition
- computeIntrinsicLogicalWidths
- computePreferredLogicalWidths
- sliderThumbElement
- layout
- inDragMode
#include "config.h"
#include "core/rendering/RenderSlider.h"
#include "core/dom/shadow/ShadowRoot.h"
#include "core/html/HTMLInputElement.h"
#include "core/html/shadow/ShadowElementNames.h"
#include "core/html/shadow/SliderThumbElement.h"
#include "core/rendering/LayoutRectRecorder.h"
#include "wtf/MathExtras.h"
using std::min;
namespace WebCore {
const int RenderSlider::defaultTrackLength = 129;
RenderSlider::RenderSlider(HTMLInputElement* element)
: RenderFlexibleBox(element)
{
ASSERT(element->isRangeControl());
}
RenderSlider::~RenderSlider()
{
}
int RenderSlider::baselinePosition(FontBaseline, bool , LineDirectionMode, LinePositionMode linePositionMode) const
{
ASSERT(linePositionMode == PositionOnContainingLine);
return height() + marginTop();
}
void RenderSlider::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, LayoutUnit& maxLogicalWidth) const
{
maxLogicalWidth = defaultTrackLength * style()->effectiveZoom();
if (!style()->width().isPercent())
minLogicalWidth = maxLogicalWidth;
}
void RenderSlider::computePreferredLogicalWidths()
{
m_minPreferredLogicalWidth = 0;
m_maxPreferredLogicalWidth = 0;
if (style()->width().isFixed() && style()->width().value() > 0)
m_minPreferredLogicalWidth = m_maxPreferredLogicalWidth = adjustContentBoxLogicalWidthForBoxSizing(style()->width().value());
else
computeIntrinsicLogicalWidths(m_minPreferredLogicalWidth, m_maxPreferredLogicalWidth);
if (style()->minWidth().isFixed() && style()->minWidth().value() > 0) {
m_maxPreferredLogicalWidth = max(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
m_minPreferredLogicalWidth = max(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->minWidth().value()));
}
if (style()->maxWidth().isFixed()) {
m_maxPreferredLogicalWidth = min(m_maxPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
m_minPreferredLogicalWidth = min(m_minPreferredLogicalWidth, adjustContentBoxLogicalWidthForBoxSizing(style()->maxWidth().value()));
}
LayoutUnit toAdd = borderAndPaddingWidth();
m_minPreferredLogicalWidth += toAdd;
m_maxPreferredLogicalWidth += toAdd;
clearPreferredLogicalWidthsDirty();
}
inline SliderThumbElement* RenderSlider::sliderThumbElement() const
{
return toSliderThumbElement(toElement(node())->userAgentShadowRoot()->getElementById(ShadowElementNames::sliderThumb()));
}
void RenderSlider::layout()
{
LayoutRectRecorder recorder(*this);
RenderBox* thumbBox = sliderThumbElement()->renderBox();
if (thumbBox && thumbBox->isSliderThumb())
static_cast<RenderSliderThumb*>(thumbBox)->updateAppearance(style());
RenderFlexibleBox::layout();
}
bool RenderSlider::inDragMode() const
{
return sliderThumbElement()->active();
}
}