summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/RenderTheme.cpp
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-05-21 16:53:46 +0100
committerKristian Monsen <kristianm@google.com>2010-05-25 10:24:15 +0100
commit6c2af9490927c3c5959b5cb07461b646f8b32f6c (patch)
treef7111b9b22befab472616c1d50ec94eb50f1ec8c /WebCore/rendering/RenderTheme.cpp
parenta149172322a9067c14e8b474a53e63649aa17cad (diff)
downloadexternal_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.zip
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.gz
external_webkit-6c2af9490927c3c5959b5cb07461b646f8b32f6c.tar.bz2
Merge WebKit at r59636: Initial merge by git
Change-Id: I59b289c4e6b18425f06ce41cc9d34c522515de91
Diffstat (limited to 'WebCore/rendering/RenderTheme.cpp')
-rw-r--r--WebCore/rendering/RenderTheme.cpp75
1 files changed, 75 insertions, 0 deletions
diff --git a/WebCore/rendering/RenderTheme.cpp b/WebCore/rendering/RenderTheme.cpp
index 76af001..b1c23b1 100644
--- a/WebCore/rendering/RenderTheme.cpp
+++ b/WebCore/rendering/RenderTheme.cpp
@@ -24,6 +24,7 @@
#include "CSSValueKeywords.h"
#include "Document.h"
+#include "FloatConversion.h"
#include "FocusController.h"
#include "FontSelector.h"
#include "Frame.h"
@@ -38,6 +39,11 @@
#include "Settings.h"
#include "TextControlInnerElements.h"
+#if ENABLE(METER_TAG)
+#include "HTMLMeterElement.h"
+#include "RenderMeter.h"
+#endif
+
// The methods in this file are shared by all themes on every platform.
namespace WebCore {
@@ -218,6 +224,10 @@ void RenderTheme::adjustStyle(CSSStyleSelector* selector, RenderStyle* style, El
case ProgressBarPart:
return adjustProgressBarStyle(selector, style, e);
#endif
+#if ENABLE(Meter_TAG)
+ case MeterPart:
+ return adjustMeterStyle(selector, style, e);
+#endif
default:
break;
}
@@ -276,6 +286,10 @@ bool RenderTheme::paint(RenderObject* o, const RenderObject::PaintInfo& paintInf
#endif
case MenulistPart:
return paintMenuList(o, paintInfo, r);
+#if ENABLE(METER_TAG)
+ case MeterPart:
+ return paintMeter(o, paintInfo, r);
+#endif
#if ENABLE(PROGRESS_TAG)
case ProgressBarPart:
return paintProgressBar(o, paintInfo, r);
@@ -370,6 +384,9 @@ bool RenderTheme::paintBorderOnly(RenderObject* o, const RenderObject::PaintInfo
case DefaultButtonPart:
case ButtonPart:
case MenulistPart:
+#if ENABLE(METER_TAG)
+ case MeterPart:
+#endif
#if ENABLE(PROGRESS_TAG)
case ProgressBarPart:
#endif
@@ -408,6 +425,9 @@ bool RenderTheme::paintDecorations(RenderObject* o, const RenderObject::PaintInf
case DefaultButtonPart:
case ButtonPart:
case MenulistPart:
+#if ENABLE(METER_TAG)
+ case MeterPart:
+#endif
#if ENABLE(PROGRESS_TAG)
case ProgressBarPart:
#endif
@@ -871,6 +891,61 @@ void RenderTheme::adjustMenuListStyle(CSSStyleSelector*, RenderStyle*, Element*)
{
}
+#if ENABLE(METER_TAG)
+void RenderTheme::adjustMeterStyle(CSSStyleSelector*, RenderStyle* style, Element*) const
+{
+ style->setBoxShadow(0);
+}
+
+bool RenderTheme::paintMeter(RenderObject* renderObject, const RenderObject::PaintInfo& paintInfo, const IntRect& rect)
+{
+ // Some platforms do not have a native gauge widget, so we draw here a default implementation.
+ RenderMeter* renderMeter = toRenderMeter(renderObject);
+ RenderStyle* style = renderObject->style();
+ int left = style->borderLeft().width() + style->paddingLeft().value();
+ int top = style->borderTop().width() + style->paddingTop().value();
+ int right = style->borderRight().width() + style->paddingRight().value();
+ int bottom = style->borderBottom().width() + style->paddingBottom().value();
+ FloatRect innerRect(rect.x() + left, rect.y() + top, rect.width() - left - right, rect.height() - top - bottom);
+
+ HTMLMeterElement* element = static_cast<HTMLMeterElement*>(renderMeter->node());
+ double min = element->min();
+ double max = element->max();
+ double value = element->value();
+
+ if (min >= max) {
+ paintInfo.context->fillRect(innerRect, Color::black, style->colorSpace());
+ return false;
+ }
+
+ // Paint the background first
+ paintInfo.context->fillRect(innerRect, Color::lightGray, style->colorSpace());
+
+ FloatRect valueRect;
+
+ if (rect.width() < rect.height()) {
+ // Vertical gauge
+ double scale = innerRect.height() / (max - min);
+ valueRect.setLocation(FloatPoint(innerRect.x(), innerRect.y() + narrowPrecisionToFloat((max - value) * scale)));
+ valueRect.setSize(FloatSize(innerRect.width(), narrowPrecisionToFloat((value - min) * scale)));
+ } else if (renderMeter->style()->direction() == RTL) {
+ // right to left horizontal gauge
+ double scale = innerRect.width() / (max - min);
+ valueRect.setLocation(FloatPoint(innerRect.x() + narrowPrecisionToFloat((max - value) * scale), innerRect.y()));
+ valueRect.setSize(FloatSize(narrowPrecisionToFloat((value - min) * scale), innerRect.height()));
+ } else {
+ // left to right horizontal gauge
+ double scale = innerRect.width() / (max - min);
+ valueRect.setLocation(innerRect.location());
+ valueRect.setSize(FloatSize(narrowPrecisionToFloat((value - min)) * scale, innerRect.height()));
+ }
+ if (!valueRect.isEmpty())
+ paintInfo.context->fillRect(valueRect, Color::black, style->colorSpace());
+
+ return false;
+}
+#endif
+
#if ENABLE(PROGRESS_TAG)
double RenderTheme::animationRepeatIntervalForProgressBar(RenderProgress*) const
{