Title: [125048] trunk
Revision
125048
Author
kei...@webkit.org
Date
2012-08-08 10:31:12 -0700 (Wed, 08 Aug 2012)

Log Message

Make slider tick mark snapping threshold configurable for each platform
https://bugs.webkit.org/show_bug.cgi?id=93429

Reviewed by Kent Tamura.

Source/WebCore:

This makes the slider tick mark snapping threshold configurable for each platform.
And we increase the threshold for the Chromium port.

No new tests. Covered by range-snap-to-datalist.html.

* html/shadow/SliderThumbElement.cpp:
(WebCore::SliderThumbElement::setPositionFromPoint):
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::sliderTickSnappingThreshold):
(WebCore):
* rendering/RenderTheme.h:
(RenderTheme):
(WebCore::RenderTheme::sliderTickSnappingThreshold): Returns the threshold distance to the tick mark for snapping to occur.
* rendering/RenderThemeChromiumCommon.cpp:
(WebCore::RenderThemeChromiumCommon::sliderTickSnappingThreshold):
(WebCore):
* rendering/RenderThemeChromiumCommon.h:
(RenderThemeChromiumCommon):
* rendering/RenderThemeChromiumMac.h:
* rendering/RenderThemeChromiumMac.mm:
(WebCore):
(WebCore::RenderThemeChromiumMac::sliderTickSnappingThreshold):
* rendering/RenderThemeChromiumSkia.cpp:
(WebCore):
(WebCore::RenderThemeChromiumSkia::sliderTickSnappingThreshold):
* rendering/RenderThemeChromiumSkia.h:

LayoutTests:

* fast/forms/datalist/range-snap-to-datalist-expected.txt: Removed.
* fast/forms/datalist/range-snap-to-datalist.html: Changed so we can use this test for different snapping thresholds.
* platform/chromium/fast/forms/datalist/range-snap-to-datalist-expected.txt: Added.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (125047 => 125048)


--- trunk/LayoutTests/ChangeLog	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/LayoutTests/ChangeLog	2012-08-08 17:31:12 UTC (rev 125048)
@@ -1,3 +1,14 @@
+2012-08-08  Keishi Hattori  <kei...@webkit.org>
+
+        Make slider tick mark snapping threshold configurable for each platform
+        https://bugs.webkit.org/show_bug.cgi?id=93429
+
+        Reviewed by Kent Tamura.
+
+        * fast/forms/datalist/range-snap-to-datalist-expected.txt: Removed.
+        * fast/forms/datalist/range-snap-to-datalist.html: Changed so we can use this test for different snapping thresholds.
+        * platform/chromium/fast/forms/datalist/range-snap-to-datalist-expected.txt: Added.
+
 2012-08-08  Mike West  <mk...@chromium.org>
 
         Until CSP fully supports paths, we should log a warning if we encounter a source with a path.

Deleted: trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist-expected.txt (125047 => 125048)


--- trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist-expected.txt	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist-expected.txt	2012-08-08 17:31:12 UTC (rev 125048)
@@ -1,28 +0,0 @@
-Tests if clicking close to a tick mark snaps to it.
-
-PASS input.value is "0"
-PASS parseInt(input.value, 10) < 500 is true
-PASS input.value is "0"
-PASS parseInt(input.value, 10) < 500 is true
-PASS input.value is "0"
-PASS parseInt(input.value, 10) < 500 is true
-PASS input.value is "0"
-PASS input.value is '500'
-PASS input.value is "0"
-PASS input.value is '500'
-PASS input.value is "0"
-PASS input.value is '500'
-PASS input.value is "0"
-PASS input.value is '500'
-PASS input.value is "0"
-PASS input.value is '500'
-PASS input.value is "0"
-PASS parseInt(input.value, 10) > 500 is true
-PASS input.value is "0"
-PASS parseInt(input.value, 10) > 500 is true
-PASS input.value is "0"
-PASS parseInt(input.value, 10) > 500 is true
-PASS successfullyParsed is true
-
-TEST COMPLETE
-

