Changeset 252205 in webkit
- Timestamp:
- Nov 7, 2019 2:18:37 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r252204 r252205 1 2019-11-06 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate scroll event into HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=203839 5 <rdar://problem/56890922> 6 7 Reviewed by Simon Fraser. 8 9 Added tests to test the timing at which scroll events are fired across multiple elements and documents, 10 and with visualViewport, and updated the existing tests to work with the new timing. 11 12 * editing/selection/overflow-scroll-while-selecting-text.html: 13 * fast/events/scroll-multiple-elements-in-rendering-update-expected.txt: Added. 14 * fast/events/scroll-multiple-elements-in-rendering-update.html: Added. 15 * fast/events/scroll-subframe-in-rendering-update-expected.txt: Added. 16 * fast/events/scroll-subframe-in-rendering-update.html: Added. 17 * fast/scrolling/programmatic-scroll-to-negative-offset.html: 18 * fast/shadow-dom/trusted-event-scoped-flags.html: 19 * fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe-expected.txt: Added. 20 * fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html: Added. 21 * tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html: 22 1 23 2019-11-07 Justin Fan <justin_fan@apple.com> 2 24 -
trunk/LayoutTests/editing/selection/overflow-scroll-while-selecting-text.html
r244388 r252205 31 31 const text = document.getElementById("text"); 32 32 text.scrollTo(0, 1000); 33 addEventListener("load", () => text.scrollTo(0, 500)); 34 text.addEventListener("scroll", () => { 35 text.textContent = ""; 36 testPassed("Successfully removed the text."); 37 finishJSTest(); 33 addEventListener("load", () => { 34 text.addEventListener("scroll", () => { 35 text.textContent = ""; 36 testPassed("Successfully removed the text."); 37 finishJSTest(); 38 }); 39 text.scrollTo(0, 500); 38 40 }); 39 41 </script> -
trunk/LayoutTests/fast/scrolling/programmatic-scroll-to-negative-offset.html
r245742 r252205 26 26 scroller.scrollLeft = 50; 27 27 28 scroller.addEventListener('scroll', (event) => { 29 shouldBe("scroller.scrollLeft", "0"); 30 shouldBe("scroller.scrollLeft", "0"); 31 finishJSTest(); 32 }, false); 28 setTimeout(() => { 29 scroller.addEventListener('scroll', (event) => { 30 shouldBe("scroller.scrollLeft", "0"); 31 shouldBe("scroller.scrollLeft", "0"); 32 finishJSTest(); 33 }, false); 33 34 34 setTimeout(() => {35 35 scroller.scrollLeft = -200; 36 36 scroller.scrollTop = -100; -
trunk/LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html
r251867 r252205 97 97 setTimeout(function () { 98 98 window.scrollTo(0, 1000); 99 setTimeout(function () { 100 checkFlags('', {eventType: 'scroll', composed: false}); 101 window.scrollTo(0, 0); 102 testResizeEvent(); 103 }, 0); 99 requestAnimationFrame(() => { 100 setTimeout(function () { 101 checkFlags('', {eventType: 'scroll', composed: false}); 102 window.scrollTo(0, 0); 103 testResizeEvent(); 104 }, 0); 105 }); 104 106 }, 0); 105 107 } -
trunk/LayoutTests/tiled-drawing/scrolling/fast-scroll-div-latched-mainframe.html
r235806 r252205 48 48 } 49 49 50 let didCheck = false; 50 51 function checkForScroll() 51 52 { 53 if (didCheck) 54 return; 55 didCheck = true; 56 52 57 // The div should not have scrolled at all. 53 58 var pageScrollPositionAfter = document.scrollingElement.scrollTop; … … 97 102 98 103 eventSender.monitorWheelEvents(); 99 setTimeout(scrollTest, 0); 104 requestIdleCallback(() => { 105 setTimeout(scrollTest, 0); 106 }); 100 107 } else { 101 108 var messageLocation = document.getElementById('parent'); -
trunk/Source/WebCore/ChangeLog
r252189 r252205 1 2019-11-06 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate scroll event into HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=203839 5 <rdar://problem/56890922> 6 7 Reviewed by Simon Fraser. 8 9 Dispatch scroll events on each pending scroll event targets inside the update-the-rendering step 10 of the event loop as specified in the HTML5 and CSSOM View Module specifications: 11 https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering 12 https://drafts.csswg.org/cssom-view/#run-the-scroll-steps 13 14 The new behavior also matches that of Chrome and Firefox. 15 16 Like resize event, the current visual viewport specification does not specify when scroll event 17 is dispatched on visualViewport interface: https://github.com/WICG/visual-viewport/issues/66 18 For now, we always dispatch upon it after dispatching on all pending scroll event targets. 19 20 Tests: fast/events/scroll-multiple-elements-in-rendering-update.html 21 fast/events/scroll-subframe-in-rendering-update.html 22 fast/visual-viewport/visual-viewport-scroll-after-resize-in-subframe.html 23 24 * dom/Document.cpp: 25 (WebCore::Document::addPendingScrollEventTarget): Added. 26 (WebCore::Document::setNeedsVisualViewportScrollEvent): Added. 27 (WebCore::Document::runScrollSteps): Added. This implements run the scroll steps in CSS OM View. 28 * dom/Document.h: 29 * dom/DocumentEventQueue.cpp: 30 (WebCore::DocumentEventQueue::enqueueOrDispatchScrollEvent): Deleted. 31 (WebCore::DocumentEventQueue::enqueueScrollEvent): Deleted. 32 * dom/DocumentEventQueue.h: 33 * page/EventHandler.cpp: 34 (WebCore::EventHandler::sendScrollEvent): 35 * page/Page.cpp: 36 (WebCore::Page::updateRendering): Invoke runScrollSteps on each document in the frame tree order. 37 * page/VisualViewport.cpp: 38 (WebCore::VisualViewport::update): 39 (WebCore::VisualViewport::enqueueScrollEvent): Deleted. 40 * page/VisualViewport.h: 41 * rendering/RenderLayer.cpp: 42 (WebCore::RenderLayer::scrollTo): 43 * rendering/RenderListBox.cpp: 44 (WebCore::RenderListBox::scrollTo): 45 1 46 2019-11-07 Zalan Bujtas <zalan@apple.com> 2 47 -
trunk/Source/WebCore/dom/Document.cpp
r252060 r252205 4002 4002 } 4003 4003 4004 void Document::addPendingScrollEventTarget(ContainerNode& target) 4005 { 4006 if (m_pendingScrollEventTargets.contains(&target)) 4007 return; 4008 4009 if (m_pendingScrollEventTargets.isEmpty()) 4010 scheduleTimedRenderingUpdate(); 4011 4012 m_pendingScrollEventTargets.append(makeWeakPtr(target)); 4013 } 4014 4015 void Document::setNeedsVisualViewportScrollEvent() 4016 { 4017 if (!m_needsVisualViewportScrollEvent) 4018 scheduleTimedRenderingUpdate(); 4019 m_needsVisualViewportScrollEvent = true; 4020 } 4021 4022 // https://drafts.csswg.org/cssom-view/#run-the-scroll-steps 4023 void Document::runScrollSteps() 4024 { 4025 // FIXME: The order of dispatching is not specified: https://github.com/WICG/visual-viewport/issues/66. 4026 if (!m_pendingScrollEventTargets.isEmpty()) { 4027 LOG_WITH_STREAM(Events, stream << "Document" << this << "sending scroll events to pending scroll event targets"); 4028 auto currentTargets = WTFMove(m_pendingScrollEventTargets); 4029 for (auto target : currentTargets) { 4030 auto protectedTarget = makeRefPtr(target.get()); 4031 ASSERT(protectedTarget); 4032 if (!protectedTarget) 4033 continue; 4034 auto bubbles = protectedTarget->isDocumentNode() ? Event::CanBubble::Yes : Event::CanBubble::No; 4035 protectedTarget->dispatchEvent(Event::create(eventNames().scrollEvent, bubbles, Event::IsCancelable::No)); 4036 } 4037 } 4038 if (m_needsVisualViewportScrollEvent) { 4039 LOG_WITH_STREAM(Events, stream << "Document" << this << "sending scroll events to visualViewport"); 4040 m_needsVisualViewportResizeEvent = false; 4041 if (auto* window = domWindow()) 4042 window->visualViewport().dispatchEvent(Event::create(eventNames().scrollEvent, Event::CanBubble::No, Event::IsCancelable::No)); 4043 } 4044 } 4045 4004 4046 void Document::addAudioProducer(MediaProducer& audioProducer) 4005 4047 { -
trunk/Source/WebCore/dom/Document.h
r251930 r252205 1365 1365 void runResizeSteps(); 1366 1366 1367 void addPendingScrollEventTarget(ContainerNode&); 1368 void setNeedsVisualViewportScrollEvent(); 1369 void runScrollSteps(); 1370 1367 1371 WEBCORE_EXPORT void addAudioProducer(MediaProducer&); 1368 1372 WEBCORE_EXPORT void removeAudioProducer(MediaProducer&); … … 2020 2024 bool m_needsDOMWindowResizeEvent { false }; 2021 2025 bool m_needsVisualViewportResizeEvent { false }; 2026 bool m_needsVisualViewportScrollEvent { false }; 2022 2027 bool m_isTimerThrottlingEnabled { false }; 2023 2028 bool m_isSuspended { false }; … … 2035 2040 bool m_isTelephoneNumberParsingAllowed { true }; 2036 2041 #endif 2042 2043 Vector<WeakPtr<ContainerNode>> m_pendingScrollEventTargets; 2037 2044 2038 2045 #if ENABLE(MEDIA_STREAM) -
trunk/Source/WebCore/dom/DocumentEventQueue.cpp
r252122 r252205 82 82 } 83 83 84 void DocumentEventQueue::enqueueOrDispatchScrollEvent(Node& target)85 {86 ASSERT(&target.document() == &m_document);87 88 // Per the W3C CSSOM View Module, scroll events fired at the document should bubble, others should not.89 enqueueScrollEvent(target, target.isDocumentNode() ? Event::CanBubble::Yes : Event::CanBubble::No, Event::IsCancelable::No);90 }91 92 void DocumentEventQueue::enqueueScrollEvent(EventTarget& target, Event::CanBubble canBubble, Event::IsCancelable cancelable)93 {94 if (m_isClosed)95 return;96 97 if (!m_document.hasListenerType(Document::SCROLL_LISTENER))98 return;99 100 if (!m_targetsWithQueuedScrollEvents.add(&target).isNewEntry)101 return;102 103 Ref<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubble, cancelable);104 scrollEvent->setTarget(&target);105 enqueueEvent(WTFMove(scrollEvent));106 }107 108 84 bool DocumentEventQueue::cancelEvent(Event& event) 109 85 { -
trunk/Source/WebCore/dom/DocumentEventQueue.h
r252122 r252205 48 48 void close() override; 49 49 50 void enqueueOrDispatchScrollEvent(Node&);51 void enqueueScrollEvent(EventTarget&, Event::CanBubble, Event::IsCancelable);52 50 53 51 private: -
trunk/Source/WebCore/page/EventHandler.cpp
r251517 r252205 4030 4030 Ref<Frame> protectedFrame(m_frame); 4031 4031 setFrameWasScrolledByUser(); 4032 if (m_frame.view() && m_frame.document()) 4033 m_frame.document()->eventQueue().enqueueOrDispatchScrollEvent(*m_frame.document()); 4032 if (!m_frame.view()) 4033 return; 4034 auto document = makeRefPtr(m_frame.document()); 4035 if (!document) 4036 return; 4037 document->addPendingScrollEventTarget(*document); 4034 4038 } 4035 4039 -
trunk/Source/WebCore/page/Page.cpp
r252013 r252205 1291 1291 layoutIfNeeded(); 1292 1292 1293 // Flush autofocus candidates 1294 1293 1295 forEachDocument([&](Document& document) { 1294 1296 document.runResizeSteps(); 1295 1297 }); 1296 1298 1297 // FIXME: Run the scroll steps 1299 forEachDocument([&](Document& document) { 1300 document.runScrollSteps(); 1301 }); 1298 1302 1299 1303 forEachDocument([&](Document& document) { … … 1319 1323 document->updateResizeObservations(*this); 1320 1324 #endif 1321 1322 // FIXME: Flush autofocus candidates1323 // https://github.com/whatwg/html/issues/49921324 1325 1325 1326 layoutIfNeeded(); -
trunk/Source/WebCore/page/VisualViewport.cpp
r252122 r252205 169 169 } 170 170 171 RefPtr<Document> document = frame ? frame->document() : nullptr; 171 172 if (m_offsetLeft != offsetLeft || m_offsetTop != offsetTop) { 172 enqueueScrollEvent(); 173 if (document) 174 document->setNeedsVisualViewportScrollEvent(); 173 175 m_offsetLeft = offsetLeft; 174 176 m_offsetTop = offsetTop; 175 177 } 176 178 if (m_width != width || m_height != height || m_scale != scale) { 177 if ( auto* frame = this->frame())178 frame->document()->setNeedsVisualViewportResize();179 if (document) 180 document->setNeedsVisualViewportResize(); 179 181 m_width = width; 180 182 m_height = height; … … 183 185 } 184 186 185 void VisualViewport::enqueueScrollEvent()186 {187 auto* frame = this->frame();188 if (!frame)189 return;190 191 frame->document()->eventQueue().enqueueScrollEvent(*this, Event::CanBubble::No, Event::IsCancelable::No);192 }193 194 187 } // namespace WebCore -
trunk/Source/WebCore/page/VisualViewport.h
r246490 r252205 61 61 void derefEventTarget() final { deref(); } 62 62 63 void enqueueResizeEvent();64 void enqueueScrollEvent();65 66 63 void updateFrameLayout() const; 67 64 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r251369 r252205 2674 2674 // Schedule the scroll and scroll-related DOM events. 2675 2675 if (Element* element = renderer().element()) 2676 element->document(). eventQueue().enqueueOrDispatchScrollEvent(*element);2676 element->document().addPendingScrollEventTarget(*element); 2677 2677 2678 2678 if (scrollsOverflow()) -
trunk/Source/WebCore/rendering/RenderListBox.cpp
r250946 r252205 714 714 715 715 repaint(); 716 document(). eventQueue().enqueueOrDispatchScrollEvent(selectElement());716 document().addPendingScrollEventTarget(selectElement()); 717 717 } 718 718
Note: See TracChangeset
for help on using the changeset viewer.