Changeset 251269 in webkit
- Timestamp:
- Oct 17, 2019, 5:15:28 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/LayoutTests/ChangeLog ¶
r251266 r251269 1 2019-10-17 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate resize event with HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=202964 5 6 Reviewed by Geoffrey Garen. 7 8 Added a regression test and fixed an existing test to work with the new behavior. 9 10 * fast/events/resize-subframe-in-rendering-update-expected.txt: Added. 11 * fast/events/resize-subframe-in-rendering-update.html: Added. 12 * fast/shadow-dom/trusted-event-scoped-flags.html: 13 1 14 2019-10-17 Tim Horton <timothy_horton@apple.com> 2 15 -
TabularUnified trunk/LayoutTests/fast/shadow-dom/trusted-event-scoped-flags.html ¶
r202953 r251269 111 111 112 112 iframe.onload = function () { 113 iframe.contentDocument.body.getBoundingClientRect(); 114 log(iframe.contentWindow, "resize"); 115 setTimeout(function () { 116 iframe.style.width = '200px'; 117 iframe.style.height = '200px'; 118 iframe.contentDocument.body.getBoundingClientRect(); 113 requestAnimationFrame(function () { 119 114 setTimeout(function () { 120 checkFlags('', {eventType: 'resize', composed: false}); 121 finishJSTest(); 115 iframe.contentDocument.body.getBoundingClientRect(); 116 log(iframe.contentWindow, "resize"); 117 iframe.style.width = '200px'; 118 iframe.style.height = '200px'; 119 iframe.contentDocument.body.getBoundingClientRect(); 120 requestAnimationFrame(function () { 121 checkFlags('', {eventType: 'resize', composed: false}); 122 finishJSTest(); 123 }); 122 124 }, 0); 123 } , 0);125 }); 124 126 } 125 127 -
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r251267 r251269 1 2019-10-17 Ryosuke Niwa <rniwa@webkit.org> 2 3 Integrate resize event with HTML5 event loop 4 https://bugs.webkit.org/show_bug.cgi?id=202964 5 6 Reviewed by Geoffrey Garen. 7 8 Dispatch resize events in "run the resize steps" during the "update the rendering": 9 https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering 10 11 Exisitng code in WebCore which was dispatching or scheduling dispatching of resize events now simply sets 12 a flag on document and schedules a rendering update. In Page::updateRendering, we fire resize events on 13 any documents with this flag set. 14 15 Test: fast/events/resize-subframe-in-rendering-update.html 16 17 * dom/Document.cpp: 18 (WebCore::Document::setNeedsDOMWindowResizeEvent): Added. 19 (WebCore::Document::setNeedsVisualViewportResize): Added. 20 (WebCore::Document::runResizeSteps): Added. https://drafts.csswg.org/cssom-view/#run-the-resize-steps 21 * dom/Document.h: 22 * page/DOMWindow.cpp: 23 (WebCore::DOMWindow::resizeTo const): 24 * page/FrameView.cpp: 25 (WebCore::FrameView::sendResizeEventIfNeeded): Now sets m_needsDOMWindowResizeEvent on Document instead of 26 enqueuing a resize event. 27 * page/Page.cpp: 28 (WebCore::Page::updateRendering): Call runResizeSteps on each document. 29 (WebCore::Page::collectDocuments): Added. 30 * page/Page.h: 31 * page/VisualViewport.cpp: 32 (WebCore::VisualViewport::enqueueResizeEvent): 33 1 34 2019-10-17 Chris Dumez <cdumez@apple.com> 2 35 -
TabularUnified trunk/Source/WebCore/dom/Document.cpp ¶
r251220 r251269 223 223 #include "VisibilityChangeClient.h" 224 224 #include "VisitedLinkState.h" 225 #include "VisualViewport.h" 225 226 #include "WebAnimation.h" 226 227 #include "WheelEvent.h" … … 3961 3962 } 3962 3963 3964 void Document::setNeedsDOMWindowResizeEvent() 3965 { 3966 m_needsDOMWindowResizeEvent = true; 3967 scheduleTimedRenderingUpdate(); 3968 } 3969 3970 void Document::setNeedsVisualViewportResize() 3971 { 3972 m_needsVisualViewportResizeEvent = true; 3973 scheduleTimedRenderingUpdate(); 3974 } 3975 3976 // https://drafts.csswg.org/cssom-view/#run-the-resize-steps 3977 void Document::runResizeSteps() 3978 { 3979 // FIXME: The order of dispatching is not specified: https://github.com/WICG/visual-viewport/issues/65. 3980 if (m_needsDOMWindowResizeEvent) { 3981 LOG(Events, "Document %p sending resize events to window", this); 3982 m_needsDOMWindowResizeEvent = false; 3983 dispatchWindowEvent(Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 3984 } 3985 if (m_needsVisualViewportResizeEvent) { 3986 LOG(Events, "Document %p sending resize events to visualViewport", this); 3987 m_needsVisualViewportResizeEvent = false; 3988 if (auto* window = domWindow()) 3989 window->visualViewport().dispatchEvent(Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No)); 3990 } 3991 } 3992 3963 3993 void Document::addAudioProducer(MediaProducer& audioProducer) 3964 3994 { -
TabularUnified trunk/Source/WebCore/dom/Document.h ¶
r251258 r251269 1359 1359 void updateViewportUnitsOnResize(); 1360 1360 1361 void setNeedsDOMWindowResizeEvent(); 1362 void setNeedsVisualViewportResize(); 1363 void runResizeSteps(); 1364 1361 1365 WEBCORE_EXPORT void addAudioProducer(MediaProducer&); 1362 1366 WEBCORE_EXPORT void removeAudioProducer(MediaProducer&); … … 2008 2012 2009 2013 bool m_hasStyleWithViewportUnits { false }; 2014 bool m_needsDOMWindowResizeEvent { false }; 2015 bool m_needsVisualViewportResizeEvent { false }; 2010 2016 bool m_isTimerThrottlingEnabled { false }; 2011 2017 bool m_isSuspended { false }; -
TabularUnified trunk/Source/WebCore/page/FrameView.cpp ¶
r251220 r251269 3377 3377 #endif 3378 3378 3379 LOG(Events, "FrameView %p sendResizeEventIfNeeded scheduling resize event for document %p, size %dx%d", this, frame().document(), currentSize.width(), currentSize.height()); 3380 frame().document()->setNeedsDOMWindowResizeEvent(); 3381 3379 3382 bool isMainFrame = frame().isMainFrame(); 3380 bool canSendResizeEventSynchronously = isMainFrame && !m_shouldAutoSize;3381 3382 LOG(Events, "FrameView %p sendResizeEventIfNeeded sending resize event, size %dx%d (canSendResizeEventSynchronously %d)", this, currentSize.width(), currentSize.height(), canSendResizeEventSynchronously);3383 3384 Ref<Event> resizeEvent = Event::create(eventNames().resizeEvent, Event::CanBubble::No, Event::IsCancelable::No);3385 if (canSendResizeEventSynchronously)3386 frame().document()->dispatchWindowEvent(resizeEvent);3387 else {3388 // FIXME: Queueing this event for an unpredictable time in the future seems3389 // intrinsically racy. By the time this resize event fires, the frame might3390 // be resized again, so we could end up with two resize events for the same size.3391 frame().document()->enqueueWindowEvent(WTFMove(resizeEvent));3392 }3393 3394 3383 if (InspectorInstrumentation::hasFrontends() && isMainFrame) { 3395 3384 if (Page* page = frame().page()) { -
TabularUnified trunk/Source/WebCore/page/Page.cpp ¶
r251220 r251269 1295 1295 SetForScope<bool> change(m_inUpdateRendering, true); 1296 1296 1297 Vector<RefPtr<Document>> documents; 1298 1299 // The requestAnimationFrame callbacks may change the frame hierarchy of the page 1300 forEachDocument([&documents] (Document& document) { 1301 documents.append(&document); 1302 }); 1303 1304 // FIXME: Run the resize steps 1297 layoutIfNeeded(); 1298 1299 for (auto& document : collectDocuments()) 1300 document->runResizeSteps(); 1305 1301 1306 1302 // FIXME: Run the scroll steps … … 1308 1304 // FIXME: Evaluate media queries and report changes. 1309 1305 1306 Vector<Ref<Document>> documents = collectDocuments(); // The requestAnimationFrame callbacks may change the frame hierarchy of the page 1310 1307 for (auto& document : documents) { 1311 1308 DOMHighResTimeStamp timestamp = document->domWindow()->nowTimestamp(); … … 2874 2871 } 2875 2872 2873 Vector<Ref<Document>> Page::collectDocuments() 2874 { 2875 Vector<Ref<Document>> documents; 2876 for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 2877 auto* document = frame->document(); 2878 if (!document) 2879 continue; 2880 documents.append(*document); 2881 } 2882 return documents; 2883 } 2884 2876 2885 void Page::applicationWillResignActive() 2877 2886 { -
TabularUnified trunk/Source/WebCore/page/Page.h ¶
r251220 r251269 751 751 752 752 void forEachDocument(const WTF::Function<void(Document&)>&); 753 Vector<Ref<Document>> collectDocuments(); 753 754 754 755 enum class TimerThrottlingState { Disabled, Enabled, EnabledIncreasing }; -
TabularUnified trunk/Source/WebCore/page/VisualViewport.cpp ¶
r246490 r251269 186 186 if (!frame) 187 187 return; 188 189 frame->document()->eventQueue().enqueueResizeEvent(*this, Event::CanBubble::No, Event::IsCancelable::No); 188 frame->document()->setNeedsVisualViewportResize(); 190 189 } 191 190
Note:
See TracChangeset
for help on using the changeset viewer.