Log Message
2011-07-07 Shinya Kawanaka <shin...@google.com> Added more key bindings for input[type=range]. https://bugs.webkit.org/show_bug.cgi?id=52262
Added PageUp/PageDown/Home/End key bindings tests for input[type=range]. Reviewed by Kent Tamura. * fast/forms/range-keyoperation-expected.txt: Regenerated. * fast/forms/range-keyoperation.html: Added more key bindings tests. 2011-07-07 Shinya Kawanaka <shin...@google.com> Added more key bindings for input[type=range]. https://bugs.webkit.org/show_bug.cgi?id=52262 Added PageUp/PageDown/Home/End key bindings for input[type=range]. PageUp/PageDown change value by about 10%. Home/End change value to minimum/maximum. Reviewed by Kent Tamura. * html/RangeInputType.cpp: (WebCore::RangeInputType::handleKeydownEvent): Added key bindings.
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (90551 => 90552)
--- trunk/LayoutTests/ChangeLog 2011-07-07 10:29:19 UTC (rev 90551)
+++ trunk/LayoutTests/ChangeLog 2011-07-07 10:37:41 UTC (rev 90552)
@@ -1,3 +1,15 @@
+2011-07-07 Shinya Kawanaka <shin...@google.com>
+
+ Added more key bindings for input[type=range].
+ https://bugs.webkit.org/show_bug.cgi?id=52262
+
+ Added PageUp/PageDown/Home/End key bindings tests for input[type=range].
+
+ Reviewed by Kent Tamura.
+
+ * fast/forms/range-keyoperation-expected.txt: Regenerated.
+ * fast/forms/range-keyoperation.html: Added more key bindings tests.
+
2011-07-06 Mihnea Ovidenie <mih...@adobe.com>
Reviewed by David Hyatt.
Modified: trunk/LayoutTests/fast/forms/range-keyoperation-expected.txt (90551 => 90552)
--- trunk/LayoutTests/fast/forms/range-keyoperation-expected.txt 2011-07-07 10:29:19 UTC (rev 90551)
+++ trunk/LayoutTests/fast/forms/range-keyoperation-expected.txt 2011-07-07 10:37:41 UTC (rev 90552)
@@ -10,12 +10,28 @@
PASS input.value is "49"
Press the right arrow key:
PASS input.value is "50"
+Press the PageUp key:
+PASS input.value is "60"
+Press the PageDown key:
+PASS input.value is "50"
+Press the Home key:
+PASS input.value is "0"
+Press the End key:
+PASS input.value is "100"
Edge cases
PASS input.value is "0"
PASS changeEventCounter is lastChangeEventCounter
PASS input.value is "1"
PASS input.value is "100"
PASS input.value is "99"
+PASS input.value is "0"
+PASS changeEventCounter is lastChangeEventCounter
+PASS input.value is "0"
+PASS changeEventCounter is lastChangeEventCounter
+PASS input.value is "100"
+PASS changeEventCounter is lastChangeEventCounter
+PASS input.value is "100"
+PASS changeEventCounter is lastChangeEventCounter
Tests for a vertical range
Press the up arrow key:
@@ -23,9 +39,17 @@
Press the down arrow key:
PASS input.value is "50"
Press the left arrow key:
-PASS input.value is "49"
+PASS input.value is "51"
Press the right arrow key:
PASS input.value is "50"
+Press the PageUp key:
+PASS input.value is "60"
+Press the PageDown key:
+PASS input.value is "50"
+Press the Home key:
+PASS input.value is "100"
+Press the End key:
+PASS input.value is "0"
step=any cases
Press the up arrow key:
@@ -34,19 +58,50 @@
Press the down arrow key:
PASS input.value is "100"
PASS changeEventCounter is lastChangeEventCounter + 1
+Press the pageup key:
+PASS input.value is "120"
+PASS changeEventCounter is lastChangeEventCounter + 1
+Press the pagedown key:
+PASS input.value is "100"
+PASS changeEventCounter is lastChangeEventCounter + 1
+Press the home key:
+PASS input.value is "200"
+PASS changeEventCounter is lastChangeEventCounter + 1
+Press the end key:
+PASS input.value is "0"
+PASS changeEventCounter is lastChangeEventCounter + 1
Edge cases
PASS input.value is "200"
PASS input.value is "200"
PASS changeEventCounter is lastChangeEventCounter
PASS input.value is "198"
+PASS input.value is "200"
+PASS input.value is "200"
+PASS changeEventCounter is lastChangeEventCounter
+PASS input.value is "180"
PASS input.value is "0"
PASS input.value is "0"
PASS changeEventCounter is lastChangeEventCounter
PASS input.value is "2"
+PASS input.value is "0"
+PASS input.value is "0"
+PASS changeEventCounter is lastChangeEventCounter
+PASS input.value is "20"
+small range
+PASS input.value is "9"
+PASS input.value is "6"
+PASS input.value is "0"
+PASS input.value is "9"
+PASS input.value is "0"
+
Disabled and read-only
PASS input.value is "1"
PASS input.value is "1"
+PASS input.value is "1"
+PASS input.value is "1"
+PASS input.value is "1"
+PASS input.value is "1"
PASS successfullyParsed is true
Modified: trunk/LayoutTests/fast/forms/range-keyoperation.html (90551 => 90552)
--- trunk/LayoutTests/fast/forms/range-keyoperation.html 2011-07-07 10:29:19 UTC (rev 90551)
+++ trunk/LayoutTests/fast/forms/range-keyoperation.html 2011-07-07 10:37:41 UTC (rev 90552)
@@ -47,6 +47,22 @@
sendKey(input, 'Right');
shouldBe('input.value', '"50"');
+debug('Press the PageUp key:');
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"60"');
+
+debug('Press the PageDown key:');
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"50"');
+
+debug('Press the Home key:');
+sendKey(input, 'Home');
+shouldBe('input.value', '"0"');
+
+debug('Press the End key:');
+sendKey(input, 'End');
+shouldBe('input.value', '"100"');
+
debug('Edge cases');
input.valueAsNumber = 0;
lastChangeEventCounter = changeEventCounter;
@@ -61,9 +77,28 @@
sendKey(input, 'Left');
shouldBe('input.value', '"99"');
+input.valueAsNumber = 0;
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"0"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+sendKey(input, 'Home');
+shouldBe('input.value', '"0"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+input.valueAsNumber = 100;
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"100"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+sendKey(input, 'End');
+shouldBe('input.value', '"100"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+
debug('');
input.setAttribute('style', '-webkit-appearance:slider-vertical; height: 40px;');
+input.offsetLeft; // force layout
+
input.valueAsNumber = 50;
debug('Tests for a vertical range');
debug('Press the up arrow key:');
@@ -76,12 +111,28 @@
debug('Press the left arrow key:');
sendKey(input, 'Left');
-shouldBe('input.value', '"49"');
+shouldBe('input.value', '"51"');
debug('Press the right arrow key:');
sendKey(input, 'Right');
shouldBe('input.value', '"50"');
+debug('Press the PageUp key:');
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"60"');
+
+debug('Press the PageDown key:');
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"50"');
+
+debug('Press the Home key:');
+sendKey(input, 'Home');
+shouldBe('input.value', '"100"');
+
+debug('Press the End key:');
+sendKey(input, 'End');
+shouldBe('input.value', '"0"');
+
debug('');
debug('step=any cases');
input.step = 'any';
@@ -101,6 +152,30 @@
shouldBe('input.value', '"100"');
shouldBe('changeEventCounter', 'lastChangeEventCounter + 1');
+debug('Press the pageup key:');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"120"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter + 1');
+
+debug('Press the pagedown key:');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"100"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter + 1');
+
+debug('Press the home key:');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'Home');
+shouldBe('input.value', '"200"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter + 1');
+
+debug('Press the end key:');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'End');
+shouldBe('input.value', '"0"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter + 1');
+
debug('Edge cases');
input.valueAsNumber = 199;
sendKey(input, 'Up');
@@ -111,6 +186,17 @@
shouldBe('changeEventCounter', 'lastChangeEventCounter');
sendKey(input, 'Down');
shouldBe('input.value', '"198"');
+
+input.valueAsNumber = 199;
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"200"');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"200"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"180"');
+
input.valueAsNumber = 1;
sendKey(input, 'Down');
shouldBe('input.value', '"0"');
@@ -121,19 +207,63 @@
sendKey(input, 'Up');
shouldBe('input.value', '"2"');
+input.valueAsNumber = 1;
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"0"');
+lastChangeEventCounter = changeEventCounter;
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"0"');
+shouldBe('changeEventCounter', 'lastChangeEventCounter');
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"20"');
+
debug('');
+debug('small range');
+input.min = '0';
+input.max = '10';
+input.step = '3';
+input.valueAsNumber = 6;
+
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"9"');
+
+sendKey(input, 'PageDown');
+shouldBe('input.value', '"6"');
+
+sendKey(input, 'End');
+shouldBe('input.value', '"0"');
+
+sendKey(input, 'Home');
+shouldBe('input.value', '"9"');
+
+sendKey(input, 'End');
+shouldBe('input.value', '"0"');
+
+
+debug('');
debug('Disabled and read-only');
-input.disabled = true;
-input.value = '1';
-input.step = '1';
input.min = '0';
input.max = '100';
+input.step = '1';
+input.value = '1';
+
+input.disabled = true;
sendKey(input, 'Up');
shouldBe('input.value', '"1"');
+sendKey(input, 'Home');
+shouldBe('input.value', '"1"');
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"1"');
input.removeAttribute('disabled');
+
input.readOnly = true;
sendKey(input, 'Up');
shouldBe('input.value', '"1"');
+sendKey(input, 'Home');
+shouldBe('input.value', '"1"');
+sendKey(input, 'PageUp');
+shouldBe('input.value', '"1"');
+input.readOnly = false;
debug('');
var successfullyParsed = true;
Modified: trunk/Source/WebCore/ChangeLog (90551 => 90552)
--- trunk/Source/WebCore/ChangeLog 2011-07-07 10:29:19 UTC (rev 90551)
+++ trunk/Source/WebCore/ChangeLog 2011-07-07 10:37:41 UTC (rev 90552)
@@ -1,3 +1,18 @@
+2011-07-07 Shinya Kawanaka <shin...@google.com>
+
+ Added more key bindings for input[type=range].
+ https://bugs.webkit.org/show_bug.cgi?id=52262
+
+ Added PageUp/PageDown/Home/End key bindings for input[type=range].
+ PageUp/PageDown change value by about 10%.
+ Home/End change value to minimum/maximum.
+
+ Reviewed by Kent Tamura.
+
+ * html/RangeInputType.cpp:
+ (WebCore::RangeInputType::handleKeydownEvent):
+ Added key bindings.
+
2011-07-07 Oleg Romashin <rom...@gmail.com>
Fix InspectorInstrumentation compilation.
Modified: trunk/Source/WebCore/html/RangeInputType.cpp (90551 => 90552)
--- trunk/Source/WebCore/html/RangeInputType.cpp 2011-07-07 10:29:19 UTC (rev 90551)
+++ trunk/Source/WebCore/html/RangeInputType.cpp 2011-07-07 10:37:41 UTC (rev 90552)
@@ -166,40 +166,59 @@
if (element()->disabled() || element()->readOnly())
return;
const String& key = event->keyIdentifier();
- if (key != "Up" && key != "Right" && key != "Down" && key != "Left")
- return;
- ExceptionCode ec;
+ double current = parseToDouble(element()->value(), numeric_limits<double>::quiet_NaN());
+ ASSERT(isfinite(current));
+
+ double step, bigStep;
if (equalIgnoringCase(element()->fastGetAttribute(stepAttr), "any")) {
- double min = minimum();
- double max = maximum();
// FIXME: We can't use stepUp() for the step value "any". So, we increase
// or decrease the value by 1/100 of the value range. Is it reasonable?
- double step = (max - min) / 100;
- double current = parseToDouble(element()->value(), numeric_limits<double>::quiet_NaN());
- ASSERT(isfinite(current));
- // Stepping-up and -down for step="any" are special cases for type="range" from renderer for convenient.
- // No stepping normally for step="any". They cannot be handled by stepUp()/stepDown()/stepUpFromRenderer().
- // So calculating values stepped-up or -down here.
- double newValue;
- if (key == "Up" || key == "Right") {
- newValue = current + step;
- if (newValue > max)
- newValue = max;
- } else {
- newValue = current - step;
- if (newValue < min)
- newValue = min;
- }
- if (newValue != current) {
- setValueAsNumber(newValue, ec);
- element()->dispatchFormControlChangeEvent();
- }
+ step = (maximum() - minimum()) / 100;
+ bigStep = step * 10;
} else {
- int stepMagnification = (key == "Up" || key == "Right") ? 1 : -1;
- // Reasonable stepping-up/-down by stepUpFromRenderer() unless step="any"
- element()->stepUpFromRenderer(stepMagnification);
+ if (!element()->getAllowedValueStep(&step))
+ ASSERT_NOT_REACHED();
+
+ bigStep = (maximum() - minimum()) / 10;
+ if (bigStep < step)
+ bigStep = step;
}
+
+ bool isVertical = false;
+ if (element()->renderer()) {
+ ControlPart part = element()->renderer()->style()->appearance();
+ isVertical = part == SliderVerticalPart || part == MediaVolumeSliderPart;
+ }
+
+ double newValue;
+ if (key == "Up")
+ newValue = current + step;
+ else if (key == "Down")
+ newValue = current - step;
+ else if (key == "Left")
+ newValue = isVertical ? current + step : current - step;
+ else if (key == "Right")
+ newValue = isVertical ? current - step : current + step;
+ else if (key == "PageUp")
+ newValue = current + bigStep;
+ else if (key == "PageDown")
+ newValue = current - bigStep;
+ else if (key == "Home")
+ newValue = isVertical ? maximum() : minimum();
+ else if (key == "End")
+ newValue = isVertical ? minimum() : maximum();
+ else
+ return; // Did not match any key binding.
+
+ newValue = StepRange(element()).clampValue(newValue);
+
+ if (newValue != current) {
+ ExceptionCode ec;
+ setValueAsNumber(newValue, ec);
+ element()->dispatchFormControlChangeEvent();
+ }
+
event->setDefaultHandled();
}
_______________________________________________ webkit-changes mailing list webkit-changes@lists.webkit.org http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes