| Differences between
and this patch
- a/Source/WTF/ChangeLog +11 lines
Lines 1-3 a/Source/WTF/ChangeLog_sec1
1
2019-03-01  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
2019-03-01  Simon Fraser  <simon.fraser@apple.com>
12
2019-03-01  Simon Fraser  <simon.fraser@apple.com>
2
13
3
        Add a system trace scope for event region building
14
        Add a system trace scope for event region building
- a/Source/WebCore/ChangeLog +118 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2019-03-01  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
        * animation/DocumentAnimationScheduler.cpp: Removed.
35
        * animation/DocumentAnimationScheduler.h: Removed.
36
        * animation/DocumentTimeline.cpp:
37
        (WebCore::DocumentTimeline::DocumentTimeline):
38
        (WebCore::DocumentTimeline::updateThrottlingState):
39
        (WebCore::DocumentTimeline::resumeAnimations):
40
        (WebCore::DocumentTimeline::liveCurrentTime const):
41
        (WebCore::DocumentTimeline::currentTime):
42
        (WebCore::DocumentTimeline::animationTimingDidChange):
43
        (WebCore::DocumentTimeline::scheduleAnimationResolution):
44
        (WebCore::DocumentTimeline::unscheduleAnimationResolution):
45
        (WebCore::DocumentTimeline::updateAnimationsAndSendEvents):
46
        (WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents):
47
        (WebCore::DocumentTimeline::scheduleNextTick):
48
        (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement):
49
        Simplify this function by handling the case of no-animations separately.
50
51
        (WebCore::DocumentTimeline::resolveAnimationsForElement):
52
        Simplify the loop and delete hasPendingAcceleratedAnimations because it
53
        is initialized to true and is not changed inside the loop.
54
55
        (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Deleted.
56
        (WebCore::DocumentTimeline::animationResolutionTimerFired): Deleted.
57
        * animation/DocumentTimeline.h:
58
        * dom/Document.cpp:
59
        (WebCore::Document::resolveStyle):
60
        There is no need to force update in resolveStyle(). notifyFlushRequired()
61
        will be called eventually which will scheduleRenderingUpdate().
62
63
        (WebCore::Document::prepareForDestruction):
64
        (WebCore::Document::updateAnimationsAndSendEvents):
65
        (WebCore::Document::serviceRequestAnimationFrameCallbacks):
66
        (WebCore::Document::windowScreenDidChange):
67
        (WebCore::Document::updateIntersectionObservations):
68
        (WebCore::Document::scheduleForcedIntersectionObservationUpdate): Deleted.
69
        (WebCore::Document::animationScheduler): Deleted.
70
        * dom/Document.h:
71
        (WebCore::Document::numberOfIntersectionObservers const):
72
        * dom/ScriptedAnimationController.cpp:
73
        (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks):
74
        (WebCore::ScriptedAnimationController::scheduleAnimation):
75
        (WebCore::ScriptedAnimationController::animationTimerFired):
76
        (WebCore::ScriptedAnimationController::serviceScriptedAnimations): Deleted.
77
        (WebCore::ScriptedAnimationController::documentAnimationSchedulerDidFire): Deleted.
78
        * dom/ScriptedAnimationController.h:
79
        * page/FrameView.cpp:
80
        (WebCore::FrameView::viewportContentsChanged):
81
        * page/IntersectionObserver.cpp:
82
        (WebCore::IntersectionObserver::observe):
83
        * page/Page.cpp:
84
        (WebCore::Page::Page):
85
        (WebCore::Page::layoutIfNeeded):
86
        (WebCore::Page::renderingUpdate):
87
        (WebCore::Page::renderingUpdateScheduler):
88
        (WebCore::Page::willDisplayPage): Deleted.
89
        (WebCore::Page::addDocumentNeedingIntersectionObservationUpdate): Deleted.
90
        (WebCore::Page::updateIntersectionObservations): Deleted.
91
        (WebCore::Page::scheduleForcedIntersectionObservationUpdate): Deleted.
92
        * page/Page.h:
93
        * page/PageOverlayController.cpp:
94
        (WebCore::PageOverlayController::didChangeViewExposedRect):
95
        (WebCore::PageOverlayController::notifyFlushRequired):
96
        * page/ResourceUsageData.h:
97
        Include header files that become missing because of adding 
98
        RenderingUpdateScheduler.cpp.
99
100
        * page/RenderingUpdateScheduler.cpp: Added.
101
        (WebCore::RenderingUpdateScheduler::RenderingUpdateScheduler):
102
        (WebCore::RenderingUpdateScheduler::scheduleRenderingUpdate):
103
        (WebCore::RenderingUpdateScheduler::startTimer):
104
        (WebCore::RenderingUpdateScheduler::clearTimer):
105
        (WebCore::RenderingUpdateScheduler::windowScreenDidChange):
106
        (WebCore::RenderingUpdateScheduler::createDisplayRefreshMonitor const):
107
        (WebCore::RenderingUpdateScheduler::displayRefreshFired):
108
        * page/RenderingUpdateScheduler.h: Added.
109
        (WebCore::RenderingUpdateScheduler::create):
110
        * page/ios/ContentChangeObserver.h:
111
        Include header files that become missing because of adding 
112
        RenderingUpdateScheduler.cpp.
113
114
        * page/mac/ServicesOverlayController.mm:
115
        (WebCore::ServicesOverlayController::Highlight::notifyFlushRequired):
116
        * rendering/RenderLayerCompositor.cpp:
117
        (WebCore::RenderLayerCompositor::scheduleLayerFlushNow):
118
1
2019-03-01  Antoine Quint  <graouts@apple.com>
119
2019-03-01  Antoine Quint  <graouts@apple.com>
2
120
3
        [iOS] Turn mouse event simulation on by default
121
        [iOS] Turn mouse event simulation on by default
- a/Source/WebKit/ChangeLog +28 lines
Lines 1-3 a/Source/WebKit/ChangeLog_sec1
1
2019-03-01  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
2019-03-01  Antoine Quint  <graouts@apple.com>
29
2019-03-01  Antoine Quint  <graouts@apple.com>
2
30
3
        [iOS] Turn mouse event simulation on by default
31
        [iOS] Turn mouse event simulation on by default
- a/Source/WebKitLegacy/mac/ChangeLog +12 lines
Lines 1-3 a/Source/WebKitLegacy/mac/ChangeLog_sec1
1
2019-03-01  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
2019-03-01  Tim Horton  <timothy_horton@apple.com>
13
2019-03-01  Tim Horton  <timothy_horton@apple.com>
2
14
3
        Remove unused code in WebKitLegacy
15
        Remove unused code in WebKitLegacy
- a/Source/WebKitLegacy/win/ChangeLog +13 lines
Lines 1-3 a/Source/WebKitLegacy/win/ChangeLog_sec1
1
2019-03-02  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 NOBODY (OOPS!).
7
8
        * WebView.cpp:
9
        (WebView::updateBackingStore):
10
        (WebView::flushPendingGraphicsLayerChanges):
11
        Call Page::renderingUpdate() which implements  "Update the rendering"
12
        step of the HTML Event Loop specification.
13
1
2019-02-27  Simon Fraser  <simon.fraser@apple.com>
14
2019-02-27  Simon Fraser  <simon.fraser@apple.com>
2
15
3
        Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
16
        Roll out r242014; it caused crashes in compositing logging (webkit.org/b/195141)
- a/Source/WTF/wtf/SystemTracing.h +5 lines
Lines 77-82 enum TracePointCode { a/Source/WTF/wtf/SystemTracing.h_sec1
77
    ComputeEventRegionsStart,
77
    ComputeEventRegionsStart,
78
    ComputeEventRegionsEnd,
78
    ComputeEventRegionsEnd,
79
79
80
    ScheduleRenderingUpdate,
81
    TriggerRenderingUpdate,
82
    RenderingUpdateStart,
83
    RenderingUpdateEnd,
84
80
    WebKitRange = 10000,
85
    WebKitRange = 10000,
81
    WebHTMLViewPaintStart,
86
    WebHTMLViewPaintStart,
82
    WebHTMLViewPaintEnd,
87
    WebHTMLViewPaintEnd,
- a/Source/WebCore/Sources.txt -1 / +1 lines
Lines 417-423 animation/AnimationTimeline.cpp a/Source/WebCore/Sources.txt_sec1
417
animation/CSSAnimation.cpp
417
animation/CSSAnimation.cpp
418
animation/CSSTransition.cpp
418
animation/CSSTransition.cpp
419
animation/DeclarativeAnimation.cpp
419
animation/DeclarativeAnimation.cpp
420
animation/DocumentAnimationScheduler.cpp
421
animation/DocumentTimeline.cpp
420
animation/DocumentTimeline.cpp
422
animation/KeyframeEffect.cpp
421
animation/KeyframeEffect.cpp
423
animation/WebAnimation.cpp
422
animation/WebAnimation.cpp
Lines 1536-1541 page/ProcessWarming.cpp a/Source/WebCore/Sources.txt_sec2
1536
page/Quirks.cpp
1535
page/Quirks.cpp
1537
page/RemoteDOMWindow.cpp
1536
page/RemoteDOMWindow.cpp
1538
page/RemoteFrame.cpp
1537
page/RemoteFrame.cpp
1538
page/RenderingUpdateScheduler.cpp
1539
page/ResourceUsageOverlay.cpp
1539
page/ResourceUsageOverlay.cpp
1540
page/ResourceUsageThread.cpp
1540
page/ResourceUsageThread.cpp
1541
page/RuntimeEnabledFeatures.cpp
1541
page/RuntimeEnabledFeatures.cpp
- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj -6 / +6 lines
Lines 1777-1782 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec1
1777
		5550CB421E955E3C00111AA0 /* ImageTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 5550CB411E955E3C00111AA0 /* ImageTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
1777
		5550CB421E955E3C00111AA0 /* ImageTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 5550CB411E955E3C00111AA0 /* ImageTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
1778
		555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
1778
		555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
1779
		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
1779
		555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; };
1780
		556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
1780
		5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
1781
		5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; };
1781
		55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
1782
		55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; };
1782
		55AF14E61EAAC59B0026EEAA /* UTIRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 55AF14E41EAAC59B0026EEAA /* UTIRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
1783
		55AF14E61EAAC59B0026EEAA /* UTIRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = 55AF14E41EAAC59B0026EEAA /* UTIRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; };
Lines 2114-2120 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec2
2114
		7156BCA121CA350F00534397 /* BasicEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 7156BC9F21CA350600534397 /* BasicEffectTiming.h */; };
2115
		7156BCA121CA350F00534397 /* BasicEffectTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 7156BC9F21CA350600534397 /* BasicEffectTiming.h */; };
2115
		715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
2116
		715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; };
2116
		715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; };
2117
		715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; };
2117
		716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };
2118
		71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
2118
		71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
2119
		71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; };
2119
		71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; };
2120
		71A1B6081DEE5AD70073BCFB /* modern-media-controls-localized-strings.js in Resources */ = {isa = PBXBuildFile; fileRef = 71A1B6061DEE5A820073BCFB /* modern-media-controls-localized-strings.js */; };
2120
		71A1B6081DEE5AD70073BCFB /* modern-media-controls-localized-strings.js in Resources */ = {isa = PBXBuildFile; fileRef = 71A1B6061DEE5A820073BCFB /* modern-media-controls-localized-strings.js */; };
