Commit a3f13fdc authored by adele's avatar adele

Reviewed by Adam.

        Slider cleanup.  Let the theme set the size of the slider thumb.

        * rendering/RenderSlider.cpp:
        (WebCore::RenderSlider::setStyle): Moving the thumb's appearance adjustment to createThumbStyle.
        (WebCore::RenderSlider::createThumbStyle):
        (WebCore::RenderSlider::layout): Let the theme set the size of the thumb.
        * rendering/RenderTheme.cpp: (WebCore::RenderTheme::adjustSliderThumbSize):  Added.
        * rendering/RenderTheme.h: ditto.
        * rendering/RenderThemeMac.h: ditto.
        * rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::adjustSliderThumbSize): ditto.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@17823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 02b2f195
2006-11-16 Adele Peterson <adele@apple.com>
Reviewed by Adam.
Slider cleanup. Let the theme set the size of the slider thumb.
* rendering/RenderSlider.cpp:
(WebCore::RenderSlider::setStyle): Moving the thumb's appearance adjustment to createThumbStyle.
(WebCore::RenderSlider::createThumbStyle):
(WebCore::RenderSlider::layout): Let the theme set the size of the thumb.
* rendering/RenderTheme.cpp: (WebCore::RenderTheme::adjustSliderThumbSize): Added.
* rendering/RenderTheme.h: ditto.
* rendering/RenderThemeMac.h: ditto.
* rendering/RenderThemeMac.mm: (WebCore::RenderThemeMac::adjustSliderThumbSize): ditto.
2006-11-15 Anders Carlsson <acarlsson@apple.com>
Reviewed by Darin.
......@@ -10640,7 +10640,6 @@
mainGroup = 0867D691FE84028FC02AAC07 /* WebKit */;
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
projectDirPath = "";
projectRoot = "";
targets = (
93F198A508245E59001E9ABC /* WebCore */,
DD041FBE09D9DDBE0010AF2A /* Derived Sources */,
......@@ -31,6 +31,7 @@
#include "HTMLDivElement.h"
#include "HTMLNames.h"
#include "MouseEvent.h"
#include "RenderTheme.h"
#include <wtf/MathExtras.h>
using std::min;
......@@ -160,14 +161,10 @@ void RenderSlider::setStyle(RenderStyle* newStyle)
RenderBlock::setStyle(newStyle);
RenderStyle* thumbStyle = createThumbStyle(newStyle);
if (m_thumb)
m_thumb->renderer()->setStyle(thumbStyle);
if (newStyle->appearance() == SliderVerticalAppearance)
thumbStyle->setAppearance(SliderThumbVerticalAppearance);
else
thumbStyle->setAppearance(SliderThumbHorizontalAppearance);
setReplaced(isInline());
}
......@@ -183,6 +180,11 @@ RenderStyle* RenderSlider::createThumbStyle(RenderStyle* parentStyle)
style->setDisplay(BLOCK);
style->setPosition(RelativePosition);
if (parentStyle->appearance() == SliderVerticalAppearance)
style->setAppearance(SliderThumbVerticalAppearance);
else if (parentStyle->appearance() == SliderHorizontalAppearance)
style->setAppearance(SliderThumbHorizontalAppearance);
return style;
}
......@@ -191,6 +193,7 @@ void RenderSlider::layout()
bool relayoutChildren = false;
if (m_thumb && m_thumb->renderer()) {
int oldWidth = m_width;
calcWidth();
int oldHeight = m_height;
......@@ -199,11 +202,15 @@ void RenderSlider::layout()
if (oldWidth != m_width || oldHeight != m_height)
relayoutChildren = true;
// Allow the theme to set the size of the thumb
if (m_thumb->renderer()->style()->hasAppearance())
theme()->adjustSliderThumbSize(m_thumb->renderer());
if (style()->appearance() == SliderVerticalAppearance)
m_thumb->renderer()->style()->setLeft(Length(m_width / 2 - m_thumb->renderer()->style()->width().value() / 2, Fixed));
else
m_thumb->renderer()->style()->setTop(Length(m_height / 2 - m_thumb->renderer()->style()->height().value() / 2, Fixed));
if (relayoutChildren)
setPositionFromValue(true);
}
......
......@@ -411,4 +411,8 @@ void RenderTheme::adjustSliderThumbStyle(CSSStyleSelector* selector, RenderStyle
{
}
void RenderTheme::adjustSliderThumbSize(RenderObject*) const
{
}
}
......@@ -113,6 +113,8 @@ public:
virtual int minimumMenuListSize(RenderStyle*) const { return 0; }
virtual void adjustSliderThumbSize(RenderObject*) const;
protected:
// Methods for state querying
bool isChecked(const RenderObject*) const;
......
......@@ -60,6 +60,8 @@ public:
virtual void systemFont(int propId, FontDescription&) const;
virtual int minimumMenuListSize(RenderStyle*) const;
virtual void adjustSliderThumbSize(RenderObject*) const;
protected:
// Methods for each appearance value.
......@@ -85,12 +87,9 @@ protected:
virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
virtual void adjustMenuListButtonStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual void adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual bool paintSliderTrack(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
virtual void adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual bool paintSliderThumb(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
private:
IntRect inflateRect(const IntRect&, const IntSize&, const int* margins) const;
......
......@@ -1030,17 +1030,15 @@ bool RenderThemeMac::paintSliderThumb(RenderObject* o, const RenderObject::Paint
return false;
}
void RenderThemeMac::adjustSliderTrackStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
{
}
const int sliderThumbWidth = 15;
const int sliderThumbHeight = 15;
void RenderThemeMac::adjustSliderThumbStyle(CSSStyleSelector*, RenderStyle* style, Element* e) const
void RenderThemeMac::adjustSliderThumbSize(RenderObject* o) const
{
style->setWidth(Length(sliderThumbWidth, Fixed));
style->setHeight(Length(sliderThumbHeight, Fixed));
if (o->style()->appearance() == SliderThumbHorizontalAppearance || o->style()->appearance() == SliderThumbVerticalAppearance) {
o->style()->setWidth(Length(sliderThumbWidth, Fixed));
o->style()->setHeight(Length(sliderThumbHeight, Fixed));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment