diff options
Diffstat (limited to 'WebCore/html/HTMLMeterElement.cpp')
-rw-r--r-- | WebCore/html/HTMLMeterElement.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/WebCore/html/HTMLMeterElement.cpp b/WebCore/html/HTMLMeterElement.cpp index a1b74b2..1e8956d 100644 --- a/WebCore/html/HTMLMeterElement.cpp +++ b/WebCore/html/HTMLMeterElement.cpp @@ -24,10 +24,11 @@ #include "Attribute.h" #include "EventNames.h" +#include "ExceptionCode.h" #include "FormDataList.h" #include "HTMLFormElement.h" #include "HTMLNames.h" -#include "HTMLParser.h" +#include "LegacyHTMLTreeConstructor.h" #include "RenderMeter.h" #include <wtf/StdLibExtras.h> @@ -162,5 +163,38 @@ void HTMLMeterElement::setOptimum(double optimum, ExceptionCode& ec) setAttribute(optimumAttr, String::number(optimum)); } +HTMLMeterElement::GaugeRegion HTMLMeterElement::gaugeRegion() const +{ + double lowValue = low(); + double highValue = high(); + double theValue = value(); + double optimumValue = optimum(); + + if (optimumValue <= lowValue) { + // The optimum range stays under low + if (theValue <= lowValue) + return GaugeRegionOptimum; + if (theValue <= highValue) + return GaugeRegionSuboptimal; + return GaugeRegionEvenLessGood; + } + + if (highValue <= optimumValue) { + // The optimum range stays over high + if (highValue <= theValue) + return GaugeRegionOptimum; + if (lowValue <= theValue) + return GaugeRegionSuboptimal; + return GaugeRegionEvenLessGood; + } + + // The optimum range stays between high and low + if (lowValue < highValue && theValue < highValue) + return GaugeRegionOptimum; + if (theValue == min() || max() == theValue) + return GaugeRegionEvenLessGood; + return GaugeRegionSuboptimal; +} + } // namespace #endif |