Changeset 244182 in webkit
- Timestamp:
- Apr 10, 2019, 10:44:13 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 deleted
- 50 edited
- 1 moved
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/TestExpectations (modified) (1 diff)
-
LayoutTests/accessibility/mac/selection-notification-focus-change-expected.txt (modified) (2 diffs)
-
LayoutTests/accessibility/mac/selection-notification-focus-change.html (modified) (3 diffs)
-
LayoutTests/animations/animation-multiple-callbacks-timestamp.html (modified) (1 diff)
-
LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt (modified) (1 diff)
-
LayoutTests/animations/no-style-recalc-during-accelerated-animation.html (modified) (1 diff)
-
LayoutTests/animations/resources/animation-test-helpers.js (modified) (1 diff)
-
LayoutTests/compositing/video/video-clip-change-src.html (modified) (1 diff)
-
LayoutTests/css3/filters/composited-during-animation.html (modified) (1 diff)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/resize-observer/resources/resizeTestHelper.js (modified) (1 diff)
-
LayoutTests/media/media-controls-accessibility.html (modified) (1 diff)
-
LayoutTests/platform/mac-wk2/accessibility/mac (deleted)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/SystemTracing.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (2 diffs)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (8 diffs)
-
Source/WebCore/accessibility/mac/AXObjectCacheMac.mm (modified) (1 diff)
-
Source/WebCore/animation/DocumentAnimationScheduler.cpp (deleted)
-
Source/WebCore/animation/DocumentTimeline.cpp (modified) (15 diffs)
-
Source/WebCore/animation/DocumentTimeline.h (modified) (3 diffs)
-
Source/WebCore/dom/Document.cpp (modified) (10 diffs)
-
Source/WebCore/dom/Document.h (modified) (7 diffs)
-
Source/WebCore/dom/ScriptedAnimationController.cpp (modified) (6 diffs)
-
Source/WebCore/dom/ScriptedAnimationController.h (modified) (2 diffs)
-
Source/WebCore/page/FrameView.cpp (modified) (2 diffs)
-
Source/WebCore/page/FrameViewLayoutContext.cpp (modified) (1 diff)
-
Source/WebCore/page/IntersectionObserver.cpp (modified) (1 diff)
-
Source/WebCore/page/Page.cpp (modified) (5 diffs)
-
Source/WebCore/page/Page.h (modified) (8 diffs)
-
Source/WebCore/page/PageOverlayController.cpp (modified) (2 diffs)
-
Source/WebCore/page/RenderingUpdateScheduler.cpp (added)
-
Source/WebCore/page/RenderingUpdateScheduler.h (moved) (moved from trunk/Source/WebCore/animation/DocumentAnimationScheduler.h ) (2 diffs)
-
Source/WebCore/page/ResizeObserver.cpp (modified) (2 diffs)
-
Source/WebCore/page/ResizeObserver.h (modified) (1 diff)
-
Source/WebCore/page/ios/ContentChangeObserver.h (modified) (2 diffs)
-
Source/WebCore/page/mac/ServicesOverlayController.mm (modified) (1 diff)
-
Source/WebCore/page/scrolling/ScrollingStateTree.cpp (modified) (1 diff)
-
Source/WebCore/rendering/RenderLayerCompositor.cpp (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp (modified) (4 diffs)
-
Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp (modified) (1 diff)
-
Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.cpp (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/WebPage.h (modified) (2 diffs)
-
Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm (modified) (1 diff)
-
Source/WebKitLegacy/mac/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/mac/WebView/WebView.mm (modified) (2 diffs)
-
Source/WebKitLegacy/win/ChangeLog (modified) (1 diff)
-
Source/WebKitLegacy/win/WebView.cpp (modified) (3 diffs)
-
Tools/ChangeLog (modified) (1 diff)
-
Tools/Tracing/SystemTracePoints.plist (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r244181 r244182 1 2019-04-10 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 * accessibility/mac/selection-notification-focus-change-expected.txt: 14 * accessibility/mac/selection-notification-focus-change.html: 15 Remove the debug statements form notificationCallback() since the number 16 of times this function is called back and the order of notifications are 17 not defined. This test has been flaky and some trials were made to make 18 it more reliable. With this change it became flaky again. 19 20 * animations/animation-multiple-callbacks-timestamp.html: 21 Fix variable names used by an error message. 22 23 * animations/no-style-recalc-during-accelerated-animation-expected.txt: 24 * animations/no-style-recalc-during-accelerated-animation.html: 25 One extra styleReclc was incurred due to the document styleRecalcTimer. 26 I think this timer is not needed anymore. I will look at removing it in 27 a separate patch. 28 29 * animations/resources/animation-test-helpers.js: 30 (waitForAnimationToStart): 31 The expectation that animation will start at the beginning of the next 32 event loop is not true anymore. The animation will start at the time the 33 requestAnimationFrame fires. 34 35 * compositing/video/video-clip-change-src.html: 36 This test loads a video data and pushes it to the encoder. Originally it 37 used to wait 150 ms after receiving the second canplaythrough. I had to 38 change this timing to 250 ms. 39 40 * css3/filters/composited-during-animation.html: 41 Ditto. setTimeout({...}, 0) versus requestAnimationFrame. 42 43 * media/media-controls-accessibility.html: 44 Updating the accessibility button happens asynchronously, see 45 [WebAccessibilityObjectWrapper accessibilityPerformPressAction]. Due to 46 changing the page update timing, this test became flaky. Originally it used 47 to setTimeout({...}, 10) to ensure the stringValue of the mutate button 48 was changed after it was pressed. The fix is to loop using rAF till the 49 stringValue changes. 50 51 * platform/mac-wk2/accessibility/mac/selection-notification-focus-change-expected.txt: Removed. 52 The number of time notificationCallback() is called and the order of 53 notifications are not defined. And this is why we have two expected files: 54 one for WK1 and the other for WK2. Since the test is now simplified, we 55 can get rid of this duplication. We will test the minimum reliable thing 56 we can test. 57 1 58 2019-04-10 Ryosuke Niwa <rniwa@webkit.org> 2 59 -
trunk/LayoutTests/TestExpectations
r244112 r244182 3028 3028 # This is fallout from turning Web Animations on. 3029 3029 webkit.org/b/190032 animations/animation-playstate-paused-style-resolution.html [ Failure ] 3030 webkit.org/b/190032 animations/missing-values-first-keyframe.html [ Failure ] 3031 webkit.org/b/190032 animations/missing-values-last-keyframe.html [ Failure ] 3030 3032 webkit.org/b/190032 compositing/backing/backing-store-attachment-fill-forwards-animation.html [ Failure ] 3031 3033 webkit.org/b/190032 compositing/backing/transform-transition-from-outside-view.html [ Failure ] -
trunk/LayoutTests/accessibility/mac/selection-notification-focus-change-expected.txt
r228417 r244182 1 This tests that selection changes as a result of advancing focus include AXTextSelectionChangedFocus flag.1 This tests that selection changes as a result of advancing focus. 2 2 3 3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". … … 6 6 PASS webArea.addNotificationListener(notificationCallback) is true 7 7 eventSender.keyDown(tabCharacter); 8 Received AXSelectedTextChanged9 PASS userInfo["AXTextSelectionChangedFocus"] is true10 Received AXFocusChanged11 Received AXSelectedTextChanged12 PASS userInfo["AXTextSelectionChangedFocus"] is true13 8 14 9 PASS accessibilityController.accessibleElementById("1").isFocusable is true 15 10 accessibilityController.accessibleElementById("1").takeFocus() 16 Received AXFocusChanged17 11 18 12 eventSender.keyDown(tabCharacter) 19 Received AXSelectedTextChanged20 PASS userInfo["AXTextSelectionChangedFocus"] is true21 Received AXFocusChanged22 Received AXSelectedTextChanged23 PASS userInfo["AXTextSelectionChangedFocus"] is true24 13 PASS successfullyParsed is true 25 14 -
trunk/LayoutTests/accessibility/mac/selection-notification-focus-change.html
r227713 r244182 16 16 </fieldset> 17 17 <script> 18 description("This tests that selection changes as a result of advancing focus include AXTextSelectionChangedFocus flag.");18 description("This tests that selection changes as a result of advancing focus."); 19 19 jsTestIsAsync = true; 20 20 21 21 var webArea = 0; 22 var axTextFocusChangeOne = 0;23 var axTextFocusChangeTwo = 0;24 var axTextFocusChangeThree = 0;25 var axTextFocusChangeFour = 0;26 22 var tabCharacter = "\t"; 27 23 28 24 function notificationCallback(notification, userInfo) { 29 if (notification == "AXSelectedTextChanged") { 30 debug("Received AXSelectedTextChanged"); 31 window.userInfo = userInfo; 32 shouldBeTrue("userInfo[\"AXTextSelectionChangedFocus\"]"); 33 } else if (notification == "AXFocusChanged") 34 debug("Received AXFocusChanged"); 25 if (notification == "AXSelectedTextChanged" || notification == "AXFocusChanged") 26 window.promise.resolve(); 35 27 } 36 28 37 29 function runTest() { 38 if (window.accessibilityController) { 39 testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); 40 41 accessibilityController.enableEnhancedAccessibility(true); 42 webArea = accessibilityController.rootElement.childAtIndex(0); 43 webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true) 44 45 shouldBeTrue("webArea.addNotificationListener(notificationCallback)"); 46 evalAndLog("eventSender.keyDown(tabCharacter);"); 47 setTimeout(runTakeFocusTest, 0); 48 } else { 30 if (!window.accessibilityController) { 49 31 debug("window.accessibilityController is not present"); 50 32 finishJSTest(); 33 return; 51 34 } 35 36 runFirstTabMoveTest(); 37 } 38 39 function runFirstTabMoveTest() { 40 testRunner.overridePreference("WebKitTabToLinksPreferenceKey", 1); 41 42 accessibilityController.enableEnhancedAccessibility(true); 43 webArea = accessibilityController.rootElement.childAtIndex(0); 44 webArea.setBoolAttributeValue("AXCaretBrowsingEnabled", true) 45 46 shouldBeTrue("webArea.addNotificationListener(notificationCallback)"); 47 evalAndLog("eventSender.keyDown(tabCharacter);"); 48 49 window.promise = new Promise(function(resolve, reject) { 50 setTimeout(() => { 51 runTakeFocusTest(); 52 }, 0); 53 }); 52 54 } 53 55 … … 56 58 shouldBeTrue("accessibilityController.accessibleElementById(\"1\").isFocusable"); 57 59 evalAndLog("accessibilityController.accessibleElementById(\"1\").takeFocus()"); 58 setTimeout(runSecondTabMoveTest, 0); 60 61 window.promise = new Promise(function(resolve, reject) { 62 setTimeout(() => { 63 runSecondTabMoveTest(); 64 }, 0); 65 }); 59 66 } 60 67 … … 62 69 debug(''); 63 70 evalAndLog("eventSender.keyDown(tabCharacter)"); 64 setTimeout(() => { 65 webArea.removeNotificationListener(); 66 finishJSTest(); 67 }, 0); 71 72 window.promise = new Promise(function(resolve, reject) { 73 setTimeout(() => { 74 webArea.removeNotificationListener(); 75 finishJSTest(); 76 }, 0); 77 }); 68 78 } 69 79 -
trunk/LayoutTests/animations/animation-multiple-callbacks-timestamp.html
r242714 r244182 36 36 const WarmupFrames = 5; 37 37 if (++currentFrame > WarmupFrames && timestamp != timestamp1) { 38 testFailed("timestamp 1 = " + timestamp1 + ", timestamp2 = " + timestamp2+ ", window.performance.now() = " + window.performance.now());38 testFailed("timestamp = " + timestamp + ", timestamp1 = " + timestamp1 + ", window.performance.now() = " + window.performance.now()); 39 39 failed = true; 40 40 } -
trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation-expected.txt
r242714 r244182 1 1 Got iteration event. 2 PASS: saw t woor fewer style recalcs during the animation.2 PASS: saw three or fewer style recalcs during the animation. -
trunk/LayoutTests/animations/no-style-recalc-during-accelerated-animation.html
r242714 r244182 36 36 box.addEventListener("animationend", () => { 37 37 const numRecalcs = internals.styleRecalcCount(); 38 if (numRecalcs > 2)39 result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see t wo."38 if (numRecalcs > 3) 39 result.innerText += "FAIL: saw " + numRecalcs + " style recalcs during the animation, should only see three." 40 40 else 41 result.innerText += "PASS: saw t woor fewer style recalcs during the animation."41 result.innerText += "PASS: saw three or fewer style recalcs during the animation." 42 42 43 43 if (window.testRunner) -
trunk/LayoutTests/animations/resources/animation-test-helpers.js
r232559 r244182 596 596 { 597 597 element.addEventListener('webkitAnimationStart', function() { 598 window.setTimeout(callback, 0); // delay to give hardware animations a chance to start598 requestAnimationFrame(callback); // delay to give hardware animations a chance to start 599 599 }, false); 600 600 } -
trunk/LayoutTests/compositing/video/video-clip-change-src.html
r238090 r244182 38 38 function endTest() { 39 39 if (window.testRunner) 40 setTimeout(function() { testRunner.notifyDone(); }, 150);40 setTimeout(function() { testRunner.notifyDone(); }, 250); 41 41 } 42 42 </script> -
trunk/LayoutTests/css3/filters/composited-during-animation.html
r236541 r244182 150 150 151 151 // Completed the pre-animation tests. Now start the animation. 152 setTimeout(function () {152 requestAnimationFrame(function () { 153 153 document.body.className = "animating"; 154 154 runAnimationTest(expectedValues); 155 } , 0);155 }); 156 156 } 157 157 -
trunk/LayoutTests/imported/w3c/ChangeLog
r244094 r244182 1 2019-04-10 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 * web-platform-tests/resize-observer/resources/resizeTestHelper.js: 11 Change ResizeTestHelper.TIMEOUT to be 1 second instead of 100 ms which 12 is too short for layout tests. 13 1 14 2019-04-09 Youenn Fablet <youenn@apple.com> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/resize-observer/resources/resizeTestHelper.js
r240655 r244182 53 53 } 54 54 55 ResizeTestHelper.TIMEOUT = 100 ;55 ResizeTestHelper.TIMEOUT = 1000; 56 56 57 57 ResizeTestHelper.prototype = { -
trunk/LayoutTests/media/media-controls-accessibility.html
r219906 r244182 33 33 // Mute button should be a checkbox with on/off state. 34 34 muteButton = videoElement.childAtIndex(0).childAtIndex(9); 35 muteButtonStringValue = muteButton.stringValue; 35 36 debug("muteButton.description: " + muteButton.description); 36 37 debug("muteButton.role: " + muteButton.role); 37 debug("muteButton.stringValue: " + muteButton .stringValue);38 debug("muteButton.stringValue: " + muteButtonStringValue); 38 39 debug("press muteButton"); 39 40 muteButton.press(); 40 setTimeout(function() { 41 42 function checkMuteButton() { 43 if (muteButtonStringValue == muteButton.stringValue) { 44 requestAnimationFrame(checkMuteButton); 45 return; 46 } 47 41 48 debug("muteButton.stringValue: " + muteButton.stringValue + "\n"); 42 43 49 // Left/Right arrow key should have 0.5 second step on timeline. 44 50 checkTimeLineValue(rightArrow); 45 }, 10); 51 } 52 53 requestAnimationFrame(checkMuteButton); 46 54 }); 47 55 -
trunk/Source/WTF/ChangeLog
r244135 r244182 1 2019-04-10 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 Add trace points for the page RenderingUpdate. 9 10 * wtf/SystemTracing.h: 11 1 12 2019-04-10 Claudio Saavedra <csaavedra@igalia.com> 2 13 -
trunk/Source/WTF/wtf/SystemTracing.h
r242714 r244182 78 78 ComputeEventRegionsEnd, 79 79 80 ScheduleRenderingUpdate, 81 TriggerRenderingUpdate, 82 RenderingUpdateStart, 83 RenderingUpdateEnd, 84 80 85 WebKitRange = 10000, 81 86 WebHTMLViewPaintStart, -
trunk/Source/WebCore/ChangeLog
r244181 r244182 1 2019-04-10 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 these 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, intersection observations and resize observations per the 27 "Update the rendering" step of the HTML Event Loop specification: 28 <https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering>. 29 30 In the future, more rendering steps will be added to this code. 31 32 * Sources.txt: 33 * WebCore.xcodeproj/project.pbxproj: 34 * accessibility/mac/AXObjectCacheMac.mm: 35 (WebCore::AXObjectCache::platformHandleFocusedUIElementChanged): 36 Fix layout tests by adding null check. 37 38 * animation/DocumentAnimationScheduler.cpp: Removed. 39 * animation/DocumentAnimationScheduler.h: Removed. 40 * animation/DocumentTimeline.cpp: 41 (WebCore::DocumentTimeline::DocumentTimeline): 42 (WebCore::DocumentTimeline::updateThrottlingState): 43 (WebCore::DocumentTimeline::suspendAnimations): 44 (WebCore::DocumentTimeline::resumeAnimations): 45 (WebCore::DocumentTimeline::liveCurrentTime const): 46 (WebCore::DocumentTimeline::currentTime): 47 (WebCore::DocumentTimeline::cacheCurrentTime): 48 (WebCore::DocumentTimeline::animationTimingDidChange): 49 (WebCore::DocumentTimeline::scheduleAnimationResolution): 50 (WebCore::DocumentTimeline::unscheduleAnimationResolution): 51 (WebCore::DocumentTimeline::updateAnimationsAndSendEvents): 52 (WebCore::DocumentTimeline::internalUpdateAnimationsAndSendEvents): 53 (WebCore::DocumentTimeline::scheduleNextTick): 54 (WebCore::DocumentTimeline::updateListOfElementsWithRunningAcceleratedAnimationsForElement): 55 Simplify this function by handling the case of no-animations separately. 56 57 (WebCore::DocumentTimeline::resolveAnimationsForElement): 58 Simplify the loop and delete hasPendingAcceleratedAnimations because it 59 is initialized to true and is not changed inside the loop. 60 61 (WebCore::DocumentTimeline::scheduleAnimationResolutionIfNeeded): Deleted. 62 (WebCore::DocumentTimeline::animationResolutionTimerFired): Deleted. 63 * animation/DocumentTimeline.h: 64 * dom/Document.cpp: 65 (WebCore::Document::resolveStyle): 66 There is no need to force update in resolveStyle(). notifyFlushRequired() 67 will be called eventually which will scheduleRenderingUpdate(). 68 69 (WebCore::Document::prepareForDestruction): 70 (WebCore::Document::updateAnimationsAndSendEvents): 71 (WebCore::Document::serviceRequestAnimationFrameCallbacks): 72 (WebCore::Document::windowScreenDidChange): 73 (WebCore::Document::scheduleRenderingUpdate): 74 (WebCore::Document::updateIntersectionObservations): 75 (WebCore::Document::addResizeObserver): 76 (WebCore::Document::updateResizeObservations): 77 (WebCore::Document::scheduleForcedIntersectionObservationUpdate): Deleted. 78 (WebCore::Document::scheduleResizeObservations): Deleted. 79 (WebCore::Document::animationScheduler): Deleted. 80 No need to schedule web-animations, intersection observations and resize 81 observations updates separately. All of them will be updated through the 82 "Update the rendering" step, i.e. Page::updateRendering(). 83 84 * dom/Document.h: 85 (WebCore::Document::numberOfIntersectionObservers const): 86 * dom/ScriptedAnimationController.cpp: 87 (WebCore::ScriptedAnimationController::serviceRequestAnimationFrameCallbacks): 88 (WebCore::ScriptedAnimationController::scheduleAnimation): 89 (WebCore::ScriptedAnimationController::animationTimerFired): 90 (WebCore::ScriptedAnimationController::serviceScriptedAnimations): Deleted. 91 (WebCore::ScriptedAnimationController::documentAnimationSchedulerDidFire): Deleted. 92 * dom/ScriptedAnimationController.h: 93 * page/FrameView.cpp: 94 (WebCore::FrameView::didLayout): 95 (WebCore::FrameView::viewportContentsChanged): 96 * page/FrameViewLayoutContext.cpp: 97 (WebCore::FrameViewLayoutContext::layoutTimerFired): 98 * page/IntersectionObserver.cpp: 99 (WebCore::IntersectionObserver::observe): 100 * page/Page.cpp: 101 (WebCore::Page::Page): 102 (WebCore::Page::layoutIfNeeded): 103 (WebCore::Page::updateRendering): 104 (WebCore::Page::renderingUpdateScheduler): 105 (WebCore::Page::willDisplayPage): Deleted. 106 (WebCore::Page::addDocumentNeedingIntersectionObservationUpdate): Deleted. 107 (WebCore::Page::updateIntersectionObservations): Deleted. 108 (WebCore::Page::scheduleForcedIntersectionObservationUpdate): Deleted. 109 (WebCore::Page::hasResizeObservers const): Deleted. 110 (WebCore::Page::gatherDocumentsNeedingResizeObservationCheck): Deleted. 111 (WebCore::Page::checkResizeObservations): Deleted. 112 (WebCore::Page::scheduleResizeObservations): Deleted. 113 (WebCore::Page::notifyResizeObservers): Deleted. 114 * page/Page.h: 115 (WebCore::Page::setNeedsCheckResizeObservations): Deleted. 116 (WebCore::Page::needsCheckResizeObservations const): Deleted. 117 The IntersectionObserver and the ResizeObserver do not need to schedule 118 their own timers. The RenderingUpdateScheduler will schedule the "Update 119 the rendering" step in which these obverses will be served. 120 121 * page/PageOverlayController.cpp: 122 (WebCore::PageOverlayController::didChangeViewExposedRect): 123 (WebCore::PageOverlayController::notifyFlushRequired): 124 Force committing the layers to be 60 fps at maximum. 125 126 * page/RenderingUpdateScheduler.cpp: Added. 127 (WebCore::RenderingUpdateScheduler::RenderingUpdateScheduler): 128 (WebCore::RenderingUpdateScheduler::scheduleRenderingUpdate): 129 (WebCore::RenderingUpdateScheduler::isScheduled const): 130 (WebCore::RenderingUpdateScheduler::startTimer): 131 (WebCore::RenderingUpdateScheduler::clearScheduled): 132 (WebCore::RenderingUpdateScheduler::createDisplayRefreshMonitor const): 133 (WebCore::RenderingUpdateScheduler::windowScreenDidChange): 134 (WebCore::RenderingUpdateScheduler::displayRefreshFired): 135 (WebCore::RenderingUpdateScheduler::scheduleCompositingLayerFlush): 136 * page/RenderingUpdateScheduler.h: Added. 137 (WebCore::RenderingUpdateScheduler::create): 138 * page/ResizeObserver.cpp: 139 (WebCore::ResizeObserver::observe): 140 (WebCore::ResizeObserver::scheduleObservations): Deleted. 141 * page/ResizeObserver.h: 142 (WebCore::ResizeObserver::hasActiveObservations const): 143 * page/ios/ContentChangeObserver.h: 144 * page/mac/ServicesOverlayController.mm: 145 (WebCore::ServicesOverlayController::Highlight::notifyFlushRequired): 146 * page/scrolling/ScrollingStateTree.cpp: 147 * rendering/RenderLayerCompositor.cpp: 148 (WebCore::RenderLayerCompositor::scheduleLayerFlushNow): 149 (WebCore::RenderLayerCompositor::layerTreeAsText): 150 1 151 2019-04-10 Ryosuke Niwa <rniwa@webkit.org> 2 152 -
trunk/Source/WebCore/Sources.txt
r244078 r244182 427 427 animation/CSSTransition.cpp 428 428 animation/DeclarativeAnimation.cpp 429 animation/DocumentAnimationScheduler.cpp430 429 animation/DocumentTimeline.cpp 431 430 animation/KeyframeEffect.cpp … … 1533 1532 page/RemoteDOMWindow.cpp 1534 1533 page/RemoteFrame.cpp 1534 page/RenderingUpdateScheduler.cpp 1535 1535 page/ResizeObservation.cpp 1536 1536 page/ResizeObserver.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r244078 r244182 1732 1732 555130011E7CCCCB00A69E38 /* DecodingOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 555130001E7CCCCA00A69E38 /* DecodingOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1733 1733 555B87ED1CAAF0AB00349425 /* ImageDecoderCG.h in Headers */ = {isa = PBXBuildFile; fileRef = 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */; }; 1734 556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1734 1735 5576A5651D88A70800CCC04C /* ImageFrame.h in Headers */ = {isa = PBXBuildFile; fileRef = 5576A5631D88A70800CCC04C /* ImageFrame.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1735 1736 55A336F91D821E3C0022C4C7 /* ImageBackingStore.h in Headers */ = {isa = PBXBuildFile; fileRef = 55A336F81D821E3C0022C4C7 /* ImageBackingStore.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 2076 2077 715AD7202050513200D592DC /* DeclarativeAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = 715AD71D2050512400D592DC /* DeclarativeAnimation.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2077 2078 715AD7212050513F00D592DC /* CSSTransition.h in Headers */ = {isa = PBXBuildFile; fileRef = 7123C186204739BA00789392 /* CSSTransition.h */; }; 2078 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */ = {isa = PBXBuildFile; fileRef = 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */; settings = {ATTRIBUTES = (Private, ); }; };2079 2079 71729F7B20F3BA4900801CE6 /* DocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7A20F3BA3A00801CE6 /* DocumentTimelineOptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 2080 2080 71729F7E20F3BB4700801CE6 /* JSDocumentTimelineOptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 71729F7C20F3BAB900801CE6 /* JSDocumentTimelineOptions.h */; }; … … 8485 8485 555B87EA1CAAF0AB00349425 /* ImageDecoderCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageDecoderCG.cpp; sourceTree = "<group>"; }; 8486 8486 555B87EB1CAAF0AB00349425 /* ImageDecoderCG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageDecoderCG.h; sourceTree = "<group>"; }; 8487 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderingUpdateScheduler.h; sourceTree = "<group>"; }; 8488 556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderingUpdateScheduler.cpp; sourceTree = "<group>"; }; 8487 8489 5576A5621D88A70800CCC04C /* ImageFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ImageFrame.cpp; sourceTree = "<group>"; }; 8488 8490 5576A5631D88A70800CCC04C /* ImageFrame.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageFrame.h; sourceTree = "<group>"; }; … … 9255 9257 716C8DF31E48B284005BD0DA /* volume-down-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-down-button.js"; sourceTree = "<group>"; }; 9256 9258 716C8DF41E48B284005BD0DA /* volume-up-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "volume-up-button.js"; sourceTree = "<group>"; }; 9257 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentAnimationScheduler.h; sourceTree = "<group>"; };9258 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentAnimationScheduler.cpp; sourceTree = "<group>"; };9259 9259 716FA0D81DB26591007323CC /* airplay-button.css */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.css; path = "airplay-button.css"; sourceTree = "<group>"; }; 9260 9260 716FA0D91DB26591007323CC /* airplay-button.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = "airplay-button.js"; sourceTree = "<group>"; }; … … 20216 20216 46B9518C207D632900A7D2DD /* RemoteFrame.cpp */, 20217 20217 46B95192207D632E00A7D2DD /* RemoteFrame.h */, 20218 556C7C4922123943009B06CA /* RenderingUpdateScheduler.cpp */, 20219 556C7C4722123942009B06CA /* RenderingUpdateScheduler.h */, 20218 20220 58B2F9F22232D43F00938D63 /* ResizeObservation.cpp */, 20219 20221 58B2F9F32232D43F00938D63 /* ResizeObservation.h */, … … 20378 20380 715AD71F2050512400D592DC /* DeclarativeAnimation.cpp */, 20379 20381 715AD71D2050512400D592DC /* DeclarativeAnimation.h */, 20380 716E55AF20DBABDD00F0CF29 /* DocumentAnimationScheduler.cpp */,20381 716E55AD20DBABDC00F0CF29 /* DocumentAnimationScheduler.h */,20382 20382 71025EC41F99F096004A250C /* DocumentTimeline.cpp */, 20383 20383 71025EC51F99F096004A250C /* DocumentTimeline.h */, … … 28768 28768 7EE6846F12D26E3800E73215 /* DNSResolveQueueCFNet.h in Headers */, 28769 28769 A8185F4009765766005826D9 /* Document.h in Headers */, 28770 716E55B020DBABF100F0CF29 /* DocumentAnimationScheduler.h in Headers */,28771 28770 A3BB59F41457A40D00AC56FE /* DocumentEventQueue.h in Headers */, 28772 28771 A8185F3D09765766005826D9 /* DocumentFragment.h in Headers */, … … 30958 30957 08F2F00A1213E61700DCEC48 /* RenderImageResource.h in Headers */, 30959 30958 08641D4812142F7D008DE9F6 /* RenderImageResourceStyleImage.h in Headers */, 30959 556C7C4B22123997009B06CA /* RenderingUpdateScheduler.h in Headers */, 30960 30960 BCEA4878097D93020094C9E4 /* RenderInline.h in Headers */, 30961 30961 B595FF471824CEE300FF51CD /* RenderIterator.h in Headers */, -
trunk/Source/WebCore/accessibility/mac/AXObjectCacheMac.mm
r244107 r244182 540 540 NSAccessibilityHandleFocusChanged(); 541 541 // AXFocusChanged is a test specific notification name and not something a real AT will be listening for 542 if (UNLIKELY(axShouldRepostNotificationsForTests)) 543 [rootWebArea()->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil]; 542 if (UNLIKELY(!axShouldRepostNotificationsForTests)) 543 return; 544 545 auto* rootWebArea = this->rootWebArea(); 546 if (!rootWebArea) 547 return; 548 549 [rootWebArea->wrapper() accessibilityPostedNotification:@"AXFocusChanged" userInfo:nil]; 544 550 } 545 551 -
trunk/Source/WebCore/animation/DocumentTimeline.cpp
r244032 r244182 34 34 #include "DeclarativeAnimation.h" 35 35 #include "Document.h" 36 #include "DocumentAnimationScheduler.h"37 36 #include "GraphicsLayer.h" 38 37 #include "KeyframeEffect.h" … … 62 61 DocumentTimeline::DocumentTimeline(Document& document, Seconds originTime) 63 62 : AnimationTimeline() 64 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 65 , m_animationResolutionTimer(*this, &DocumentTimeline::animationResolutionTimerFired) 66 #endif 67 , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolutionIfNeeded) 63 , m_tickScheduleTimer(*this, &DocumentTimeline::scheduleAnimationResolution) 68 64 , m_document(&document) 69 65 , m_originTime(originTime) … … 195 191 void DocumentTimeline::updateThrottlingState() 196 192 { 197 scheduleAnimationResolution IfNeeded();193 scheduleAnimationResolution(); 198 194 } 199 195 … … 211 207 212 208 if (!m_cachedCurrentTime) 213 m_cachedCurrentTime = liveCurrentTime();209 m_cachedCurrentTime = Seconds(liveCurrentTime()); 214 210 215 211 for (const auto& animation : m_animations) … … 235 231 animation->setSuspended(false); 236 232 237 scheduleAnimationResolution IfNeeded();233 scheduleAnimationResolution(); 238 234 } 239 235 … … 253 249 } 254 250 255 Seconds DocumentTimeline::liveCurrentTime() const 256 { 257 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 258 return m_document->animationScheduler().lastTimestamp(); 259 #else 260 return Seconds(m_document->domWindow()->nowTimestamp()); 261 #endif 251 DOMHighResTimeStamp DocumentTimeline::liveCurrentTime() const 252 { 253 return m_document->domWindow()->nowTimestamp(); 262 254 } 263 255 … … 274 266 } 275 267 276 auto currentTime = liveCurrentTime(); 277 278 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 279 // If we're in the middle of firing a frame, either due to a requestAnimationFrame callback 280 // or scheduling an animation update, we want to ensure we use the same time we're using as 281 // the timestamp for requestAnimationFrame() callbacks. 282 if (m_document->animationScheduler().isFiring()) 283 cacheCurrentTime(currentTime); 284 #endif 285 286 if (!m_cachedCurrentTime) { 287 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 288 // If we're not in the middle of firing a frame, let's make our best guess at what the currentTime should 289 // be since the last time a frame fired by increment of our update interval. This way code using something 290 // like setTimeout() or handling events will get a time that's only updating at around 60fps, or less if 291 // we're throttled. 292 auto lastAnimationSchedulerTimestamp = currentTime; 293 auto delta = Seconds(m_document->domWindow()->nowTimestamp()) - lastAnimationSchedulerTimestamp; 294 int frames = std::floor(delta.seconds() / animationInterval().seconds()); 295 cacheCurrentTime(lastAnimationSchedulerTimestamp + Seconds(frames * animationInterval().seconds())); 296 #else 297 cacheCurrentTime(currentTime); 298 #endif 299 } 268 if (!m_cachedCurrentTime) 269 cacheCurrentTime(liveCurrentTime()); 270 300 271 return m_cachedCurrentTime.value() - m_originTime; 301 272 } 302 273 303 void DocumentTimeline::cacheCurrentTime( SecondsnewCurrentTime)304 { 305 m_cachedCurrentTime = newCurrentTime;274 void DocumentTimeline::cacheCurrentTime(DOMHighResTimeStamp newCurrentTime) 275 { 276 m_cachedCurrentTime = Seconds(newCurrentTime); 306 277 // We want to be sure to keep this time cached until we've both finished running JS and finished updating 307 278 // animations, so we schedule the invalidation task and register a whenIdle callback on the VM, which will … … 326 297 } 327 298 328 void DocumentTimeline::scheduleAnimationResolutionIfNeeded()329 {330 if (!m_isUpdatingAnimations && !m_isSuspended && !m_animations.isEmpty())331 scheduleAnimationResolution();332 }333 334 299 void DocumentTimeline::animationTimingDidChange(WebAnimation& animation) 335 300 { 336 301 AnimationTimeline::animationTimingDidChange(animation); 337 scheduleAnimationResolution IfNeeded();302 scheduleAnimationResolution(); 338 303 } 339 304 … … 348 313 void DocumentTimeline::scheduleAnimationResolution() 349 314 { 350 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 351 m_document->animationScheduler().scheduleWebAnimationsResolution(); 352 #else 353 // FIXME: We need to use the same logic as ScriptedAnimationController here, 354 // which will be addressed by the refactor tracked by webkit.org/b/179293. 355 m_animationResolutionTimer.startOneShot(animationInterval()); 356 #endif 315 if (m_isSuspended || m_animations.isEmpty() || m_animationResolutionScheduled) 316 return; 317 318 if (!m_document || !m_document->page()) 319 return; 320 321 m_document->page()->renderingUpdateScheduler().scheduleRenderingUpdate(); 322 m_animationResolutionScheduled = true; 357 323 } 358 324 … … 360 326 { 361 327 m_tickScheduleTimer.stop(); 362 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 363 m_document->animationScheduler().unscheduleWebAnimationsResolution(); 364 #else 365 // FIXME: We need to use the same logic as ScriptedAnimationController here, 366 // which will be addressed by the refactor tracked by webkit.org/b/179293. 367 m_animationResolutionTimer.stop(); 368 #endif 369 } 370 371 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 372 void DocumentTimeline::documentAnimationSchedulerDidFire() 373 #else 374 void DocumentTimeline::animationResolutionTimerFired() 375 #endif 376 { 377 updateAnimationsAndSendEvents(); 328 m_animationResolutionScheduled = false; 329 } 330 331 void DocumentTimeline::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp) 332 { 333 // We need to freeze the current time even if no animation is running. 334 // document.timeline.currentTime may be called from a rAF callback and 335 // it has to match the rAF timestamp. 336 if (!m_isSuspended) 337 cacheCurrentTime(timestamp); 338 339 if (m_isSuspended || m_animations.isEmpty() || !m_animationResolutionScheduled) 340 return; 341 342 internalUpdateAnimationsAndSendEvents(); 378 343 applyPendingAcceleratedAnimations(); 344 345 m_animationResolutionScheduled = false; 379 346 scheduleNextTick(); 380 347 } 381 348 382 void DocumentTimeline:: updateAnimationsAndSendEvents()349 void DocumentTimeline::internalUpdateAnimationsAndSendEvents() 383 350 { 384 351 m_numberOfAnimationTimelineInvalidationsForTesting++; 385 386 m_isUpdatingAnimations = true;387 352 388 353 // https://drafts.csswg.org/web-animations/#update-animations-and-send-events … … 448 413 for (auto& completedTransition : completedTransitions) 449 414 transitionDidComplete(completedTransition); 450 451 m_isUpdatingAnimations = false;452 415 } 453 416 … … 473 436 for (const auto& animation : m_animations) { 474 437 if (!animation->isRunningAccelerated()) { 475 scheduleAnimationResolution IfNeeded();438 scheduleAnimationResolution(); 476 439 return; 477 440 } … … 483 446 auto animationTimeToNextRequiredTick = animation->timeToNextTick(); 484 447 if (animationTimeToNextRequiredTick < animationInterval()) { 485 scheduleAnimationResolution IfNeeded();448 scheduleAnimationResolution(); 486 449 return; 487 450 } … … 593 556 { 594 557 auto animations = animationsForElement(element); 595 bool runningAnimationsForElementAreAllAccelerated = !animations.isEmpty(); 558 559 if (animations.isEmpty()) { 560 m_elementsWithRunningAcceleratedAnimations.remove(&element); 561 return; 562 } 563 596 564 for (const auto& animation : animations) { 597 565 if (!animation->isRunningAccelerated()) { 598 runningAnimationsForElementAreAllAccelerated = false; 599 break; 600 } 601 } 602 603 if (runningAnimationsForElementAreAllAccelerated) 604 m_elementsWithRunningAcceleratedAnimations.add(&element); 605 else 606 m_elementsWithRunningAcceleratedAnimations.remove(&element); 566 m_elementsWithRunningAcceleratedAnimations.remove(&element); 567 return; 568 } 569 } 570 571 m_elementsWithRunningAcceleratedAnimations.add(&element); 607 572 } 608 573 … … 625 590 bool DocumentTimeline::resolveAnimationsForElement(Element& element, RenderStyle& targetStyle) 626 591 { 627 bool hasNonAcceleratedAnimation s= false;628 bool hasPendingAcceleratedAnimations = true; 592 bool hasNonAcceleratedAnimationProperty = false; 593 629 594 for (const auto& animation : animationsForElement(element)) { 630 595 animation->resolve(targetStyle); 631 if (!hasNonAcceleratedAnimations) { 632 if (auto* effect = animation->effect()) {633 if (is<KeyframeEffect>(effect)) {634 auto* keyframeEffect = downcast<KeyframeEffect>(effect); 635 for (auto cssPropertyId : keyframeEffect->animatedProperties()) {636 if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) {637 hasNonAcceleratedAnimations = true;638 continue; 639 }640 if (!hasPendingAcceleratedAnimations)641 hasPendingAcceleratedAnimations = keyframeEffect->hasPendingAcceleratedAction();642 }643 }596 597 if (hasNonAcceleratedAnimationProperty) 598 continue; 599 600 auto* effect = animation->effect(); 601 if (!effect || !is<KeyframeEffect>(effect)) 602 continue; 603 604 auto* keyframeEffect = downcast<KeyframeEffect>(effect); 605 for (auto cssPropertyId : keyframeEffect->animatedProperties()) { 606 if (!CSSPropertyAnimation::animationOfPropertyIsAccelerated(cssPropertyId)) { 607 hasNonAcceleratedAnimationProperty = true; 608 break; 644 609 } 645 610 } 646 611 } 647 612 648 // If there are no non-accelerated animations and we've encountered at least one pending 649 // accelerated animation, we should recomposite this element's layer for animation purposes. 650 return !hasNonAcceleratedAnimations && hasPendingAcceleratedAnimations; 613 return !hasNonAcceleratedAnimationProperty; 651 614 } 652 615 -
trunk/Source/WebCore/animation/DocumentTimeline.h
r242714 r244182 72 72 73 73 void enqueueAnimationPlaybackEvent(AnimationPlaybackEvent&); 74 75 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 76 void documentAnimationSchedulerDidFire(); 77 #endif 74 75 void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp); 78 76 79 77 void updateThrottlingState(); … … 89 87 DocumentTimeline(Document&, Seconds); 90 88 91 SecondsliveCurrentTime() const;92 void cacheCurrentTime( Seconds);93 void scheduleAnimationResolutionIfNeeded();89 DOMHighResTimeStamp liveCurrentTime() const; 90 void cacheCurrentTime(DOMHighResTimeStamp); 91 void maybeClearCachedCurrentTime(); 94 92 void scheduleInvalidationTaskIfNeeded(); 95 93 void performInvalidationTask(); 96 void animationScheduleTimerFired();97 94 void scheduleAnimationResolution(); 98 95 void unscheduleAnimationResolution(); 99 void updateAnimationsAndSendEvents();96 void internalUpdateAnimationsAndSendEvents(); 100 97 void performEventDispatchTask(); 101 void maybeClearCachedCurrentTime();102 98 void updateListOfElementsWithRunningAcceleratedAnimationsForElement(Element&); 103 99 void transitionDidComplete(RefPtr<CSSTransition>); 104 100 void scheduleNextTick(); 105 106 #if !USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)107 void animationResolutionTimerFired();108 Timer m_animationResolutionTimer;109 #endif110 101 111 102 Timer m_tickScheduleTimer; … … 120 111 bool m_isSuspended { false }; 121 112 bool m_waitingOnVMIdle { false }; 122 bool m_ isUpdatingAnimations{ false };113 bool m_animationResolutionScheduled { false }; 123 114 }; 124 115 -
trunk/Source/WebCore/dom/Document.cpp
r244151 r244182 58 58 #include "DateComponents.h" 59 59 #include "DebugPageOverlays.h" 60 #include "DocumentAnimationScheduler.h"61 60 #include "DocumentLoader.h" 62 61 #include "DocumentMarkerController.h" … … 1942 1941 1943 1942 // Usually this is handled by post-layout. 1944 if (!frameView.needsLayout()) {1943 if (!frameView.needsLayout()) 1945 1944 frameView.frame().selection().scheduleAppearanceUpdateAfterStyleChange(); 1946 if (m_needsForcedIntersectionObservationUpdate)1947 page()->scheduleForcedIntersectionObservationUpdate(*this);1948 }1949 1945 1950 1946 // As a result of the style recalculation, the currently hovered element might have been … … 2542 2538 } 2543 2539 2544 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)2545 if (m_animationScheduler) {2546 m_animationScheduler->detachFromDocument();2547 m_animationScheduler = nullptr;2548 }2549 #endif2550 2551 2540 #if ENABLE(CSS_PAINTING_API) 2552 2541 for (auto& scope : m_paintWorkletGlobalScopes.values()) … … 6266 6255 } 6267 6256 6257 void Document::updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp) 6258 { 6259 if (m_timeline) 6260 m_timeline->updateAnimationsAndSendEvents(timestamp); 6261 } 6262 6263 void Document::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp) 6264 { 6265 if (m_scriptedAnimationController) 6266 m_scriptedAnimationController->serviceRequestAnimationFrameCallbacks(timestamp); 6267 } 6268 6268 6269 void Document::windowScreenDidChange(PlatformDisplayID displayID) 6269 6270 { 6270 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)6271 if (m_animationScheduler)6272 m_animationScheduler->windowScreenDidChange(displayID);6273 #endif6274 6275 6271 if (RenderView* view = renderView()) { 6276 6272 if (view->usesCompositing()) … … 7811 7807 } 7812 7808 7809 void Document::scheduleRenderingUpdate() 7810 { 7811 if (auto page = this->page()) 7812 page->renderingUpdateScheduler().scheduleRenderingUpdate(); 7813 } 7814 7813 7815 #if ENABLE(INTERSECTION_OBSERVER) 7814 7816 void Document::addIntersectionObserver(IntersectionObserver& observer) … … 7941 7943 if (needsLayout || hasPendingStyleRecalc()) 7942 7944 return; 7943 7944 m_needsForcedIntersectionObservationUpdate = false;7945 7945 7946 7946 for (const auto& observer : m_intersectionObservers) { … … 8020 8020 } 8021 8021 8022 void Document::scheduleForcedIntersectionObservationUpdate()8023 {8024 ASSERT(!m_intersectionObservers.isEmpty());8025 if (m_needsForcedIntersectionObservationUpdate)8026 return;8027 8028 m_needsForcedIntersectionObservationUpdate = true;8029 if (auto* page = this->page())8030 page->scheduleForcedIntersectionObservationUpdate(*this);8031 }8032 8033 8022 void Document::notifyIntersectionObserversTimerFired() 8034 8023 { … … 8044 8033 void Document::addResizeObserver(ResizeObserver& observer) 8045 8034 { 8046 ASSERT(m_resizeObservers.find(&observer) == notFound);8047 m_resizeObservers.append(makeWeakPtr(&observer));8035 if (!m_resizeObservers.contains(&observer)) 8036 m_resizeObservers.append(makeWeakPtr(&observer)); 8048 8037 } 8049 8038 … … 8094 8083 } 8095 8084 8096 void Document::scheduleResizeObservations() 8097 { 8098 if (!page()) 8099 return; 8100 page()->scheduleResizeObservations(); 8085 void Document::updateResizeObservations(Page& page) 8086 { 8087 if (!hasResizeObservers()) 8088 return; 8089 8090 // We need layout the whole frame tree here. Because ResizeObserver could observe element in other frame, 8091 // and it could change other frame in deliverResizeObservations(). 8092 page.layoutIfNeeded(); 8093 8094 // Start check resize obervers; 8095 for (size_t depth = gatherResizeObservations(0); depth != ResizeObserver::maxElementDepth(); depth = gatherResizeObservations(depth)) { 8096 deliverResizeObservations(); 8097 page.layoutIfNeeded(); 8098 } 8099 8100 if (hasSkippedResizeObservations()) { 8101 setHasSkippedResizeObservations(false); 8102 String url; 8103 unsigned line = 0; 8104 unsigned column = 0; 8105 getParserLocation(url, line, column); 8106 reportException("ResizeObserver loop completed with undelivered notifications.", line, column, url, nullptr, nullptr); 8107 // Starting a new schedule the next round of notify. 8108 scheduleRenderingUpdate(); 8109 } 8101 8110 } 8102 8111 #endif … … 8525 8534 } 8526 8535 8527 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)8528 DocumentAnimationScheduler& Document::animationScheduler()8529 {8530 if (!m_animationScheduler)8531 m_animationScheduler = DocumentAnimationScheduler::create(*this, page() ? page()->chrome().displayID() : 0);8532 8533 return *m_animationScheduler;8534 }8535 #endif8536 8537 8536 DocumentTimeline& Document::timeline() 8538 8537 { -
trunk/Source/WebCore/dom/Document.h
r244151 r244182 109 109 class DatabaseThread; 110 110 class DeferredPromise; 111 class DocumentAnimationScheduler;112 111 class DocumentFragment; 113 112 class DocumentLoader; … … 1057 1056 void suspendScriptedAnimationControllerCallbacks(); 1058 1057 void resumeScriptedAnimationControllerCallbacks(); 1059 1058 1059 void updateAnimationsAndSendEvents(DOMHighResTimeStamp timestamp); 1060 void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp); 1061 1060 1062 void windowScreenDidChange(PlatformDisplayID); 1061 1063 … … 1412 1414 void removeAppearanceDependentPicture(HTMLPictureElement&); 1413 1415 1416 void scheduleRenderingUpdate(); 1417 1414 1418 #if ENABLE(INTERSECTION_OBSERVER) 1415 1419 void addIntersectionObserver(IntersectionObserver&); 1416 1420 void removeIntersectionObserver(IntersectionObserver&); 1417 1421 unsigned numberOfIntersectionObservers() const { return m_intersectionObservers.size(); } 1418 void scheduleForcedIntersectionObservationUpdate();1419 1422 void updateIntersectionObservations(); 1420 1423 #endif … … 1429 1432 bool hasSkippedResizeObservations() const; 1430 1433 void setHasSkippedResizeObservations(bool); 1431 void scheduleResizeObservations();1434 void updateResizeObservations(Page&); 1432 1435 #endif 1433 1436 … … 1501 1504 WEBCORE_EXPORT void setConsoleMessageListener(RefPtr<StringCallback>&&); // For testing. 1502 1505 1503 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)1504 DocumentAnimationScheduler& animationScheduler();1505 #endif1506 1507 1506 WEBCORE_EXPORT DocumentTimeline& timeline(); 1508 1507 DocumentTimeline* existingTimeline() const { return m_timeline.get(); } … … 2072 2071 #endif 2073 2072 2074 #if ENABLE(INTERSECTION_OBSERVER)2075 bool m_needsForcedIntersectionObservationUpdate { false };2076 #endif2077 2078 2073 #if ENABLE(MEDIA_STREAM) 2079 2074 HashSet<HTMLMediaElement*> m_mediaStreamStateChangeElements; … … 2095 2090 bool m_grantStorageAccessOverride { false }; 2096 2091 2097 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)2098 RefPtr<DocumentAnimationScheduler> m_animationScheduler;2099 #endif2100 2092 RefPtr<DocumentTimeline> m_timeline; 2101 2093 DocumentIdentifier m_identifier; -
trunk/Source/WebCore/dom/ScriptedAnimationController.cpp
r243810 r244182 31 31 #include "DOMWindow.h" 32 32 #include "Document.h" 33 #include "DocumentAnimationScheduler.h"34 33 #include "DocumentLoader.h" 35 34 #include "Frame.h" … … 190 189 } 191 190 192 void ScriptedAnimationController::service ScriptedAnimations(doubletimestamp)191 void ScriptedAnimationController::serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp) 193 192 { 194 193 if (!m_callbacks.size() || m_suspendCount || !requestAnimationFrameEnabled()) … … 198 197 199 198 // We round this to the nearest microsecond so that we can return a time that matches what is returned by document.timeline.currentTime. 200 doublehighResNowMs = std::round(1000 * timestamp);199 DOMHighResTimeStamp highResNowMs = std::round(1000 * timestamp); 201 200 202 201 // First, generate a list of callbacks to consider. Callbacks registered from this point … … 210 209 211 210 for (auto& callback : callbacks) { 212 if ( !callback->m_firedOrCancelled) {213 c allback->m_firedOrCancelled = true;214 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id);215 callback->handleEvent(highResNowMs);216 InspectorInstrumentation::didFireAnimationFrame(cookie);217 }211 if (callback->m_firedOrCancelled) 212 continue; 213 callback->m_firedOrCancelled = true; 214 InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(protectedDocument, callback->m_id); 215 callback->handleEvent(highResNowMs); 216 InspectorInstrumentation::didFireAnimationFrame(cookie); 218 217 } 219 218 220 219 // Remove any callbacks we fired from the list of pending callbacks. 221 for (size_t i = 0; i < m_callbacks.size();) { 222 if (m_callbacks[i]->m_firedOrCancelled) 223 m_callbacks.remove(i); 224 else 225 ++i; 226 } 220 m_callbacks.removeAllMatching([](auto& callback) { 221 return callback->m_firedOrCancelled; 222 }); 227 223 228 224 if (m_callbacks.size()) … … 259 255 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 260 256 if (!m_isUsingTimer && !isThrottled()) { 261 if (m_document->animationScheduler().scheduleScriptedAnimationResolution()) 257 if (auto* page = this->page()) { 258 page->renderingUpdateScheduler().scheduleRenderingUpdate(); 262 259 return; 260 } 263 261 264 262 m_isUsingTimer = true; … … 289 287 { 290 288 m_lastAnimationFrameTimestamp = m_document->domWindow()->nowTimestamp(); 291 serviceScriptedAnimations(m_lastAnimationFrameTimestamp); 292 } 293 294 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 295 void ScriptedAnimationController::documentAnimationSchedulerDidFire() 296 { 297 // We obtain the time from the animation scheduler so that we use the same timestamp as the DocumentTimeline. 298 serviceScriptedAnimations(m_document->animationScheduler().lastTimestamp().seconds()); 299 } 300 #endif 301 302 } 289 serviceRequestAnimationFrameCallbacks(m_lastAnimationFrameTimestamp); 290 } 291 292 } -
trunk/Source/WebCore/dom/ScriptedAnimationController.h
r243459 r244182 53 53 CallbackId registerCallback(Ref<RequestAnimationFrameCallback>&&); 54 54 void cancelCallback(CallbackId); 55 void service ScriptedAnimations(doubletimestamp);55 void serviceRequestAnimationFrameCallbacks(DOMHighResTimeStamp timestamp); 56 56 57 57 void suspend(); … … 69 69 WEBCORE_EXPORT bool isThrottled() const; 70 70 WEBCORE_EXPORT Seconds interval() const; 71 72 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)73 void documentAnimationSchedulerDidFire();74 #endif75 71 76 72 private: -
trunk/Source/WebCore/page/FrameView.cpp
r244141 r244182 1268 1268 void FrameView::didLayout(WeakPtr<RenderElement> layoutRoot) 1269 1269 { 1270 #if ENABLE(RESIZE_OBSERVER)1271 auto page = frame().page();1272 if (page && page->hasResizeObservers())1273 page->setNeedsCheckResizeObservations(true);1274 #endif1275 1270 renderView()->releaseProtectedRenderWidgets(); 1276 1271 auto* layoutRootEnclosingLayer = layoutRoot->enclosingLayer(); … … 1977 1972 renderView->updateVisibleViewportRect(visibleRect); 1978 1973 }); 1979 1980 #if ENABLE(INTERSECTION_OBSERVER)1981 if (auto* document = frame().document()) {1982 if (auto* page = frame().page()) {1983 if (document->numberOfIntersectionObservers())1984 page->addDocumentNeedingIntersectionObservationUpdate(*document);1985 if (!frame().isMainFrame()) {1986 if (auto* mainDocument = frame().mainFrame().document()) {1987 if (mainDocument->numberOfIntersectionObservers())1988 page->addDocumentNeedingIntersectionObservationUpdate(*mainDocument);1989 }1990 }1991 }1992 }1993 #endif1994 1974 } 1995 1975 -
trunk/Source/WebCore/page/FrameViewLayoutContext.cpp
r243919 r244182 457 457 #endif 458 458 layout(); 459 460 #if ENABLE(RESIZE_OBSERVER)461 // After this layout, it might not trigger display timer. E.g.: Running layout test for WK1.462 // So scheduleResizeObservations() here to make sure ResizeObserver could be fired properly.463 auto page = frame().page();464 if (page && page->needsCheckResizeObservations())465 page->scheduleResizeObservations();466 #endif467 459 } 468 460 -
trunk/Source/WebCore/page/IntersectionObserver.cpp
r244115 r244182 159 159 if (!hadObservationTargets) 160 160 document->addIntersectionObserver(*this); 161 document->scheduleForcedIntersectionObservationUpdate();162 161 } 163 162 -
trunk/Source/WebCore/page/Page.cpp
r243762 r244182 123 123 #include "WheelEventDeltaFilter.h" 124 124 #include "Widget.h" 125 #if ENABLE(RESIZE_OBSERVER)126 #include <JavaScriptCore/ScriptCallStack.h>127 #endif128 125 #include <wtf/FileSystem.h> 129 126 #include <wtf/RefCountedLeakCounter.h> 130 127 #include <wtf/StdLibExtras.h> 128 #include <wtf/SystemTracing.h> 131 129 #include <wtf/text/Base64.h> 132 130 #include <wtf/text/StringHash.h> … … 258 256 , m_userContentProvider(*WTFMove(pageConfiguration.userContentProvider)) 259 257 , m_visitedLinkStore(*WTFMove(pageConfiguration.visitedLinkStore)) 260 #if ENABLE(INTERSECTION_OBSERVER)261 , m_intersectionObservationUpdateTimer(*this, &Page::updateIntersectionObservations)262 #endif263 258 , m_sessionID(PAL::SessionID::defaultSessionID()) 264 259 #if ENABLE(VIDEO) 265 260 , m_playbackControlsManagerUpdateTimer(*this, &Page::playbackControlsManagerUpdateTimerFired) 266 #endif267 #if ENABLE(RESIZE_OBSERVER)268 , m_resizeObserverTimer(*this, &Page::checkResizeObservations)269 261 #endif 270 262 , m_isUtilityPage(isUtilityPageChromeClient(chrome().client())) … … 1122 1114 } 1123 1115 1124 void Page::willDisplayPage()1125 {1126 #if ENABLE(RESIZE_OBSERVER)1127 checkResizeObservations();1128 #endif1129 1130 #if ENABLE(INTERSECTION_OBSERVER)1131 updateIntersectionObservations();1132 #endif1133 }1134 1135 1116 bool Page::isOnlyNonUtilityPage() const 1136 1117 { … … 1274 1255 } 1275 1256 1257 void Page::layoutIfNeeded() 1258 { 1259 if (FrameView* view = m_mainFrame->view()) 1260 view->updateLayoutAndStyleIfNeededRecursive(); 1261 } 1262 1263 void Page::updateRendering() 1264 { 1265 // This function is not reentrant, e.g. a rAF callback may force repaint. 1266 if (m_inUpdateRendering) { 1267 layoutIfNeeded(); 1268 return; 1269 } 1270 1271 TraceScope traceScope(RenderingUpdateStart, RenderingUpdateEnd); 1272 1273 SetForScope<bool> change(m_inUpdateRendering, true); 1274 1275 Vector<RefPtr<Document>> documents; 1276 1277 // The requestAnimationFrame callbacks may change the frame hierarchy of the page 1278 forEachDocument([&documents] (Document& document) { 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 1276 1290 #if ENABLE(INTERSECTION_OBSERVER) 1277 void Page::addDocumentNeedingIntersectionObservationUpdate(Document& document) 1278 { 1279 if (m_documentsNeedingIntersectionObservationUpdate.find(&document) == notFound) 1280 m_documentsNeedingIntersectionObservationUpdate.append(makeWeakPtr(document)); 1281 } 1282 1283 void Page::updateIntersectionObservations() 1284 { 1285 m_intersectionObservationUpdateTimer.stop(); 1286 for (const auto& document : m_documentsNeedingIntersectionObservationUpdate) { 1287 if (document) 1288 document->updateIntersectionObservations(); 1289 } 1290 m_documentsNeedingIntersectionObservationUpdate.clear(); 1291 } 1292 1293 void Page::scheduleForcedIntersectionObservationUpdate(Document& document) 1294 { 1295 addDocumentNeedingIntersectionObservationUpdate(document); 1296 if (m_intersectionObservationUpdateTimer.isActive()) 1297 return; 1298 m_intersectionObservationUpdateTimer.startOneShot(0_s); 1299 } 1300 #endif 1301 1291 for (auto& document : documents) 1292 document->updateIntersectionObservations(); 1293 #endif 1302 1294 #if ENABLE(RESIZE_OBSERVER) 1303 bool Page::hasResizeObservers() const 1304 { 1305 for (const Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) { 1306 auto doc = frame->document(); 1307 if (doc && doc->hasResizeObservers()) 1308 return true; 1309 } 1310 return false; 1311 } 1312 1313 void Page::gatherDocumentsNeedingResizeObservationCheck(Vector<WeakPtr<Document>>& documentsNeedingResizeObservationCheck) 1314 { 1315 forEachDocument([&] (Document& document) { 1316 if (document.hasResizeObservers()) 1317 documentsNeedingResizeObservationCheck.append(makeWeakPtr(document)); 1318 }); 1319 } 1320 1321 void Page::checkResizeObservations() 1322 { 1323 if (!needsCheckResizeObservations()) 1324 return; 1325 setNeedsCheckResizeObservations(false); 1326 m_resizeObserverTimer.stop(); 1327 1328 Vector<WeakPtr<Document>> documentsNeedingResizeObservationCheck; 1329 gatherDocumentsNeedingResizeObservationCheck(documentsNeedingResizeObservationCheck); 1330 for (const auto& document : documentsNeedingResizeObservationCheck) 1331 notifyResizeObservers(document); 1332 documentsNeedingResizeObservationCheck.clear(); 1333 } 1334 1335 void Page::scheduleResizeObservations() 1336 { 1337 setNeedsCheckResizeObservations(true); 1338 if (m_resizeObserverTimer.isActive()) 1339 return; 1340 m_resizeObserverTimer.startOneShot(0_s); 1341 } 1342 1343 void Page::notifyResizeObservers(WeakPtr<Document> document) 1344 { 1345 if (!document) 1346 return; 1347 1348 // We need layout the whole frame tree here. Because ResizeObserver could observe element in other frame, 1349 // and it could change other frame in deliverResizeObservations(). 1350 if (mainFrame().view()) 1351 mainFrame().view()->updateLayoutAndStyleIfNeededRecursive(); 1352 1353 // Start check resize obervers; 1354 for (size_t depth = document->gatherResizeObservations(0); depth != ResizeObserver::maxElementDepth(); depth = document->gatherResizeObservations(depth)) { 1355 document->deliverResizeObservations(); 1356 if (!document) 1357 return; 1358 if (mainFrame().view()) 1359 mainFrame().view()->updateLayoutAndStyleIfNeededRecursive(); 1360 } 1361 1362 if (document->hasSkippedResizeObservations()) { 1363 document->setHasSkippedResizeObservations(false); 1364 String url; 1365 unsigned line = 0; 1366 unsigned column = 0; 1367 document->getParserLocation(url, line, column); 1368 document->reportException("ResizeObserver loop completed with undelivered notifications.", line, column, url, nullptr, nullptr); 1369 // TODO: We are starting a timer to schedule the next round of notify. 1370 // However, this should be in synchrony with the next requestAnimationFrame. 1371 scheduleResizeObservations(); 1372 } 1373 } 1374 #endif 1295 for (auto& document : documents) 1296 document->updateResizeObservations(*this); 1297 #endif 1298 1299 layoutIfNeeded(); 1300 } 1375 1301 1376 1302 void Page::suspendScriptedAnimations() … … 2912 2838 } 2913 2839 2840 RenderingUpdateScheduler& Page::renderingUpdateScheduler() 2841 { 2842 if (!m_renderingUpdateScheduler) 2843 m_renderingUpdateScheduler = RenderingUpdateScheduler::create(*this); 2844 return *m_renderingUpdateScheduler; 2845 } 2846 2914 2847 void Page::forEachDocument(const Function<void(Document&)>& functor) 2915 2848 { -
trunk/Source/WebCore/page/Page.h
r243899 r244182 34 34 #include "Region.h" 35 35 #include "RegistrableDomain.h" 36 #include "RenderingUpdateScheduler.h" 36 37 #include "ScrollTypes.h" 37 38 #include "Supplementable.h" … … 265 266 PerformanceMonitor* performanceMonitor() { return m_performanceMonitor.get(); } 266 267 268 RenderingUpdateScheduler& renderingUpdateScheduler(); 269 267 270 ValidationMessageClient* validationMessageClient() const { return m_validationMessageClient.get(); } 268 271 void updateValidationBubbleStateIfNeeded(); … … 340 343 void didFinishLoad(); // Called when the load has been committed in the main frame. 341 344 342 WEBCORE_EXPORT void willDisplayPage();343 344 345 // The view scale factor is multiplied into the page scale factor by all 345 346 // callers of setPageScaleFactor. … … 469 470 WEBCORE_EXPORT void removeActivityStateChangeObserver(ActivityStateChangeObserver&); 470 471 471 #if ENABLE(INTERSECTION_OBSERVER) 472 void addDocumentNeedingIntersectionObservationUpdate(Document&); 473 void scheduleForcedIntersectionObservationUpdate(Document&); 474 void updateIntersectionObservations(); 475 #endif 476 477 #if ENABLE(RESIZE_OBSERVER) 478 WEBCORE_EXPORT void checkResizeObservations(); 479 bool hasResizeObservers() const; 480 void gatherDocumentsNeedingResizeObservationCheck(Vector<WeakPtr<Document>>&); 481 void scheduleResizeObservations(); 482 void notifyResizeObservers(WeakPtr<Document>); 483 void setNeedsCheckResizeObservations(bool check) { m_needsCheckResizeObservations = check; } 484 bool needsCheckResizeObservations() const { return m_needsCheckResizeObservations; } 485 486 #endif 472 WEBCORE_EXPORT void layoutIfNeeded(); 473 WEBCORE_EXPORT void updateRendering(); 487 474 488 475 WEBCORE_EXPORT void suspendScriptedAnimations(); … … 888 875 int m_headerHeight { 0 }; 889 876 int m_footerHeight { 0 }; 877 878 std::unique_ptr<RenderingUpdateScheduler> m_renderingUpdateScheduler; 890 879 891 880 HashSet<RenderObject*> m_relevantUnpaintedRenderObjects; … … 929 918 HashSet<ActivityStateChangeObserver*> m_activityStateChangeObservers; 930 919 931 #if ENABLE(INTERSECTION_OBSERVER)932 Vector<WeakPtr<Document>> m_documentsNeedingIntersectionObservationUpdate;933 934 // FIXME: Schedule intersection observation updates in a way that fits into the HTML935 // EventLoop. See https://bugs.webkit.org/show_bug.cgi?id=160711.936 Timer m_intersectionObservationUpdateTimer;937 #endif938 939 920 #if ENABLE(RESOURCE_USAGE) 940 921 std::unique_ptr<ResourceUsageOverlay> m_resourceUsageOverlay; … … 950 931 #if ENABLE(VIDEO) 951 932 Timer m_playbackControlsManagerUpdateTimer; 952 #endif953 954 #if ENABLE(RESIZE_OBSERVER)955 Timer m_resizeObserverTimer;956 bool m_needsCheckResizeObservations { false };957 933 #endif 958 934 … … 1002 978 bool m_mediaPlaybackIsSuspended { false }; 1003 979 bool m_mediaBufferingIsSuspended { false }; 980 bool m_inUpdateRendering { false }; 1004 981 }; 1005 982 -
trunk/Source/WebCore/page/PageOverlayController.cpp
r242714 r244182 319 319 void PageOverlayController::didChangeViewExposedRect() 320 320 { 321 m_page. chrome().client().scheduleCompositingLayerFlush();321 m_page.renderingUpdateScheduler().scheduleRenderingUpdate(); 322 322 } 323 323 … … 413 413 void PageOverlayController::notifyFlushRequired(const WebCore::GraphicsLayer*) 414 414 { 415 m_page. chrome().client().scheduleCompositingLayerFlush();415 m_page.renderingUpdateScheduler().scheduleRenderingUpdate(); 416 416 } 417 417 -
trunk/Source/WebCore/page/RenderingUpdateScheduler.h
r244181 r244182 1 1 /* 2 * Copyright (C) 201 8Apple Inc. All rights reserved.2 * Copyright (C) 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 26 26 #pragma once 27 27 28 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR)29 30 28 #include "DisplayRefreshMonitorClient.h" 31 #include "PlatformScreen.h"32 #include <wtf/Ref.h>33 #include <wtf/RefCounted.h>34 #include <wtf/RefPtr.h>35 29 #include <wtf/Seconds.h> 36 30 37 31 namespace WebCore { 38 32 39 class Document; 33 class Page; 34 class Timer; 40 35 41 class DocumentAnimationScheduler : public RefCounted<DocumentAnimationScheduler> 42 , public DisplayRefreshMonitorClient { 36 class RenderingUpdateScheduler 37 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 38 : public DisplayRefreshMonitorClient 39 #endif 40 { 41 WTF_MAKE_FAST_ALLOCATED; 43 42 public: 44 static Ref<DocumentAnimationScheduler> create(Document&, PlatformDisplayID); 45 ~DocumentAnimationScheduler(); 43 static std::unique_ptr<RenderingUpdateScheduler> create(Page& page) 44 { 45 return std::make_unique<RenderingUpdateScheduler>(page); 46 } 46 47 47 void detachFromDocument(); 48 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; } 48 RenderingUpdateScheduler(Page&); 49 void scheduleRenderingUpdate(); 50 void scheduleCompositingLayerFlush(); 56 51 57 52 private: 58 DocumentAnimationScheduler(Document&, PlatformDisplayID); 53 #if USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 54 RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const final; 55 void windowScreenDidChange(PlatformDisplayID); 56 void displayRefreshFired() final; 57 #else 58 void displayRefreshFired(); 59 #endif 59 60 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 }; 61 bool isScheduled() const; 62 void startTimer(Seconds); 63 void clearScheduled(); 65 64 66 void displayRefreshFired() override; 67 RefPtr<DisplayRefreshMonitor> createDisplayRefreshMonitor(PlatformDisplayID) const override; 65 Page& m_page; 66 bool m_scheduled { false }; 67 std::unique_ptr<Timer> m_refreshTimer; 68 68 }; 69 69 70 } // namespace WebCore 71 72 #endif // USE(REQUEST_ANIMATION_FRAME_DISPLAY_MONITOR) 70 } -
trunk/Source/WebCore/page/ResizeObserver.cpp
r243643 r244182 54 54 } 55 55 56 void ResizeObserver::scheduleObservations()57 {58 if (m_document)59 m_document->scheduleResizeObservations();60 }61 62 56 void ResizeObserver::observe(Element& target) 63 57 { … … 65 59 return; 66 60 67 for (auto& observation : m_observations) { 68 if (observation->target() == &target) 69 return; 70 } 61 auto position = m_observations.findMatching([&](auto& observation) { 62 return observation->target() == ⌖ 63 }); 64 65 if (position != notFound) 66 return; 71 67 72 68 auto& observerData = target.ensureResizeObserverData(); 73 69 observerData.observers.append(makeWeakPtr(this)); 74 if (m_document && !hasObservations()) 75 m_document->addResizeObserver(*this); 70 76 71 m_observations.append(ResizeObservation::create(&target)); 77 72 78 scheduleObservations(); 73 if (m_document) { 74 m_document->addResizeObserver(*this); 75 m_document->scheduleRenderingUpdate(); 76 } 79 77 } 80 78 -
trunk/Source/WebCore/page/ResizeObserver.h
r243643 r244182 51 51 bool hasObservations() const { return m_observations.size(); } 52 52 bool hasActiveObservations() const { return m_activeObservations.size(); } 53 void scheduleObservations();54 53 55 54 void observe(Element&); -
trunk/Source/WebCore/page/ios/ContentChangeObserver.h
r243752 r244182 29 29 30 30 #include "CSSPropertyNames.h" 31 #include "Document.h" 31 32 #include "PlatformEvent.h" 33 #include "RenderStyleConstants.h" 32 34 #include "Timer.h" 33 35 #include "WKContentObservation.h" 34 36 #include <wtf/HashSet.h> 37 #include <wtf/Seconds.h> 35 38 36 39 namespace WebCore { … … 38 41 class Animation; 39 42 class DOMTimer; 40 class Document;41 43 class Element; 42 44 -
trunk/Source/WebCore/page/mac/ServicesOverlayController.mm
r242714 r244182 122 122 return; 123 123 124 m_controller->page(). chrome().client().scheduleCompositingLayerFlush();124 m_controller->page().renderingUpdateScheduler().scheduleRenderingUpdate(); 125 125 } 126 126 -
trunk/Source/WebCore/page/scrolling/ScrollingStateTree.cpp
r243539 r244182 35 35 #include "ScrollingStateFrameScrollingNode.h" 36 36 #include "ScrollingStateOverflowScrollingNode.h" 37 #include "ScrollingStatePositionedNode.h" 37 38 #include "ScrollingStateStickyNode.h" 38 39 #include <wtf/text/CString.h> -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r244068 r244182 451 451 { 452 452 m_hasPendingLayerFlush = false; 453 page(). chrome().client().scheduleCompositingLayerFlush();453 page().renderingUpdateScheduler().scheduleRenderingUpdate(); 454 454 } 455 455 … … 1924 1924 1925 1925 flushPendingLayerChanges(true); 1926 page().renderingUpdateScheduler().scheduleCompositingLayerFlush(); 1926 1927 1927 1928 LayerTreeAsTextBehavior layerTreeBehavior = LayerTreeAsTextBehaviorNormal; -
trunk/Source/WebKit/ChangeLog
r244180 r244182 1 2019-04-10 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::updateRendering(). 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/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp: 14 (WebKit::DrawingAreaCoordinatedGraphics::scheduleCompositingLayerFlush): 15 (WebKit::DrawingAreaCoordinatedGraphics::updateBackingStoreState): 16 (WebKit::DrawingAreaCoordinatedGraphics::display): 17 * WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp: 18 (WebKit::LayerTreeHost::layerFlushTimerFired): 19 20 * WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm: 21 (WebKit::RemoteLayerTreeDrawingArea::flushLayers): 22 -- Call Page::updateRendering() to make sure that "Update the rendering" 23 happens immediately before updating the page. 24 25 -- Move the call to RemoteLayerBackingStoreCollection::willFlushLayers() 26 to be exactly before flushing the layers. This fixes the assertion 27 ASSERT(m_inLayerFlush) which was firing when running a layout test. 28 RemoteLayerTreeDrawingArea::flushLayers() now can call itself through 29 TestRunner::notifyDone(). flushLayers() was calling willFlushLayers() 30 twice before calling didFlushLayers(). 31 32 * WebProcess/WebPage/WebPage.cpp: 33 (WebKit::WebPage::layoutIfNeeded): 34 (WebKit::WebPage::updateRendering): 35 (WebKit::WebPage::willDisplayPage): Deleted. 36 * WebProcess/WebPage/WebPage.h: 37 * WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm: 38 (WebKit::TiledCoreAnimationDrawingArea::flushLayers): 39 1 40 2019-04-10 Devin Rousso <drousso@apple.com> 2 41 -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/DrawingAreaCoordinatedGraphics.cpp
r243796 r244182 304 304 if (m_layerTreeHost) 305 305 m_layerTreeHost->scheduleLayerFlush(); 306 else 307 setNeedsDisplay(); 306 308 } 307 309 … … 382 384 m_webPage.setDeviceScaleFactor(deviceScaleFactor); 383 385 m_webPage.setSize(size); 384 m_webPage. layoutIfNeeded();386 m_webPage.updateRendering(); 385 387 m_webPage.flushPendingEditorStateUpdate(); 386 388 m_webPage.scrollMainFrameIfNotAtMaxScrollPosition(scrollOffset); 387 m_webPage.willDisplayPage();388 389 389 390 if (m_layerTreeHost) … … 707 708 ASSERT(!m_webPage.size().isEmpty()); 708 709 709 m_webPage. layoutIfNeeded();710 m_webPage.updateRendering(); 710 711 m_webPage.flushPendingEditorStateUpdate(); 711 712 … … 715 716 return; 716 717 717 m_webPage.willDisplayPage();718 718 updateInfo.viewSize = m_webPage.size(); 719 719 updateInfo.deviceScaleFactor = m_webPage.corePage()->deviceScaleFactor(); -
trunk/Source/WebKit/WebProcess/WebPage/CoordinatedGraphics/LayerTreeHost.cpp
r243865 r244182 146 146 147 147 m_coordinator.syncDisplayState(); 148 m_webPage.updateRendering(); 148 149 m_webPage.flushPendingEditorStateUpdate(); 149 m_webPage.willDisplayPage();150 150 151 151 if (!m_isValid || !m_coordinator.rootCompositingLayer()) -
trunk/Source/WebKit/WebProcess/WebPage/RemoteLayerTree/RemoteLayerTreeDrawingArea.mm
r242714 r244182 345 345 } 346 346 347 RELEASE_ASSERT(!m_pendingBackingStoreFlusher || m_pendingBackingStoreFlusher->hasFlushed()); 348 349 RemoteLayerBackingStoreCollection& backingStoreCollection = m_remoteLayerTreeContext->backingStoreCollection(); 350 backingStoreCollection.willFlushLayers(); 351 352 m_webPage.layoutIfNeeded(); 353 m_webPage.willDisplayPage(); 347 m_webPage.updateRendering(); 354 348 355 349 FloatRect visibleRect(FloatPoint(), m_viewSize); … … 373 367 if (m_viewOverlayRootLayer) 374 368 m_viewOverlayRootLayer->flushCompositingState(visibleRect); 369 370 RELEASE_ASSERT(!m_pendingBackingStoreFlusher || m_pendingBackingStoreFlusher->hasFlushed()); 371 372 RemoteLayerBackingStoreCollection& backingStoreCollection = m_remoteLayerTreeContext->backingStoreCollection(); 373 backingStoreCollection.willFlushLayers(); 375 374 376 375 m_rootLayer->flushCompositingStateForThisLayerOnly(); -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp
r244151 r244182 1612 1612 } 1613 1613 1614 void WebPage::layoutIfNeeded()1615 {1616 if (m_mainFrame->coreFrame()->view())1617 m_mainFrame->coreFrame()->view()->updateLayoutAndStyleIfNeededRecursive();1618 }1619 1620 1614 WebPage* WebPage::fromCorePage(Page* page) 1621 1615 { … … 3653 3647 #endif 3654 3648 3655 void WebPage::willDisplayPage() 3656 { 3657 m_page->willDisplayPage(); 3649 void WebPage::layoutIfNeeded() 3650 { 3651 m_page->layoutIfNeeded(); 3652 } 3653 3654 void WebPage::updateRendering() 3655 { 3656 m_page->updateRendering(); 3658 3657 } 3659 3658 -
trunk/Source/WebKit/WebProcess/WebPage/WebPage.h
r244148 r244182 307 307 #endif 308 308 309 void willDisplayPage(); 309 void layoutIfNeeded(); 310 void updateRendering(); 310 311 311 312 enum class LazyCreationPolicy { UseExistingOnly, CreateIfNeeded }; … … 340 341 // FIXME: We could genericize these into a DrawingArea client interface. Would that be beneficial? 341 342 void drawRect(WebCore::GraphicsContext&, const WebCore::IntRect&); 342 void layoutIfNeeded();343 343 344 344 // -- Called from WebCore clients. -
trunk/Source/WebKit/WebProcess/WebPage/mac/TiledCoreAnimationDrawingArea.mm
r243469 r244182 460 460 scaleViewToFitDocumentIfNeeded(); 461 461 462 m_webPage. layoutIfNeeded();462 m_webPage.updateRendering(); 463 463 m_webPage.flushPendingEditorStateUpdate(); 464 m_webPage.willDisplayPage();465 464 466 465 updateIntrinsicContentSizeIfNeeded(); -
trunk/Source/WebKitLegacy/mac/ChangeLog
r244180 r244182 1 2019-04-10 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 (-[WebView _flushCompositingChanges]): 11 Call Page::updateRendering() which implements "Update the rendering" 12 step of the HTML Event Loop specification. 13 1 14 2019-04-10 Devin Rousso <drousso@apple.com> 2 15 -
trunk/Source/WebKitLegacy/mac/WebView/WebView.mm
r243666 r244182 1621 1621 - (void)_viewWillDrawInternal 1622 1622 { 1623 Frame* frame = [self _mainCoreFrame]; 1624 if (frame && frame->view()) 1625 frame->view()->updateLayoutAndStyleIfNeededRecursive(); 1623 if (_private->page) 1624 _private->page->updateRendering(); 1626 1625 } 1627 1626 … … 9389 9388 - (BOOL)_flushCompositingChanges 9390 9389 { 9391 #if ENABLE(RESIZE_OBSERVER)9392 if (_private->page)9393 _private->page->checkResizeObservations();9394 #endif9395 9396 9390 Frame* frame = [self _mainCoreFrame]; 9397 9391 if (frame && frame->view()) -
trunk/Source/WebKitLegacy/win/ChangeLog
r244180 r244182 1 2019-04-10 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 * WebView.cpp: 9 (WebView::updateBackingStore): 10 (WebView::flushPendingGraphicsLayerChangesSoon): 11 (WebView::flushPendingGraphicsLayerChanges): 12 Call Page::updateRendering() which implements "Update the rendering" 13 step of the HTML Event Loop specification. 14 1 15 2019-04-10 Devin Rousso <drousso@apple.com> 2 16 -
trunk/Source/WebKitLegacy/win/WebView.cpp
r243643 r244182 1172 1172 if (m_backingStoreBitmap && (m_backingStoreDirtyRegion || backingStoreCompletelyDirty)) { 1173 1173 // Do a layout first so that everything we render to the backing store is always current. 1174 if (Frame* coreFrame = core(m_mainFrame)) 1175 if (FrameView* view = coreFrame->view()) 1176 view->updateLayoutAndStyleIfNeededRecursive(); 1174 m_page->updateRendering(); 1177 1175 1178 1176 Vector<IntRect> paintRects; … … 7161 7159 { 7162 7160 #if USE(CA) 7163 if (!m_layerTreeHost) 7161 if (!m_layerTreeHost) { 7162 m_page->updateRendering(); 7164 7163 return; 7164 } 7165 7165 m_layerTreeHost->flushPendingGraphicsLayerChangesSoon(); 7166 7166 #elif USE(TEXTURE_MAPPER_GL) … … 7390 7390 return; 7391 7391 7392 view->updateLayoutAndStyleIfNeededRecursive();7392 m_page->updateRendering(); 7393 7393 7394 7394 // Updating layout might have taken us out of compositing mode. -
trunk/Tools/ChangeLog
r244171 r244182 1 2019-04-10 Said Abou-Hallawa <sabouhallawa@apple.com> 2 3 requestAnimationFrame should execute before the next frame 4 https://bugs.webkit.org/show_bug.cgi?id=177484 5 6 Reviewed by Simon Fraser. 7 8 Add trace points for the page RenderingUpdate. 9 10 * Tracing/SystemTracePoints.plist: 11 1 12 2019-04-10 Fujii Hironori <Hironori.Fujii@sony.com> 2 13 -
trunk/Tools/Tracing/SystemTracePoints.plist
r242714 r244182 219 219 <dict> 220 220 <key>Name</key> 221 <string>Schedule rendering update</string> 222 <key>Type</key> 223 <string>Impulse</string> 224 <key>Component</key> 225 <string>47</string> 226 <key>Code</key> 227 <string>5028</string> 228 </dict> 229 <dict> 230 <key>Name</key> 231 <string>Trigger rendering update</string> 232 <key>Type</key> 233 <string>Impulse</string> 234 <key>Component</key> 235 <string>47</string> 236 <key>Code</key> 237 <string>5029</string> 238 </dict> 239 <dict> 240 <key>Name</key> 241 <string>Rendering update</string> 242 <key>Type</key> 243 <string>Interval</string> 244 <key>Component</key> 245 <string>47</string> 246 <key>CodeBegin</key> 247 <string>5030</string> 248 <key>CodeEnd</key> 249 <string>5031</string> 250 </dict> 251 <dict> 252 <key>Name</key> 253 <string>Schedule rendering update</string> 254 <key>Type</key> 255 <string>Impulse</string> 256 <key>Component</key> 257 <string>47</string> 258 <key>Code</key> 259 <string>5028</string> 260 </dict> 261 <dict> 262 <key>Name</key> 263 <string>Trigger rendering update</string> 264 <key>Type</key> 265 <string>Impulse</string> 266 <key>Component</key> 267 <string>47</string> 268 <key>Code</key> 269 <string>5029</string> 270 </dict> 271 <dict> 272 <key>Name</key> 273 <string>Rendering update</string> 274 <key>Type</key> 275 <string>Interval</string> 276 <key>Component</key> 277 <string>47</string> 278 <key>CodeBegin</key> 279 <string>5030</string> 280 <key>CodeEnd</key> 281 <string>5031</string> 282 </dict> 283 <dict> 284 <key>Name</key> 221 285 <string>Paint WebHTMLView</string> 222 286 <key>Type</key>
Note:
See TracChangeset
for help on using the changeset viewer.