Modified: trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist.html (125047 => 125048)


--- trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist.html	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/LayoutTests/fast/forms/datalist/range-snap-to-datalist.html	2012-08-08 17:31:12 UTC (rev 125048)
@@ -4,7 +4,7 @@
 <script src=""
 </head>
 <body>
-<p id="description">Tests if clicking close to a tick mark snaps to it.</p>
+<p id="description">Tests if clicking close to a tick mark snaps to it. Result will change depending on the return value of RenderTheme::sliderTickSnappingThreshold().</p>
 <div id="console"></div>
 <input id="input" type=range min=0 max=1000 step=1 list=target style="width: 100px">
 <datalist id="target">
@@ -20,41 +20,26 @@
 }
 function resetSliderPosition() {
     clickSlider(0);
-    shouldBe('input.value', '"0"');
+    if (input.value !== "0") {
+    	testFailed('Failed to reset slider position');
+    }
 }
-resetSliderPosition();
-clickSlider(45);
-shouldBeTrue('parseInt(input.value, 10) < 500');
-resetSliderPosition();
-clickSlider(46);
-shouldBeTrue('parseInt(input.value, 10) < 500');
-resetSliderPosition();
-clickSlider(47);
-shouldBeTrue('parseInt(input.value, 10) < 500');
-resetSliderPosition();
-clickSlider(48);
-shouldBe('input.value', "'500'");
-resetSliderPosition();
-clickSlider(49);
-shouldBe('input.value', "'500'");
-resetSliderPosition();
-clickSlider(50);
-shouldBe('input.value', "'500'");
-resetSliderPosition();
-clickSlider(51);
-shouldBe('input.value', "'500'");
-resetSliderPosition();
-clickSlider(52);
-shouldBe('input.value', "'500'");
-resetSliderPosition();
-clickSlider(53);
-shouldBeTrue('parseInt(input.value, 10) > 500');
-resetSliderPosition();
-clickSlider(54);
-shouldBeTrue('parseInt(input.value, 10) > 500');
-resetSliderPosition();
-clickSlider(55);
-shouldBeTrue('parseInt(input.value, 10) > 500');
+function test(position) {
+	resetSliderPosition();
+	clickSlider(position);
+	var value = parseInt(input.value, 10);
+	if (value < 500) {
+		debug('value for ' + position + ' is &lt;500');
+	} else if (value > 500) {
+		debug('value for ' + position + ' is &gt;500');
+	} else {
+		debug('value for ' + position + ' is =500');
+	}
+}
+
+for (var i = 40; i <= 60; ++i) {
+	test(i);
+}
 </script>
 
 <script src=""

Added: trunk/LayoutTests/platform/chromium/fast/forms/datalist/range-snap-to-datalist-expected.txt (0 => 125048)


--- trunk/LayoutTests/platform/chromium/fast/forms/datalist/range-snap-to-datalist-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/chromium/fast/forms/datalist/range-snap-to-datalist-expected.txt	2012-08-08 17:31:12 UTC (rev 125048)
@@ -0,0 +1,27 @@
+Tests if clicking close to a tick mark snaps to it. Result will change depending on the return value of RenderTheme::sliderTickSnappingThreshold().
+
+value for 40 is <500
+value for 41 is <500
+value for 42 is <500
+value for 43 is <500
+value for 44 is <500
+value for 45 is =500
+value for 46 is =500
+value for 47 is =500
+value for 48 is =500
+value for 49 is =500
+value for 50 is =500
+value for 51 is =500
+value for 52 is =500
+value for 53 is =500
+value for 54 is =500
+value for 55 is =500
+value for 56 is >500
+value for 57 is >500
+value for 58 is >500
+value for 59 is >500
+value for 60 is >500
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Modified: trunk/Source/WebCore/ChangeLog (125047 => 125048)


