Commit 1b27cba5 authored by tkent@chromium.org's avatar tkent@chromium.org

2011-01-25 Kent Tamura <tkent@chromium.org>

        Reviewed by Dimitri Glazkov.

        Range and number inputs should reject increment and decrement by
        keyboard or mouse wheel if they are disabled or read-only
        https://bugs.webkit.org/show_bug.cgi?id=53151

        Add checks for 'disabled' and 'readOnly'.

        * fast/forms/input-number-keyoperation-expected.txt:
        * fast/forms/input-number-wheel-expected.txt:
        * fast/forms/range-keyoperation-expected.txt:
        * fast/forms/range-keyoperation.html:
        * fast/forms/script-tests/input-number-keyoperation.js:
        * fast/forms/script-tests/input-number-wheel.js:
2011-01-25  Kent Tamura  <tkent@chromium.org>

        Reviewed by Dimitri Glazkov.

        Range and number inputs should reject increment and decrement by
        keyboard or mouse wheel if they are disabled or read-only
        https://bugs.webkit.org/show_bug.cgi?id=53151

        * html/RangeInputType.cpp:
        (WebCore::RangeInputType::handleKeydownEvent): Check disabled() and readOnly().
        * html/TextFieldInputType.cpp:
        (WebCore::TextFieldInputType::handleKeydownEventForSpinButton): ditto.
        (WebCore::TextFieldInputType::handleWheelEventForSpinButton): ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76662 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent a2a0e4ec
2011-01-25 Kent Tamura <tkent@chromium.org>
Reviewed by Dimitri Glazkov.
Range and number inputs should reject increment and decrement by
keyboard or mouse wheel if they are disabled or read-only
https://bugs.webkit.org/show_bug.cgi?id=53151
Add checks for 'disabled' and 'readOnly'.
* fast/forms/input-number-keyoperation-expected.txt:
* fast/forms/input-number-wheel-expected.txt:
* fast/forms/range-keyoperation-expected.txt:
* fast/forms/range-keyoperation.html:
* fast/forms/script-tests/input-number-keyoperation.js:
* fast/forms/script-tests/input-number-wheel.js:
2011-01-25 Cris Neckar <cdn@chromium.org>
Reviewed by Adam Barth.
......
......@@ -9,6 +9,10 @@ Press the up arrow key:
PASS input.value is "124"
Press the down arrow key:
PASS input.value is "123"
Disable input element:
PASS input.value is "123"
Read-only input element:
PASS input.value is "123"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -11,6 +11,10 @@ Wheel down by 1:
PASS input.value is "1"
Wheel down by 256:
PASS input.value is "0"
Disabled input element:
PASS input.value is "0"
Read-only input element:
PASS input.value is "0"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -44,6 +44,10 @@ PASS input.value is "0"
PASS changeEventCounter is lastChangeEventCounter
PASS input.value is "2"
Disabled and read-only
PASS input.value is "1"
PASS input.value is "1"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -121,6 +121,20 @@ shouldBe('changeEventCounter', 'lastChangeEventCounter');
sendKey(input, 'Up');
shouldBe('input.value', '"2"');
debug('');
debug('Disabled and read-only');
input.disabled = true;
input.value = '1';
input.step = '1';
input.min = '0';
input.max = '100';
sendKey(input, 'Up');
shouldBe('input.value', '"1"');
input.removeAttribute('disabled');
input.readOnly = true;
sendKey(input, 'Up');
shouldBe('input.value', '"1"');
debug('');
var successfullyParsed = true;
</script>
......
......@@ -17,4 +17,15 @@ debug('Press the down arrow key:');
eventSender.keyDown('downArrow');
shouldBe('input.value', '"123"');
debug('Disable input element:');
input.disabled = true;
eventSender.keyDown('upArrow');
shouldBe('input.value', '"123"');
input.removeAttribute('disabled');
debug('Read-only input element:');
input.readOnly = true;
eventSender.keyDown('upArrow');
shouldBe('input.value', '"123"');
var successfullyParsed = true;
......@@ -29,4 +29,15 @@ debug('Wheel down by 256:');
dispatchWheelEvent(input, 0, -256);
shouldBe('input.value', '"0"');
debug('Disabled input element:');
input.disabled = true;
dispatchWheelEvent(input, 0, 1);
shouldBe('input.value', '"0"');
input.removeAttribute('disabled');
debug('Read-only input element:');
input.readOnly = true;
dispatchWheelEvent(input, 0, 1);
shouldBe('input.value', '"0"');
var successfullyParsed = true;
2011-01-25 Kent Tamura <tkent@chromium.org>
Reviewed by Dimitri Glazkov.
Range and number inputs should reject increment and decrement by
keyboard or mouse wheel if they are disabled or read-only
https://bugs.webkit.org/show_bug.cgi?id=53151
* html/RangeInputType.cpp:
(WebCore::RangeInputType::handleKeydownEvent): Check disabled() and readOnly().
* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::handleKeydownEventForSpinButton): ditto.
(WebCore::TextFieldInputType::handleWheelEventForSpinButton): ditto.
2011-01-25 Kent Tamura <tkent@chromium.org>
Reviewed by Dimitri Glazkov.
......@@ -154,6 +154,8 @@ void RangeInputType::handleMouseDownEvent(MouseEvent* event)
void RangeInputType::handleKeydownEvent(KeyboardEvent* event)
{
if (element()->disabled() || element()->readOnly())
return;
const String& key = event->keyIdentifier();
if (key != "Up" && key != "Right" && key != "Down" && key != "Left")
return;
......
......@@ -64,6 +64,8 @@ void TextFieldInputType::handleKeydownEvent(KeyboardEvent* event)
void TextFieldInputType::handleKeydownEventForSpinButton(KeyboardEvent* event)
{
if (element()->disabled() || element()->readOnly())
return;
const String& key = event->keyIdentifier();
int step = 0;
if (key == "Up")
......@@ -78,6 +80,8 @@ void TextFieldInputType::handleKeydownEventForSpinButton(KeyboardEvent* event)
void TextFieldInputType::handleWheelEventForSpinButton(WheelEvent* event)
{
if (element()->disabled() || element()->readOnly())
return;
int step = 0;
if (event->wheelDeltaY() > 0)
step = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment