Changeset 75555 in webkit
- Timestamp:
- Jan 11, 2011 2:47:10 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r75552 r75555 1 2011-01-11 Mihai Parparita <mihaip@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Scroll event should be fired asynchronously 6 https://bugs.webkit.org/show_bug.cgi?id=45631 7 8 Update existing tests that assumed that scroll events fired 9 synchronously. 10 11 * editing/input/page-up-down-scrolls-expected.txt: 12 * editing/input/page-up-down-scrolls.html: 13 * fast/events/fire-scroll-event-element-expected.txt: Copied from LayoutTests/fast/events/fire-scroll-event-expected.txt. 14 * fast/events/fire-scroll-event-element.html: Added. Does the same 15 tests as fire-scroll-event.html, but on an individual element instead 16 of the whole document. 17 * fast/events/fire-scroll-event-expected.txt: 18 * fast/events/fire-scroll-event.html: Now explicitly tests for 19 synchronous behavior when scrolling the document, and that we don't 20 fire the event more than once. 21 * fast/events/remove-child-onscroll.html: 22 * fast/events/scroll-during-zoom-change.html: 23 * fast/events/scroll-event-does-not-bubble.html: 24 * fast/events/scroll-event-phase-expected.txt: Added. 25 * fast/events/scroll-event-phase.html: Added. Checks that we can listen 26 for scroll events in both the capture and bubble phase. 27 * fast/layers/removed-by-scroll-handler.html: 28 * fast/overflow/onscroll-layer-self-destruct.html: 29 * fast/repaint/repaint-during-scroll.html: 30 1 31 2011-01-11 Mihai Parparita <mihaip@chromium.org> 2 32 -
trunk/LayoutTests/editing/input/page-up-down-scrolls-expected.txt
r60591 r75555 1 1 xx 2 This test simulates hitting page up and page down once each. Both keypresses should generate exactly one scroll event. This test requires DRT to pass.2 This test simulates hitting page up and page down once each. Both keypresses should generate exactly one scroll event. If running manually, press the keys now. 3 3 PASS 4 4 (just here to force scrollbars) -
trunk/LayoutTests/editing/input/page-up-down-scrolls.html
r60591 r75555 3 3 <head> 4 4 <script> 5 if (window.layoutTestController) 5 if (window.layoutTestController) { 6 6 layoutTestController.dumpAsText(); 7 layoutTestController.waitUntilDone(); 8 } 7 9 8 function scr() 9 { 10 var step = 0; 11 12 onscroll = function() { 10 13 document.getElementById('log').innerText += 'x'; 14 15 switch (step) { 16 case 0: 17 if (window.eventSender) 18 eventSender.keyDown('pageUp'); 19 break; 20 case 1: 21 document.getElementById('results').innerText = 'PASS'; 22 if (window.layoutTestController) 23 layoutTestController.notifyDone(); 24 break; 25 } 26 27 step++; 11 28 } 12 29 13 30 function runTest() 14 31 { 15 if (!window.eventSender) 16 return; 17 18 window.addEventListener('scroll', scr, false); 19 20 eventSender.keyDown("pageDown"); 21 var text = document.getElementById('log').innerText; 22 if (text != "x") 23 throw "log should contain x, not " + text; 24 25 eventSender.keyDown("pageUp"); 26 var text = document.getElementById('log').innerText; 27 if (text != "xx") 28 throw "log should contain xx, not " + text; 29 30 document.getElementById("results").innerText = "PASS"; 32 if (window.eventSender) 33 eventSender.keyDown('pageDown'); 31 34 } 32 35 </script> … … 34 37 <body onload="runTest()"> 35 38 <span id="log" style="position:fixed"></span> 36 <div>This test simulates hitting page up and page down once each. Both keypresses should generate exactly one scroll event. This test requires DRT to pass.</div>39 <div>This test simulates hitting page up and page down once each. Both keypresses should generate exactly one scroll event. If running manually, press the keys now.</div> 37 40 <div id="results">FAIL</div> 38 41 <div style="height:50000px">(just here to force scrollbars)</div> -
trunk/LayoutTests/fast/events/fire-scroll-event-expected.txt
r20982 r75555 1 PASSED 1 Checks that the scroll event fires on the document asychronously and only once. 2 2 3 If the word 'PASSED' does not appear above, then the test has failed. If the test fails, it means that a scroll event did not fire.3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 4 4 5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 a17 a18 a19 a20 a21 a22 a23 a24 a25 a26 a27 a28 a29 a30 a31 a32 a33 a34 a35 a36 a37 a38 a39 a40 a41 a42 a43 a44 a45 a46 a47 a48 a49 a50 a51 a52 a53 a54 a55 a56 a57 a58 a59 5 6 Scroll event bubbles: true 7 PASS Scroll position: (200, 200) 8 PASS successfullyParsed is true 9 10 TEST COMPLETE 11 -
trunk/LayoutTests/fast/events/fire-scroll-event.html
r20982 r75555 1 1 <html> 2 <link rel="stylesheet" href="../js/resources/js-test-style.css"> 3 <script src="../js/resources/js-test-pre.js"></script> 4 <body style="min-width: 5000px; min-height: 5000px"> 5 <p id="description"></p> 6 <div id="console"></div> 2 7 <script> 3 var eventFired = false;8 description('Checks that the scroll event fires on the document asychronously and only once.'); 4 9 5 function scroller() { 6 if (!eventFired) { 7 eventFired = true; 8 document.getElementById("passed").innerHTML = "<p style='color:red'>PASSED</p>"; 10 var eventCount = 0; 11 var doneTimeout; 12 13 onscroll = function(event) 14 { 15 eventCount++; 16 if (eventCount == 1) { 17 debug('Scroll event bubbles: ' + event.bubbles); 18 var scrollX = document.body.scrollLeft; 19 var scrollY = document.body.scrollTop; 20 testPassed('Scroll position: (' + scrollX + ', ' + scrollY + ')'); 21 // Don't call notifyDone straight away, in case there's another scroll event coming. 22 doneTimeout = setTimeout(finishJSTest, 100); 23 } else { 24 clearTimeout(doneTimeout); 25 testFailed('Scroll handler was invoked ' + eventCount + ' times'); 26 finishJSTest(); 9 27 } 10 28 } 11 29 12 window.onload = function() { 13 window.addEventListener('scroll', scroller, false); 14 window.scrollTo(500, 500); 15 if (window.layoutTestController) { 16 layoutTestController.dumpAsText(); 30 onload = function() 31 { 32 window.scrollTo(100, 100); 33 if (eventCount > 0) { 34 testFailed('Scroll event fired synchronously'); 35 finishJSTest(); 17 36 } 37 window.scrollTo(200, 200); 18 38 } 19 39 40 var successfullyParsed = true; 41 var jsTestIsAsync = true; 20 42 </script> 21 <body> 22 <div id="passed"></div> 23 24 <p>If the word 'PASSED' does not appear above, then the test has failed. If the test fails, it means that a scroll event did not fire.</p> 25 26 a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br> 27 a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br> 28 a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br>a<br> 43 <script src="../js/resources/js-test-post.js"></script> 29 44 </body> 30 45 </html> -
trunk/LayoutTests/fast/events/remove-child-onscroll.html
r55737 r75555 10 10 { 11 11 if (window.eventSender && window.layoutTestController) { 12 layoutTestController.waitUntilDone(); 12 13 eventSender.mouseMoveTo(100, 100); 13 14 eventSender.mouseScrollBy(0, -1); 14 eventSender.mouseScrollBy(-1, -1); 15 layoutTestController.notifyDone(); 15 var scrollCount = 0; 16 document.getElementById('dv').addEventListener( 17 'scroll', 18 function(event) { 19 this.removeChild(this.firstChild); 20 scrollCount++; 21 if (scrollCount == 1) 22 eventSender.mouseScrollBy(-1, -1); 23 else 24 layoutTestController.notifyDone(); 25 }, 26 false); 16 27 } 17 28 } … … 20 31 <body onload="setTimeout('dispatchScrollEvents();', 1);"> 21 32 This test verifies that children can be removed by their parent element's onscroll event handler. The test succeeds if this is the only text remaining after the two scroll events are dispatched. The test fails if the inner div remains in the output or if WebKit crashes.<br><br> 22 <div id="dv" style="overflow: auto; width: 200px; height: 200px; whitespace: nowrap;" onscroll="this.removeChild(this.firstChild)">33 <div id="dv" style="overflow: auto; width: 200px; height: 200px; whitespace: nowrap;"> 23 34 <div style="width:300px; height:300px">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum 24 35 </div> -
trunk/LayoutTests/fast/events/scroll-during-zoom-change.html
r41338 r75555 17 17 { 18 18 event.target.parentNode.removeChild(event.target); 19 if (window.layoutTestController) { 20 layoutTestController.notifyDone(); 21 } 19 22 } 20 23 … … 28 31 } 29 32 30 if (window.layoutTestController) 33 if (window.layoutTestController) { 31 34 layoutTestController.dumpAsText(); 35 layoutTestController.waitUntilDone(); 36 } 32 37 test(); 33 38 </script> -
trunk/LayoutTests/fast/events/scroll-event-does-not-bubble.html
r35168 r75555 1 1 <html> 2 2 <script> 3 var windowWasScrolled = false; 4 var doneTimeout; 5 3 6 function windowScrolled() { 7 windowWasScrolled = true; 4 8 document.getElementById('result').innerHTML = 'FAILURE: window.onscroll was called.'; 9 clearTimeout(doneTimeout); 5 10 } 6 11 7 12 function divScrolled() { 8 document.getElementById('result').innerHTML = 'SUCCESS: div.onscroll was called, but window.onscroll was not.'; 13 if (!windowWasScrolled) 14 document.getElementById('result').innerHTML = 'SUCCESS: div.onscroll was called, but window.onscroll was not.'; 15 // Don't call notifyDone straight away, in case there's another scroll event coming/bubbling. 16 doneTimeout = setTimeout(function() { 17 if (window.layoutTestController) 18 layoutTestController.notifyDone(); 19 }, 100); 9 20 } 10 21 … … 25 36 // Don't pollute the test result with nonsense. 26 37 div.innerHTML = ''; 27 28 if (window.layoutTestController)29 layoutTestController.notifyDone();30 31 38 } 32 39 -
trunk/LayoutTests/fast/layers/removed-by-scroll-handler.html
r19204 r75555 12 12 Result: <span id="result">test did not complete.</span> 13 13 </p> 14 <div id="t" style="overflow: auto; width: 200px; height: 100px;" onscroll=" if (overflowRemove) this.parentNode.removeChild(this);">14 <div id="t" style="overflow: auto; width: 200px; height: 100px;" onscroll="this.parentNode.removeChild(this);handleScroll(0);"> 15 15 <div style="height: 200px;"></div> 16 16 </div> 17 17 18 <div style="overflow: auto; width: 200px; height: 100px;" onscroll=" if (secondOverflowRemove) this.parentNode.removeChild(this);">18 <div style="overflow: auto; width: 200px; height: 100px;" onscroll="this.parentNode.removeChild(this);handleScroll(1);"> 19 19 <div style="height: 200px;"></div> 20 20 <div id="d"></div> … … 22 22 23 23 <script> 24 var overflowRemove= false;25 var s econdOverflowRemove= false;24 var scrolledFirstContainer = false; 25 var scrolledSecondContainer = false; 26 26 27 27 document.body.offsetTop; t.scrollTop = 20; 28 28 29 overflowRemove = true;30 document.getElementById('t').innerHTML = '';31 32 secondOverflowRemove = true;33 29 document.getElementById('d').scrollIntoView(); 34 30 35 document.getElementById('result').innerText = "SUCCESS"; 36 37 if (window.layoutTestController) 38 layoutTestController.notifyDone(); 31 function handleScroll(index) 32 { 33 if (index == 0) scrolledFirstContainer = true; 34 else if (index == 1) scrolledSecondContainer = true; 35 36 if (scrolledFirstContainer && scrolledSecondContainer) { 37 document.getElementById('result').innerText = "SUCCESS"; 38 39 if (window.layoutTestController) 40 layoutTestController.notifyDone(); 41 } 42 } 39 43 </script> -
trunk/LayoutTests/fast/overflow/onscroll-layer-self-destruct.html
r12581 r75555 2 2 <script> 3 3 function test() { 4 if (window.layoutTestController) 4 if (window.layoutTestController) { 5 5 layoutTestController.dumpAsText(); 6 layoutTestController.waitUntilDone(); 7 } 6 8 document.getElementById("it").scrollTop = 100; 7 9 } … … 9 11 <body onload="test()"> 10 12 <p>This test involves a layer that self-destructs when scrolled. If there's no crash, then the test succeeded.</p> 11 <div id="it" style="height: 100%; overflow: auto;" onscroll="style.display = 'none' ">13 <div id="it" style="height: 100%; overflow: auto;" onscroll="style.display = 'none';if (window.layoutTestController) layoutTestController.notifyDone();"> 12 14 <div style="height: 2000px;"></div> 13 15 </div> -
trunk/LayoutTests/fast/repaint/repaint-during-scroll.html
r55159 r75555 4 4 function repaintTest() 5 5 { 6 if (window.layoutTestController) 7 layoutTestController.waitUntilDone(); 6 8 var target = document.getElementById("target"); 7 9 scrollBy(0, 100); … … 12 14 var target = document.getElementById("target"); 13 15 target.style.backgroundColor = "green"; 16 if (window.layoutTestController) 17 layoutTestController.notifyDone(); 14 18 } 15 19 </script> -
trunk/Source/WebCore/ChangeLog
r75549 r75555 1 2011-01-11 Mihai Parparita <mihaip@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 Scroll event should be fired asynchronously 6 https://bugs.webkit.org/show_bug.cgi?id=45631 7 8 Tests: fast/events/fire-scroll-event.html 9 fast/events/fire-scroll-event-element.html 10 fast/events/scroll-event-phase.html 11 12 Makes scroll events fire asynchronously to be in compliance with the 13 CSSOM View Module and consistent with Gecko, Opera and (to some degree) 14 IE. 15 16 Implemented via the EventQueue class added by r74062 (EventQueue now 17 has a convenience enqueueScrollEvent method). 18 19 * dom/EventQueue.cpp: 20 (WebCore::EventQueue::enqueueScrollEvent): 21 (WebCore::EventQueue::pendingEventTimerFired): 22 * dom/EventQueue.h: 23 * page/EventHandler.cpp: 24 (WebCore::EventHandler::sendScrollEvent): 25 * rendering/RenderLayer.cpp: 26 (WebCore::RenderLayer::scrollToOffset): 27 * rendering/RenderListBox.cpp: 28 (WebCore::RenderListBox::valueChanged): 29 1 30 2011-01-11 Patrick Gansterer <paroga@webkit.org> 2 31 -
trunk/Source/WebCore/dom/EventQueue.cpp
r74062 r75555 49 49 } 50 50 51 void EventQueue::enqueueScrollEvent(PassRefPtr<Node> target, ScrollEventTargetType targetType) 52 { 53 if (!m_nodesWithQueuedScrollEvents.add(target.get()).second) 54 return; 55 56 // Per the W3C CSSOM View Module, scroll events fired at the document should bubble, others should not. 57 bool canBubble = targetType == ScrollEventDocumentTarget; 58 RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubble, false /* non cancelleable */); 59 scrollEvent->setTarget(target); 60 enqueueEvent(scrollEvent.release()); 61 } 62 51 63 void EventQueue::pendingEventTimerFired(Timer<EventQueue>*) 52 64 { … … 55 67 Vector<RefPtr<Event> > queuedEvents; 56 68 queuedEvents.swap(m_queuedEvents); 69 70 m_nodesWithQueuedScrollEvents.clear(); 57 71 58 72 for (size_t i = 0; i < queuedEvents.size(); i++) -
trunk/Source/WebCore/dom/EventQueue.h
r74062 r75555 29 29 30 30 #include "Timer.h" 31 #include <wtf/HashSet.h> 31 32 #include <wtf/Noncopyable.h> 32 33 #include <wtf/RefPtr.h> … … 42 43 43 44 public: 45 enum ScrollEventTargetType { 46 ScrollEventDocumentTarget, 47 ScrollEventElementTarget 48 }; 49 44 50 EventQueue(); 45 51 46 52 void enqueueEvent(PassRefPtr<Event>); 53 void enqueueScrollEvent(PassRefPtr<Node>, ScrollEventTargetType); 47 54 48 55 private: … … 52 59 Timer<EventQueue> m_pendingEventTimer; 53 60 Vector<RefPtr<Event> > m_queuedEvents; 61 HashSet<Node*> m_nodesWithQueuedScrollEvents; 54 62 }; 55 63 -
trunk/Source/WebCore/page/EventHandler.cpp
r75287 r75555 37 37 #include "Editor.h" 38 38 #include "EventNames.h" 39 #include "EventQueue.h" 39 40 #include "FloatPoint.h" 40 41 #include "FloatRect.h" … … 2799 2800 setFrameWasScrolledByUser(); 2800 2801 if (m_frame->view() && m_frame->document()) 2801 m_frame->document()-> dispatchEvent(Event::create(eventNames().scrollEvent, true, false));2802 m_frame->document()->eventQueue()->enqueueScrollEvent(m_frame->document(), EventQueue::ScrollEventDocumentTarget); 2802 2803 } 2803 2804 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r75472 r75555 52 52 #include "Document.h" 53 53 #include "EventHandler.h" 54 #include "Event Names.h"54 #include "EventQueue.h" 55 55 #include "FloatPoint3D.h" 56 56 #include "FloatRect.h" … … 1398 1398 1399 1399 // Schedule the scroll DOM event. 1400 if (view) { 1401 if (FrameView* frameView = view->frameView()) 1402 frameView->scheduleEvent(Event::create(eventNames().scrollEvent, false, false), renderer()->node()); 1403 } 1400 renderer()->node()->document()->eventQueue()->enqueueScrollEvent(renderer()->node(), EventQueue::ScrollEventElementTarget); 1404 1401 } 1405 1402 -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r75537 r75555 37 37 #include "Document.h" 38 38 #include "EventHandler.h" 39 #include "Event Names.h"39 #include "EventQueue.h" 40 40 #include "FocusController.h" 41 41 #include "Frame.h" … … 540 540 m_indexOffset = newOffset; 541 541 repaint(); 542 node()->d ispatchEvent(Event::create(eventNames().scrollEvent, false, false));542 node()->document()->eventQueue()->enqueueScrollEvent(node(), EventQueue::ScrollEventElementTarget); 543 543 } 544 544 }
Note: See TracChangeset
for help on using the changeset viewer.