--- trunk/Source/WebCore/ChangeLog	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/ChangeLog	2012-08-08 17:31:12 UTC (rev 125048)
@@ -1,3 +1,37 @@
+2012-08-08  Keishi Hattori  <kei...@webkit.org>
+
+        Make slider tick mark snapping threshold configurable for each platform
+        https://bugs.webkit.org/show_bug.cgi?id=93429
+
+        Reviewed by Kent Tamura.
+
+        This makes the slider tick mark snapping threshold configurable for each platform.
+        And we increase the threshold for the Chromium port.
+
+        No new tests. Covered by range-snap-to-datalist.html.
+
+        * html/shadow/SliderThumbElement.cpp:
+        (WebCore::SliderThumbElement::setPositionFromPoint):
+        * rendering/RenderTheme.cpp:
+        (WebCore::RenderTheme::sliderTickSnappingThreshold):
+        (WebCore):
+        * rendering/RenderTheme.h:
+        (RenderTheme):
+        (WebCore::RenderTheme::sliderTickSnappingThreshold): Returns the threshold distance to the tick mark for snapping to occur.
+        * rendering/RenderThemeChromiumCommon.cpp:
+        (WebCore::RenderThemeChromiumCommon::sliderTickSnappingThreshold):
+        (WebCore):
+        * rendering/RenderThemeChromiumCommon.h:
+        (RenderThemeChromiumCommon):
+        * rendering/RenderThemeChromiumMac.h:
+        * rendering/RenderThemeChromiumMac.mm:
+        (WebCore):
+        (WebCore::RenderThemeChromiumMac::sliderTickSnappingThreshold):
+        * rendering/RenderThemeChromiumSkia.cpp:
+        (WebCore):
+        (WebCore::RenderThemeChromiumSkia::sliderTickSnappingThreshold):
+        * rendering/RenderThemeChromiumSkia.h:
+
 2012-08-08  Mike West  <mk...@chromium.org>
 
         Until CSP fully supports paths, we should log a warning if we encounter a source with a path.

Modified: trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp (125047 => 125048)


--- trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp	2012-08-08 17:31:12 UTC (rev 125048)
@@ -275,14 +275,16 @@
     Decimal value = stepRange.clampValue(stepRange.valueFromProportion(fraction));
 
 #if ENABLE(DATALIST_ELEMENT)