Lines 8637-8642 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec3
8637
		555130001E7CCCCA00A69E38 /* DecodingOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodingOptions.h; sourceTree = "<group>"; };
8637
		555130001E7CCCCA00A69E38 /* DecodingOptions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodingOptions.h; sourceTree = "<group>"; };
8638
		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
8638
		555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; };
8639
		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
8639
		555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; };
8640
		556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderingUpdateScheduler.h; sourceTree = "<group>"; };
8641
		556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderingUpdateScheduler.cpp; sourceTree = "<group>"; };
8640
		5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; };
8642
		5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; };
8641
		5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
8643
		5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; };
8642
		5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
8644
		5597FCCB2076C06800D35BB0 /* GlyphDisplayListCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GlyphDisplayListCache.h; sourceTree = "<group>"; };
Lines 9363-9370 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec4
9363
		716C8DF21E48B269005BD0DA /* volume-up-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-support.js"; sourceTree = "<group>"; };
9365
		716C8DF21E48B269005BD0DA /* volume-up-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-support.js"; sourceTree = "<group>"; };
9364
		716C8DF31E48B284005BD0DA /* volume-down-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-down-button.js"; sourceTree = "<group>"; };
9366
		716C8DF31E48B284005BD0DA /* volume-down-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-down-button.js"; sourceTree = "<group>"; };
9365
		716C8DF41E48B284005BD0DA /* volume-up-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-button.js"; sourceTree = "<group>"; };
9367
		716C8DF41E48B284005BD0DA /* volume-up-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-button.js"; sourceTree = "<group>"; };
9366
		716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentAnimationScheduler.h; sourceTree = "<group>"; };
9367
		716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentAnimationScheduler.cpp; sourceTree = "<group>"; };
9368
		716FA0D81DB26591007323CC /* airplay-button.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "airplay-button.css"; sourceTree = "<group>"; };
9368
		716FA0D81DB26591007323CC /* airplay-button.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "airplay-button.css"; sourceTree = "<group>"; };
9369
		716FA0D91DB26591007323CC /* airplay-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-button.js"; sourceTree = "<group>"; };
9369
		716FA0D91DB26591007323CC /* airplay-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-button.js"; sourceTree = "<group>"; };
9370
		716FA0DA1DB26591007323CC /* airplay-placard.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-placard.js"; sourceTree = "<group>"; };
9370
		716FA0DA1DB26591007323CC /* airplay-placard.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-placard.js"; sourceTree = "<group>"; };
Lines 20472-20477 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec5
20472
				46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */,
20472
				46BCBBC3208500A700710638 /* RemoteDOMWindow.idl */,
20473
				46B9518C207D632900A7D2DD /* RemoteFrame.cpp */,
20473
				46B9518C207D632900A7D2DD /* RemoteFrame.cpp */,
20474
				46B95192207D632E00A7D2DD /* RemoteFrame.h */,
20474
				46B95192207D632E00A7D2DD /* RemoteFrame.h */,
20475
				556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */,
20476
				556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */,
20475
				A5071E821C56D079009951BE /* ResourceUsageData.h */,
20477
				A5071E821C56D079009951BE /* ResourceUsageData.h */,
20476
				ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
20478
				ADBAD6EC1BCDD95000381325 /* ResourceUsageOverlay.cpp */,
20477
				ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */,
20479
				ADBAD6ED1BCDD95000381325 /* ResourceUsageOverlay.h */,
Lines 20624-20631 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec6
20624
				7123C185204739B900789392 /* CSSTransition.idl */,
20626
				7123C185204739B900789392 /* CSSTransition.idl */,
20625
				715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */,
20627
				715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */,
20626
				715AD71D2050512400D592DC /* DeclarativeAnimation.h */,
20628
				715AD71D2050512400D592DC /* DeclarativeAnimation.h */,
20627
				716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */,
20628
				716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */,
20629
				71025EC41F99F096004A250C /* DocumentTimeline.cpp */,
20629
				71025EC41F99F096004A250C /* DocumentTimeline.cpp */,
20630
				71025EC51F99F096004A250C /* DocumentTimeline.h */,
20630
				71025EC51F99F096004A250C /* DocumentTimeline.h */,
20631
				71025ECA1F99F096004A250C /* DocumentTimeline.idl */,
20631
				71025ECA1F99F096004A250C /* DocumentTimeline.idl */,
Lines 29036-29042 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec7
29036
				B2F34FE60E82F81400F627CD /* DNS.h in Headers */,
29036
				B2F34FE60E82F81400F627CD /* DNS.h in Headers */,
29037
				7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */,
29037
				7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */,
29038
				A8185F4009765766005826D9 /* Document.h in Headers */,
29038
				A8185F4009765766005826D9 /* Document.h in Headers */,
29039
				716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */,
29040
				A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */,
29039
				A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */,
29041
				A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
29040
				A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */,
29042
				46E1666E1FCC86A200C9710B /* DocumentIdentifier.h in Headers */,
29041
				46E1666E1FCC86A200C9710B /* DocumentIdentifier.h in Headers */,
Lines 31238-31243 a/Source/WebCore/WebCore.xcodeproj/project.pbxproj_sec8
31238
				BCEA4876097D93020094C9E4 /* RenderImage.h in Headers */,
31237
				BCEA4876097D93020094C9E4 /* RenderImage.h in Headers */,
31239
				08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */,
31238
				08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */,
31240
				08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */,
31239
				08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */,
31240
				556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */,
31241
				BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */,
31241
				BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */,
31242
				B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */,
31242
				B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */,
31243
				BCEA487A097D93020094C9E4 /* RenderLayer.h in Headers */,
31243
				BCEA487A097D93020094C9E4 /* RenderLayer.h in Headers */,
- a/Source/WebCore/animation/DocumentAnimationScheduler.cpp -124 lines
Lines 1-124 a/Source/WebCore/animation/DocumentAnimationScheduler.cpp_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "DocumentAnimationScheduler.h"
28
29
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
30
31
#include "Chrome.h"
32
#include "ChromeClient.h"
33
#include "DOMWindow.h"
34
#include "DisplayRefreshMonitor.h"
35
#include "DisplayRefreshMonitorManager.h"
36
#include "Document.h"
37
#include "DocumentTimeline.h"
38
#include "Page.h"
39
#include "ScriptedAnimationController.h"
40
41
namespace WebCore {
42
43
Ref<DocumentAnimationScheduler> DocumentAnimationScheduler::create(Document& document, PlatformDisplayID displayID)
44
{
45
    return adoptRef(*new DocumentAnimationScheduler(document, displayID));
46
}
47
48
DocumentAnimationScheduler::DocumentAnimationScheduler(Document& document, PlatformDisplayID displayID)
49
    : m_document(&document)
50
{
51
    windowScreenDidChange(displayID);
52
}
53
54
DocumentAnimationScheduler::~DocumentAnimationScheduler() = default;
55
56
void DocumentAnimationScheduler::detachFromDocument()
57
{
58
    m_document = nullptr;
59
}
60
61
bool DocumentAnimationScheduler::scheduleWebAnimationsResolution()
62
{
63
    m_scheduledWebAnimationsResolution = true;
64
    return DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this);
65
}
66
67
void DocumentAnimationScheduler::unscheduleWebAnimationsResolution()
68
{
69
    m_scheduledWebAnimationsResolution = false;
70
71
    if (!m_scheduledScriptedAnimationResolution)
72
        DisplayRefreshMonitorManager::sharedManager().unregisterClient(*this);
73
}
74
75
bool DocumentAnimationScheduler::scheduleScriptedAnimationResolution()
76
{
77
    m_scheduledScriptedAnimationResolution = true;
78
    return DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this);
79
}
80
81
void DocumentAnimationScheduler::displayRefreshFired()
82
{
83
    if (!m_document || !m_document->domWindow())
84
        return;
85
86
    // This object could be deleted after scripts in the the requestAnimationFrame callbacks are executed.
87
    auto protectedThis = makeRef(*this);
88
89
    m_isFiring = true;
90
    m_lastTimestamp = Seconds(m_document->domWindow()->nowTimestamp());
91
92
    if (m_scheduledWebAnimationsResolution) {
93
        m_scheduledWebAnimationsResolution = false;
94
        m_document->timeline().documentAnimationSchedulerDidFire();
95
    }
96
97
    if (m_scheduledScriptedAnimationResolution) {
98
        m_scheduledScriptedAnimationResolution = false;
99
        if (auto* scriptedAnimationController = m_document->scriptedAnimationController())
100
            scriptedAnimationController->documentAnimationSchedulerDidFire();
101
    }
102
103
    m_isFiring = false;
104
}
105
106
void DocumentAnimationScheduler::windowScreenDidChange(PlatformDisplayID displayID)
107
{
108
    DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, *this);
