Commit 21294937 authored by barraclough@apple.com's avatar barraclough@apple.com

Merge didMoveOnscreen / page visibility to isVisible

https://bugs.webkit.org/show_bug.cgi?id=126268

Reviewed by Tim Horton.

The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.

Source/WebCore: 

* WebCore.exp.in:
* page/EventHandler.cpp:
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* page/FrameView.cpp:
(WebCore::FrameView::shouldSetCursor):
* page/Page.cpp:
(WebCore::Page::Page):
    - initialize new variables.
(WebCore::Page::setIsVisible):
    - merge setVisibilityState, didMoveOnscreen, willMoveOffscreen.
(WebCore::Page::setIsPrerender):
    - switches visibility state from hidden to prerender.
(WebCore::Page::visibilityState):
    - computed from m_isVisible, m_isPrerender.
(WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged):
    - m_visibilityState -> m_isVisible.
* page/Page.h:
    - remove didMoveOnscreen/willMoveOffscreen
      m_isOnscreen & m_visibilityState -> m_isVisible & m_isPrerender
      setVisibilityState -> setIsVisible & setIsPrerender.
(WebCore::Page::isVisible):
    - isOnscreen -> isVisible.

Source/WebKit/blackberry: 

* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setPageVisibilityState):
    - setVisibilityState -> setIsVisible.

Source/WebKit/efl: 

* ewk/ewk_view.cpp:
(ewk_view_visibility_state_set):
    - setVisibilityState -> setIsVisible/setIsPrerender.

Source/WebKit/gtk: 

* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::setPageVisibility):
    - setVisibilityState -> setIsVisible/setIsPrerender.

Source/WebKit/mac: 

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView _updateVisibilityState]):
    - _setVisibilityState:isInitialState: -> _setIsVisibile:isInitialState:.
(-[WebView _setIsVisible:isInitialState:]):
    - added.
(-[WebView _setVisibilityState:isInitialState:]):
    - setVisibilityState -> setIsVisible/setIsPrerender.
(-[WebView viewWillMoveToWindow:]):
(-[WebView viewDidMoveToWindow]):
    - remove redundant calls to willMoveOffscreen/didMoveOnscreen
      (this is handled by _updateVisibilityState).

Source/WebKit2: 

* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setViewIsVisible):
    - updateVisibilityState -> setIsVisible.
(WebKit::WebPage::setIsInWindow):
    - remove redundant willMoveOffscreen/didMoveOnscreen calls - this is handled
      by setIsVisible.
(WebKit::WebPage::setMayStartMediaWhenInWindow):
    - isOnscreen -> isInWindow. We start media when the view is in a window, not
      when the view is visible.
