<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[56241] trunk/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/56241">56241</a></dd>
<dt>Author</dt> <dd>joepeck@webkit.org</dd>
<dt>Date</dt> <dd>2010-03-19 09:16:03 -0700 (Fri, 19 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>2010-03-19  Joseph Pecoraro  &lt;joepeck@webkit.org&gt;

        Reviewed by David Kilzer.

        &lt;input type=range&gt; does not validate correctly without a renderer and the tests are incorrect
        https://bugs.webkit.org/show_bug.cgi?id=36259

        Part 1 of 2: Refactoring the SliderRange struct out of RenderSlider
        into a more appropriate place. Changed the named to StepRange. Changed
        from a struct to a class.

          Added new files to the build.

        * GNUmakefile.am:
        * WebCore.gypi:
        * WebCore.pro:
        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:

          Renamed and moved class SliderRange to StepRange.

        * html/StepRange.cpp: Added.
        (WebCore::StepRange::StepRange):
        (WebCore::StepRange::clampValue):
        (WebCore::StepRange::valueFromElement):
        (WebCore::sliderPosition):
        * html/StepRange.h: Added.
        (WebCore::StepRange::proportionFromValue):
        (WebCore::StepRange::valueFromProportion):
        * rendering/RenderSlider.cpp:
        (WebCore::RenderSlider::updateFromElement): updated to use StepRange
        (WebCore::RenderSlider::setValueForPosition): updated to use StepRange</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreGNUmakefileam">trunk/WebCore/GNUmakefile.am</a></li>
<li><a href="#trunkWebCoreWebCoregypi">trunk/WebCore/WebCore.gypi</a></li>
<li><a href="#trunkWebCoreWebCorepro">trunk/WebCore/WebCore.pro</a></li>
<li><a href="#trunkWebCoreWebCorevcprojWebCorevcproj">trunk/WebCore/WebCore.vcproj/WebCore.vcproj</a></li>
<li><a href="#trunkWebCoreWebCorexcodeprojprojectpbxproj">trunk/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkWebCorerenderingRenderSlidercpp">trunk/WebCore/rendering/RenderSlider.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebCorehtmlStepRangecpp">trunk/WebCore/html/StepRange.cpp</a></li>
<li><a href="#trunkWebCorehtmlStepRangeh">trunk/WebCore/html/StepRange.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/ChangeLog        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2010-03-19  Joseph Pecoraro  &lt;joepeck@webkit.org&gt;
+
+        Reviewed by David Kilzer.
+
+        &lt;input type=range&gt; does not validate correctly without a renderer and the tests are incorrect
+        https://bugs.webkit.org/show_bug.cgi?id=36259
+
+        Part 1 of 2: Refactoring the SliderRange struct out of RenderSlider
+        into a more appropriate place. Changed the named to StepRange. Changed
+        from a struct to a class.
+
+          Added new files to the build.
+
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+
+          Renamed and moved class SliderRange to StepRange.
+
+        * html/StepRange.cpp: Added.
+        (WebCore::StepRange::StepRange):
+        (WebCore::StepRange::clampValue):
+        (WebCore::StepRange::valueFromElement):
+        (WebCore::sliderPosition):
+        * html/StepRange.h: Added.
+        (WebCore::StepRange::proportionFromValue):
+        (WebCore::StepRange::valueFromProportion):
+        * rendering/RenderSlider.cpp:
+        (WebCore::RenderSlider::updateFromElement): updated to use StepRange
+        (WebCore::RenderSlider::setValueForPosition): updated to use StepRange
+
</ins><span class="cx"> 2010-03-19  Antti Koivisto  &lt;koivisto@iki.fi&gt;
</span><span class="cx"> 
</span><span class="cx">         Reviewed by Simon Hausmann.
</span></span></pre></div>
<a id="trunkWebCoreGNUmakefileam"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/GNUmakefile.am (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/GNUmakefile.am        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/GNUmakefile.am        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -1189,6 +1189,8 @@
</span><span class="cx">         WebCore/html/MediaError.h \
</span><span class="cx">         WebCore/html/PreloadScanner.cpp \
</span><span class="cx">         WebCore/html/PreloadScanner.h \
</span><ins>+        WebCore/html/StepRange.cpp \
+        WebCore/html/StepRange.h \
</ins><span class="cx">         WebCore/html/TextMetrics.h \
</span><span class="cx">         WebCore/html/ValidityState.cpp \
</span><span class="cx">         WebCore/html/ValidityState.h \
</span></span></pre></div>
<a id="trunkWebCoreWebCoregypi"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.gypi (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.gypi        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/WebCore.gypi        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -1604,6 +1604,8 @@
</span><span class="cx">             'html/MediaError.h',
</span><span class="cx">             'html/PreloadScanner.cpp',
</span><span class="cx">             'html/PreloadScanner.h',
</span><ins>+            'html/StepRange.cpp',
+            'html/StepRange.h',
</ins><span class="cx">             'html/TextMetrics.h',
</span><span class="cx">             'html/TimeRanges.cpp',
</span><span class="cx">             'html/TimeRanges.h',
</span></span></pre></div>
<a id="trunkWebCoreWebCorepro"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.pro (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.pro        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/WebCore.pro        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -687,6 +687,7 @@
</span><span class="cx">     html/HTMLViewSourceDocument.cpp \
</span><span class="cx">     html/ImageData.cpp \
</span><span class="cx">     html/PreloadScanner.cpp \
</span><ins>+    html/StepRange.cpp \
</ins><span class="cx">     html/ValidityState.cpp \
</span><span class="cx">     inspector/ConsoleMessage.cpp \
</span><span class="cx">     inspector/InjectedScript.cpp \
</span><span class="lines">@@ -1394,6 +1395,7 @@
</span><span class="cx">     html/HTMLViewSourceDocument.h \
</span><span class="cx">     html/ImageData.h \
</span><span class="cx">     html/PreloadScanner.h \
</span><ins>+    html/StepRange.h \
</ins><span class="cx">     html/TimeRanges.h \
</span><span class="cx">     html/ValidityState.h \
</span><span class="cx">     inspector/ConsoleMessage.h \
</span></span></pre></div>
<a id="trunkWebCoreWebCorevcprojWebCorevcproj"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.vcproj/WebCore.vcproj (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.vcproj/WebCore.vcproj        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/WebCore.vcproj/WebCore.vcproj        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -34385,6 +34385,14 @@
</span><span class="cx">                                 &gt;
</span><span class="cx">                         &lt;/File&gt;
</span><span class="cx">                         &lt;File
</span><ins>+                                RelativePath=&quot;..\html\StepRange.cpp&quot;
+                                &gt;
+                        &lt;/File&gt;
+                        &lt;File
+                                RelativePath=&quot;..\html\StepRange.h&quot;
+                                &gt;
+                        &lt;/File&gt;
+                        &lt;File
</ins><span class="cx">                                 RelativePath=&quot;..\html\TimeRanges.cpp&quot;
</span><span class="cx">                                 &gt;
</span><span class="cx">                         &lt;/File&gt;
</span></span></pre></div>
<a id="trunkWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/WebCore.xcodeproj/project.pbxproj (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/WebCore.xcodeproj/project.pbxproj        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -2493,6 +2493,8 @@
</span><span class="cx">                 A43BF5991149290A00C643CA /* HTMLProgressElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A43BF5971149290A00C643CA /* HTMLProgressElement.h */; };
</span><span class="cx">                 A43BF59C1149292800C643CA /* RenderProgress.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A43BF59A1149292800C643CA /* RenderProgress.cpp */; };
</span><span class="cx">                 A43BF59D1149292800C643CA /* RenderProgress.h in Headers */ = {isa = PBXBuildFile; fileRef = A43BF59B1149292800C643CA /* RenderProgress.h */; };
</span><ins>+                A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
+                A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; };
</ins><span class="cx">                 A718760E0B2A120100A16ECE /* DragActions.h in Headers */ = {isa = PBXBuildFile; fileRef = A718760D0B2A120100A16ECE /* DragActions.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 A71878900B2D04AC00A16ECE /* DragControllerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */; };
</span><span class="cx">                 A7352C190B1BB89D00A986D0 /* RenderSVGBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7352C170B1BB89D00A986D0 /* RenderSVGBlock.cpp */; };
</span><span class="lines">@@ -7895,6 +7897,8 @@
</span><span class="cx">                 A43BF5971149290A00C643CA /* HTMLProgressElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLProgressElement.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A43BF59A1149292800C643CA /* RenderProgress.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderProgress.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A43BF59B1149292800C643CA /* RenderProgress.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderProgress.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                A5AFB34D115151A700B045CB /* StepRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StepRange.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 A718760D0B2A120100A16ECE /* DragActions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DragActions.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DragControllerMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 A7352C170B1BB89D00A986D0 /* RenderSVGBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = RenderSVGBlock.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -13176,6 +13180,8 @@
</span><span class="cx">                                 E446139C0CD6331000FADA75 /* MediaError.idl */,
</span><span class="cx">                                 E4D4ABE00D7542F000F96869 /* PreloadScanner.cpp */,
</span><span class="cx">                                 E4D4ABE10D7542F100F96869 /* PreloadScanner.h */,
</span><ins>+                                A5AFB34D115151A700B045CB /* StepRange.cpp */,
+                                A5AFB34E115151A700B045CB /* StepRange.h */,
</ins><span class="cx">                                 BCEF45E80E687767001C1287 /* TextMetrics.h */,
</span><span class="cx">                                 BCEF453F0E676AC1001C1287 /* TextMetrics.idl */,
</span><span class="cx">                                 E446139D0CD6331000FADA75 /* TimeRanges.cpp */,
</span><span class="lines">@@ -18697,6 +18703,7 @@
</span><span class="cx">                                 A43BF5991149290A00C643CA /* HTMLProgressElement.h in Headers */,
</span><span class="cx">                                 A43BF59D1149292800C643CA /* RenderProgress.h in Headers */,
</span><span class="cx">                                 F375CC071150D300008DDB81 /* InspectorWorkerResource.h in Headers */,
</span><ins>+                                A5AFB350115151A700B045CB /* StepRange.h in Headers */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span><span class="lines">@@ -20904,6 +20911,7 @@
</span><span class="cx">                                 97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
</span><span class="cx">                                 A43BF5981149290A00C643CA /* HTMLProgressElement.cpp in Sources */,
</span><span class="cx">                                 A43BF59C1149292800C643CA /* RenderProgress.cpp in Sources */,
</span><ins>+                                A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */,
</ins><span class="cx">                         );
</span><span class="cx">                         runOnlyForDeploymentPostprocessing = 0;
</span><span class="cx">                 };
</span></span></pre></div>
<a id="trunkWebCorehtmlStepRangecpp"></a>
<div class="addfile"><h4>Added: trunk/WebCore/html/StepRange.cpp (0 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/StepRange.cpp                                (rev 0)
+++ trunk/WebCore/html/StepRange.cpp        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -0,0 +1,74 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include &quot;config.h&quot;
+#include &quot;StepRange.h&quot;
+
+#include &quot;HTMLInputElement.h&quot;
+#include &quot;HTMLNames.h&quot;
+#include &lt;wtf/MathExtras.h&gt;
+
+using namespace std;
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+StepRange::StepRange(HTMLInputElement* element)
+{
+    if (element-&gt;hasAttribute(precisionAttr)) {
+        step = 1.0;
+        hasStep = !equalIgnoringCase(element-&gt;getAttribute(precisionAttr), &quot;float&quot;);
+    } else
+        hasStep = element-&gt;getAllowedValueStep(&amp;step);
+
+    maximum = element-&gt;maximum();
+    minimum = element-&gt;minimum();
+}
+
+double StepRange::clampValue(double value)
+{
+    double clampedValue = max(minimum, min(value, maximum));
+    if (!hasStep)
+        return clampedValue;
+    // Rounds clampedValue to minimum + N * step.
+    clampedValue = minimum + round((clampedValue - minimum) / step) * step;
+    if (clampedValue &gt; maximum)
+       clampedValue -= step;
+    ASSERT(clampedValue &gt;= minimum);
+    ASSERT(clampedValue &lt;= maximum);
+    return clampedValue;
+}
+
+double StepRange::valueFromElement(HTMLInputElement* element, bool* wasClamped)
+{
+    double oldValue;
+    bool parseSuccess = HTMLInputElement::parseToDoubleForNumberType(element-&gt;value(), &amp;oldValue);
+    if (!parseSuccess)
+        oldValue = (minimum + maximum) / 2;
+    double newValue = clampValue(oldValue);
+
+    if (wasClamped)
+        *wasClamped = !parseSuccess || newValue != oldValue;
+
+    return newValue;
+}
+
+}
</ins></span></pre></div>
<a id="trunkWebCorehtmlStepRangeh"></a>
<div class="addfile"><h4>Added: trunk/WebCore/html/StepRange.h (0 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/html/StepRange.h                                (rev 0)
+++ trunk/WebCore/html/StepRange.h        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -0,0 +1,60 @@
</span><ins>+/*
+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef StepRange_h
+#define StepRange_h
+
+#include &lt;wtf/Noncopyable.h&gt;
+
+namespace WebCore {
+
+class HTMLInputElement;
+
+class StepRange : public Noncopyable {
+public:
+    bool hasStep;
+    double step;
+    double minimum;
+    double maximum; // maximum must be &gt;= minimum.
+
+    explicit StepRange(HTMLInputElement*);
+    double clampValue(double value);
+
+    // Map value into 0-1 range
+    double proportionFromValue(double value)
+    {
+        if (minimum == maximum)
+            return 0;
+
+        return (value - minimum) / (maximum - minimum);
+    }
+
+    // Map from 0-1 range to value
+    double valueFromProportion(double proportion)
+    {
+        return minimum + proportion * (maximum - minimum);
+    }
+
+    double valueFromElement(HTMLInputElement*, bool* wasClamped = 0);
+};
+
+}
+
+#endif // StepRange_h
</ins></span></pre></div>
<a id="trunkWebCorerenderingRenderSlidercpp"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/rendering/RenderSlider.cpp (56240 => 56241)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/rendering/RenderSlider.cpp        2010-03-19 15:33:07 UTC (rev 56240)
+++ trunk/WebCore/rendering/RenderSlider.cpp        2010-03-19 16:16:03 UTC (rev 56241)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
</ins><span class="cx">  *
</span><span class="cx">  * This library is free software; you can redistribute it and/or
</span><span class="cx">  * modify it under the terms of the GNU Library General Public
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &quot;RenderLayer.h&quot;
</span><span class="cx"> #include &quot;RenderTheme.h&quot;
</span><span class="cx"> #include &quot;RenderView.h&quot;
</span><ins>+#include &quot;StepRange.h&quot;
</ins><span class="cx"> #include &lt;wtf/MathExtras.h&gt;
</span><span class="cx"> 
</span><span class="cx"> using std::min;
</span><span class="lines">@@ -45,80 +46,10 @@
</span><span class="cx"> 
</span><span class="cx"> static const int defaultTrackLength = 129;
</span><span class="cx"> 
</span><del>-// FIXME: The SliderRange class and functions are entirely based on the DOM,
-// and could be put with HTMLInputElement (possibly with a new name) instead of here.
-struct SliderRange {
-    bool hasStep;
-    double step;
-    double minimum;
-    double maximum;  // maximum must be &gt;= minimum.
-
-    explicit SliderRange(HTMLInputElement*);
-    double clampValue(double value);
-
-    // Map value into 0-1 range
-    double proportionFromValue(double value)
-    {
-        if (minimum == maximum)
-            return 0;
-
-        return (value - minimum) / (maximum - minimum);
-    }
-    
-    // Map from 0-1 range to value
-    double valueFromProportion(double proportion)
-    {
-        return minimum + proportion * (maximum - minimum);
-    }
-    
-    double valueFromElement(HTMLInputElement*, bool* wasClamped = 0);
-};
-
-SliderRange::SliderRange(HTMLInputElement* element)
-{
-    if (element-&gt;hasAttribute(precisionAttr)) {
-        step = 1.0;
-        hasStep = !equalIgnoringCase(element-&gt;getAttribute(precisionAttr), &quot;float&quot;);
-    } else
-        hasStep = element-&gt;getAllowedValueStep(&amp;step);
-
-    maximum = element-&gt;maximum();
-    minimum = element-&gt;minimum();
-}
-
-double SliderRange::clampValue(double value)
-{
-    double clampedValue = max(minimum, min(value, maximum));
-    if (!hasStep)
-        return clampedValue;
-    // Rounds clampedValue to minimum + N * step.
-    clampedValue = minimum + round((clampedValue - minimum) / step) * step;
-    if (clampedValue &gt; maximum)
-       clampedValue -= step;
-    ASSERT(clampedValue &gt;= minimum);
-    ASSERT(clampedValue &lt;= maximum);
-    return clampedValue;
-}
-
-double SliderRange::valueFromElement(HTMLInputElement* element, bool* wasClamped)
-{
-    double oldValue;
-    bool parseSuccess = HTMLInputElement::parseToDoubleForNumberType(element-&gt;value(), &amp;oldValue);
-    if (!parseSuccess)
-        oldValue = (minimum + maximum) / 2;
-    double newValue = clampValue(oldValue);
-
-    if (wasClamped)
-        *wasClamped = !parseSuccess || newValue != oldValue;
-
-    return newValue;
-}
-
</del><span class="cx"> // Returns a value between 0 and 1.
</span><del>-// As with SliderRange, this could be on HTMLInputElement instead of here.
</del><span class="cx"> static double sliderPosition(HTMLInputElement* element)
</span><span class="cx"> {
</span><del>-    SliderRange range(element);
</del><ins>+    StepRange range(element);
</ins><span class="cx">     return range.proportionFromValue(range.valueFromElement(element));
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -375,7 +306,7 @@
</span><span class="cx">     HTMLInputElement* element = static_cast&lt;HTMLInputElement*&gt;(node());
</span><span class="cx"> 
</span><span class="cx">     // Send the value back to the element if the range changes it.
</span><del>-    SliderRange range(element);
</del><ins>+    StepRange range(element);
</ins><span class="cx">     bool clamped;
</span><span class="cx">     double value = range.valueFromElement(element, &amp;clamped);
</span><span class="cx">     if (clamped)
</span><span class="lines">@@ -430,7 +361,7 @@
</span><span class="cx">     HTMLInputElement* element = static_cast&lt;HTMLInputElement*&gt;(node());
</span><span class="cx"> 
</span><span class="cx">     // Calculate the new value based on the position, and send it to the element.
</span><del>-    SliderRange range(element);
</del><ins>+    StepRange range(element);
</ins><span class="cx">     double fraction = static_cast&lt;double&gt;(position) / trackSize();
</span><span class="cx">     if (style()-&gt;appearance() == SliderVerticalPart || style()-&gt;appearance() == MediaVolumeSliderPart)
</span><span class="cx">         fraction = 1 - fraction;
</span></span></pre>
</div>
</div>

</body>
</html>