Changeset 170808 in webkit
- Timestamp:
- Jul 4, 2014, 12:12:25 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r170806 r170808 1 2014-07-04 Julien Quint <pom@graougraou.com> 2 3 input type=range element should only fire change events after committing a value 4 https://bugs.webkit.org/show_bug.cgi?id=134545 5 6 Reviewed by Dean Jackson. 7 8 Two existing tests are updated to count "input" events as well as 9 "change" events. The tests now verify that "change" is only fired once 10 after every slider drag completes, whereas "input" may be fired more 11 than once. 12 13 * fast/forms/range/range-drag-expected.txt: 14 * fast/forms/range/range-drag-when-toggled-disabled-expected.txt: 15 * fast/forms/range/range-drag-when-toggled-disabled.html: 16 * fast/forms/range/range-drag.html: 17 1 18 2014-07-04 Mario Sanchez Prada <mario.prada@samsung.com> 2 19 -
trunk/LayoutTests/fast/forms/range/range-drag-expected.txt
r93593 r170808 4 4 readOnly=false, disabled=false 5 5 PASS input.value is "100" 6 PASS changeEventCounter is >= lastChangeEventCounter + 1 6 PASS inputEventCounter is >= lastInputEventCounter + 1 7 PASS changeEventCounter is lastChangeEventCounter + 1 7 8 readOnly=true 8 9 PASS input.value is "50" 10 PASS lastInputEventCounter is inputEventCounter 9 11 PASS lastChangeEventCounter is changeEventCounter 10 12 disabled=true 11 13 PASS input.value is "50" 14 PASS lastInputEventCounter is inputEventCounter 12 15 PASS lastChangeEventCounter is changeEventCounter 13 16 … … 15 18 readOnly=false, disabled=false 16 19 PASS input.value is "100" 17 PASS changeEventCounter is >= lastChangeEventCounter + 1 20 PASS inputEventCounter is >= lastInputEventCounter + 1 21 PASS changeEventCounter is lastChangeEventCounter + 1 18 22 readOnly=true 19 23 PASS input.value is "50" 24 PASS lastInputEventCounter is inputEventCounter 20 25 PASS lastChangeEventCounter is changeEventCounter 21 26 disabled=true 22 27 PASS input.value is "50" 28 PASS lastInputEventCounter is inputEventCounter 23 29 PASS lastChangeEventCounter is changeEventCounter 24 30 -
trunk/LayoutTests/fast/forms/range/range-drag-when-toggled-disabled-expected.txt
r112547 r170808 4 4 readOnly=false, disabled=false 5 5 PASS input.value is "100" 6 PASS changeEventCounter is >= lastChangeEventCounter + 16 PASS inputEventCounter is >= lastInputEventCounter + 1 7 7 PASS input.value is "0" 8 PASS changeEventCounter is >= lastChangeEventCounter + 18 PASS inputEventCounter is >= lastInputEventCounter + 1 9 9 readOnly=true 10 10 PASS input.value is "0" 11 PASS last ChangeEventCounter is changeEventCounter11 PASS lastInputEventCounter is inputEventCounter 12 12 13 13 Tests for range dragging while it toggles to be disabled. 14 14 readOnly=false, disabled=false 15 15 PASS input.value is "100" 16 PASS changeEventCounter is >= lastChangeEventCounter + 116 PASS inputEventCounter is >= lastInputEventCounter + 1 17 17 PASS input.value is "0" 18 PASS changeEventCounter is >= lastChangeEventCounter + 118 PASS inputEventCounter is >= lastInputEventCounter + 1 19 19 disabled=true 20 20 PASS input.value is "0" 21 PASS lastChangeEventCounter is changeEventCounter 21 PASS lastInputEventCounter is inputEventCounter 22 23 PASS changeEventCounter is 1 22 24 23 25 PASS successfullyParsed is true -
trunk/LayoutTests/fast/forms/range/range-drag-when-toggled-disabled.html
r155268 r170808 12 12 13 13 var changeEventCounter = 0; 14 var lastChangeEventCounter = changeEventCounter;15 14 function handleChange() { 16 15 changeEventCounter++; 16 } 17 18 var inputEventCounter = 0; 19 var lastInputEventCounter = inputEventCounter; 20 function handleInput() { 21 inputEventCounter++; 17 22 } 18 23 … … 25 30 input = document.getElementById(id); 26 31 input.onchange = handleChange; 32 input.oninput = handleInput; 27 33 input.focus(); 28 34 … … 50 56 debug('readOnly=false, disabled=false'); 51 57 input.valueAsNumber = 50; 52 last ChangeEventCounter = changeEventCounter;58 lastInputEventCounter = inputEventCounter; 53 59 dragToRightEdge(); 54 60 shouldBe('input.value', '"100"'); 55 shouldBeGreaterThanOrEqual(' changeEventCounter', 'lastChangeEventCounter + 1');56 last ChangeEventCounter = changeEventCounter;61 shouldBeGreaterThanOrEqual('inputEventCounter', 'lastInputEventCounter + 1'); 62 lastInputEventCounter = inputEventCounter; 57 63 dragToLeftEdge(); 58 64 shouldBe('input.value', '"0"'); 59 shouldBeGreaterThanOrEqual(' changeEventCounter', 'lastChangeEventCounter + 1');65 shouldBeGreaterThanOrEqual('inputEventCounter', 'lastInputEventCounter + 1'); 60 66 61 67 // Toggle (readonly | disabled). … … 64 70 65 71 // Attempt to drag to right edge. Should not change. 66 last ChangeEventCounter = changeEventCounter;72 lastInputEventCounter = inputEventCounter; 67 73 dragToRightEdge(); 68 74 shouldBe('input.value', '"0"'); 69 shouldBe('last ChangeEventCounter', 'changeEventCounter');75 shouldBe('lastInputEventCounter', 'inputEventCounter'); 70 76 71 77 stopDrag(); … … 84 90 debug(''); 85 91 92 shouldBe('changeEventCounter', '1'); 93 debug(''); 94 86 95 </script> 87 96 <script src="../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/fast/forms/range/range-drag.html
r155268 r170808 8 8 <div id="console"></div> 9 9 <script> 10 11 var inputEventCounter = 0; 12 function handleInput() { 13 inputEventCounter++; 14 } 15 var lastInputEventCounter = inputEventCounter; 10 16 11 17 var changeEventCounter = 0; … … 41 47 debug('readOnly=false, disabled=false'); 42 48 input.valueAsNumber = 50; 49 lastInputEventCounter = inputEventCounter; 43 50 lastChangeEventCounter = changeEventCounter; 44 51 dragMouse(); 45 52 shouldBe('input.value', '"100"'); 46 shouldBeGreaterThanOrEqual('changeEventCounter', 'lastChangeEventCounter + 1'); 53 shouldBeGreaterThanOrEqual('inputEventCounter', 'lastInputEventCounter + 1'); 54 shouldBe('changeEventCounter', 'lastChangeEventCounter + 1'); 47 55 48 56 debug('readOnly=true'); … … 50 58 input.readOnly = true; 51 59 input.valueAsNumber = 50; 60 lastInputEventCounter = inputEventCounter; 52 61 lastChangeEventCounter = changeEventCounter; 53 62 dragMouse(); 54 63 shouldBe('input.value', '"50"'); 64 shouldBe('lastInputEventCounter', 'inputEventCounter'); 55 65 shouldBe('lastChangeEventCounter', 'changeEventCounter'); 56 66 … … 59 69 input.disabled = true; 60 70 input.valueAsNumber = 50; 71 lastInputEventCounter = inputEventCounter; 61 72 lastChangeEventCounter = changeEventCounter; 62 73 dragMouse(); 63 74 shouldBe('input.value', '"50"'); 75 shouldBe('lastInputEventCounter', 'inputEventCounter'); 64 76 shouldBe('lastChangeEventCounter', 'changeEventCounter'); 65 77 } … … 72 84 debug('Tests for range dragging from center.'); 73 85 var input = document.getElementById('range1'); 86 input.oninput = handleInput; 74 87 input.onchange = handleChange; 75 88 input.focus(); … … 79 92 debug('Tests for range dragging from edge'); 80 93 var input = document.getElementById('range2'); 94 input.oninput = handleInput; 81 95 input.onchange = handleChange; 82 96 input.focus(); -
trunk/Source/WebCore/ChangeLog
r170807 r170808 1 2014-07-04 Julien Quint <pom@graougraou.com> 2 3 input type=range element should only fire change events after committing a value 4 https://bugs.webkit.org/show_bug.cgi?id=134545 5 6 Reviewed by Dean Jackson. 7 8 A "change" event was fired every time the slider thumb element was dragged 9 by the user. The "change" event is now fired only after the thumb 10 element has stopped moving; previously, both "input" and "change" events 11 where dispatched while changes were being made. This new behavior is 12 consistent with the specification (cf. 13 http://www.whatwg.org/specs/web-apps/current-work/multipage/common-input-element-attributes.html#event-input-change), 14 as well as other implementations such as Firefox and Chrome. 15 16 * Modules/mediacontrols/mediaControlsApple.js: 17 (Controller.prototype.createControls): Listen to the "input" event 18 rather than the "change" event for the timeline control in order to 19 keep track of value changes when the user is dragging the thumb. 20 * accessibility/AccessibilitySlider.cpp: 21 (WebCore::AccessibilitySlider::setValue): Dispatch "change" event while 22 setting the new value rather than dispatching later, since setting the 23 value now clears the change flag. 24 * html/RangeInputType.cpp: 25 (WebCore::RangeInputType::setValue): Update the text value of the 26 control in the case when no event is to be dispatched, so that this 27 value can be checked the next time a "change" event dispatch is 28 requested. 29 * html/shadow/SliderThumbElement.cpp: 30 (WebCore::SliderThumbElement::setPositionFromPoint): Removed the 31 dispatch of the "change" event, and no longer track the text value of 32 the element as a result of dispatching a "change" event. 33 (WebCore::SliderThumbElement::stopDragging): Dispatch the "change" event 34 on completing the drag. 35 1 36 2014-07-04 Andreas Kling <akling@apple.com> 2 37 -
trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js
r170315 r170808 331 331 timeline.style.backgroundImage = '-webkit-canvas(timeline-' + this.timelineID + ')'; 332 332 timeline.type = 'range'; 333 this.listenFor(timeline, ' change', this.handleTimelineChange);333 this.listenFor(timeline, 'input', this.handleTimelineChange); 334 334 this.listenFor(timeline, 'mouseover', this.handleTimelineMouseOver); 335 335 this.listenFor(timeline, 'mouseout', this.handleTimelineMouseOut); -
trunk/Source/WebCore/accessibility/AccessibilitySlider.cpp
r165676 r170808 134 134 return; 135 135 136 input->setValue(value); 137 138 // Fire change event manually, as RenderSlider::setValueForPosition does. 139 input->dispatchFormControlChangeEvent(); 136 input->setValue(value, DispatchChangeEvent); 140 137 } 141 138 -
trunk/Source/WebCore/html/RangeInputType.cpp
r170774 r170808 328 328 return; 329 329 330 if (eventBehavior == DispatchNoEvent) 331 element().setTextAsOfLastFormControlChangeEvent(value); 332 330 333 typedSliderThumbElement().setPositionFromValue(); 331 334 } -
trunk/Source/WebCore/html/shadow/SliderThumbElement.cpp
r170774 r170808 262 262 return; 263 263 264 input->setTextAsOfLastFormControlChangeEvent(input->value());265 266 264 // Do all the tracking math relative to the input's renderer's box. 267 265 RenderBox& inputRenderer = *toRenderBox(input->renderer()); … … 313 311 if (renderer()) 314 312 renderer()->setNeedsLayout(); 315 input->dispatchFormControlChangeEvent();316 313 } 317 314 … … 334 331 if (renderer()) 335 332 renderer()->setNeedsLayout(); 333 334 RefPtr<HTMLInputElement> input = hostInput(); 335 if (input) 336 input->dispatchFormControlChangeEvent(); 336 337 } 337 338
Note:
See TracChangeset
for help on using the changeset viewer.