109
}
110
111
RefPtr<DisplayRefreshMonitor> DocumentAnimationScheduler::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
112
{
113
    if (!m_document || !m_document->page())
114
        return nullptr;
115
116
    if (auto monitor = m_document->page()->chrome().client().createDisplayRefreshMonitor(displayID))
117
        return monitor;
118
119
    return DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(displayID);
120
}
121
122
} // namespace WebCore
123
124
#endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
- a/Source/WebCore/animation/DocumentAnimationScheduler.h -72 lines
Lines 1-72 a/Source/WebCore/animation/DocumentAnimationScheduler.h_sec1
1
/*
2
 * Copyright (C) 2018 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
29
30
#include "DisplayRefreshMonitorClient.h"
31
#include "PlatformScreen.h"
32
#include <wtf/Ref.h>
33
#include <wtf/RefCounted.h>
34
#include <wtf/RefPtr.h>
35
#include <wtf/Seconds.h>
36
37
namespace WebCore {
38
39
class Document;
40
41
class DocumentAnimationScheduler : public RefCounted<DocumentAnimationScheduler>
42
    , public DisplayRefreshMonitorClient {
43
public:
44
    static Ref<DocumentAnimationScheduler> create(Document&, PlatformDisplayID);
45
    ~DocumentAnimationScheduler();
46
47
    void detachFromDocument();
48
    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; }
56
57
private:
58
    DocumentAnimationScheduler(Document&, PlatformDisplayID);
59
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 };
65
66
    void displayRefreshFired() override;
67
    RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override;
68
};
69
70
} // namespace WebCore
71
72
#endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
- a/Source/WebCore/animation/DocumentTimeline.cpp -102 / +74 lines
Lines 33-39 a/Source/WebCore/animation/DocumentTimeline.cpp_sec1
33
#include "DOMWindow.h"
33
#include "DOMWindow.h"
34
#include "DeclarativeAnimation.h"
34
#include "DeclarativeAnimation.h"
35
#include "Document.h"
35
#include "Document.h"
36
#include "DocumentAnimationScheduler.h"
37
#include "GraphicsLayer.h"
36
#include "GraphicsLayer.h"
38
#include "KeyframeEffect.h"
37
#include "KeyframeEffect.h"
39
#include "Microtasks.h"
38
#include "Microtasks.h"
Lines 61-70 Ref<DocumentTimeline> DocumentTimeline::create(Document& document, DocumentTimel a/Source/WebCore/animation/DocumentTimeline.cpp_sec2
61
60
62
DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime)
61
DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime)
63
    : AnimationTimeline()
62
    : AnimationTimeline()
64
#if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
63
    , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolution)
65
    , m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired)
66
#endif
67
    , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolutionIfNeeded)
68
    , m_document(&document)
64
    , m_document(&document)
69
    , m_originTime(originTime)
65
    , m_originTime(originTime)
70
{
66
{
Lines 194-200 Vector<RefPtr<WebAnimation>> DocumentTimeline::getAnimations() const a/Source/WebCore/animation/DocumentTimeline.cpp_sec3
194
190
195
void DocumentTimeline::updateThrottlingState()
191
void DocumentTimeline::updateThrottlingState()
196
{
192
{
197
    scheduleAnimationResolutionIfNeeded();
193
    scheduleAnimationResolution();
198
}
194
}
199
195
200
Seconds DocumentTimeline::animationInterval() const
196
Seconds DocumentTimeline::animationInterval() const
Lines 210-222 void DocumentTimeline::suspendAnimations() a/Source/WebCore/animation/DocumentTimeline.cpp_sec4
210
        return;
206
        return;
211
207
212
    if (!m_cachedCurrentTime)
208
    if (!m_cachedCurrentTime)
213
        m_cachedCurrentTime = liveCurrentTime();
209
        m_cachedCurrentTime = Seconds(liveCurrentTime());
214
210
215
    for (const auto& animation : m_animations)
211
    for (const auto& animation : m_animations)
216
        animation->setSuspended(true);
212
        animation->setSuspended(true);
217
213
218
    m_isSuspended = true;
214
    m_isSuspended = true;
219
215
216
    fprintf(stderr, "In DocumentTimeline::updateAnimationsAndSendEvents(), Animation was suspended: this = %p, liveCurrentTime = %f\n", this, liveCurrentTime());
217
    
220
    applyPendingAcceleratedAnimations();
218
    applyPendingAcceleratedAnimations();
221
219
222
    unscheduleAnimationResolution();
220
    unscheduleAnimationResolution();
Lines 230-240 void DocumentTimeline::resumeAnimations() a/Source/WebCore/animation/DocumentTimeline.cpp_sec5
230
    m_cachedCurrentTime = WTF::nullopt;
228
    m_cachedCurrentTime = WTF::nullopt;
231
229
232
    m_isSuspended = false;
230
    m_isSuspended = false;
231
    
232
    fprintf(stderr, "In DocumentTimeline::updateAnimationsAndSendEvents(), Animation was resumed: this = %p, liveCurrentTime = %f\n", this, liveCurrentTime());
233
233
234
    for (const auto& animation : m_animations)
234
    for (const auto& animation : m_animations)
235
        animation->setSuspended(false);
235
        animation->setSuspended(false);
236
236
237
    scheduleAnimationResolutionIfNeeded();
237
    scheduleAnimationResolution();
238
}
238
}
239
239
240
bool DocumentTimeline::animationsAreSuspended()
240
bool DocumentTimeline::animationsAreSuspended()
Lines 252-264 unsigned DocumentTimeline::numberOfActiveAnimationsForTesting() const a/Source/WebCore/animation/DocumentTimeline.cpp_sec6
252
    return count;
252
    return count;
253
}
253
}
254
254
255
Seconds DocumentTimeline::liveCurrentTime() const
255
DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const
256
{
256
{
257
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
257
    return m_document->domWindow()->nowTimestamp();
258
    return m_document->animationScheduler().lastTimestamp();
259
#else
260
    return Seconds(m_document->domWindow()->nowTimestamp());
261
#endif
262
}
258
}
263
259
264
Optional<Seconds> DocumentTimeline::currentTime()
260
Optional<Seconds> DocumentTimeline::currentTime()
Lines 274-309 Optional<Seconds> DocumentTimeline::currentTime() a/Source/WebCore/animation/DocumentTimeline.cpp_sec7
274
        }
270
        }
275
    }
271
    }
276
272
277
    auto currentTime = liveCurrentTime();
273
    if (!m_cachedCurrentTime)
278
274
        cacheCurrentTime(liveCurrentTime());
279
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
275
    
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
    }
301
    return m_cachedCurrentTime.value() - m_originTime;
276
    return m_cachedCurrentTime.value() - m_originTime;
302
}
277
}
303
278
304
void DocumentTimeline::cacheCurrentTime(Seconds newCurrentTime)
279
void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime)
305
{
280
{
306
    m_cachedCurrentTime = newCurrentTime;
281
    m_cachedCurrentTime = Seconds(newCurrentTime);
307
    // We want to be sure to keep this time cached until we've both finished running JS and finished updating
282
    // We want to be sure to keep this time cached until we've both finished running JS and finished updating
308
    // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
283
    // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will
309
    // fire syncronously if no JS is running.
284
    // fire syncronously if no JS is running.
Lines 326-341 void DocumentTimeline::maybeClearCachedCurrentTime() a/Source/WebCore/animation/DocumentTimeline.cpp_sec8
326
        m_cachedCurrentTime = WTF::nullopt;
301
        m_cachedCurrentTime = WTF::nullopt;
327
}
302
}
328
303
329
void DocumentTimeline::scheduleAnimationResolutionIfNeeded()
330
{
331
    if (!m_isUpdatingAnimations && !m_isSuspended && !m_animations.isEmpty())
332
        scheduleAnimationResolution();
333
}
334
335
void DocumentTimeline::animationTimingDidChange(WebAnimation& animation)
304
void DocumentTimeline::animationTimingDidChange(WebAnimation& animation)
336
{
305
{
337
    AnimationTimeline::animationTimingDidChange(animation);
306
    AnimationTimeline::animationTimingDidChange(animation);
338
    scheduleAnimationResolutionIfNeeded();
307
    scheduleAnimationResolution();
339
}
308
}
340
309
341
void DocumentTimeline::removeAnimation(WebAnimation& animation)
310
void DocumentTimeline::removeAnimation(WebAnimation& animation)
Lines 348-391 void DocumentTimeline::removeAnimation(WebAnimation& animation) a/Source/WebCore/animation/DocumentTimeline.cpp_sec9
348
317
349
void DocumentTimeline::scheduleAnimationResolution()
318
void DocumentTimeline::scheduleAnimationResolution()
350
{
319
{
351
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
320
    if (m_isSuspended || m_animations.isEmpty() || m_animationResolutionScheduled)
352
    m_document->animationScheduler().scheduleWebAnimationsResolution();
321
        return;
353
#else
322
354
    // FIXME: We need to use the same logic as ScriptedAnimationController here,
323
    if (!m_document || !m_document->page())
355
    // which will be addressed by the refactor tracked by webkit.org/b/179293.
324
        return;
356
    m_animationResolutionTimer.startOneShot(animationInterval());
325
    
357
#endif
326
    m_document->page()->renderingUpdateScheduler().scheduleRenderingUpdate();
327
    m_animationResolutionScheduled = true;
328
    
329
    fprintf(stderr, "In DocumentTimeline::updateAnimationsAndSendEvents(), RenderingUpdate was scheduled : this = %p, liveCurrentTime = %f\n", this, liveCurrentTime());
358
}
330
}
359
331
360
void DocumentTimeline::unscheduleAnimationResolution()
332
void DocumentTimeline::unscheduleAnimationResolution()
361
{
333
{
362
    m_tickScheduleTimer.stop();
334
    m_tickScheduleTimer.stop();
363
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
335
    m_animationResolutionScheduled = false;
364
    m_document->animationScheduler().unscheduleWebAnimationsResolution();
336
}
365
#else
337
366
    // FIXME: We need to use the same logic as ScriptedAnimationController here,
338
void DocumentTimeline::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
367
    // which will be addressed by the refactor tracked by webkit.org/b/179293.
339
{
368
    m_animationResolutionTimer.stop();
340
    // We need to freeze the current time even if no animation is running.
369
#endif
341
    // document.timeline.currentTime may be called from a rAF callback and
370
}
342
    // it has to match the rAF timestamp.
371
343
    if (!m_isSuspended)
372
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
344
        cacheCurrentTime(timestamp);
373
void DocumentTimeline::documentAnimationSchedulerDidFire()
345
374
#else
346
    if (m_isSuspended || m_animations.isEmpty() || !m_animationResolutionScheduled)
375
void DocumentTimeline::animationResolutionTimerFired()
347
        return;
376
#endif
348
377
{
349
    internalUpdateAnimationsAndSendEvents();
378
    updateAnimationsAndSendEvents();
379
    applyPendingAcceleratedAnimations();
350
    applyPendingAcceleratedAnimations();
351
352
    m_animationResolutionScheduled = false;
353
354
    fprintf(stderr, "In DocumentTimeline::updateAnimationsAndSendEvents(), Events were sent : this = %p, liveCurrentTime = %f\n", this, liveCurrentTime());
355
380
    scheduleNextTick();
356
    scheduleNextTick();
381
}
357
}
382
358
383
void DocumentTimeline::updateAnimationsAndSendEvents()
359
void DocumentTimeline::internalUpdateAnimationsAndSendEvents()
384
{
360
{
385
    m_numberOfAnimationTimelineInvalidationsForTesting++;
361
    m_numberOfAnimationTimelineInvalidationsForTesting++;
386
362
387
    m_isUpdatingAnimations = true;
388
389
    // https://drafts.csswg.org/web-animations/#update-animations-and-send-events
363
    // https://drafts.csswg.org/web-animations/#update-animations-and-send-events
390
364
391
    // 1. Update the current time of all timelines associated with doc passing now as the timestamp.
365
    // 1. Update the current time of all timelines associated with doc passing now as the timestamp.
Lines 448-455 void DocumentTimeline::updateAnimationsAndSendEvents() a/Source/WebCore/animation/DocumentTimeline.cpp_sec10
448
    // removed from the list of completed transitions otherwise.
422
    // removed from the list of completed transitions otherwise.
449
    for (auto& completedTransition : completedTransitions)
423
    for (auto& completedTransition : completedTransitions)
450
        transitionDidComplete(completedTransition);
424
        transitionDidComplete(completedTransition);
451
452
    m_isUpdatingAnimations = false;
453
}
425
}
454
426
455
void DocumentTimeline::transitionDidComplete(RefPtr<CSSTransition> transition)
427
void DocumentTimeline::transitionDidComplete(RefPtr<CSSTransition> transition)
Lines 473-479 void DocumentTimeline::scheduleNextTick() a/Source/WebCore/animation/DocumentTimeline.cpp_sec11
473
445
474
    for (const auto& animation : m_animations) {
446
    for (const auto& animation : m_animations) {
475
        if (!animation->isRunningAccelerated()) {
447
        if (!animation->isRunningAccelerated()) {
476
            scheduleAnimationResolutionIfNeeded();
448
            scheduleAnimationResolution();
477
            return;
449
            return;
478
        }
450
        }
479
    }
451
    }
Lines 483-489 void DocumentTimeline::scheduleNextTick() a/Source/WebCore/animation/DocumentTimeline.cpp_sec12
483
    for (const auto& animation : m_animations) {
455
    for (const auto& animation : m_animations) {
484
        auto animationTimeToNextRequiredTick = animation->timeToNextTick();
456
        auto animationTimeToNextRequiredTick = animation->timeToNextTick();
485
        if (animationTimeToNextRequiredTick < animationInterval()) {
457
        if (animationTimeToNextRequiredTick < animationInterval()) {
486
            scheduleAnimationResolutionIfNeeded();
458
            scheduleAnimationResolution();
487
            return;
459
            return;
488
        }
460
        }
489
        scheduleDelay = std::min(scheduleDelay, animationTimeToNextRequiredTick);
461
        scheduleDelay = std::min(scheduleDelay, animationTimeToNextRequiredTick);
Lines 593-610 void DocumentTimeline::animationAcceleratedRunningStateDidChange(WebAnimation& a a/Source/WebCore/animation/DocumentTimeline.cpp_sec13
593
void DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element& element)
565
void DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element& element)
594
{
566
{
595
    auto animations = animationsForElement(element);
567
    auto animations = animationsForElement(element);
596
    bool runningAnimationsForElementAreAllAccelerated = !animations.isEmpty();
568
569
    if (animations.isEmpty()) {
570
        m_elementsWithRunningAcceleratedAnimations.remove(&element);
571
        return;
572
    }
573
597
    for (const auto& animation : animations) {
574
    for (const auto& animation : animations) {
598
        if (!animation->isRunningAccelerated()) {
575
        if (!animation->isRunningAccelerated()) {
599
            runningAnimationsForElementAreAllAccelerated = false;
576
            m_elementsWithRunningAcceleratedAnimations.remove(&element);
600
            break;
577
            return;
601
        }
578
        }
602
    }
579
    }
603
580
604
    if (runningAnimationsForElementAreAllAccelerated)
581
    m_elementsWithRunningAcceleratedAnimations.add(&element);
605
        m_elementsWithRunningAcceleratedAnimations.add(&element);
606
    else
607
        m_elementsWithRunningAcceleratedAnimations.remove(&element);
608
}
582
}
609
583
610
void DocumentTimeline::applyPendingAcceleratedAnimations()
584
void DocumentTimeline::applyPendingAcceleratedAnimations()
Lines 625-654 void DocumentTimeline::applyPendingAcceleratedAnimations() a/Source/WebCore/animation/DocumentTimeline.cpp_sec14
625
599
626
bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle)
600
bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle)
627
{
601
{
628
    bool hasNonAcceleratedAnimations = false;
602
    bool hasNonAcceleratedAnimationProperty = false;
629
    bool hasPendingAcceleratedAnimations = true;
603
630
    for (const auto& animation : animationsForElement(element)) {
604
    for (const auto& animation : animationsForElement(element)) {
631
        animation->resolve(targetStyle);
605
        animation->resolve(targetStyle);
632
        if (!hasNonAcceleratedAnimations) {
606
633
            if (auto* effect = animation->effect()) {
607
        if (hasNonAcceleratedAnimationProperty)
634
                if (is<KeyframeEffect>(effect)) {
608
            continue;
635
                    auto* keyframeEffect = downcast<KeyframeEffect>(effect);
609
636
                    for (auto cssPropertyId : keyframeEffect->animatedProperties()) {
610
        auto* effect = animation->effect();
637
                        if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {
611
        if (!effect || !is<KeyframeEffect>(effect))
638
                            hasNonAcceleratedAnimations = true;
612
            continue;
639
                            continue;
613
640
                        }
614
        auto* keyframeEffect = downcast<KeyframeEffect>(effect);
641
                        if (!hasPendingAcceleratedAnimations)
615
        for (auto cssPropertyId : keyframeEffect->animatedProperties()) {
642
                            hasPendingAcceleratedAnimations = keyframeEffect->hasPendingAcceleratedAction();
616
            if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {
643
                    }
617
                hasNonAcceleratedAnimationProperty = true;
644
                }
618
                break;
645
            }
619
            }
646
        }
620
        }
647
    }
621
    }
648
622
649
    // If there are no non-accelerated animations and we've encountered at least one pending
623
    return !hasNonAcceleratedAnimationProperty;
650
    // accelerated animation, we should recomposite this element's layer for animation purposes.
651
    return !hasNonAcceleratedAnimations && hasPendingAcceleratedAnimations;
652
}
624
}
653
625
654
bool DocumentTimeline::runningAnimationsForElementAreAllAccelerated(Element& element) const
626
bool DocumentTimeline::runningAnimationsForElementAreAllAccelerated(Element& element) const
- a/Source/WebCore/animation/DocumentTimeline.h -16 / +7 lines
Lines 71-80 public: a/Source/WebCore/animation/DocumentTimeline.h_sec1
71
    void detachFromDocument();
71
    void detachFromDocument();
72
72
73
    void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
73
    void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&);
74
74
    
75
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
75
    void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
76
    void documentAnimationSchedulerDidFire();
77
#endif
78
76
79
    void updateThrottlingState();
77
    void updateThrottlingState();
80
    WEBCORE_EXPORT Seconds animationInterval() const;
78
    WEBCORE_EXPORT Seconds animationInterval() const;
Lines 88-113 public: a/Source/WebCore/animation/DocumentTimeline.h_sec2
88
private:
86
private:
89
    DocumentTimeline(Document&, Seconds);
87
    DocumentTimeline(Document&, Seconds);
90
88
91
    Seconds liveCurrentTime() const;
89
    DOMHighResTimeStamp liveCurrentTime() const;
92
    void cacheCurrentTime(Seconds);
90
    void cacheCurrentTime(DOMHighResTimeStamp);
93
    void scheduleAnimationResolutionIfNeeded();
91
    void maybeClearCachedCurrentTime();
94
    void scheduleInvalidationTaskIfNeeded();
92
    void scheduleInvalidationTaskIfNeeded();
95
    void performInvalidationTask();
93
    void performInvalidationTask();
96
    void animationScheduleTimerFired();
97
    void scheduleAnimationResolution();
94
    void scheduleAnimationResolution();
98
    void unscheduleAnimationResolution();
95
    void unscheduleAnimationResolution();
99
    void updateAnimationsAndSendEvents();
96
    void internalUpdateAnimationsAndSendEvents();
100
    void performEventDispatchTask();
97
    void performEventDispatchTask();
101
    void maybeClearCachedCurrentTime();
102
    void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&);
98
    void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&);
103
    void transitionDidComplete(RefPtr<CSSTransition>);
99
    void transitionDidComplete(RefPtr<CSSTransition>);
104
    void scheduleNextTick();
100
    void scheduleNextTick();
105
101
106
#if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
107
    void animationResolutionTimerFired();
108
    Timer m_animationResolutionTimer;
109
#endif
110
111
    Timer m_tickScheduleTimer;
102
    Timer m_tickScheduleTimer;
112
    GenericTaskQueue<Timer> m_currentTimeClearingTaskQueue;
103
    GenericTaskQueue<Timer> m_currentTimeClearingTaskQueue;
113
    HashSet<RefPtr<WebAnimation>> m_acceleratedAnimationsPendingRunningStateChange;
104
    HashSet<RefPtr<WebAnimation>> m_acceleratedAnimationsPendingRunningStateChange;
Lines 119-125 private: a/Source/WebCore/animation/DocumentTimeline.h_sec3
119
    unsigned m_numberOfAnimationTimelineInvalidationsForTesting { 0 };
110
    unsigned m_numberOfAnimationTimelineInvalidationsForTesting { 0 };
120
    bool m_isSuspended { false };
111
    bool m_isSuspended { false };
121
    bool m_waitingOnVMIdle { false };
112
    bool m_waitingOnVMIdle { false };
122
    bool m_isUpdatingAnimations { false };
113
    bool m_animationResolutionScheduled { false };
123
};
114
};
124
115
125
} // namespace WebCore
116
} // namespace WebCore
- a/Source/WebCore/animation/WebAnimation.cpp +2 lines
Lines 813-818 void WebAnimation::finishNotificationSteps() a/Source/WebCore/animation/WebAnimation.cpp_sec1
813
    //    effect end to an origin-relative time.
813
    //    effect end to an origin-relative time.
814
    //    Otherwise, queue a task to dispatch finishEvent at animation. The task source for this task is the DOM manipulation task source.
814
    //    Otherwise, queue a task to dispatch finishEvent at animation. The task source for this task is the DOM manipulation task source.
815
    enqueueAnimationPlaybackEvent(eventNames().finishEvent, currentTime(), m_timeline ? m_timeline->currentTime() : WTF::nullopt);
815
    enqueueAnimationPlaybackEvent(eventNames().finishEvent, currentTime(), m_timeline ? m_timeline->currentTime() : WTF::nullopt);
816
    
817
    fprintf(stderr, "In WebAnimation::finishNotificationSteps(), finish event was enqueued : this = %p\n", this);
816
}
818
}
817
819
818
ExceptionOr<void> WebAnimation::play()
820
ExceptionOr<void> WebAnimation::play()
- a/Source/WebCore/dom/Document.cpp -40 / +13 lines
Lines 57-63 a/Source/WebCore/dom/Document.cpp_sec1
57
#include "DOMWindow.h"
57
#include "DOMWindow.h"
58
#include "DateComponents.h"
58
#include "DateComponents.h"
59
#include "DebugPageOverlays.h"
59
#include "DebugPageOverlays.h"
60
#include "DocumentAnimationScheduler.h"
61
#include "DocumentLoader.h"
60
#include "DocumentLoader.h"
62
#include "DocumentMarkerController.h"
61
#include "DocumentMarkerController.h"
63
#include "DocumentSharedObjectPool.h"
62
#include "DocumentSharedObjectPool.h"
Lines 1957-1967 void Document::resolveStyle(ResolveStyleType type) a/Source/WebCore/dom/Document.cpp_sec2
1957
            frameView.layoutContext().scheduleLayout();
1956
            frameView.layoutContext().scheduleLayout();
1958
1957
1959
        // Usually this is handled by post-layout.
1958
        // Usually this is handled by post-layout.
1960
        if (!frameView.needsLayout()) {
1959
        if (!frameView.needsLayout())
1961
            frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange();
1960
            frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange();
1962
            if (m_needsForcedIntersectionObservationUpdate)
1963
                page()->scheduleForcedIntersectionObservationUpdate(*this);
1964
        }
1965
1961
1966
        // As a result of the style recalculation, the currently hovered element might have been
1962
        // As a result of the style recalculation, the currently hovered element might have been
1967
        // detached (for example, by setting display:none in the :hover style), schedule another mouseMove event
1963
        // detached (for example, by setting display:none in the :hover style), schedule another mouseMove event
Lines 2556-2568 void Document::prepareForDestruction() a/Source/WebCore/dom/Document.cpp_sec3
2556
        m_timeline = nullptr;
2552
        m_timeline = nullptr;
2557
    }
2553
    }
2558
2554
2559
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
2560
    if (m_animationScheduler) {
2561
        m_animationScheduler->detachFromDocument();
2562
        m_animationScheduler = nullptr;
2563
    }
2564
#endif
2565
2566
#if ENABLE(CSS_PAINTING_API)
2555
#if ENABLE(CSS_PAINTING_API)
2567
    for (auto& scope : m_paintWorkletGlobalScopes.values())
2556
    for (auto& scope : m_paintWorkletGlobalScopes.values())
2568
        scope->prepareForDestruction();
2557
        scope->prepareForDestruction();
Lines 6256-6268 void Document::resumeScriptedAnimationControllerCallbacks() a/Source/WebCore/dom/Document.cpp_sec4
6256
        m_scriptedAnimationController->resume();
6245
        m_scriptedAnimationController->resume();
6257
}
6246
}
6258
6247
6259
void Document::windowScreenDidChange(PlatformDisplayID displayID)
6248
void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp)
6260
{
6249
{
6261
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
6250
    if (m_timeline)
6262
    if (m_animationScheduler)
6251
        m_timeline->updateAnimationsAndSendEvents(timestamp);
6263
        m_animationScheduler->windowScreenDidChange(displayID);
6252
}
6264
#endif
6253
6254
void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
6255
{
6256
    if (m_scriptedAnimationController)
6257
        m_scriptedAnimationController->serviceRequestAnimationFrameCallbacks(timestamp);
6258
}
6265
6259
6260
void Document::windowScreenDidChange(PlatformDisplayID displayID)
6261
{
6266
    if (RenderView* view = renderView()) {
6262
    if (RenderView* view = renderView()) {
6267
        if (view->usesCompositing())
6263
        if (view->usesCompositing())
6268
            view->compositor().windowScreenDidChange(displayID);
6264
            view->compositor().windowScreenDidChange(displayID);
Lines 7924-7931 void Document::updateIntersectionObservations() a/Source/WebCore/dom/Document.cpp_sec5
7924
    if (needsLayout || hasPendingStyleRecalc())
7920
    if (needsLayout || hasPendingStyleRecalc())
7925
        return;
7921
        return;
7926
7922
7927
    m_needsForcedIntersectionObservationUpdate = false;
7928
7929
    for (const auto& observer : m_intersectionObservers) {
7923
    for (const auto& observer : m_intersectionObservers) {
7930
        bool needNotify = false;
7924
        bool needNotify = false;
7931
        DOMHighResTimeStamp timestamp;
7925
        DOMHighResTimeStamp timestamp;
Lines 8002-8018 void Document::updateIntersectionObservations() a/Source/WebCore/dom/Document.cpp_sec6
8002
        m_intersectionObserversNotifyTimer.startOneShot(0_s);
7996
        m_intersectionObserversNotifyTimer.startOneShot(0_s);
8003
}
7997
}
8004
7998
8005
void Document::scheduleForcedIntersectionObservationUpdate()
8006
{
8007
    ASSERT(!m_intersectionObservers.isEmpty());
8008
    if (m_needsForcedIntersectionObservationUpdate)
8009
        return;
8010
8011
    m_needsForcedIntersectionObservationUpdate = true;
8012
    if (auto* page = this->page())
8013
        page->scheduleForcedIntersectionObservationUpdate(*this);
8014
}
8015
8016
void Document::notifyIntersectionObserversTimerFired()
7999
void Document::notifyIntersectionObserversTimerFired()
8017
{
8000
{
8018
    for (const auto& observer : m_intersectionObserversWithPendingNotifications) {
8001
    for (const auto& observer : m_intersectionObserversWithPendingNotifications) {
Lines 8446-8461 void Document::setConsoleMessageListener(RefPtr<StringCallback>&& listener) a/Source/WebCore/dom/Document.cpp_sec7
8446
    m_consoleMessageListener = listener;
8429
    m_consoleMessageListener = listener;
8447
}
8430
}
8448
8431
8449
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
8450
DocumentAnimationScheduler& Document::animationScheduler()
8451
{
8452
    if (!m_animationScheduler)
8453
        m_animationScheduler = DocumentAnimationScheduler::create(*this, page() ? page()->chrome().displayID() : 0);
8454
8455
    return *m_animationScheduler;
8456
}
8457
#endif
8458
8459
DocumentTimeline& Document::timeline()
8432
DocumentTimeline& Document::timeline()
8460
{
8433
{
8461
    if (!m_timeline)
8434
    if (!m_timeline)
- a/Source/WebCore/dom/Document.h -14 / +4 lines
Lines 106-112 class DOMWrapperWorld; a/Source/WebCore/dom/Document.h_sec1
106
class Database;
106
class Database;
107
class DatabaseThread;
107
class DatabaseThread;
108
class DeferredPromise;
108
class DeferredPromise;
109
class DocumentAnimationScheduler;
110
class DocumentFragment;
109
class DocumentFragment;
111
class DocumentLoader;
110
class DocumentLoader;
112
class DocumentMarkerController;
111
class DocumentMarkerController;
Lines 1042-1048 public: a/Source/WebCore/dom/Document.h_sec2
1042
    ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
1041
    ScriptedAnimationController* scriptedAnimationController() { return m_scriptedAnimationController.get(); }
1043
    void suspendScriptedAnimationControllerCallbacks();
1042
    void suspendScriptedAnimationControllerCallbacks();
1044
    void resumeScriptedAnimationControllerCallbacks();
1043
    void resumeScriptedAnimationControllerCallbacks();
1045
    
1044
1045
    void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp);
1046
    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
1047
1046
    void windowScreenDidChange(PlatformDisplayID);
1048
    void windowScreenDidChange(PlatformDisplayID);
1047
1049
1048
    void finishedParsing();
1050
    void finishedParsing();
Lines 1395-1401 public: a/Source/WebCore/dom/Document.h_sec3
1395
    void addIntersectionObserver(IntersectionObserver&);
1397
    void addIntersectionObserver(IntersectionObserver&);
1396
    void removeIntersectionObserver(IntersectionObserver&);
1398
    void removeIntersectionObserver(IntersectionObserver&);
1397
    unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
1399
    unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); }
1398
    void scheduleForcedIntersectionObservationUpdate();
1399
    void updateIntersectionObservations();
1400
    void updateIntersectionObservations();
1400
#endif
1401
#endif
1401
1402
Lines 1468-1477 public: a/Source/WebCore/dom/Document.h_sec4
1468
1469
1469
    WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
1470
    WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing.
1470
1471
1471
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
1472
    DocumentAnimationScheduler& animationScheduler();
1473
#endif
1474
1475
    WEBCORE_EXPORT DocumentTimeline& timeline();
1472
    WEBCORE_EXPORT DocumentTimeline& timeline();
1476
    DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
1473
    DocumentTimeline* existingTimeline() const { return m_timeline.get(); }
1477
    Vector<RefPtr<WebAnimation>> getAnimations();
1474
    Vector<RefPtr<WebAnimation>> getAnimations();
Lines 2026-2035 private: a/Source/WebCore/dom/Document.h_sec5
2026
    bool m_isTelephoneNumberParsingAllowed { true };
2023
    bool m_isTelephoneNumberParsingAllowed { true };
2027
#endif
2024
#endif
2028
2025
2029
#if ENABLE(INTERSECTION_OBSERVER)
2030
    bool m_needsForcedIntersectionObservationUpdate { false };
2031
#endif
2032
2033
#if ENABLE(MEDIA_STREAM)
2026
#if ENABLE(MEDIA_STREAM)
2034
    HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
2027
    HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements;
2035
    String m_idHashSalt;
2028
    String m_idHashSalt;
Lines 2049-2057 private: a/Source/WebCore/dom/Document.h_sec6
2049
2042
2050
    bool m_grantStorageAccessOverride { false };
2043
    bool m_grantStorageAccessOverride { false };
2051
2044
2052
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
2053
    RefPtr<DocumentAnimationScheduler> m_animationScheduler;
2054
#endif
2055
    RefPtr<DocumentTimeline> m_timeline;
2045
    RefPtr<DocumentTimeline> m_timeline;
2056
    DocumentIdentifier m_identifier;
2046
    DocumentIdentifier m_identifier;
2057
2047
- a/Source/WebCore/dom/ScriptedAnimationController.cpp -29 / +19 lines
Lines 30-36 a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec1
30
#include "ChromeClient.h"
30
#include "ChromeClient.h"
31
#include "DOMWindow.h"
31
#include "DOMWindow.h"
32
#include "Document.h"
32
#include "Document.h"
33
#include "DocumentAnimationScheduler.h"
34
#include "DocumentLoader.h"
33
#include "DocumentLoader.h"
35
#include "Frame.h"
34
#include "Frame.h"
36
#include "FrameView.h"
35
#include "FrameView.h"
Lines 189-195 void ScriptedAnimationController::cancelCallback(CallbackId id) a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec2
189
    }
188
    }
190
}
189
}
191
190
192
void ScriptedAnimationController::serviceScriptedAnimations(double timestamp)
191
void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp)
193
{
192
{
194
    if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
193
    if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled())
195
        return;
194
        return;
Lines 197-204 void ScriptedAnimationController::serviceScriptedAnimations(double timestamp) a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec3
197
    TraceScope tracingScope(RAFCallbackStart, RAFCallbackEnd);
196
    TraceScope tracingScope(RAFCallbackStart, RAFCallbackEnd);
198
197
199
    // We round this to the nearest microsecond so that we can return a time that matches what is returned by document.timeline.currentTime.
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
    double highResNowMs = std::round(1000 * timestamp);
199
    DOMHighResTimeStamp highResNowMs = std::round(1000 * timestamp);
201
    double legacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds());
200
    DOMHighResTimeStamp legacyHighResNowMs = 1000 * (timestamp + m_document->loader()->timing().referenceWallTime().secondsSinceEpoch().seconds());
202
201
203
    // First, generate a list of callbacks to consider.  Callbacks registered from this point
202
    // First, generate a list of callbacks to consider.  Callbacks registered from this point
204
    // on are considered only for the "next" frame, not this one.
203
    // on are considered only for the "next" frame, not this one.
Lines 210-233 void ScriptedAnimationController::serviceScriptedAnimations(double timestamp) a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec4
210
    Ref<Document> protectedDocument(*m_document);
209
    Ref<Document> protectedDocument(*m_document);
211
210
212
    for (auto& callback : callbacks) {
211
    for (auto& callback : callbacks) {
213
        if (!callback->m_firedOrCancelled) {
212
        if (callback->m_firedOrCancelled)
214
            callback->m_firedOrCancelled = true;
213
            continue;
215
            InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);
214
        callback->m_firedOrCancelled = true;
216
            if (callback->m_useLegacyTimeBase)
215
        InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);
217
                callback->handleEvent(legacyHighResNowMs);
216
        if (callback->m_useLegacyTimeBase)
218
            else
217
            callback->handleEvent(legacyHighResNowMs);
219
                callback->handleEvent(highResNowMs);
218
        else
220
            InspectorInstrumentation::didFireAnimationFrame(cookie);
219
            callback->handleEvent(highResNowMs);
221
        }
220
        InspectorInstrumentation::didFireAnimationFrame(cookie);
222
    }
221
    }
223
222
224
    // Remove any callbacks we fired from the list of pending callbacks.
223
    // Remove any callbacks we fired from the list of pending callbacks.
225
    for (size_t i = 0; i < m_callbacks.size();) {
224
    m_callbacks.removeAllMatching([](auto& callback) {
226
        if (m_callbacks[i]->m_firedOrCancelled)
225
        return callback->m_firedOrCancelled;
227
            m_callbacks.remove(i);
226
    });
228
        else
229
            ++i;
230
    }
231
227
232
    if (m_callbacks.size())
228
    if (m_callbacks.size())
233
        scheduleAnimation();
229
        scheduleAnimation();
Lines 262-269 void ScriptedAnimationController::scheduleAnimation() a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec5
262
258
263
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
259
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
264
    if (!m_isUsingTimer && !isThrottled()) {
260
    if (!m_isUsingTimer && !isThrottled()) {
265
        if (m_document->animationScheduler().scheduleScriptedAnimationResolution())
261
        if (auto* page = this->page()) {
262
            page->renderingUpdateScheduler().scheduleRenderingUpdate();
266
            return;
263
            return;
264
        }
267
265
268
        m_isUsingTimer = true;
266
        m_isUsingTimer = true;
269
    }
267
    }
Lines 292-306 void ScriptedAnimationController::scheduleAnimation() a/Source/WebCore/dom/ScriptedAnimationController.cpp_sec6
292
void ScriptedAnimationController::animationTimerFired()
290
void ScriptedAnimationController::animationTimerFired()
293
{
291
{
294
    m_lastAnimationFrameTimestamp = m_document->domWindow()->nowTimestamp();
292
    m_lastAnimationFrameTimestamp = m_document->domWindow()->nowTimestamp();
295
    serviceScriptedAnimations(m_lastAnimationFrameTimestamp);
293
    serviceRequestAnimationFrameCallbacks(m_lastAnimationFrameTimestamp);
296
}
294
}
297
295
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
}
296
}
- a/Source/WebCore/dom/ScriptedAnimationController.h -5 / +1 lines
Lines 52-58 public: a/Source/WebCore/dom/ScriptedAnimationController.h_sec1
52
52
53
    CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&);
53
    CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&);
54
    void cancelCallback(CallbackId);
54
    void cancelCallback(CallbackId);
55
    void serviceScriptedAnimations(double timestamp);
55
    void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp);
56
56
57
    void suspend();
57
    void suspend();
58
    void resume();
58
    void resume();
Lines 69-78 public: a/Source/WebCore/dom/ScriptedAnimationController.h_sec2
69
    WEBCORE_EXPORT bool isThrottled() const;
69
    WEBCORE_EXPORT bool isThrottled() const;
70
    WEBCORE_EXPORT Seconds interval() const;
70
    WEBCORE_EXPORT Seconds interval() const;
71
71
72
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
73
    void documentAnimationSchedulerDidFire();
74
#endif
75
76
private:
72
private:
77
    ScriptedAnimationController(Document&);
73
    ScriptedAnimationController(Document&);
78
74
- a/Source/WebCore/page/FrameView.cpp -15 lines
Lines 1962-1982 void FrameView::viewportContentsChanged() a/Source/WebCore/page/FrameView.cpp_sec1
1962
        if (auto* renderView = frameView.frame().contentRenderer())
1962
        if (auto* renderView = frameView.frame().contentRenderer())
1963
            renderView->updateVisibleViewportRect(visibleRect);
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
#endif
1980
}
1965
}
1981
1966
1982
IntRect FrameView::unobscuredContentRectExpandedByContentInsets() const
1967
IntRect FrameView::unobscuredContentRectExpandedByContentInsets() const
- a/Source/WebCore/page/IntersectionObserver.cpp -1 lines
Lines 157-163 void IntersectionObserver::observe(Element& target) a/Source/WebCore/page/IntersectionObserver.cpp_sec1
157
    auto* document = trackingDocument();
157
    auto* document = trackingDocument();
158
    if (!hadObservationTargets)
158
    if (!hadObservationTargets)
159
        document->addIntersectionObserver(*this);
159
        document->addIntersectionObserver(*this);
160
    document->scheduleForcedIntersectionObservationUpdate();
161
}
160
}
162
161
163
void IntersectionObserver::unobserve(Element& target)
162
void IntersectionObserver::unobserve(Element& target)
- a/Source/WebCore/page/Page.cpp -28 / +37 lines
Lines 257-265 Page::Page(PageConfiguration&& pageConfiguration) a/Source/WebCore/page/Page.cpp_sec1
257
    , m_storageNamespaceProvider(*WTFMove(pageConfiguration.storageNamespaceProvider))
257
    , m_storageNamespaceProvider(*WTFMove(pageConfiguration.storageNamespaceProvider))
258
    , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider))
258
    , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider))
259
    , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore))
259
    , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore))
260
#if ENABLE(INTERSECTION_OBSERVER)
261
    , m_intersectionObservationUpdateTimer(*this, &Page::updateIntersectionObservations)
262
#endif
263
    , m_sessionID(PAL::SessionID::defaultSessionID())
260
    , m_sessionID(PAL::SessionID::defaultSessionID())
264
#if ENABLE(VIDEO)
261
#if ENABLE(VIDEO)
265
    , m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired)
262
    , m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired)
Lines 1118-1130 void Page::didFinishLoad() a/Source/WebCore/page/Page.cpp_sec2
1118
        m_performanceMonitor->didFinishLoad();
1115
        m_performanceMonitor->didFinishLoad();
1119
}
1116
}
1120
1117
1121
void Page::willDisplayPage()
1122
{
1123
#if ENABLE(INTERSECTION_OBSERVER)
1124
    updateIntersectionObservations();
1125
#endif
1126
}
1127
1128
bool Page::isOnlyNonUtilityPage() const
1118
bool Page::isOnlyNonUtilityPage() const
1129
{
1119
{
1130
    return !isUtilityPage() && nonUtilityPageCount == 1;
1120
    return !isUtilityPage() && nonUtilityPageCount == 1;
Lines 1266-1296 void Page::removeActivityStateChangeObserver(ActivityStateChangeObserver& observ a/Source/WebCore/page/Page.cpp_sec3
1266
    m_activityStateChangeObservers.remove(&observer);
1256
    m_activityStateChangeObservers.remove(&observer);
1267
}
1257
}
1268
1258
1269
#if ENABLE(INTERSECTION_OBSERVER)
1259
void Page::layoutIfNeeded()
1270
void Page::addDocumentNeedingIntersectionObservationUpdate(Document& document)
1271
{
1260
{
1272
    if (m_documentsNeedingIntersectionObservationUpdate.find(&document) == notFound)
1261
    if (FrameView* view = m_mainFrame->view())
1273
        m_documentsNeedingIntersectionObservationUpdate.append(makeWeakPtr(document));
1262
        view->updateLayoutAndStyleIfNeededRecursive();
1274
}
1263
}
1275
1264
1276
void Page::updateIntersectionObservations()
1265
void Page::renderingUpdate()
1277
{
1266
{
1278
    m_intersectionObservationUpdateTimer.stop();
1267
    // This function is not reentrant, e.g. a rAF callback may force repaint.
1279
    for (const auto& document : m_documentsNeedingIntersectionObservationUpdate) {
1268
    if (m_inRenderingUpdate) {
1280
        if (document)
1269
        layoutIfNeeded();
1281
            document->updateIntersectionObservations();
1270
        return;
1282
    }
1271
    }
1283
    m_documentsNeedingIntersectionObservationUpdate.clear();
1284
}
1285
1272
1286
void Page::scheduleForcedIntersectionObservationUpdate(Document& document)
1273
    SetForScope<bool> change(m_inRenderingUpdate, true);
1287
{
1274
1288
    addDocumentNeedingIntersectionObservationUpdate(document);
1275
    Vector<RefPtr<Document>> documents;
1289
    if (m_intersectionObservationUpdateTimer.isActive())
1276
1290
        return;
1277
    // The requestAnimationFrame callbacks may change the frame hierarchy of the page
1291
    m_intersectionObservationUpdateTimer.startOneShot(0_s);
1278
    forEachDocument([&documents] (Document& document) {
1292
}
1279
        documents.append(&document);
1280
    });
1281
1282
    for (auto& document : documents) {
1283
        DOMHighResTimeStamp timestamp = document->domWindow()->nowTimestamp();
1284
        document->updateAnimationsAndSendEvents(timestamp);
1285
        document->serviceRequestAnimationFrameCallbacks(timestamp);
1286
    }
1287
1288
    layoutIfNeeded();
1289
1290
    for (auto& document : documents) {
1291
#if ENABLE(INTERSECTION_OBSERVER)
1292
        document->updateIntersectionObservations();
1293
#endif
1293
#endif
1294
    }
1295
}
1294
1296
1295
void Page::suspendScriptedAnimations()
1297
void Page::suspendScriptedAnimations()
1296
{
1298
{
Lines 2831-2836 void Page::didChangeMainDocument() a/Source/WebCore/page/Page.cpp_sec4
2831
#endif
2833
#endif
2832
}
2834
}
2833
2835
2836
RenderingUpdateScheduler& Page::renderingUpdateScheduler()
2837
{
2838
    if (!m_renderingUpdateScheduler)
2839
        m_renderingUpdateScheduler = RenderingUpdateScheduler::create(*this);
2840
    return *m_renderingUpdateScheduler;
2841
}
2842
2834
void Page::forEachDocument(const Function<void(Document&)>& functor)
2843
void Page::forEachDocument(const Function<void(Document&)>& functor)
2835
{
2844
{
2836
    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
2845
    for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
- a/Source/WebCore/page/Page.h -15 / +8 lines
Lines 33-38 a/Source/WebCore/page/Page.h_sec1
33
#include "RTCController.h"
33
#include "RTCController.h"
34
#include "Region.h"
34
#include "Region.h"
35
#include "RegistrableDomain.h"
35
#include "RegistrableDomain.h"
36
#include "RenderingUpdateScheduler.h"
36
#include "ScrollTypes.h"
37
#include "ScrollTypes.h"
37
#include "Supplementable.h"
38
#include "Supplementable.h"
38
#include "Timer.h"
39
#include "Timer.h"
Lines 268-273 public: a/Source/WebCore/page/Page.h_sec2
268
269
269
    PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); }
270
    PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); }
270
271
272
    RenderingUpdateScheduler& renderingUpdateScheduler();
273
271
    ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); }
274
    ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); }
272
    void updateValidationBubbleStateIfNeeded();
275
    void updateValidationBubbleStateIfNeeded();
273
276
Lines 340-347 public: a/Source/WebCore/page/Page.h_sec3
340
    void didStartProvisionalLoad();
343
    void didStartProvisionalLoad();
341
    void didFinishLoad(); // Called when the load has been committed in the main frame.
344
    void didFinishLoad(); // Called when the load has been committed in the main frame.
342
345
343
    WEBCORE_EXPORT void willDisplayPage();
344
345
    // The view scale factor is multiplied into the page scale factor by all
346
    // The view scale factor is multiplied into the page scale factor by all
346
    // callers of setPageScaleFactor.
347
    // callers of setPageScaleFactor.
347
    WEBCORE_EXPORT void setViewScaleFactor(float);
348
    WEBCORE_EXPORT void setViewScaleFactor(float);
Lines 469-479 public: a/Source/WebCore/page/Page.h_sec4
469
    WEBCORE_EXPORT void addActivityStateChangeObserver(ActivityStateChangeObserver&);
470
    WEBCORE_EXPORT void addActivityStateChangeObserver(ActivityStateChangeObserver&);
470
    WEBCORE_EXPORT void removeActivityStateChangeObserver(ActivityStateChangeObserver&);
471
    WEBCORE_EXPORT void removeActivityStateChangeObserver(ActivityStateChangeObserver&);
471
472
472
#if ENABLE(INTERSECTION_OBSERVER)
473
    WEBCORE_EXPORT void layoutIfNeeded();
473
    void addDocumentNeedingIntersectionObservationUpdate(Document&);
474
    WEBCORE_EXPORT void renderingUpdate();
474
    void scheduleForcedIntersectionObservationUpdate(Document&);
475
    void updateIntersectionObservations();
476
#endif
477
475
478
    WEBCORE_EXPORT void suspendScriptedAnimations();
476
    WEBCORE_EXPORT void suspendScriptedAnimations();
479
    WEBCORE_EXPORT void resumeScriptedAnimations();
477
    WEBCORE_EXPORT void resumeScriptedAnimations();
Lines 869-874 private: a/Source/WebCore/page/Page.h_sec5
869
    int m_headerHeight { 0 };
867
    int m_headerHeight { 0 };
870
    int m_footerHeight { 0 };
868
    int m_footerHeight { 0 };
871
869
870
    std::unique_ptr<RenderingUpdateScheduler> m_renderingUpdateScheduler;
871
872
    HashSet<RenderObject*> m_relevantUnpaintedRenderObjects;
872
    HashSet<RenderObject*> m_relevantUnpaintedRenderObjects;
873
    Region m_topRelevantPaintedRegion;
873
    Region m_topRelevantPaintedRegion;
874
    Region m_bottomRelevantPaintedRegion;
874
    Region m_bottomRelevantPaintedRegion;
Lines 909-922 private: a/Source/WebCore/page/Page.h_sec6
909
909
910
    HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers;
910
    HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers;
911
911
912
#if ENABLE(INTERSECTION_OBSERVER)
913
    Vector<WeakPtr<Document>> m_documentsNeedingIntersectionObservationUpdate;
914
915
    // FIXME: Schedule intersection observation updates in a way that fits into the HTML
916
    // EventLoop. See https://bugs.webkit.org/show_bug.cgi?id=160711.
917
    Timer m_intersectionObservationUpdateTimer;
918
#endif
919
920
#if ENABLE(RESOURCE_USAGE)
912
#if ENABLE(RESOURCE_USAGE)
921
    std::unique_ptr<ResourceUsageOverlay> m_resourceUsageOverlay;
913
    std::unique_ptr<ResourceUsageOverlay> m_resourceUsageOverlay;
922
#endif
914
#endif
Lines 977-982 private: a/Source/WebCore/page/Page.h_sec7
977
    bool m_shouldEnableICECandidateFilteringByDefault { true };
969
    bool m_shouldEnableICECandidateFilteringByDefault { true };
978
    bool m_mediaPlaybackIsSuspended { false };
970
    bool m_mediaPlaybackIsSuspended { false };
979
    bool m_mediaBufferingIsSuspended { false };
971
    bool m_mediaBufferingIsSuspended { false };
972
    bool m_inRenderingUpdate { false };
980
};
973
};
981
974
982
inline PageGroup& Page::group()
975
inline PageGroup& Page::group()
- a/Source/WebCore/page/PageOverlayController.cpp -2 / +2 lines
Lines 318-324 void PageOverlayController::didChangeDeviceScaleFactor() a/Source/WebCore/page/PageOverlayController.cpp_sec1
318
318
319
void PageOverlayController::didChangeViewExposedRect()
319
void PageOverlayController::didChangeViewExposedRect()
320
{
320
{
321
    m_page.chrome().client().scheduleCompositingLayerFlush();
321
    m_page.renderingUpdateScheduler().scheduleRenderingUpdate();
322
}
322
}
323
323
324
void PageOverlayController::didScrollFrame(Frame& frame)
324
void PageOverlayController::didScrollFrame(Frame& frame)
Lines 412-418 float PageOverlayController::deviceScaleFactor() const a/Source/WebCore/page/PageOverlayController.cpp_sec2
412
412
413
void PageOverlayController::notifyFlushRequired(const WebCore::GraphicsLayer*)
413
void PageOverlayController::notifyFlushRequired(const WebCore::GraphicsLayer*)
414
{
414
{
415
    m_page.chrome().client().scheduleCompositingLayerFlush();
415
    m_page.renderingUpdateScheduler().scheduleRenderingUpdate();
416
}
416
}
417
417
418
void PageOverlayController::didChangeOverlayFrame(PageOverlay& overlay)
418
void PageOverlayController::didChangeOverlayFrame(PageOverlay& overlay)
- a/Source/WebCore/page/RenderingUpdateScheduler.cpp +96 lines
Line 0 a/Source/WebCore/page/RenderingUpdateScheduler.cpp_sec1
1
/*
2
 * Copyright (C) 2019 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#include "config.h"
27
#include "RenderingUpdateScheduler.h"
28
29
#include "Chrome.h"
30
#include "ChromeClient.h"
31
#include "DisplayRefreshMonitorManager.h"
32
#include "Page.h"
33
#include <wtf/SystemTracing.h>
34
35
namespace WebCore {
36
37
RenderingUpdateScheduler::RenderingUpdateScheduler(Page& page)
38
    : m_page(page)
39
{
40
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
41
    windowScreenDidChange(page.chrome().displayID());
42
#endif
43
}
44
45
void RenderingUpdateScheduler::scheduleRenderingUpdate()
46
{
47
    if (m_scheduled)
48
        return;
49
50
    tracePoint(ScheduleRenderingUpdate);
51
52
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
53
        if (!DisplayRefreshMonitorManager::sharedManager().scheduleAnimation(*this))
54
#endif
55
            startTimer(Seconds(1.0 / 60));
56
57
    m_scheduled = true;
58
}
59
60
void RenderingUpdateScheduler::startTimer(Seconds delay)
61
{
62
    ASSERT(!m_refreshTimer);
63
    m_refreshTimer = std::make_unique<Timer>(*this, &RenderingUpdateScheduler::displayRefreshFired);
64
    m_refreshTimer->startOneShot(delay);
65
}
66
67
void RenderingUpdateScheduler::clearTimer()
68
{
69
    m_refreshTimer = nullptr;
70
}
71
72
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
73
void RenderingUpdateScheduler::windowScreenDidChange(PlatformDisplayID displayID)
74
{
75
    DisplayRefreshMonitorManager::sharedManager().windowScreenDidChange(displayID, *this);
76
}
77
78
RefPtr<DisplayRefreshMonitor> RenderingUpdateScheduler::createDisplayRefreshMonitor(PlatformDisplayID displayID) const
79
{
80
    if (auto monitor = m_page.chrome().client().createDisplayRefreshMonitor(displayID))
81
        return monitor;
82
83
    return DisplayRefreshMonitor::createDefaultDisplayRefreshMonitor(displayID);
84
}
85
#endif
86
87
void RenderingUpdateScheduler::displayRefreshFired()
88
{
89
    tracePoint(TriggerRenderingUpdate);
90
91
    m_page.chrome().client().scheduleCompositingLayerFlush();
92
    clearTimer();
93
    m_scheduled = false;
94
}
95
96
}
- a/Source/WebCore/page/RenderingUpdateScheduler.h +71 lines
Line 0 a/Source/WebCore/page/RenderingUpdateScheduler.h_sec1
1
/*
2
 * Copyright (C) 2019 Apple Inc. All rights reserved.
3
 *
4
 * Redistribution and use in source and binary forms, with or without
5
 * modification, are permitted provided that the following conditions
6
 * are met:
7
 * 1. Redistributions of source code must retain the above copyright
8
 *    notice, this list of conditions and the following disclaimer.
9
 * 2. Redistributions in binary form must reproduce the above copyright
10
 *    notice, this list of conditions and the following disclaimer in the
11
 *    documentation and/or other materials provided with the distribution.
12
 *
13
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24
 */
