Skip to content

Commit

Permalink
Merge r164367 - Do not dispatch change event twice in single step action
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=116936
<rdar://problem/16086828>

Reviewed by Ryosuke Niwa.

Merged from Blink (patch by Kent Tamura):
https://src.chromium.org/viewvc/blink?view=rev&revision=151175

Source/WebCore:

Test: fast/forms/number/number-type-update-by-change-event.html

* html/InputType.cpp:
(WebCore::InputType::stepUpFromRenderer):

LayoutTests:

* fast/forms/number/number-type-update-by-change-event-expected.txt: Added.
* fast/forms/number/number-type-update-by-change-event.html: Added.
  • Loading branch information
dydz authored and carlosgcampos committed Apr 14, 2014
1 parent 5618fdb commit 08d744a
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 1 deletion.
14 changes: 14 additions & 0 deletions LayoutTests/ChangeLog
@@ -1,3 +1,17 @@
2014-02-19 Daniel Bates <dabates@apple.com>

Do not dispatch change event twice in single step action
https://bugs.webkit.org/show_bug.cgi?id=116936
<rdar://problem/16086828>

Reviewed by Ryosuke Niwa.

Merged from Blink (patch by Kent Tamura):
https://src.chromium.org/viewvc/blink?view=rev&revision=151175

* fast/forms/number/number-type-update-by-change-event-expected.txt: Added.
* fast/forms/number/number-type-update-by-change-event.html: Added.

2014-02-17 Chris Fleizach <cfleizach@apple.com>

AX: Invalid cast in WebCore::AccessibilityTable::isDataTable (CRBug 280352)
Expand Down
@@ -0,0 +1,6 @@
PASS if not crashed in ASAN build.
PASS changeEventCounter is 1
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,28 @@
<!DOCTYPE>
<html>
<body>
<script src="../../../resources/js-test-pre.js"></script>
<input type="number" onchange="handleChange(this);">
<script>
function sendKey(keyName) {
var event = document.createEvent('KeyboardEvent');
event.initKeyboardEvent('keydown', true, true, document.defaultView, keyName);
document.activeElement.dispatchEvent(event);
}

function handleChange(element) {
element.type = '';
++changeEventCounter;
}

var changeEventCounter = 0;
var numberInput = document.getElementsByTagName('input')[0];
numberInput.focus();
sendKey('Up');

testPassed('if not crashed in ASAN build.');
shouldBe('changeEventCounter', '1');
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>
16 changes: 16 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,19 @@
2014-02-19 Daniel Bates <dabates@apple.com>

Do not dispatch change event twice in single step action
https://bugs.webkit.org/show_bug.cgi?id=116936
<rdar://problem/16086828>

Reviewed by Ryosuke Niwa.

Merged from Blink (patch by Kent Tamura):
https://src.chromium.org/viewvc/blink?view=rev&revision=151175

Test: fast/forms/number/number-type-update-by-change-event.html

* html/InputType.cpp:
(WebCore::InputType::stepUpFromRenderer):

2014-02-17 Chris Fleizach <cfleizach@apple.com>

AX: Invalid cast in WebCore::AccessibilityTable::isDataTable (CRBug 280352)
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/html/InputType.cpp
Expand Up @@ -64,6 +64,7 @@
#include "RenderTheme.h"
#include "ResetInputType.h"
#include "RuntimeEnabledFeatures.h"
#include "ScopedEventQueue.h"
#include "SearchInputType.h"
#include "ShadowRoot.h"
#include "SubmitInputType.h"
Expand Down Expand Up @@ -1098,6 +1099,7 @@ void InputType::stepUpFromRenderer(int n)
if (!stepRange.hasStep())
return;

EventQueueScope scope;
const Decimal step = stepRange.step();

int sign;
Expand All @@ -1117,7 +1119,7 @@ void InputType::stepUpFromRenderer(int n)
current = stepRange.minimum() - nextDiff;
if (current > stepRange.maximum() - nextDiff)
current = stepRange.maximum() - nextDiff;
setValueAsDecimal(current, DispatchInputAndChangeEvent, IGNORE_EXCEPTION);
setValueAsDecimal(current, DispatchNoEvent, IGNORE_EXCEPTION);
}
if ((sign > 0 && current < stepRange.minimum()) || (sign < 0 && current > stepRange.maximum()))
setValueAsDecimal(sign > 0 ? stepRange.minimum() : stepRange.maximum(), DispatchInputAndChangeEvent, IGNORE_EXCEPTION);
Expand Down

0 comments on commit 08d744a

Please sign in to comment.