12019-10-30 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 NOBODY (OOPS!).
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 Existing 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 * css/CSSFontSelector.cpp:
18 (WebCore::CSSFontSelector::beginLoadTimerFired): Fixed the flakiness in SVG animation tests observed
19 after this patch was landed previously. The issue was that this code was calling FrameLoader's
20 checkLoadComplete before checkCompleted. checkCompleted starts SVG animations in Document::implicitClose
21 whereas checkLoadComplete can cause DumpRenderTree to end the test. As a result, depending on when this
22 function was called relative to other work being done in the main thread, DumpRenderTree could prematurely
23 end and dump the test result even though SVG animation would have immediately started in either scenario.
24 Unfortunately I couldn't come up with a new deterministic test for this issue since the exact condition
25 under which this problem comes up seems quite racy (which makes sense given this only manifested as flaky
26 failures in existing tests).
27 * dom/Document.cpp:
28 (WebCore::Document::setNeedsDOMWindowResizeEvent): Added.
29 (WebCore::Document::setNeedsVisualViewportResize): Added.
30 (WebCore::Document::runResizeSteps): Added. https://drafts.csswg.org/cssom-view/#run-the-resize-steps
31 * dom/Document.h:
32 * page/FrameView.cpp:
33 (WebCore::FrameView::sendResizeEventIfNeeded): Now sets m_needsDOMWindowResizeEvent on Document instead of
34 enqueuing a resize event.
35 * page/Page.cpp:
36 (WebCore::Page::updateRendering): Call runResizeSteps on each document.
37 (WebCore::Page::collectDocuments): Added.
38 * page/Page.h:
39 * page/VisualViewport.cpp:
40 (WebCore::VisualViewport::enqueueResizeEvent):
41