25
26
#pragma once
27
28
#include "DisplayRefreshMonitorClient.h"
29
#include <wtf/Seconds.h>
30
31
namespace WebCore {
32
33
class Page;
34
class Timer;
35
36
class RenderingUpdateScheduler
37
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
38
    : public DisplayRefreshMonitorClient
39
#endif
40
{
41
    WTF_MAKE_FAST_ALLOCATED;
42
public:
43
    static std::unique_ptr<RenderingUpdateScheduler> create(Page& page)
44
    {
45
        return std::make_unique<RenderingUpdateScheduler>(page);
46
    }
47
48
    RenderingUpdateScheduler(Page&);
49
    void scheduleRenderingUpdate();
50
51
#if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)
52
    void windowScreenDidChange(PlatformDisplayID);
53
#endif
54
55
private:
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
62
63
    void startTimer(Seconds);
64
    void clearTimer();
65
66
    Page& m_page;
67
    std::unique_ptr<Timer> m_refreshTimer;
68
    bool m_scheduled { false };
69
};
70
71
}
- a/Source/WebCore/page/ResourceUsageData.h +2 lines
Lines 30-35 a/Source/WebCore/page/ResourceUsageData.h_sec1
30
#include <array>
30
#include <array>
31
#include <wtf/MonotonicTime.h>
31
#include <wtf/MonotonicTime.h>
32
#include <wtf/Optional.h>
32
#include <wtf/Optional.h>
33
#include <wtf/Vector.h>
34
#include <wtf/text/WTFString.h>
33
35
34
namespace WebCore {
36
namespace WebCore {
35
37
- a/Source/WebCore/page/ios/ContentChangeObserver.h +4 lines
Lines 27-37 a/Source/WebCore/page/ios/ContentChangeObserver.h_sec1
27
27
28
#if PLATFORM(IOS_FAMILY)
28
#if PLATFORM(IOS_FAMILY)
29
29
30
#include "RenderStyleConstants.h"
30
#include "WKContentObservation.h"
31
#include "WKContentObservation.h"
32
#include <wtf/HashSet.h>
33
#include <wtf/Seconds.h>
31
34
32
namespace WebCore {
35
namespace WebCore {
33
36
34
class DOMTimer;
37
class DOMTimer;
38
class Element;
35
class Page;
39
class Page;
36
40
37
class ContentChangeObserver {
41
class ContentChangeObserver {
- a/Source/WebCore/page/mac/ServicesOverlayController.mm -1 / +1 lines
Lines 121-127 void ServicesOverlayController::Highlight::notifyFlushRequired(const GraphicsLay a/Source/WebCore/page/mac/ServicesOverlayController.mm_sec1
121
    if (!m_controller)
121
    if (!m_controller)
122
        return;
122
        return;
123
123
124
    m_controller->page().chrome().client().scheduleCompositingLayerFlush();
124
    m_controller->page().renderingUpdateScheduler().scheduleRenderingUpdate();
125
}
125
}
126
126
127
void ServicesOverlayController::Highlight::paintContents(const GraphicsLayer*, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect&, GraphicsLayerPaintBehavior)
127
void ServicesOverlayController::Highlight::paintContents(const GraphicsLayer*, GraphicsContext& graphicsContext, GraphicsLayerPaintingPhase, const FloatRect&, GraphicsLayerPaintBehavior)
- a/Source/WebCore/rendering/RenderLayerCompositor.cpp -1 / +1 lines
Lines 430-436 void RenderLayerCompositor::notifyFlushRequired(const GraphicsLayer* layer) a/Source/WebCore/rendering/RenderLayerCompositor.cpp_sec1
430
void RenderLayerCompositor::scheduleLayerFlushNow()
430
void RenderLayerCompositor::scheduleLayerFlushNow()
431
{
431
{
432
    m_hasPendingLayerFlush = false;
432
    m_hasPendingLayerFlush = false;
433
    page().chrome().client().scheduleCompositingLayerFlush();
433
    page().renderingUpdateScheduler().scheduleRenderingUpdate();
434
}
434
}
435
435
436
void RenderLayerCompositor::scheduleLayerFlush(bool canThrottle)
436
void RenderLayerCompositor::scheduleLayerFlush(bool canThrottle)
- a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp -2 / +1 lines
Lines 227-236 void AcceleratedDrawingArea::updateBackingStoreState(uint64_t stateID, bool resp a/Source/WebKit/WebProcess/WebPage/AcceleratedDrawingArea.cpp_sec1
227
227
228
        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
228
        m_webPage.setDeviceScaleFactor(deviceScaleFactor);
229
        m_webPage.setSize(size);
229
        m_webPage.setSize(size);
230
        m_webPage.layoutIfNeeded();
230
        m_webPage.renderingUpdate();
231
        m_webPage.flushPendingEditorStateUpdate();
231
        m_webPage.flushPendingEditorStateUpdate();
232
        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
232
        m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset);
233
        m_webPage.willDisplayPage();
234
233
235
        if (m_layerTreeHost)
234
        if (m_layerTreeHost)
236
            m_layerTreeHost->sizeDidChange(m_webPage.size());
235
            m_layerTreeHost->sizeDidChange(m_webPage.size());
- a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp -1 / +1 lines
Lines 143-150 void LayerTreeHost::layerFlushTimerFired() a/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp_sec1
143
        return;
143
        return;
144
144
145
    m_coordinator.syncDisplayState();
145
    m_coordinator.syncDisplayState();
146
    m_webPage.renderingUpdate();
146
    m_webPage.flushPendingEditorStateUpdate();
147
    m_webPage.flushPendingEditorStateUpdate();
147
    m_webPage.willDisplayPage();
148
148
149
    if (!m_isValid || !m_coordinator.rootCompositingLayer())
149
    if (!m_isValid || !m_coordinator.rootCompositingLayer())
150
        return;
150
        return;
- a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp -2 / +1 lines
Lines 396-402 void DrawingAreaImpl::display(UpdateInfo& updateInfo) a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp_sec1
396
    ASSERT(!m_layerTreeHost);
396
    ASSERT(!m_layerTreeHost);
397
    ASSERT(!m_webPage.size().isEmpty());
397
    ASSERT(!m_webPage.size().isEmpty());
398
398
399
    m_webPage.layoutIfNeeded();
399
    m_webPage.renderingUpdate();
400
    m_webPage.flushPendingEditorStateUpdate();
400
    m_webPage.flushPendingEditorStateUpdate();
401
401
402
    // The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is
402
    // The layout may have put the page into accelerated compositing mode. If the LayerTreeHost is
Lines 404-410 void DrawingAreaImpl::display(UpdateInfo& updateInfo) a/Source/WebKit/WebProcess/WebPage/DrawingAreaImpl.cpp_sec2
404
    if (m_layerTreeHost)
404
    if (m_layerTreeHost)
405
        return;
405
        return;
406
406
407
    m_webPage.willDisplayPage();
408
    updateInfo.viewSize = m_webPage.size();
407
    updateInfo.viewSize = m_webPage.size();
409
    updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
408
    updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor();
410
409
- a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm -2 / +1 lines
Lines 349-356 void RemoteLayerTreeDrawingArea::flushLayers() a/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm_sec1
349
    RemoteLayerBackingStoreCollection& backingStoreCollection = m_remoteLayerTreeContext->backingStoreCollection();
349
    RemoteLayerBackingStoreCollection& backingStoreCollection = m_remoteLayerTreeContext->backingStoreCollection();
350
    backingStoreCollection.willFlushLayers();
350
    backingStoreCollection.willFlushLayers();
351
351
352
    m_webPage.layoutIfNeeded();
352
    m_webPage.renderingUpdate();
353
    m_webPage.willDisplayPage();
354
353
355
    FloatRect visibleRect(FloatPoint(), m_viewSize);
354
    FloatRect visibleRect(FloatPoint(), m_viewSize);
356
    if (m_scrolledViewExposedRect)
355
    if (m_scrolledViewExposedRect)
- a/Source/WebKit/WebProcess/WebPage/WebPage.cpp -8 / +7 lines
Lines 1552-1563 void WebPage::tryRestoreScrollPosition() a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec1
1552
    m_page->mainFrame().loader().history().restoreScrollPositionAndViewState();
1552
    m_page->mainFrame().loader().history().restoreScrollPositionAndViewState();
1553
}
1553
}
1554
1554
1555
void WebPage::layoutIfNeeded()
1556
{
1557
    if (m_mainFrame->coreFrame()->view())
1558
        m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();
1559
}
1560
1561
WebPage* WebPage::fromCorePage(Page* page)
1555
WebPage* WebPage::fromCorePage(Page* page)
1562
{
1556
{
1563
    return &static_cast<WebChromeClient&>(page->chrome().client()).page();
1557
    return &static_cast<WebChromeClient&>(page->chrome().client()).page();
Lines 3597-3605 void WebPage::didFlushLayerTreeAtTime(MonotonicTime timestamp) a/Source/WebKit/WebProcess/WebPage/WebPage.cpp_sec2
3597
}
3591
}
3598
#endif
3592
#endif
3599
3593
3600
void WebPage::willDisplayPage()
3594
void WebPage::layoutIfNeeded()
3595
{
3596
    m_page->layoutIfNeeded();
3597
}
3598
    
3599
void WebPage::renderingUpdate()
3601
{
3600
{
3602
    m_page->willDisplayPage();
3601
    m_page->renderingUpdate();
3603
}
3602
}
3604
3603
3605
WebInspector* WebPage::inspector(LazyCreationPolicy behavior)
3604
WebInspector* WebPage::inspector(LazyCreationPolicy behavior)
- a/Source/WebKit/WebProcess/WebPage/WebPage.h -2 / +2 lines
Lines 300-306 public: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec1
300
    void didFlushLayerTreeAtTime(MonotonicTime);
300
    void didFlushLayerTreeAtTime(MonotonicTime);
301
#endif
301
#endif
302
302
303
    void willDisplayPage();
303
    void layoutIfNeeded();
304
    void renderingUpdate();
304
305
305
    enum class LazyCreationPolicy { UseExistingOnly, CreateIfNeeded };
306
    enum class LazyCreationPolicy { UseExistingOnly, CreateIfNeeded };
306
307
Lines 333-339 public: a/Source/WebKit/WebProcess/WebPage/WebPage.h_sec2
333
    // -- Called by the DrawingArea.
334
    // -- Called by the DrawingArea.
334
    // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
335
    // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial?
335
    void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
336
    void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&);
336
    void layoutIfNeeded();
337
337
338
    // -- Called from WebCore clients.
338
    // -- Called from WebCore clients.
339
    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
339
    bool handleEditingKeyboardEvent(WebCore::KeyboardEvent*);
- a/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm -2 / +4 lines
Lines 59-64 a/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm_sec1
59
#import <pal/spi/cocoa/QuartzCoreSPI.h>
59
#import <pal/spi/cocoa/QuartzCoreSPI.h>
60
#import <wtf/MachSendRight.h>
60
#import <wtf/MachSendRight.h>
61
#import <wtf/MainThread.h>
61
#import <wtf/MainThread.h>
62
#import <wtf/SystemTracing.h>
62
63
63
#if ENABLE(ASYNC_SCROLLING)
64
#if ENABLE(ASYNC_SCROLLING)
64
#import <WebCore/AsyncScrollingCoordinator.h>
65
#import <WebCore/AsyncScrollingCoordinator.h>
Lines 459-470 void TiledCoreAnimationDrawingArea::flushLayers() a/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm_sec2
459
    if (layerTreeStateIsFrozen())
460
    if (layerTreeStateIsFrozen())
460
        return;
461
        return;
461
462
463
    TraceScope traceScope(RenderingUpdateStart, RenderingUpdateEnd);
464
462
    @autoreleasepool {
465
    @autoreleasepool {
463
        scaleViewToFitDocumentIfNeeded();
466
        scaleViewToFitDocumentIfNeeded();
464
467
465
        m_webPage.layoutIfNeeded();
468
        m_webPage.renderingUpdate();
466
        m_webPage.flushPendingEditorStateUpdate();
469
        m_webPage.flushPendingEditorStateUpdate();
467
        m_webPage.willDisplayPage();
468
470
469
        updateIntrinsicContentSizeIfNeeded();
471
        updateIntrinsicContentSizeIfNeeded();
470
472
- a/Source/WebKitLegacy/mac/WebView/WebView.mm -3 / +2 lines
Lines 1620-1628 static void WebKitInitializeGamepadProviderIfNecessary() a/Source/WebKitLegacy/mac/WebView/WebView.mm_sec1
1620
1620
1621
- (void)_viewWillDrawInternal
1621
- (void)_viewWillDrawInternal
1622
{
1622
{
1623
    Frame* frame = [self _mainCoreFrame];
1623
    if (_private->page)
1624
    if (frame && frame->view())
1624
        _private->page->renderingUpdate();
1625
        frame->view()->updateLayoutAndStyleIfNeededRecursive();
1626
}
1625
}
1627
1626
1628
+ (NSArray *)_supportedMIMETypes
1627
+ (NSArray *)_supportedMIMETypes
- a/Source/WebKitLegacy/win/WebView.cpp -4 / +2 lines
Lines 1173-1181 void WebView::updateBackingStore(FrameView* frameView, HDC dc, bool backingStore a/Source/WebKitLegacy/win/WebView.cpp_sec1
1173
1173
1174
    if (m_backingStoreBitmap && (m_backingStoreDirtyRegion || backingStoreCompletelyDirty)) {
1174
    if (m_backingStoreBitmap && (m_backingStoreDirtyRegion || backingStoreCompletelyDirty)) {
1175
        // Do a layout first so that everything we render to the backing store is always current.
1175
        // Do a layout first so that everything we render to the backing store is always current.
1176
        if (Frame* coreFrame = core(m_mainFrame))
1176
        m_page->renderingUpdate();
1177
            if (FrameView* view = coreFrame->view())
1178
                view->updateLayoutAndStyleIfNeededRecursive();
1179
1177
1180
        Vector<IntRect> paintRects;
1178
        Vector<IntRect> paintRects;
1181
        if (!backingStoreCompletelyDirty && m_backingStoreDirtyRegion) {
1179
        if (!backingStoreCompletelyDirty && m_backingStoreDirtyRegion) {
Lines 7388-7394 void WebView::flushPendingGraphicsLayerChanges() a/Source/WebKitLegacy/win/WebView.cpp_sec2
7388
    if (!isAcceleratedCompositing())
7386
    if (!isAcceleratedCompositing())
7389
        return;
7387
        return;
7390
7388
7391
    view->updateLayoutAndStyleIfNeededRecursive();
7389
    m_page->renderingUpdate();
7392
7390
7393
    // Updating layout might have taken us out of compositing mode.
7391
    // Updating layout might have taken us out of compositing mode.
7394
    if (m_backingLayer)
7392
    if (m_backingLayer)
- a/Tools/ChangeLog +11 lines
Lines 1-3 a/Tools/ChangeLog_sec1
1
2019-03-01  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
2019-03-01  Simon Fraser  <simon.fraser@apple.com>
12
2019-03-01  Simon Fraser  <simon.fraser@apple.com>
2
13
3
        Add a system trace scope for event region building
14
        Add a system trace scope for event region building
- a/LayoutTests/ChangeLog +18 lines
Lines 1-3 a/LayoutTests/ChangeLog_sec1
1
2019-03-01  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/no-style-recalc-during-accelerated-animation-expected.txt:
14
        * animations/no-style-recalc-during-accelerated-animation.html:
15
        One extra styleReclc was incurred due to the document styleRecalcTimer.
16
        I think this timer is not needed anymore. I will look at removing it in
17
        a separate patch.
18
1
2019-03-01  Zalan Bujtas  <zalan@apple.com>
19
2019-03-01  Zalan Bujtas  <zalan@apple.com>
2
20
3
        [ContentChangeObserver] Check for pending style recalcs at the end of each timer run.
21
        [ContentChangeObserver] Check for pending style recalcs at the end of each timer run.
- a/LayoutTests/TestExpectations +2 lines
Lines 2865-2870 webkit.org/b/187773 http/tests/webAPIStatistics [ Skip ] a/LayoutTests/TestExpectations_sec1
2865
2865
2866
# This is fallout from turning Web Animations on.
2866
# This is fallout from turning Web Animations on.
2867
webkit.org/b/190032 animations/animation-playstate-paused-style-resolution.html [ Failure ]
2867
webkit.org/b/190032 animations/animation-playstate-paused-style-resolution.html [ Failure ]
2868
webkit.org/b/190032 animations/missing-values-first-keyframe.html [ Failure ]
2869
webkit.org/b/190032 animations/missing-values-last-keyframe.html [ Failure ]
2868
webkit.org/b/190032 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Failure ]
2870
webkit.org/b/190032 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Failure ]
2869
webkit.org/b/190032 compositing/backing/transform-transition-from-outside-view.html [ Failure ]
2871
webkit.org/b/190032 compositing/backing/transform-transition-from-outside-view.html [ Failure ]
2870
webkit.org/b/190032 compositing/layer-creation/mismatched-rotated-transform-transition-overlap.html [ Failure ]
2872
webkit.org/b/190032 compositing/layer-creation/mismatched-rotated-transform-transition-overlap.html [ Failure ]
- a/LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt -1 / +1 lines
Lines 1-2 a/LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt_sec1
1
Got iteration event.
1
Got iteration event.
2
PASS: saw two or fewer style recalcs during the animation.
2
PASS: saw three or fewer style recalcs during the animation.
- a/LayoutTests/animations/no-style-recalc-during-accelerated-animation.html -3 / +3 lines
Lines 35-44 a/LayoutTests/animations/no-style-recalc-during-accelerated-animation.html_sec1
35
            box.addEventListener("animationiteration", () => result.innerText = "Got iteration event.\n");
35
            box.addEventListener("animationiteration", () => result.innerText = "Got iteration event.\n");
36
            box.addEventListener("animationend", () => {
36
            box.addEventListener("animationend", () => {
37
                const numRecalcs = internals.styleRecalcCount();
37
                const numRecalcs = internals.styleRecalcCount();
38
                if (numRecalcs > 2)
38
                if (numRecalcs > 3)
39
                    result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see two."
39
                    result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see three."
40
                else 
40
                else 
41
                    result.innerText += "PASS: saw two or fewer style recalcs during the animation."
41
                    result.innerText += "PASS: saw three or fewer style recalcs during the animation."
42
42
43
                if (window.testRunner)
43
                if (window.testRunner)
44
                    testRunner.notifyDone();
44
                    testRunner.notifyDone();

Return to Bug 177484