Changeset 242624 in webkit
- Timestamp:
- Mar 7, 2019, 4:52:57 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 1 deleted
- 38 edited
- 1 moved
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/animations/animation-multiple-callbacks-timestamp.html (modified) (1 diff)
-
LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt (modified) (1 diff)
-
LayoutTests/animations/no-style-recalc-during-accelerated-animation.html (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/SystemTracing.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (2 diffs)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (8 diffs)
-
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (modified) (1 diff)
-
Source/WebCore/animation/DocumentAnimationScheduler.cpp (deleted)
-
Source/WebCore/animation/DocumentTimeline.cpp (modified) (15 diffs)
-
Source/WebCore/animation/DocumentTimeline.h (modified) (3 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (7 diffs)
-
Source/WebCore/dom/Document.h (modified) (6 diffs)
-
Source/WebCore/dom/ScriptedAnimationController.cpp (modified) (6 diffs)
-
Source/WebCore/dom/ScriptedAnimationController.h (modified) (2 diffs)
-
Source/WebCore/page/FrameView.cpp (modified) (1 diff)
-
Source/WebCore/page/IntersectionObserver.cpp (modified) (1 diff)
-
Source/WebCore/page/Page.cpp (modified) (4 diffs)
-
Source/WebCore/page/Page.h (modified) (7 diffs)
-
Source/WebCore/page/PageOverlayController.cpp (modified) (2 diffs)
-
Source/WebCore/page/RenderingUpdateScheduler.cpp (added)
-
Source/WebCore/page/RenderingUpdateScheduler.h (moved) (moved from trunk/Source/WebCore/animation/DocumentAnimationScheduler.h ) (2 diffs)
-
Source/WebCore/page/ios/ContentChangeObserver.h (modified) (1 diff)
-
Source/WebCore/page/mac/ServicesOverlayController.mm (modified) (1 diff)
-
Source/WebCore/rendering/RenderLayerCompositor.cpp (modified) (1 diff)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (modified) (3 diffs)
-
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (2 diffs)
-
Source/WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/mac/WebView/WebView.mm (modified) (1 diff)
-
Source/WebKitLegacy/win/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/win/WebView.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/Tracing/SystemTracePoints.plist (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r242621 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 * TestExpectations: 9 There is a slight difference between the actual DRT and the expected DRT 10 due to animation timing change. But these two tests are not animating 11 correctly if they are opened in Safari with web animation turned on. 12 13 * animations/animation-multiple-callbacks-timestamp.html: 14 Fix variable names used by an error message. 15 * animations/no-style-recalc-during-accelerated-animation-expected.txt: 16 * animations/no-style-recalc-during-accelerated-animation.html: 17 One extra styleReclc was incurred due to the document styleRecalcTimer. 18 I think this timer is not needed anymore. I will look at removing it in 19 a separate patch. 20 1 21 2019-03-07 Zalan Bujtas <zalan@apple.com> 2 22 -
trunk/LayoutTests/TestExpectations
r242612 r242624 3039 3039 # This is fallout from turning Web Animations on. 3040 3040 webkit.org/b/190032 animations/animation-playstate-paused-style-resolution.html [ Failure ] 3041 webkit.org/b/190032 animations/missing-values-first-keyframe.html [ Failure ] 3042 webkit.org/b/190032 animations/missing-values-last-keyframe.html [ Failure ] 3041 3043 webkit.org/b/190032 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Failure ] 3042 3044 webkit.org/b/190032 compositing/backing/transform-transition-from-outside-view.html [ Failure ] -
trunk/LayoutTests/animations/animation-multiple-callbacks-timestamp.html
r202399 r242624 36 36 const WarmupFrames = 5; 37 37 if (++currentFrame > WarmupFrames && timestamp != timestamp1) { 38 testFailed("timestamp 1 = " + timestamp1 + ", timestamp2 = " + timestamp2+ ", window.performance.now() = " + window.performance.now());38 testFailed("timestamp = " + timestamp + ", timestamp1 = " + timestamp1 + ", window.performance.now() = " + window.performance.now()); 39 39 failed = true; 40 40 } -
trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt
r238128 r242624 1 1 Got iteration event. 2 PASS: saw t woor fewer style recalcs during the animation.2 PASS: saw three or fewer style recalcs during the animation. -
trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation.html
r238128 r242624 36 36 box.addEventListener("animationend", () => { 37 37 const numRecalcs = internals.styleRecalcCount(); 38 if (numRecalcs > 2)39 result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see t wo."38 if (numRecalcs > 3) 39 result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see three." 40 40 else 41 result.innerText += "PASS: saw t woor fewer style recalcs during the animation."41 result.innerText += "PASS: saw three or fewer style recalcs during the animation." 42 42 43 43 if (window.testRunner) -
trunk/Source/WTF/ChangeLog
r242592 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 Add trace points for the page RenderingUpdate. 9 10 * wtf/SystemTracing.h: 11 1 12 2019-03-06 Ross Kirsling <ross.kirsling@sony.com> 2 13 -
trunk/Source/WTF/wtf/SystemTracing.h
r242294 r242624 78 78 ComputeEventRegionsEnd, 79 79 80 ScheduleRenderingUpdate, 81 TriggerRenderingUpdate, 82 RenderingUpdateStart, 83 RenderingUpdateEnd, 84 80 85 WebKitRange = 10000, 81 86 WebHTMLViewPaintStart, -
trunk/Source/WebCore/ChangeLog
r242621 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 This change fixes two issues with animation timing: 9 10 1. Calling the requestAnimationFrame callbacks would have happened when 11 the DisplayLink fires. This may have happened even if the frame is 12 missed and no display is committed. 13 14 2. Style changes and layout triggered by script could trigger painting 15 at more than 60fps. CoreAnimation commits could happen at more than 16 60fps, although WindowServer will throttle those, and only some will 17 be shown on the screen. 18 19 This change introduces a new paint scheduling model where painting is 20 driven by a "RenderingUpdateScheduler", which only triggers paints once 21 per 16.7ms frame. 22 23 Code that previously scheduled a compositing layer flush now schedules a 24 "RenderingUpdate", and that update is driven by a DisplayRefreshMonitor 25 callback. When the render happens, we service requestAnimationFrame callbacks, 26 Web Animations and intersection observations per the "Update the rendering" 27 step of the HTML Event Loop specification 28 <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>. 29 30 In the future, more rendering steps will be added to this code. 31 32 * Sources.txt: 33 * WebCore.xcodeproj/project.pbxproj: 34 * accessibility/mac/AXObjectCacheMac.mm: 35 Fix layout tests by adding null check. 36 37 * animation/DocumentAnimationScheduler.cpp: Removed. 38 * animation/DocumentAnimationScheduler.h: Removed. 39 * animation/DocumentTimeline.cpp: 40 (WebCore::DocumentTimeline::DocumentTimeline): 41 (WebCore::DocumentTimeline::updateThrottlingState): 42 (WebCore::DocumentTimeline::resumeAnimations): 43 (WebCore::DocumentTimeline::liveCurrentTime const): 44 (WebCore::DocumentTimeline::currentTime): 45 (WebCore::DocumentTimeline::animationTimingDidChange): 46 (WebCore::DocumentTimeline::scheduleAnimationResolution): 47 (WebCore::DocumentTimeline::unscheduleAnimationResolution): 48 (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): 49 (WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents): 50 (WebCore::DocumentTimeline::scheduleNextTick): 51 (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): 52 Simplify this function by handling the case of no-animations separately. 53 54 (WebCore::DocumentTimeline::resolveAnimationsForElement): 55 Simplify the loop and delete hasPendingAcceleratedAnimations because it 56 is initialized to true and is not changed inside the loop. 57 58 (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Deleted. 59 (WebCore::DocumentTimeline::animationResolutionTimerFired): Deleted. 60 * animation/DocumentTimeline.h: 61 * dom/Document.cpp: 62 (WebCore::Document::resolveStyle): 63 There is no need to force update in resolveStyle(). notifyFlushRequired() 64 will be called eventually which will scheduleRenderingUpdate(). 65 66 (WebCore::Document::prepareForDestruction): 67 (WebCore::Document::updateAnimationsAndSendEvents): 68 (WebCore::Document::serviceRequestAnimationFrameCallbacks): 69 (WebCore::Document::windowScreenDidChange): 70 (WebCore::Document::updateIntersectionObservations): 71 (WebCore::Document::scheduleForcedIntersectionObservationUpdate): Deleted. 72 (WebCore::Document::animationScheduler): Deleted. 73 * dom/Document.h: 74 (WebCore::Document::numberOfIntersectionObservers const): 75 * dom/ScriptedAnimationController.cpp: 76 (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks): 77 (WebCore::ScriptedAnimationController::scheduleAnimation): 78 (WebCore::ScriptedAnimationController::animationTimerFired): 79 (WebCore::ScriptedAnimationController::serviceScriptedAnimations): Deleted. 80 (WebCore::ScriptedAnimationController::documentAnimationSchedulerDidFire): Deleted. 81 * dom/ScriptedAnimationController.h: 82 * page/FrameView.cpp: 83 (WebCore::FrameView::viewportContentsChanged): 84 * page/IntersectionObserver.cpp: 85 (WebCore::IntersectionObserver::observe): 86 * page/Page.cpp: 87 (WebCore::Page::Page): 88 (WebCore::Page::layoutIfNeeded): 89 (WebCore::Page::renderingUpdate): 90 (WebCore::Page::renderingUpdateScheduler): 91 (WebCore::Page::willDisplayPage): Deleted. 92 (WebCore::Page::addDocumentNeedingIntersectionObservationUpdate): Deleted. 93 (WebCore::Page::updateIntersectionObservations): Deleted. 94 (WebCore::Page::scheduleForcedIntersectionObservationUpdate): Deleted. 95 * page/Page.h: 96 * page/PageOverlayController.cpp: 97 (WebCore::PageOverlayController::didChangeViewExposedRect): 98 (WebCore::PageOverlayController::notifyFlushRequired): 99 * page/ResourceUsageData.h: 100 Include header files that become missing because of adding 101 RenderingUpdateScheduler.cpp. 102 103 * page/RenderingUpdateScheduler.cpp: Added. 104 (WebCore::RenderingUpdateScheduler::RenderingUpdateScheduler): 105 (WebCore::RenderingUpdateScheduler::scheduleRenderingUpdate): 106 (WebCore::RenderingUpdateScheduler::startTimer): 107 (WebCore::RenderingUpdateScheduler::clearTimer): 108 (WebCore::RenderingUpdateScheduler::windowScreenDidChange): 109 (WebCore::RenderingUpdateScheduler::createDisplayRefreshMonitor const): 110 (WebCore::RenderingUpdateScheduler::displayRefreshFired): 111 * page/RenderingUpdateScheduler.h: Added. 112 (WebCore::RenderingUpdateScheduler::create): 113 * page/ios/ContentChangeObserver.h: 114 Include header files that become missing because of adding 115 RenderingUpdateScheduler.cpp. 116 117 * page/mac/ServicesOverlayController.mm: 118 (WebCore::ServicesOverlayController::Highlight::notifyFlushRequired): 119 * rendering/RenderLayerCompositor.cpp: 120 (WebCore::RenderLayerCompositor::scheduleLayerFlushNow): 121 1 122 2019-03-07 Zalan Bujtas <zalan@apple.com> 2 123 -
trunk/Source/WebCore/Sources.txt
r242615 r242624 421 421 animation/CSSTransition.cpp 422 422 animation/DeclarativeAnimation.cpp 423 animation/DocumentAnimationScheduler.cpp424 423 animation/DocumentTimeline.cpp 425 424 animation/KeyframeEffect.cpp … … 1540 1539 page/RemoteDOMWindow.cpp 1541 1540 page/RemoteFrame.cpp 1541 page/RenderingUpdateScheduler.cpp 1542 1542 page/ResourceUsageOverlay.cpp 1543 1543 page/ResourceUsageThread.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r242615 r242624 1781 1781 555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1782 1782 555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; }; 1783 556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1783 1784 5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1784 1785 55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2118 2119 715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2119 2120 715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; }; 2120 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };2121 2121 71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2122 2122 71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; }; … … 8644 8644 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; }; 8645 8645 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; }; 8646 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderingUpdateScheduler.h; sourceTree = "<group>"; }; 8647 556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderingUpdateScheduler.cpp; sourceTree = "<group>"; }; 8646 8648 5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; }; 8647 8649 5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; }; … … 9370 9372 716C8DF31E48B284005BD0DA /* volume-down-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-down-button.js"; sourceTree = "<group>"; }; 9371 9373 716C8DF41E48B284005BD0DA /* volume-up-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-button.js"; sourceTree = "<group>"; }; 9372 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentAnimationScheduler.h; sourceTree = "<group>"; };9373 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentAnimationScheduler.cpp; sourceTree = "<group>"; };9374 9374 716FA0D81DB26591007323CC /* airplay-button.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "airplay-button.css"; sourceTree = "<group>"; }; 9375 9375 716FA0D91DB26591007323CC /* airplay-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-button.js"; sourceTree = "<group>"; }; … … 20496 20496 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */, 20497 20497 46B95192207D632E00A7D2DD /* RemoteFrame.h */, 20498 556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */, 20499 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */, 20498 20500 A5071E821C56D079009951BE /* ResourceUsageData.h */, 20499 20501 ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */, … … 20648 20650 715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */, 20649 20651 715AD71D2050512400D592DC /* DeclarativeAnimation.h */, 20650 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */,20651 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */,20652 20652 71025EC41F99F096004A250C /* DocumentTimeline.cpp */, 20653 20653 71025EC51F99F096004A250C /* DocumentTimeline.h */, … … 29072 29072 7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */, 29073 29073 A8185F4009765766005826D9 /* Document.h in Headers */, 29074 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */,29075 29074 A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */, 29076 29075 A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */, … … 31274 31273 08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */, 31275 31274 08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */, 31275 556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */, 31276 31276 BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */, 31277 31277 B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */, -
trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
r241721 r242624 540 540 NSAccessibilityHandleFocusChanged(); 541 541 // AXFocusChanged is a test specific notification name and not something a real AT will be listening for 542 if (UNLIKELY(axShouldRepostNotificationsForTests)) 543 [rootWebArea()->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil]; 542 if (UNLIKELY(!axShouldRepostNotificationsForTests)) 543 return; 544 545 auto* rootWebArea = this->rootWebArea(); 546 if (!rootWebArea) 547 return; 548 549 [rootWebArea->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil]; 544 550 } 545 551 -
trunk/Source/WebCore/animation/DocumentTimeline.cpp
r239820 r242624 34 34 #include "DeclarativeAnimation.h" 35 35 #include "Document.h" 36 #include "DocumentAnimationScheduler.h"37 36 #include "GraphicsLayer.h" 38 37 #include "KeyframeEffect.h" … … 62 61 DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime) 63 62 : AnimationTimeline() 64 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 65 , m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired) 66 #endif 67 , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolutionIfNeeded) 63 , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolution) 68 64 , m_document(&document) 69 65 , m_originTime(originTime) … … 195 191 void DocumentTimeline::updateThrottlingState() 196 192 { 197 scheduleAnimationResolution IfNeeded();193 scheduleAnimationResolution(); 198 194 } 199 195 … … 211 207 212 208 if (!m_cachedCurrentTime) 213 m_cachedCurrentTime = liveCurrentTime();209 m_cachedCurrentTime = Seconds(liveCurrentTime()); 214 210 215 211 for (const auto& animation : m_animations) … … 235 231 animation->setSuspended(false); 236 232 237 scheduleAnimationResolution IfNeeded();233 scheduleAnimationResolution(); 238 234 } 239 235 … … 253 249 } 254 250 255 Seconds DocumentTimeline::liveCurrentTime() const 256 { 257 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 258 return m_document->animationScheduler().lastTimestamp(); 259 #else 260 return Seconds(m_document->domWindow()->nowTimestamp()); 261 #endif 251 DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const 252 { 253 return m_document->domWindow()->nowTimestamp(); 262 254 } 263 255 … … 275 267 } 276 268 277 auto currentTime = liveCurrentTime(); 278 279 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 280 // If we're in the middle of firing a frame, either due to a requestAnimationFrame callback 281 // or scheduling an animation update, we want to ensure we use the same time we're using as 282 // the timestamp for requestAnimationFrame() callbacks. 283 if (m_document->animationScheduler().isFiring()) 284 cacheCurrentTime(currentTime); 285 #endif 286 287 if (!m_cachedCurrentTime) { 288 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 289 // If we're not in the middle of firing a frame, let's make our best guess at what the currentTime should 290 // be since the last time a frame fired by increment of our update interval. This way code using something 291 // like setTimeout() or handling events will get a time that's only updating at around 60fps, or less if 292 // we're throttled. 293 auto lastAnimationSchedulerTimestamp = currentTime; 294 auto delta = Seconds(m_document->domWindow()->nowTimestamp()) - lastAnimationSchedulerTimestamp; 295 int frames = std::floor(delta.seconds() / animationInterval().seconds()); 296 cacheCurrentTime(lastAnimationSchedulerTimestamp + Seconds(frames * animationInterval().seconds())); 297 #else 298 cacheCurrentTime(currentTime); 299 #endif 300 } 269 if (!m_cachedCurrentTime) 270 cacheCurrentTime(liveCurrentTime()); 271 301 272 return m_cachedCurrentTime.value() - m_originTime; 302 273 } 303 274 304 void DocumentTimeline::cacheCurrentTime( SecondsnewCurrentTime)305 { 306 m_cachedCurrentTime = newCurrentTime;275 void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime) 276 { 277 m_cachedCurrentTime = Seconds(newCurrentTime); 307 278 // We want to be sure to keep this time cached until we've both finished running JS and finished updating 308 279 // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will … … 327 298 } 328 299 329 void DocumentTimeline::scheduleAnimationResolutionIfNeeded()330 {331 if (!m_isUpdatingAnimations && !m_isSuspended && !m_animations.isEmpty())332 scheduleAnimationResolution();333 }334 335 300 void DocumentTimeline::animationTimingDidChange(WebAnimation& animation) 336 301 { 337 302 AnimationTimeline::animationTimingDidChange(animation); 338 scheduleAnimationResolution IfNeeded();303 scheduleAnimationResolution(); 339 304 } 340 305 … … 349 314 void DocumentTimeline::scheduleAnimationResolution() 350 315 { 351 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 352 m_document->animationScheduler().scheduleWebAnimationsResolution(); 353 #else 354 // FIXME: We need to use the same logic as ScriptedAnimationController here, 355 // which will be addressed by the refactor tracked by webkit.org/b/179293. 356 m_animationResolutionTimer.startOneShot(animationInterval()); 357 #endif 316 if (m_isSuspended || m_animations.isEmpty() || m_animationResolutionScheduled) 317 return; 318 319 if (!m_document || !m_document->page()) 320 return; 321 322 m_document->page()->renderingUpdateScheduler().scheduleRenderingUpdate(); 323 m_animationResolutionScheduled = true; 358 324 } 359 325 … … 361 327 { 362 328 m_tickScheduleTimer.stop(); 363 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 364 m_document->animationScheduler().unscheduleWebAnimationsResolution(); 365 #else 366 // FIXME: We need to use the same logic as ScriptedAnimationController here, 367 // which will be addressed by the refactor tracked by webkit.org/b/179293. 368 m_animationResolutionTimer.stop(); 369 #endif 370 } 371 372 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 373 void DocumentTimeline::documentAnimationSchedulerDidFire() 374 #else 375 void DocumentTimeline::animationResolutionTimerFired() 376 #endif 377 { 378 updateAnimationsAndSendEvents(); 329 m_animationResolutionScheduled = false; 330 } 331 332 void DocumentTimeline::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp) 333 { 334 // We need to freeze the current time even if no animation is running. 335 // document.timeline.currentTime may be called from a rAF callback and 336 // it has to match the rAF timestamp. 337 if (!m_isSuspended) 338 cacheCurrentTime(timestamp); 339 340 if (m_isSuspended || m_animations.isEmpty() || !m_animationResolutionScheduled) 341 return; 342 343 internalUpdateAnimationsAndSendEvents(); 379 344 applyPendingAcceleratedAnimations(); 345 346 m_animationResolutionScheduled = false; 380 347 scheduleNextTick(); 381 348 } 382 349 383 void DocumentTimeline:: updateAnimationsAndSendEvents()350 void DocumentTimeline::internalUpdateAnimationsAndSendEvents() 384 351 { 385 352 m_numberOfAnimationTimelineInvalidationsForTesting++; 386 387 m_isUpdatingAnimations = true;388 353 389 354 // https://drafts.csswg.org/web-animations/#update-animations-and-send-events … … 449 414 for (auto& completedTransition : completedTransitions) 450 415 transitionDidComplete(completedTransition); 451 452 m_isUpdatingAnimations = false;453 416 } 454 417 … … 474 437 for (const auto& animation : m_animations) { 475 438 if (!animation->isRunningAccelerated()) { 476 scheduleAnimationResolution IfNeeded();439 scheduleAnimationResolution(); 477 440 return; 478 441 } … … 484 447 auto animationTimeToNextRequiredTick = animation->timeToNextTick(); 485 448 if (animationTimeToNextRequiredTick < animationInterval()) { 486 scheduleAnimationResolution IfNeeded();449 scheduleAnimationResolution(); 487 450 return; 488 451 } … … 594 557 { 595 558 auto animations = animationsForElement(element); 596 bool runningAnimationsForElementAreAllAccelerated = !animations.isEmpty(); 559 560 if (animations.isEmpty()) { 561 m_elementsWithRunningAcceleratedAnimations.remove(&element); 562 return; 563 } 564 597 565 for (const auto& animation : animations) { 598 566 if (!animation->isRunningAccelerated()) { 599 runningAnimationsForElementAreAllAccelerated = false; 600 break; 601 } 602 } 603 604 if (runningAnimationsForElementAreAllAccelerated) 605 m_elementsWithRunningAcceleratedAnimations.add(&element); 606 else 607 m_elementsWithRunningAcceleratedAnimations.remove(&element); 567 m_elementsWithRunningAcceleratedAnimations.remove(&element); 568 return; 569 } 570 } 571 572 m_elementsWithRunningAcceleratedAnimations.add(&element); 608 573 } 609 574 … … 626 591 bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle) 627 592 { 628 bool hasNonAcceleratedAnimation s= false;629 bool hasPendingAcceleratedAnimations = true; 593 bool hasNonAcceleratedAnimationProperty = false; 594 630 595 for (const auto& animation : animationsForElement(element)) { 631 596 animation->resolve(targetStyle); 632 if (!hasNonAcceleratedAnimations) { 633 if (auto* effect = animation->effect()) {634 if (is<KeyframeEffect>(effect)) {635 auto* keyframeEffect = downcast<KeyframeEffect>(effect); 636 for (auto cssPropertyId : keyframeEffect->animatedProperties()) {637 if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {638 hasNonAcceleratedAnimations = true;639 continue; 640 }641 if (!hasPendingAcceleratedAnimations)642 hasPendingAcceleratedAnimations = keyframeEffect->hasPendingAcceleratedAction();643 }644 }597 598 if (hasNonAcceleratedAnimationProperty) 599 continue; 600 601 auto* effect = animation->effect(); 602 if (!effect || !is<KeyframeEffect>(effect)) 603 continue; 604 605 auto* keyframeEffect = downcast<KeyframeEffect>(effect); 606 for (auto cssPropertyId : keyframeEffect->animatedProperties()) { 607 if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) { 608 hasNonAcceleratedAnimationProperty = true; 609 break; 645 610 } 646 611 } 647 612 } 648 613 649 // If there are no non-accelerated animations and we've encountered at least one pending 650 // accelerated animation, we should recomposite this element's layer for animation purposes. 651 return !hasNonAcceleratedAnimations && hasPendingAcceleratedAnimations; 614 return !hasNonAcceleratedAnimationProperty; 652 615 } 653 616 -
trunk/Source/WebCore/animation/DocumentTimeline.h
r239820 r242624 72 72 73 73 void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&); 74 75 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 76 void documentAnimationSchedulerDidFire(); 77 #endif 74 75 void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp); 78 76 79 77 void updateThrottlingState(); … … 89 87 DocumentTimeline(Document&, Seconds); 90 88 91 SecondsliveCurrentTime() const;92 void cacheCurrentTime( Seconds);93 void scheduleAnimationResolutionIfNeeded();89 DOMHighResTimeStamp liveCurrentTime() const; 90 void cacheCurrentTime(DOMHighResTimeStamp); 91 void maybeClearCachedCurrentTime(); 94 92 void scheduleInvalidationTaskIfNeeded(); 95 93 void performInvalidationTask(); 96 void animationScheduleTimerFired();97 94 void scheduleAnimationResolution(); 98 95 void unscheduleAnimationResolution(); 99 void updateAnimationsAndSendEvents();96 void internalUpdateAnimationsAndSendEvents(); 100 97 void performEventDispatchTask(); 101 void maybeClearCachedCurrentTime();102 98 void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&); 103 99 void transitionDidComplete(RefPtr<CSSTransition>); 104 100 void scheduleNextTick(); 105 106 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)107 void animationResolutionTimerFired();108 Timer m_animationResolutionTimer;109 #endif110 101 111 102 Timer m_tickScheduleTimer; … … 120 111 bool m_isSuspended { false }; 121 112 bool m_waitingOnVMIdle { false }; 122 bool m_ isUpdatingAnimations{ false };113 bool m_animationResolutionScheduled { false }; 123 114 }; 124 115 -
trunk/Source/WebCore/dom/Document.cpp
r242340 r242624 58 58 #include "DateComponents.h" 59 59 #include "DebugPageOverlays.h" 60 #include "DocumentAnimationScheduler.h"61 60 #include "DocumentLoader.h" 62 61 #include "DocumentMarkerController.h" … … 1958 1957 1959 1958 // Usually this is handled by post-layout. 1960 if (!frameView.needsLayout()) {1959 if (!frameView.needsLayout()) 1961 1960 frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange(); 1962 if (m_needsForcedIntersectionObservationUpdate)1963 page()->scheduleForcedIntersectionObservationUpdate(*this);1964 }1965 1961 1966 1962 // As a result of the style recalculation, the currently hovered element might have been … … 2559 2555 } 2560 2556 2561 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)2562 if (m_animationScheduler) {2563 m_animationScheduler->detachFromDocument();2564 m_animationScheduler = nullptr;2565 }2566 #endif2567 2568 2557 #if ENABLE(CSS_PAINTING_API) 2569 2558 for (auto& scope : m_paintWorkletGlobalScopes.values()) … … 6262 6251 } 6263 6252 6253 void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp) 6254 { 6255 if (m_timeline) 6256 m_timeline->updateAnimationsAndSendEvents(timestamp); 6257 } 6258 6259 void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp) 6260 { 6261 if (m_scriptedAnimationController) 6262 m_scriptedAnimationController->serviceRequestAnimationFrameCallbacks(timestamp); 6263 } 6264 6264 6265 void Document::windowScreenDidChange(PlatformDisplayID displayID) 6265 6266 { 6266 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)6267 if (m_animationScheduler)6268 m_animationScheduler->windowScreenDidChange(displayID);6269 #endif6270 6271 6267 if (RenderView* view = renderView()) { 6272 6268 if (view->usesCompositing()) … … 7930 7926 return; 7931 7927 7932 m_needsForcedIntersectionObservationUpdate = false;7933 7934 7928 for (const auto& observer : m_intersectionObservers) { 7935 7929 bool needNotify = false; … … 8006 8000 if (m_intersectionObserversWithPendingNotifications.size()) 8007 8001 m_intersectionObserversNotifyTimer.startOneShot(0_s); 8008 }8009 8010 void Document::scheduleForcedIntersectionObservationUpdate()8011 {8012 ASSERT(!m_intersectionObservers.isEmpty());8013 if (m_needsForcedIntersectionObservationUpdate)8014 return;8015 8016 m_needsForcedIntersectionObservationUpdate = true;8017 if (auto* page = this->page())8018 page->scheduleForcedIntersectionObservationUpdate(*this);8019 8002 } 8020 8003 … … 8452 8435 } 8453 8436 8454 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)8455 DocumentAnimationScheduler& Document::animationScheduler()8456 {8457 if (!m_animationScheduler)8458 m_animationScheduler = DocumentAnimationScheduler::create(*this, page() ? page()->chrome().displayID() : 0);8459 8460 return *m_animationScheduler;8461 }8462 #endif8463 8464 8437 DocumentTimeline& Document::timeline() 8465 8438 { -
trunk/Source/WebCore/dom/Document.h
r242341 r242624 108 108 class DatabaseThread; 109 109 class DeferredPromise; 110 class DocumentAnimationScheduler;111 110 class DocumentFragment; 112 111 class DocumentLoader; … … 1046 1045 void suspendScriptedAnimationControllerCallbacks(); 1047 1046 void resumeScriptedAnimationControllerCallbacks(); 1048 1047 1048 void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp); 1049 void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp); 1050 1049 1051 void windowScreenDidChange(PlatformDisplayID); 1050 1052 … … 1399 1401 void removeIntersectionObserver(IntersectionObserver&); 1400 1402 unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); } 1401 void scheduleForcedIntersectionObservationUpdate();1402 1403 void updateIntersectionObservations(); 1403 1404 #endif … … 1472 1473 WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing. 1473 1474 1474 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)1475 DocumentAnimationScheduler& animationScheduler();1476 #endif1477 1478 1475 WEBCORE_EXPORT DocumentTimeline& timeline(); 1479 1476 DocumentTimeline* existingTimeline() const { return m_timeline.get(); } … … 2030 2027 #endif 2031 2028 2032 #if ENABLE(INTERSECTION_OBSERVER)2033 bool m_needsForcedIntersectionObservationUpdate { false };2034 #endif2035 2036 2029 #if ENABLE(MEDIA_STREAM) 2037 2030 HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements; … … 2053 2046 bool m_grantStorageAccessOverride { false }; 2054 2047 2055 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)2056 RefPtr<DocumentAnimationScheduler> m_animationScheduler;2057 #endif2058 2048 RefPtr<DocumentTimeline> m_timeline; 2059 2049 DocumentIdentifier m_identifier; -
trunk/Source/WebCore/dom/ScriptedAnimationController.cpp
r235560 r242624 31 31 #include "DOMWindow.h" 32 32 #include "Document.h" 33 #include "DocumentAnimationScheduler.h"34 33 #include "DocumentLoader.h" 35 34 #include "Frame.h" … … 190 189 } 191 190 192 void ScriptedAnimationController::service ScriptedAnimations(doubletimestamp)191 void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp) 193 192 { 194 193 if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled()) … … 198 197 199 198 // We round this to the nearest microsecond so that we can return a time that matches what is returned by document.timeline.currentTime. 200 doublehighResNowMs = std::round(1000 * timestamp);201 doublelegacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds());199 DOMHighResTimeStamp highResNowMs = std::round(1000 * timestamp); 200 DOMHighResTimeStamp legacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds()); 202 201 203 202 // First, generate a list of callbacks to consider. Callbacks registered from this point … … 211 210 212 211 for (auto& callback : callbacks) { 213 if ( !callback->m_firedOrCancelled) {214 c allback->m_firedOrCancelled = true;215 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);216 if (callback->m_useLegacyTimeBase)217 callback->handleEvent(legacyHighResNowMs);218 else219 callback->handleEvent(highResNowMs);220 InspectorInstrumentation::didFireAnimationFrame(cookie);221 }212 if (callback->m_firedOrCancelled) 213 continue; 214 callback->m_firedOrCancelled = true; 215 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id); 216 if (callback->m_useLegacyTimeBase) 217 callback->handleEvent(legacyHighResNowMs); 218 else 219 callback->handleEvent(highResNowMs); 220 InspectorInstrumentation::didFireAnimationFrame(cookie); 222 221 } 223 222 224 223 // Remove any callbacks we fired from the list of pending callbacks. 225 for (size_t i = 0; i < m_callbacks.size();) { 226 if (m_callbacks[i]->m_firedOrCancelled) 227 m_callbacks.remove(i); 228 else 229 ++i; 230 } 224 m_callbacks.removeAllMatching([](auto& callback) { 225 return callback->m_firedOrCancelled; 226 }); 231 227 232 228 if (m_callbacks.size()) … … 263 259 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 264 260 if (!m_isUsingTimer && !isThrottled()) { 265 if (m_document->animationScheduler().scheduleScriptedAnimationResolution()) 261 if (auto* page = this->page()) { 262 page->renderingUpdateScheduler().scheduleRenderingUpdate(); 266 263 return; 264 } 267 265 268 266 m_isUsingTimer = true; … … 293 291 { 294 292 m_lastAnimationFrameTimestamp = m_document->domWindow()->nowTimestamp(); 295 serviceScriptedAnimations(m_lastAnimationFrameTimestamp); 296 } 297 298 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 299 void ScriptedAnimationController::documentAnimationSchedulerDidFire() 300 { 301 // We obtain the time from the animation scheduler so that we use the same timestamp as the DocumentTimeline. 302 serviceScriptedAnimations(m_document->animationScheduler().lastTimestamp().seconds()); 303 } 304 #endif 305 306 } 293 serviceRequestAnimationFrameCallbacks(m_lastAnimationFrameTimestamp); 294 } 295 296 } -
trunk/Source/WebCore/dom/ScriptedAnimationController.h
r233140 r242624 53 53 CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&); 54 54 void cancelCallback(CallbackId); 55 void service ScriptedAnimations(doubletimestamp);55 void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp); 56 56 57 57 void suspend(); … … 69 69 WEBCORE_EXPORT bool isThrottled() const; 70 70 WEBCORE_EXPORT Seconds interval() const; 71 72 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)73 void documentAnimationSchedulerDidFire();74 #endif75 71 76 72 private: -
trunk/Source/WebCore/page/FrameView.cpp
r242082 r242624 1963 1963 renderView->updateVisibleViewportRect(visibleRect); 1964 1964 }); 1965 1966 #if ENABLE(INTERSECTION_OBSERVER)1967 if (auto* document = frame().document()) {1968 if (auto* page = frame().page()) {1969 if (document->numberOfIntersectionObservers())1970 page->addDocumentNeedingIntersectionObservationUpdate(*document);1971 if (!frame().isMainFrame()) {1972 if (auto* mainDocument = frame().mainFrame().document()) {1973 if (mainDocument->numberOfIntersectionObservers())1974 page->addDocumentNeedingIntersectionObservationUpdate(*mainDocument);1975 }1976 }1977 }1978 }1979 #endif1980 1965 } 1981 1966 -
trunk/Source/WebCore/page/IntersectionObserver.cpp
r241130 r242624 158 158 if (!hadObservationTargets) 159 159 document->addIntersectionObserver(*this); 160 document->scheduleForcedIntersectionObservationUpdate();161 160 } 162 161 -
trunk/Source/WebCore/page/Page.cpp
r242586 r242624 251 251 , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider)) 252 252 , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore)) 253 #if ENABLE(INTERSECTION_OBSERVER)254 , m_intersectionObservationUpdateTimer(*this, &Page::updateIntersectionObservations)255 #endif256 253 , m_sessionID(PAL::SessionID::defaultSessionID()) 257 254 #if ENABLE(VIDEO) … … 1112 1109 } 1113 1110 1114 void Page::willDisplayPage()1115 {1116 #if ENABLE(INTERSECTION_OBSERVER)1117 updateIntersectionObservations();1118 #endif1119 }1120 1121 1111 bool Page::isOnlyNonUtilityPage() const 1122 1112 { … … 1260 1250 } 1261 1251 1252 void Page::layoutIfNeeded() 1253 { 1254 if (FrameView* view = m_mainFrame->view()) 1255 view->updateLayoutAndStyleIfNeededRecursive(); 1256 } 1257 1258 void Page::renderingUpdate() 1259 { 1260 // This function is not reentrant, e.g. a rAF callback may force repaint. 1261 if (m_inRenderingUpdate) { 1262 layoutIfNeeded(); 1263 return; 1264 } 1265 1266 SetForScope<bool> change(m_inRenderingUpdate, true); 1267 1268 Vector<RefPtr<Document>> documents; 1269 1270 // The requestAnimationFrame callbacks may change the frame hierarchy of the page 1271 forEachDocument([&documents] (Document& document) { 1272 documents.append(&document); 1273 }); 1274 1275 for (auto& document : documents) { 1276 DOMHighResTimeStamp timestamp = document->domWindow()->nowTimestamp(); 1277 document->updateAnimationsAndSendEvents(timestamp); 1278 document->serviceRequestAnimationFrameCallbacks(timestamp); 1279 } 1280 1281 layoutIfNeeded(); 1282 1283 for (auto& document : documents) { 1262 1284 #if ENABLE(INTERSECTION_OBSERVER) 1263 void Page::addDocumentNeedingIntersectionObservationUpdate(Document& document) 1264 { 1265 if (m_documentsNeedingIntersectionObservationUpdate.find(&document) == notFound) 1266 m_documentsNeedingIntersectionObservationUpdate.append(makeWeakPtr(document)); 1267 } 1268 1269 void Page::updateIntersectionObservations() 1270 { 1271 m_intersectionObservationUpdateTimer.stop(); 1272 for (const auto& document : m_documentsNeedingIntersectionObservationUpdate) { 1273 if (document) 1274 document->updateIntersectionObservations(); 1275 } 1276 m_documentsNeedingIntersectionObservationUpdate.clear(); 1277 } 1278 1279 void Page::scheduleForcedIntersectionObservationUpdate(Document& document) 1280 { 1281 addDocumentNeedingIntersectionObservationUpdate(document); 1282 if (m_intersectionObservationUpdateTimer.isActive()) 1283 return; 1284 m_intersectionObservationUpdateTimer.startOneShot(0_s); 1285 } 1286 #endif 1285 document->updateIntersectionObservations(); 1286 #endif 1287 } 1288 } 1287 1289 1288 1290 void Page::suspendScriptedAnimations() … … 2824 2826 } 2825 2827 2828 RenderingUpdateScheduler& Page::renderingUpdateScheduler() 2829 { 2830 if (!m_renderingUpdateScheduler) 2831 m_renderingUpdateScheduler = RenderingUpdateScheduler::create(*this); 2832 return *m_renderingUpdateScheduler; 2833 } 2834 2826 2835 void Page::forEachDocument(const Function<void(Document&)>& functor) 2827 2836 { -
trunk/Source/WebCore/page/Page.h
r242340 r242624 34 34 #include "Region.h" 35 35 #include "RegistrableDomain.h" 36 #include "RenderingUpdateScheduler.h" 36 37 #include "ScrollTypes.h" 37 38 #include "Supplementable.h" … … 263 264 PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); } 264 265 266 RenderingUpdateScheduler& renderingUpdateScheduler(); 267 265 268 ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); } 266 269 void updateValidationBubbleStateIfNeeded(); … … 335 338 void didFinishLoad(); // Called when the load has been committed in the main frame. 336 339 337 WEBCORE_EXPORT void willDisplayPage();338 339 340 // The view scale factor is multiplied into the page scale factor by all 340 341 // callers of setPageScaleFactor. … … 464 465 WEBCORE_EXPORT void removeActivityStateChangeObserver(ActivityStateChangeObserver&); 465 466 466 #if ENABLE(INTERSECTION_OBSERVER) 467 void addDocumentNeedingIntersectionObservationUpdate(Document&); 468 void scheduleForcedIntersectionObservationUpdate(Document&); 469 void updateIntersectionObservations(); 470 #endif 467 WEBCORE_EXPORT void layoutIfNeeded(); 468 WEBCORE_EXPORT void renderingUpdate(); 471 469 472 470 WEBCORE_EXPORT void suspendScriptedAnimations(); … … 862 860 int m_headerHeight { 0 }; 863 861 int m_footerHeight { 0 }; 862 863 std::unique_ptr<RenderingUpdateScheduler> m_renderingUpdateScheduler; 864 864 865 865 HashSet<RenderObject*> m_relevantUnpaintedRenderObjects; … … 902 902 903 903 HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers; 904 905 #if ENABLE(INTERSECTION_OBSERVER)906 Vector<WeakPtr<Document>> m_documentsNeedingIntersectionObservationUpdate;907 908 // FIXME: Schedule intersection observation updates in a way that fits into the HTML909 // EventLoop. See https://bugs.webkit.org/show_bug.cgi?id=160711.910 Timer m_intersectionObservationUpdateTimer;911 #endif912 904 913 905 #if ENABLE(RESOURCE_USAGE) … … 971 963 bool m_mediaPlaybackIsSuspended { false }; 972 964 bool m_mediaBufferingIsSuspended { false }; 965 bool m_inRenderingUpdate { false }; 973 966 }; 974 967 -
trunk/Source/WebCore/page/PageOverlayController.cpp
r241978 r242624 319 319 void PageOverlayController::didChangeViewExposedRect() 320 320 { 321 m_page. chrome().client().scheduleCompositingLayerFlush();321 m_page.renderingUpdateScheduler().scheduleRenderingUpdate(); 322 322 } 323 323 … … 413 413 void PageOverlayController::notifyFlushRequired(const WebCore::GraphicsLayer*) 414 414 { 415 m_page. chrome().client().scheduleCompositingLayerFlush();415 m_page.renderingUpdateScheduler().scheduleRenderingUpdate(); 416 416 } 417 417 -
trunk/Source/WebCore/page/RenderingUpdateScheduler.h
r242623 r242624 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)29 30 28 #include "DisplayRefreshMonitorClient.h" 31 #include "PlatformScreen.h"32 #include <wtf/Ref.h>33 #include <wtf/RefCounted.h>34 #include <wtf/RefPtr.h>35 29 #include <wtf/Seconds.h> 36 30 37 31 namespace WebCore { 38 32 39 class Document; 33 class Page; 34 class Timer; 40 35 41 class DocumentAnimationScheduler : public RefCounted<DocumentAnimationScheduler> 42 , public DisplayRefreshMonitorClient { 36 class RenderingUpdateScheduler 37 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 38 : public DisplayRefreshMonitorClient 39 #endif 40 { 41 WTF_MAKE_FAST_ALLOCATED; 43 42 public: 44 static Ref<DocumentAnimationScheduler> create(Document&, PlatformDisplayID); 45 ~DocumentAnimationScheduler(); 43 static std::unique_ptr<RenderingUpdateScheduler> create(Page& page) 44 { 45 return std::make_unique<RenderingUpdateScheduler>(page); 46 } 46 47 47 void detachFromDocument(); 48 RenderingUpdateScheduler(Page&); 49 void scheduleRenderingUpdate(); 50 51 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 48 52 void windowScreenDidChange(PlatformDisplayID); 49 50 bool scheduleWebAnimationsResolution(); 51 void unscheduleWebAnimationsResolution(); 52 bool scheduleScriptedAnimationResolution(); 53 54 Seconds lastTimestamp() { return m_lastTimestamp; } 55 bool isFiring() const { return m_isFiring; } 53 #endif 56 54 57 55 private: 58 DocumentAnimationScheduler(Document&, PlatformDisplayID); 56 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 57 RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const final; 58 void displayRefreshFired() final; 59 #else 60 void displayRefreshFired(); 61 #endif 59 62 60 RefPtr<Document> m_document; 61 bool m_scheduledWebAnimationsResolution { false }; 62 bool m_scheduledScriptedAnimationResolution { false }; 63 bool m_isFiring { false }; 64 Seconds m_lastTimestamp { 0_s }; 63 bool isScheduled() const; 64 void startTimer(Seconds); 65 void clearScheduled(); 65 66 66 void displayRefreshFired() override; 67 RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override; 67 Page& m_page; 68 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 69 bool m_scheduled { false }; 70 #endif 71 std::unique_ptr<Timer> m_refreshTimer; 68 72 }; 69 73 70 } // namespace WebCore 71 72 #endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 74 } -
trunk/Source/WebCore/page/ios/ContentChangeObserver.h
r242621 r242624 28 28 #if PLATFORM(IOS_FAMILY) 29 29 30 #include "Document.h" 31 #include "RenderStyleConstants.h" 30 32 #include "WKContentObservation.h" 33 #include <wtf/HashSet.h> 34 #include <wtf/Seconds.h> 31 35 32 36 namespace WebCore { 33 37 34 38 class DOMTimer; 35 class Document;39 class Element; 36 40 37 41 class ContentChangeObserver { -
trunk/Source/WebCore/page/mac/ServicesOverlayController.mm
r239535 r242624 122 122 return; 123 123 124 m_controller->page(). chrome().client().scheduleCompositingLayerFlush();124 m_controller->page().renderingUpdateScheduler().scheduleRenderingUpdate(); 125 125 } 126 126 -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r242359 r242624 432 432 { 433 433 m_hasPendingLayerFlush = false; 434 page(). chrome().client().scheduleCompositingLayerFlush();434 page().renderingUpdateScheduler().scheduleRenderingUpdate(); 435 435 } 436 436 -
trunk/Source/WebKit/ChangeLog
r242621 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 Replace the calls to Page::layoutIfNeeded() and willDisplayPage() by 9 a single call to Page::renderingUpdate(). This new function implements 10 "Update the rendering" step of the HTML Event Loop specification 11 <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>. 12 13 * WebProcess/WebPage/AcceleratedDrawingArea.cpp: 14 (WebKit::AcceleratedDrawingArea::updateBackingStoreState): 15 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: 16 (WebKit::LayerTreeHost::layerFlushTimerFired): 17 * WebProcess/WebPage/DrawingAreaImpl.cpp: 18 (WebKit::DrawingAreaImpl::display): 19 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: 20 (WebKit::RemoteLayerTreeDrawingArea::flushLayers): 21 * WebProcess/WebPage/WebPage.cpp: 22 (WebKit::WebPage::layoutIfNeeded): 23 (WebKit::WebPage::renderingUpdate): 24 (WebKit::WebPage::willDisplayPage): Deleted. 25 * WebProcess/WebPage/WebPage.h: 26 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 27 (WebKit::TiledCoreAnimationDrawingArea::flushLayers): 28 1 29 2019-03-07 Zalan Bujtas <zalan@apple.com> 2 30 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
r242364 r242624 382 382 m_webPage.setDeviceScaleFactor(deviceScaleFactor); 383 383 m_webPage.setSize(size); 384 m_webPage. layoutIfNeeded();384 m_webPage.renderingUpdate(); 385 385 m_webPage.flushPendingEditorStateUpdate(); 386 386 m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset); 387 m_webPage.willDisplayPage();388 387 389 388 if (m_layerTreeHost) … … 704 703 ASSERT(!m_webPage.size().isEmpty()); 705 704 706 m_webPage. layoutIfNeeded();705 m_webPage.renderingUpdate(); 707 706 m_webPage.flushPendingEditorStateUpdate(); 708 707 … … 712 711 return; 713 712 714 m_webPage.willDisplayPage();715 713 updateInfo.viewSize = m_webPage.size(); 716 714 updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
r242364 r242624 146 146 147 147 m_coordinator.syncDisplayState(); 148 m_webPage.renderingUpdate(); 148 149 m_webPage.flushPendingEditorStateUpdate(); 149 m_webPage.willDisplayPage();150 150 151 151 if (!m_isValid || !m_coordinator.rootCompositingLayer()) -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
r241988 r242624 350 350 backingStoreCollection.willFlushLayers(); 351 351 352 m_webPage.layoutIfNeeded(); 353 m_webPage.willDisplayPage(); 352 m_webPage.renderingUpdate(); 354 353 355 354 FloatRect visibleRect(FloatPoint(), m_viewSize); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r242611 r242624 1555 1555 } 1556 1556 1557 void WebPage::layoutIfNeeded()1558 {1559 if (m_mainFrame->coreFrame()->view())1560 m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();1561 }1562 1563 1557 WebPage* WebPage::fromCorePage(Page* page) 1564 1558 { … … 3582 3576 #endif 3583 3577 3584 void WebPage::willDisplayPage() 3585 { 3586 m_page->willDisplayPage(); 3578 void WebPage::layoutIfNeeded() 3579 { 3580 m_page->layoutIfNeeded(); 3581 } 3582 3583 void WebPage::renderingUpdate() 3584 { 3585 m_page->renderingUpdate(); 3587 3586 } 3588 3587 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r242587 r242624 302 302 #endif 303 303 304 void willDisplayPage(); 304 void layoutIfNeeded(); 305 void renderingUpdate(); 305 306 306 307 enum class LazyCreationPolicy { UseExistingOnly, CreateIfNeeded }; … … 335 336 // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial? 336 337 void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&); 337 void layoutIfNeeded();338 338 339 339 // -- Called from WebCore clients. -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r241988 r242624 60 60 #import <wtf/MachSendRight.h> 61 61 #import <wtf/MainThread.h> 62 #import <wtf/SystemTracing.h> 62 63 63 64 #if ENABLE(ASYNC_SCROLLING) … … 460 461 return; 461 462 463 TraceScope traceScope(RenderingUpdateStart, RenderingUpdateEnd); 464 462 465 @autoreleasepool { 463 466 scaleViewToFitDocumentIfNeeded(); 464 467 465 m_webPage. layoutIfNeeded();468 m_webPage.renderingUpdate(); 466 469 m_webPage.flushPendingEditorStateUpdate(); 467 m_webPage.willDisplayPage();468 470 469 471 updateIntrinsicContentSizeIfNeeded(); -
trunk/Source/WebKitLegacy/mac/ChangeLog
r242621 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 * WebView/WebView.mm: 9 (-[WebView _viewWillDrawInternal]): 10 Call Page::renderingUpdate() which implements "Update the rendering" 11 step of the HTML Event Loop specification. 12 1 13 2019-03-07 Zalan Bujtas <zalan@apple.com> 2 14 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r242621 r242624 1621 1621 - (void)_viewWillDrawInternal 1622 1622 { 1623 Frame* frame = [self _mainCoreFrame]; 1624 if (frame && frame->view()) 1625 frame->view()->updateLayoutAndStyleIfNeededRecursive(); 1623 if (_private->page) 1624 _private->page->renderingUpdate(); 1626 1625 } 1627 1626 -
trunk/Source/WebKitLegacy/win/ChangeLog
r242592 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 * WebView.cpp: 9 (WebView::updateBackingStore): 10 (WebView::flushPendingGraphicsLayerChangesSoon): 11 (WebView::flushPendingGraphicsLayerChanges): 12 Call Page::renderingUpdate() which implements "Update the rendering" 13 step of the HTML Event Loop specification. 14 1 15 2019-03-06 Ross Kirsling <ross.kirsling@sony.com> 2 16 -
trunk/Source/WebKitLegacy/win/WebView.cpp
r242592 r242624 1174 1174 if (m_backingStoreBitmap && (m_backingStoreDirtyRegion || backingStoreCompletelyDirty)) { 1175 1175 // Do a layout first so that everything we render to the backing store is always current. 1176 if (Frame* coreFrame = core(m_mainFrame)) 1177 if (FrameView* view = coreFrame->view()) 1178 view->updateLayoutAndStyleIfNeededRecursive(); 1176 m_page->renderingUpdate(); 1179 1177 1180 1178 Vector<IntRect> paintRects; … … 7160 7158 { 7161 7159 #if USE(CA) 7162 if (!m_layerTreeHost) 7160 if (!m_layerTreeHost) { 7161 m_page->renderingUpdate(); 7163 7162 return; 7163 } 7164 7164 m_layerTreeHost->flushPendingGraphicsLayerChangesSoon(); 7165 7165 #elif USE(TEXTURE_MAPPER_GL) … … 7389 7389 return; 7390 7390 7391 view->updateLayoutAndStyleIfNeededRecursive();7391 m_page->renderingUpdate(); 7392 7392 7393 7393 // Updating layout might have taken us out of compositing mode. -
trunk/Tools/ChangeLog
r242621 r242624 1 2019-03-07 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 Add trace points for the page RenderingUpdate. 9 10 * Tracing/SystemTracePoints.plist: 11 1 12 2019-03-07 Zalan Bujtas <zalan@apple.com> 2 13 -
trunk/Tools/Tracing/SystemTracePoints.plist
r242294 r242624 219 219 <dict> 220 220 <key>Name</key> 221 <string>Schedule rendering update</string> 222 <key>Type</key> 223 <string>Impulse</string> 224 <key>Component</key> 225 <string>47</string> 226 <key>Code</key> 227 <string>5028</string> 228 </dict> 229 <dict> 230 <key>Name</key> 231 <string>Trigger rendering update</string> 232 <key>Type</key> 233 <string>Impulse</string> 234 <key>Component</key> 235 <string>47</string> 236 <key>Code</key> 237 <string>5029</string> 238 </dict> 239 <dict> 240 <key>Name</key> 241 <string>Rendering update</string> 242 <key>Type</key> 243 <string>Interval</string> 244 <key>Component</key> 245 <string>47</string> 246 <key>CodeBegin</key> 247 <string>5030</string> 248 <key>CodeEnd</key> 249 <string>5031</string> 250 </dict> 251 <dict> 252 <key>Name</key> 221 253 <string>Paint WebHTMLView</string> 222 254 <key>Type</key>
Note:
See TracChangeset
for help on using the changeset viewer.