(WebKit::WebPage::setVisibilityStatePrerender):
    - setVisibilityState -> setIsPrerender.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@161223 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 61cca14e
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* WebCore.exp.in:
* page/EventHandler.cpp:
(WebCore::EventHandler::fakeMouseMoveEventTimerFired):
* page/FrameView.cpp:
(WebCore::FrameView::shouldSetCursor):
* page/Page.cpp:
(WebCore::Page::Page):
- initialize new variables.
(WebCore::Page::setIsVisible):
- merge setVisibilityState, didMoveOnscreen, willMoveOffscreen.
(WebCore::Page::setIsPrerender):
- switches visibility state from hidden to prerender.
(WebCore::Page::visibilityState):
- computed from m_isVisible, m_isPrerender.
(WebCore::Page::hiddenPageCSSAnimationSuspensionStateChanged):
- m_visibilityState -> m_isVisible.
* page/Page.h:
- remove didMoveOnscreen/willMoveOffscreen
m_isOnscreen & m_visibilityState -> m_isVisible & m_isPrerender
setVisibilityState -> setIsVisible & setIsPrerender.
(WebCore::Page::isVisible):
- isOnscreen -> isVisible.
2014-01-02 Oliver Hunt <oliver@apple.com>
Update bindings test results
......@@ -962,17 +962,17 @@ __ZN7WebCore4Page10findStringERKN3WTF6StringEj
__ZN7WebCore4Page11PageClientsC1Ev
__ZN7WebCore4Page11PageClientsD1Ev
__ZN7WebCore4Page12setGroupNameERKN3WTF6StringE
__ZN7WebCore4Page12setIsVisibleEbb
__ZN7WebCore4Page12setThrottledEb
__ZN7WebCore4Page13rangeOfStringERKN3WTF6StringEPNS_5RangeEj
__ZN7WebCore4Page13setIsInWindowEb
__ZN7WebCore4Page13setPaginationERKNS_10PaginationE
__ZN7WebCore4Page14setIsPrerenderEv
__ZN7WebCore4Page14setMediaVolumeEf
__ZN7WebCore4Page15addSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
__ZN7WebCore4Page15didMoveOnscreenEv
__ZN7WebCore4Page16countFindMatchesERKN3WTF6StringEjj
__ZN7WebCore4Page16setCanStartMediaEb
__ZN7WebCore4Page16setDefersLoadingEb
__ZN7WebCore4Page17willMoveOffscreenEv
__ZN7WebCore4Page18removeSchedulePairEN3WTF10PassRefPtrINS1_12SchedulePairEEE
__ZN7WebCore4Page18setPageScaleFactorEfRKNS_8IntPointE
__ZN7WebCore4Page19addFooterWithHeightEi
......@@ -2770,10 +2770,6 @@ __ZN7WebCore12Notification16permissionStringENS_18NotificationClient10Permission
__ZN7WebCore5Frame26sendOrientationChangeEventEi
#endif
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
__ZN7WebCore4Page18setVisibilityStateENS_19PageVisibilityStateEb
#endif
#if USE(PLUGIN_HOST_PROCESS)
__ZN3JSC13RuntimeMethod11getCallDataEPNS_6JSCellERNS_8CallDataE
__ZN3JSC13RuntimeMethod14finishCreationERNS_2VMERKN3WTF6StringE
......
......@@ -2836,7 +2836,7 @@ void EventHandler::fakeMouseMoveEventTimerFired(Timer<EventHandler>* timer)
if (!view)
return;
if (!m_frame.page() || !m_frame.page()->isOnscreen() || !m_frame.page()->focusController().isActive())
if (!m_frame.page() || !m_frame.page()->isVisible() || !m_frame.page()->focusController().isActive())
return;
bool shiftKey;
......
......@@ -1691,7 +1691,7 @@ bool FrameView::isHandlingWheelEvent() const
bool FrameView::shouldSetCursor() const
{
Page* page = frame().page();
return page && page->isOnscreen() && page->focusController().isActive();
return page && page->isVisible() && page->focusController().isActive();
}
bool FrameView::scrollContentsFastPath(const IntSize& scrollDelta, const IntRect& rectToScroll, const IntRect& clipRect)
......
......@@ -171,11 +171,9 @@ Page::Page(PageClients& pageClients)
, m_minimumTimerInterval(Settings::defaultMinDOMTimerInterval())
, m_timerAlignmentInterval(Settings::defaultDOMTimerAlignmentInterval())
, m_isEditable(false)
, m_isOnscreen(true)
, m_isInWindow(true)
#if ENABLE(PAGE_VISIBILITY_API)
, m_visibilityState(PageVisibilityStateVisible)
#endif
, m_isVisible(true)
, m_isPrerender(false)
, m_requestedLayoutMilestones(0)
, m_headerHeight(0)
, m_footerHeight(0)
......@@ -874,30 +872,6 @@ unsigned Page::pageCount() const
return contentRenderer ? contentRenderer->columnCount(contentRenderer->columnInfo()) : 0;
}
void Page::didMoveOnscreen()
{
m_isOnscreen = true;
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (FrameView* frameView = frame->view())
frameView->didMoveOnscreen();
}
resumeScriptedAnimations();
}
void Page::willMoveOffscreen()
{
m_isOnscreen = false;
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (FrameView* frameView = frame->view())
frameView->willMoveOffscreen();
}
suspendScriptedAnimations();
}
void Page::setIsInWindow(bool isInWindow)
{
if (m_isInWindow == isInWindow)
......@@ -1235,21 +1209,37 @@ void Page::resumeAnimatingImages()
CachedImage::resumeAnimatingImagesForLoader(frame->document()->cachedResourceLoader());
}
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitialState)
void Page::setIsVisible(bool isVisible, bool isInitialState)
{
#if !ENABLE(PAGE_VISIBILITY_API)
UNUSED_PARAM(isInitialState);
#else
// FIXME: The visibility state should be stored on the top-level document.
// https://bugs.webkit.org/show_bug.cgi?id=116769
if (m_visibilityState == visibilityState)
return;
if (m_visibilityState == PageVisibilityStatePrerender && visibilityState == PageVisibilityStateHidden)
if (m_isVisible == isVisible)
return;
m_visibilityState = visibilityState;
m_isVisible = isVisible;
if (isVisible) {
m_isPrerender = false;
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (FrameView* frameView = frame->view())
frameView->didMoveOnscreen();
}
resumeScriptedAnimations();
if (FrameView* view = mainFrame().view())
view->show();
unthrottleTimers();
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame().animation().resumeAnimations();
resumeAnimatingImages();
}
#if ENABLE(PAGE_VISIBILITY_API)
if (!isInitialState) {
Vector<Ref<Document>> documents;
for (Frame* frame = m_mainFrame.get(); frame; frame = frame->tree().traverseNext())
......@@ -1258,26 +1248,42 @@ void Page::setVisibilityState(PageVisibilityState visibilityState, bool isInitia
for (size_t i = 0, size = documents.size(); i < size; ++i)
documents[i]->visibilityStateChanged();
}
#else
UNUSED_PARAM(isInitialState);
#endif
if (visibilityState == WebCore::PageVisibilityStateHidden) {
if (!isVisible) {
if (m_pageThrottler->shouldThrottleTimers())
throttleTimers();
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame().animation().suspendAnimations();
} else {
unthrottleTimers();
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame().animation().resumeAnimations();
resumeAnimatingImages();
for (Frame* frame = &mainFrame(); frame; frame = frame->tree().traverseNext()) {
if (FrameView* frameView = frame->view())
frameView->willMoveOffscreen();
}
suspendScriptedAnimations();
if (FrameView* view = mainFrame().view())
view->hide();
}
}
#endif // ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
void Page::setIsPrerender()
{
m_isPrerender = true;
}
#if ENABLE(PAGE_VISIBILITY_API)
PageVisibilityState Page::visibilityState() const
{
return m_visibilityState;
if (m_isVisible)
return PageVisibilityStateVisible;
if (m_isPrerender)
return PageVisibilityStatePrerender;
return PageVisibilityStateHidden;
}
#endif
......@@ -1535,7 +1541,7 @@ void Page::hiddenPageDOMTimerThrottlingStateChanged()
#if (ENABLE_PAGE_VISIBILITY_API)
void Page::hiddenPageCSSAnimationSuspensionStateChanged()
{
if (m_visibilityState == WebCore::PageVisibilityStateHidden) {
if (!m_isVisible) {
if (m_settings->hiddenPageCSSAnimationSuspensionEnabled())
mainFrame().animation().suspendAnimations();
else
......
......@@ -294,9 +294,9 @@ public:
unsigned pageCount() const;
// Notifications when the Page starts and stops being presented via a native window.
void didMoveOnscreen();
void willMoveOffscreen();
bool isOnscreen() const { return m_isOnscreen; }
void setIsVisible(bool isVisible, bool isInitial);
void setIsPrerender();
bool isVisible() const { return m_isVisible; }
// Notification that this Page was moved into or out of a native window.
void setIsInWindow(bool);
......@@ -354,9 +354,6 @@ public:
#if ENABLE(PAGE_VISIBILITY_API)
PageVisibilityState visibilityState() const;
#endif
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
void setVisibilityState(PageVisibilityState, bool);
#endif
void resumeAnimatingImages();
......@@ -525,12 +522,9 @@ private:
double m_timerAlignmentInterval;
bool m_isEditable;
bool m_isOnscreen;
bool m_isInWindow;
#if ENABLE(PAGE_VISIBILITY_API)
PageVisibilityState m_visibilityState;
#endif
bool m_isVisible;
bool m_isPrerender;
LayoutMilestones m_requestedLayoutMilestones;
......
......@@ -3118,7 +3118,8 @@ void WebPagePrivate::setPageVisibilityState()
static bool s_initialVisibilityState = true;
m_page->setVisibilityState(m_visible && m_activationState == ActivationActive ? PageVisibilityStateVisible : PageVisibilityStateHidden, s_initialVisibilityState);
m_page->setIsVisible(m_visible && m_activationState == ActivationActive, s_initialVisibilityState);
s_initialVisibilityState = false;
}
}
......
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* Api/WebPage.cpp:
(BlackBerry::WebKit::WebPagePrivate::setPageVisibilityState):
- setVisibilityState -> setIsVisible.
2013-12-30 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Cleanup static_cast<HTMLFormElement*> by using toHTMLFormElement()
......
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* ewk/ewk_view.cpp:
(ewk_view_visibility_state_set):
- setVisibilityState -> setIsVisible/setIsPrerender.
2013-12-29 Ryuan Choi <ryuan.choi@samsung.com>
[EFL] Remove ewk_view_tiled
......
......@@ -4238,7 +4238,9 @@ Eina_Bool ewk_view_visibility_state_set(Evas_Object* ewkView, Ewk_Page_Visibilit
if (pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_UNLOADED)
return false;
priv->page->setVisibilityState(static_cast<WebCore::PageVisibilityState>(pageVisibilityState), initialState);
priv->page->setIsVisible(pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_VISIBLE, initialState);
if (pageVisibilityState == EWK_PAGE_VISIBILITY_STATE_PRERENDER)
priv->page->setIsPrerender();
return true;
#else
......
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* WebCoreSupport/DumpRenderTreeSupportGtk.cpp:
(DumpRenderTreeSupportGtk::setPageVisibility):
- setVisibilityState -> setIsVisible/setIsPrerender.
2014-01-02 Zan Dobersek <zdobersek@igalia.com>
[GTK] Fix mismatched header guards in private WK1 header files
......
......@@ -699,6 +699,8 @@ void DumpRenderTreeSupportGtk::setPageVisibility(WebKitWebView* webView, WebCore
if (!page)
return;
page->setVisibilityState(visibilityState, isInitialState);
page->setIsVisible(visibilityState == PageVisibilityStateVisible, isInitialState);
if (visibilityState == PageVisibilityStatePrerender)
page->setIsPrerender();
#endif
}
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(-[WebView _updateVisibilityState]):
- _setVisibilityState:isInitialState: -> _setIsVisibile:isInitialState:.
(-[WebView _setIsVisible:isInitialState:]):
- added.
(-[WebView _setVisibilityState:isInitialState:]):
- setVisibilityState -> setIsVisible/setIsPrerender.
(-[WebView viewWillMoveToWindow:]):
(-[WebView viewDidMoveToWindow]):
- remove redundant calls to willMoveOffscreen/didMoveOnscreen
(this is handled by _updateVisibilityState).
2013-12-23 Oliver Hunt <oliver@apple.com>
Refactor PutPropertySlot to be aware of custom properties
......
......@@ -507,21 +507,6 @@ WebLayoutMilestones kitLayoutMilestones(LayoutMilestones milestones)
| (milestones & DidHitRelevantRepaintedObjectsAreaThreshold ? WebDidHitRelevantRepaintedObjectsAreaThreshold : 0);
}
static PageVisibilityState core(WebPageVisibilityState visibilityState)
{
switch (visibilityState) {
case WebPageVisibilityStateVisible:
return PageVisibilityStateVisible;
case WebPageVisibilityStateHidden:
return PageVisibilityStateHidden;
case WebPageVisibilityStatePrerender:
return PageVisibilityStatePrerender;
}
ASSERT_NOT_REACHED();
return PageVisibilityStateVisible;
}
static WebPageVisibilityState kit(PageVisibilityState visibilityState)
{
switch (visibilityState) {
......@@ -1050,7 +1035,7 @@ static bool shouldUseLegacyBackgroundSizeShorthandBehavior()
[self _registerDraggedTypes];
#endif
[self _setVisibilityState:([self _isViewVisible] ? WebPageVisibilityStateVisible : WebPageVisibilityStateHidden) isInitialState:YES];
[self _setIsVisible:[self _isViewVisible] isInitialState:YES];
WebPreferences *prefs = [self preferences];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_preferencesChangedNotification:)
......@@ -4009,7 +3994,7 @@ static inline IMP getMethod(id o, SEL s)
- (void)_updateVisibilityState
{
if (_private && _private->page)
[self _setVisibilityState:([self _isViewVisible] ? WebPageVisibilityStateVisible : WebPageVisibilityStateHidden) isInitialState:NO];
[self _setIsVisible:[self _isViewVisible] isInitialState:NO];
}
- (void)_updateActiveState
......@@ -4374,12 +4359,19 @@ static Vector<String> toStringVector(NSArray* patterns)
return WebPageVisibilityStateVisible;
}
- (void)_setVisibilityState:(WebPageVisibilityState)visibilityState isInitialState:(BOOL)isInitialState
- (void)_setIsVisible:(BOOL)isVisible isInitialState:(BOOL)isInitialState
{
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
if (_private->page)
_private->page->setVisibilityState(core(visibilityState), isInitialState);
#endif
_private->page->setIsVisible(isVisible, isInitialState);
}
- (void)_setVisibilityState:(WebPageVisibilityState)visibilityState isInitialState:(BOOL)isInitialState
{
if (_private->page) {
_private->page->setIsVisible(visibilityState == WebPageVisibilityStateVisible, isInitialState);
if (visibilityState == WebPageVisibilityStatePrerender)
_private->page->setIsPrerender();
}
}
- (void)_setPaginationBehavesLikeColumns:(BOOL)behavesLikeColumns
......@@ -5283,7 +5275,6 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
WKSetNSWindowShouldPostEventNotifications(window, YES);
} else {
_private->page->setCanStartMedia(false);
_private->page->willMoveOffscreen();
_private->page->setIsInWindow(false);
}
......@@ -5305,7 +5296,6 @@ static NSString * const backingPropertyOldScaleFactorKey = @"NSBackingPropertyOl
if ([self window]) {
_private->page->setCanStartMedia(true);
_private->page->didMoveOnscreen();
_private->page->setIsInWindow(true);
#if PLATFORM(IOS)
......
2014-01-02 Gavin Barraclough <barraclough@apple.com>
Merge didMoveOnscreen / page visibility to isVisible
https://bugs.webkit.org/show_bug.cgi?id=126268
Reviewed by Tim Horton.
The onscreen state most closely tracks view visibility (though currently
also tracks a mix of in-window state). Make more consistent, simplify,
and move all animation suspension logic to Page, so it can be controlled
by the PageThrottler.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::WebPage):
(WebKit::WebPage::setViewIsVisible):
- updateVisibilityState -> setIsVisible.
(WebKit::WebPage::setIsInWindow):
- remove redundant willMoveOffscreen/didMoveOnscreen calls - this is handled
by setIsVisible.
(WebKit::WebPage::setMayStartMediaWhenInWindow):
- isOnscreen -> isInWindow. We start media when the view is in a window, not
when the view is visible.
(WebKit::WebPage::setVisibilityStatePrerender):
- setVisibilityState -> setIsPrerender.
2013-12-23 Oliver Hunt <oliver@apple.com>
Refactor PutPropertySlot to be aware of custom properties
......
......@@ -82,7 +82,7 @@ typedef GenericCallback<WKDictionaryRef> DictionaryCallback;
class WebNetworkInfoManagerProxy;
#endif
#if ENABLE(NETWORK_PROCESS)
struct NetworkProcessCreationParameters;
struc t NetworkProcessCreationParameters;
#endif
class WebContext : public API::ObjectImpl<API::Object::Type::Context>, private IPC::MessageReceiver
......
......@@ -425,7 +425,7 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
WebProcess::shared().eventDispatcher().addScrollingTreeForPage(this);
#endif
updateVisibilityState(true);
m_page->setIsVisible(m_viewState & ViewState::IsVisible, true);
}
WebPage::~WebPage()
......@@ -1922,20 +1922,12 @@ void WebPage::setActive(bool isActive)
void WebPage::setViewIsVisible(bool isVisible)
{
if (!isVisible) {
m_drawingArea->suspendPainting();
m_page->suspendScriptedAnimations();
} else {
if (isVisible)
m_drawingArea->resumePainting();
// FIXME: this seems redundant; for the view to be visible the window must be visible too!
// refactoring for now, will change the logic later.
if (m_windowIsVisible) {
m_page->resumeScriptedAnimations();
m_page->resumeAnimatingImages();
}
}
else
m_drawingArea->suspendPainting();
updateVisibilityState();
m_page->setIsVisible(m_viewState & ViewState::IsVisible, false);
}
void WebPage::setDrawsBackground(bool drawsBackground)
......@@ -2059,7 +2051,6 @@ void WebPage::setIsInWindow(bool isInWindow)
if (!isInWindow) {
m_setCanStartMediaTimer.stop();
m_page->setCanStartMedia(false);
m_page->willMoveOffscreen();
if (pageWasInWindow)
WebProcess::shared().pageWillLeaveWindow(m_pageID);
......@@ -2070,8 +2061,6 @@ void WebPage::setIsInWindow(bool isInWindow)
if (m_mayStartMediaWhenInWindow)
m_setCanStartMediaTimer.startOneShot(0);
m_page->didMoveOnscreen();
if (!pageWasInWindow)
WebProcess::shared().pageDidEnterWindow(m_pageID);
}
......@@ -3538,7 +3527,7 @@ void WebPage::setMayStartMediaWhenInWindow(bool mayStartMedia)
return;
m_mayStartMediaWhenInWindow = mayStartMedia;
if (m_mayStartMediaWhenInWindow && m_page->isOnscreen())
if (m_mayStartMediaWhenInWindow && m_page->isInWindow())
m_setCanStartMediaTimer.startOneShot(0);
}
......@@ -3707,49 +3696,10 @@ FrameView* WebPage::mainFrameView() const
return 0;
}
void WebPage::updateVisibilityState(bool isInitialState)
{
bool isVisible = m_viewState & ViewState::IsVisible;
if (!m_page)
return;
#if ENABLE(PAGE_VISIBILITY_API)
FrameView* view = m_page->mainFrame().view();
if (isVisible) {
m_page->didMoveOnscreen();
if (view)
view->show();
}
PageVisibilityState state = isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden;
m_page->setVisibilityState(state, isInitialState);
if (!isVisible) {
m_page->willMoveOffscreen();
if (view)
view->hide();
}
#elif ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
PageVisibilityState state = isVisible ? PageVisibilityStateVisible : PageVisibilityStateHidden;
m_page->setVisibilityState(state, isInitialState);
#else
UNUSED_PARAM(isVisible);
UNUSED_PARAM(isInitialState);
#endif
}
void WebPage::setVisibilityStatePrerender()
{
#if ENABLE(PAGE_VISIBILITY_API) || ENABLE(HIDDEN_PAGE_DOM_TIMER_THROTTLING)
if (!m_page)
return;
m_page->setVisibilityState(PageVisibilityStatePrerender, true);
#endif
if (m_page)
m_page->setIsPrerender();
}
void WebPage::setThrottled(bool isThrottled)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment