Changeset 207699 in webkit
- Timestamp:
- Oct 21, 2016 4:20:11 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207698 r207699 1 2016-10-21 Gavin Barraclough <barraclough@apple.com> 2 3 WebPage should take UserActivity directly for user input 4 https://bugs.webkit.org/show_bug.cgi?id=163813 5 6 Reviewed by Anders Carlsson. 7 8 When we receive mouse/keyboard events in a page, we want to prevent AppNap. We currently do so 9 via the PageThrottler. This patch is to just make the WebPage drive the UserActivity directly. 10 11 Two reasons to do so: (1) to cleanup & simplify for further refactoring. (2) The current code 12 isn't really achieving the desired effect. The page setting the flag in the throttler to get 13 the activity to be set is now a less effective way of achieving this goal, since the 14 PageActivityState bounces back across to the UI process & then messages back to the WebContent 15 process to take the UserActivity. These extra hops defeat the purpose of making sure the boost 16 from the initial message isn't lost. 17 18 * page/PageThrottler.cpp: 19 (WebCore::PageThrottler::PageThrottler): 20 (WebCore::m_userInputHysteresis): Deleted. 21 * page/PageThrottler.h: 22 (WebCore::PageThrottler::didReceiveUserInput): Deleted. 23 - removed PageActivityState::UserInputActivity, didReceiveUserInput, m_userInputHysteresis. 24 1 25 2016-10-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 26 -
trunk/Source/WebCore/page/PageThrottler.cpp
r200625 r207699 35 35 PageThrottler::PageThrottler(Page& page) 36 36 : m_page(page) 37 , m_userInputHysteresis([this](HysteresisState state) { setActivityFlag(PageActivityState::UserInputActivity, state == HysteresisState::Started); })38 37 , m_mediaActivityHysteresis([this](HysteresisState state) { setActivityFlag(PageActivityState::MediaActivity, state == HysteresisState::Started); }) 39 38 , m_pageLoadActivityHysteresis([this](HysteresisState state) { setActivityFlag(PageActivityState::PageLoadActivity, state == HysteresisState::Started); }, PageLoadHysteresisSeconds) -
trunk/Source/WebCore/page/PageThrottler.h
r200625 r207699 43 43 struct PageActivityState { 44 44 enum { 45 UserInputActivity = 1 << 0, 46 MediaActivity = 1 << 1, 47 PageLoadActivity = 1 << 2, 45 MediaActivity = 1 << 0, 46 PageLoadActivity = 1 << 1, 48 47 }; 49 48 … … 51 50 52 51 static const Flags NoFlags = 0; 53 static const Flags AllFlags = UserInputActivity |MediaActivity | PageLoadActivity;52 static const Flags AllFlags = MediaActivity | PageLoadActivity; 54 53 }; 55 54 … … 59 58 PageThrottler(Page&); 60 59 61 void didReceiveUserInput() { m_userInputHysteresis.impulse(); }62 60 PageActivityState::Flags activityState() { return m_activityState; } 63 61 void pluginDidEvaluateWhileAudioIsPlaying() { m_mediaActivityHysteresis.impulse(); } … … 72 70 Page& m_page; 73 71 PageActivityState::Flags m_activityState { PageActivityState::NoFlags }; 74 HysteresisActivity m_userInputHysteresis;75 72 HysteresisActivity m_mediaActivityHysteresis; 76 73 HysteresisActivity m_pageLoadActivityHysteresis; -
trunk/Source/WebKit2/ChangeLog
r207698 r207699 1 2016-10-21 Gavin Barraclough <barraclough@apple.com> 2 3 WebPage should take UserActivity directly for user input 4 https://bugs.webkit.org/show_bug.cgi?id=163813 5 6 Reviewed by Anders Carlsson. 7 8 When we receive mouse/keyboard events in a page, we want to prevent AppNap. We currently do so 9 via the PageThrottler. This patch is to just make the WebPage drive the UserActivity directly. 10 11 Two reasons to do so: (1) to cleanup & simplify for further refactoring. (2) The current code 12 isn't really achieving the desired effect. The page setting the flag in the throttler to get 13 the activity to be set is now a less effective way of achieving this goal, since the 14 PageActivityState bounces back across to the UI process & then messages back to the WebContent 15 process to take the UserActivity. These extra hops defeat the purpose of making sure the boost 16 from the initial message isn't lost. 17 18 * WebProcess/WebPage/WebPage.cpp: 19 (WebKit::m_userActivityHysteresis): 20 - m_userActivityHysteresis triggers updateUserActivity. 21 (WebKit::WebPage::setPageSuppressed): 22 - setPageSuppressed starts/stops m_userActivityHysteresis. 23 (WebKit::WebPage::updateUserActivity): 24 - update UserActivity based on state of m_userActivityHysteresis. 25 (WebKit::WebPage::mouseEvent): 26 (WebKit::WebPage::wheelEvent): 27 (WebKit::WebPage::keyEvent): 28 - input events impulse m_userActivityHysteresis. 29 * WebProcess/WebPage/WebPage.h: 30 1 31 2016-10-21 Wenson Hsieh <wenson_hsieh@apple.com> 2 32 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r207689 r207699 379 379 , m_viewState(parameters.viewState) 380 380 , m_userActivity("Process suppression disabled for page.") 381 , m_userActivityHysteresis([this](HysteresisState) { updateUserActivity(); }) 381 382 , m_pendingNavigationID(0) 382 383 #if ENABLE(WEBGL) … … 591 592 // If the page should not be supressed, start it. 592 593 if (pageSuppressed) 594 m_userActivityHysteresis.stop(); 595 else 596 m_userActivityHysteresis.start(); 597 } 598 599 void WebPage::updateUserActivity() 600 { 601 if (m_userActivityHysteresis.state() == HysteresisState::Started) 602 m_userActivity.start(); 603 else 593 604 m_userActivity.stop(); 594 else595 m_userActivity.start();596 605 } 597 606 … … 2239 2248 TemporaryChange<bool> userIsInteractingChange { m_userIsInteracting, true }; 2240 2249 2241 m_ page->pageThrottler().didReceiveUserInput();2250 m_userActivityHysteresis.impulse(); 2242 2251 2243 2252 bool shouldHandleEvent = true; … … 2294 2303 void WebPage::wheelEvent(const WebWheelEvent& wheelEvent) 2295 2304 { 2296 m_ page->pageThrottler().didReceiveUserInput();2305 m_userActivityHysteresis.impulse(); 2297 2306 2298 2307 CurrentEvent currentEvent(wheelEvent); … … 2317 2326 TemporaryChange<bool> userIsInteractingChange { m_userIsInteracting, true }; 2318 2327 2319 m_ page->pageThrottler().didReceiveUserInput();2328 m_userActivityHysteresis.impulse(); 2320 2329 2321 2330 CurrentEvent currentEvent(keyboardEvent); -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r207689 r207699 972 972 WebPage(uint64_t pageID, const WebPageCreationParameters&); 973 973 974 void updateUserActivity(); 975 974 976 // IPC::MessageSender 975 977 IPC::Connection* messageSenderConnection() override; … … 1487 1489 1488 1490 UserActivity m_userActivity; 1491 WebCore::HysteresisActivity m_userActivityHysteresis; 1489 1492 1490 1493 uint64_t m_pendingNavigationID;
Note: See TracChangeset
for help on using the changeset viewer.