-    Decimal closest = input->findClosestTickMarkValue(value);
-    if (closest.isFinite()) {
-        double closestFraction = stepRange.proportionFromValue(closest).toDouble();
-        double closestRatio = isVertical || !renderBox()->style()->isLeftToRightDirection() ? 1.0 - closestFraction : closestFraction;
-        LayoutUnit closestPosition = trackSize * closestRatio;
-        const LayoutUnit snapThreshold = 3;
-        if ((closestPosition - position).abs() < snapThreshold)
-            value = closest;
+    const LayoutUnit snappingThreshold = renderer()->theme()->sliderTickSnappingThreshold();
+    if (snappingThreshold > 0) {
+        Decimal closest = input->findClosestTickMarkValue(value);
+        if (closest.isFinite()) {
+            double closestFraction = stepRange.proportionFromValue(closest).toDouble();
+            double closestRatio = isVertical || !renderBox()->style()->isLeftToRightDirection() ? 1.0 - closestFraction : closestFraction;
+            LayoutUnit closestPosition = trackSize * closestRatio;
+            if ((closestPosition - position).abs() <= snappingThreshold)
+                value = closest;
+        }
     }
 #endif
 

Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderTheme.cpp	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp	2012-08-08 17:31:12 UTC (rev 125048)
@@ -963,6 +963,11 @@
 #endif
 
 #if ENABLE(DATALIST_ELEMENT)
+LayoutUnit RenderTheme::sliderTickSnappingThreshold() const
+{
+    return 0;
+}
+
 void RenderTheme::paintSliderTicks(RenderObject* o, const PaintInfo& paintInfo, const IntRect& rect)
 {
     Node* node = o->node();

Modified: trunk/Source/WebCore/rendering/RenderTheme.h (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderTheme.h	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderTheme.h	2012-08-08 17:31:12 UTC (rev 125048)
@@ -215,6 +215,8 @@
 #endif
 
 #if ENABLE(DATALIST_ELEMENT)
+    // Returns the threshold distance for snapping to a slider tick mark.
+    virtual LayoutUnit sliderTickSnappingThreshold() const;
     // Returns size of one slider tick mark for a horizontal track.
     // For vertical tracks we rotate it and use it. i.e. Width is always length along the track.
     virtual IntSize sliderTickSize() const = 0;

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.cpp (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.cpp	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.cpp	2012-08-08 17:31:12 UTC (rev 125048)
@@ -41,4 +41,9 @@
         || type == InputTypeNames::range();
 }
 
+LayoutUnit RenderThemeChromiumCommon::sliderTickSnappingThreshold()
+{
+    return 5;
 }
+
+}

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.h (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.h	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumCommon.h	2012-08-08 17:31:12 UTC (rev 125048)
@@ -27,6 +27,7 @@
 #ifndef RenderThemeChromiumCommon_h
 #define RenderThemeChromiumCommon_h
 
+#include "LayoutTypes.h"
 #include <wtf/text/AtomicString.h>
 
 namespace WebCore {
@@ -34,6 +35,7 @@
 class RenderThemeChromiumCommon {
 public:
     static bool supportsDataListUI(const AtomicString& type);
+    static LayoutUnit sliderTickSnappingThreshold();
 };
 
 }

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.h	2012-08-08 17:31:12 UTC (rev 125048)
@@ -71,6 +71,9 @@
     virtual Color disabledTextColor(const Color& textColor, const Color&) const OVERRIDE { return textColor; }
     virtual void updateActiveState(NSCell*, const RenderObject*);
     virtual String extraDefaultStyleSheet();
+#if ENABLE(DATALIST_ELEMENT)
+    virtual LayoutUnit sliderTickSnappingThreshold() const OVERRIDE;
+#endif
 #if ENABLE(CALENDAR_PICKER)
     virtual CString extraCalendarPickerStyleSheet() OVERRIDE;
 #endif

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumMac.mm	2012-08-08 17:31:12 UTC (rev 125048)
@@ -192,6 +192,13 @@
            String(themeChromiumUserAgentStyleSheet, sizeof(themeChromiumUserAgentStyleSheet));
 }
 
+#if ENABLE(DATALIST_ELEMENT)
+LayoutUnit RenderThemeChromiumMac::sliderTickSnappingThreshold() const
+{
+    return RenderThemeChromiumCommon::sliderTickSnappingThreshold();
+}
+#endif
+
 #if ENABLE(CALENDAR_PICKER)
 CString RenderThemeChromiumMac::extraCalendarPickerStyleSheet()
 {

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.cpp	2012-08-08 17:31:12 UTC (rev 125048)
@@ -591,6 +591,13 @@
     return true;
 }
 
+#if ENABLE(DATALIST_ELEMENT)
+LayoutUnit RenderThemeChromiumSkia::sliderTickSnappingThreshold() const
+{
+    return RenderThemeChromiumCommon::sliderTickSnappingThreshold();
+}
+#endif
+
 #if ENABLE(PROGRESS_ELEMENT)
 
 //

Modified: trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h (125047 => 125048)


--- trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-08-08 17:24:41 UTC (rev 125047)
+++ trunk/Source/WebCore/rendering/RenderThemeChromiumSkia.h	2012-08-08 17:31:12 UTC (rev 125048)
@@ -174,6 +174,10 @@
     virtual Color disabledTextColor(const Color& textColor, const Color&) const OVERRIDE { return textColor; }
     virtual bool shouldShowPlaceholderWhenFocused() const OVERRIDE;
 
+#if ENABLE(DATALIST_ELEMENT)
+    virtual LayoutUnit sliderTickSnappingThreshold() const OVERRIDE;
+#endif
+
     int menuListInternalPadding(RenderStyle*, int paddingType) const;
     bool paintMediaButtonInternal(GraphicsContext*, const IntRect&, Image*);
     IntRect convertToPaintingRect(RenderObject* inputRenderer, const RenderObject* partRenderer, LayoutRect partRect, const IntRect& localOffset) const;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to