Add IsVisibleOrOccluded to ViewState
https://bugs.webkit.org/show_bug.cgi?id=127875
Reviewed by Anders Carlsson.
../WebCore:
* page/ViewState.h:
- added IsVisibleOrOccluded
../WebKit2:
When the WKView associated with a plugin becomes occluded
we tell the plugin it is no longer visible. This is a problem
if the plugin is being occluded by its own fullscreen window.
Instead, consider plugins to be visible any time they are in
a visible window – i.e. when they are visible or occluded.
* UIProcess/API/mac/PageClientImpl.h:
* UIProcess/API/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::isViewVisibleOrOccluded):
* UIProcess/PageClient.h:
(WebKit::PageClient::isViewVisibleOrOccluded):
- added isViewVisibleOrOccluded.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::updateViewState):
- update IsVisibleOrOccluded.
(WebKit::WebPageProxy::viewStateDidChange):
- when updating IsVisible also update IsVisibleOrOccluded.
* WebProcess/Plugins/PluginView.cpp:
(WebKit::PluginView::platformViewStateDidChange):
- use isVisibleOrOccluded to determine plugin visibility.
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::isVisibleOrOccluded):
- accessor.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@163061 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index cbb9d31..47bc7ba 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
+2014-01-29 Gavin Barraclough <barraclough@apple.com>
+
+ Add IsVisibleOrOccluded to ViewState
+ https://bugs.webkit.org/show_bug.cgi?id=127875
+
+ Reviewed by Anders Carlsson.
+
+ * page/ViewState.h:
+ - added IsVisibleOrOccluded
+
2014-01-29 Ryosuke Niwa <rniwa@webkit.org>
EventHandler::handleMouseReleaseEvent shouldn't call updateSelectionCachesIfSelectionIsInsideTextFormControl
diff --git a/Source/WebCore/page/ViewState.h b/Source/WebCore/page/ViewState.h
index 788a7ff..c99e1f0 100644
--- a/Source/WebCore/page/ViewState.h
+++ b/Source/WebCore/page/ViewState.h
@@ -33,14 +33,15 @@
WindowIsActive = 1 << 0,
IsFocused = 1 << 1,
IsVisible = 1 << 2,
- IsInWindow = 1 << 3,
- IsVisuallyIdle = 1 << 4,
+ IsVisibleOrOccluded = 1 << 3,
+ IsInWindow = 1 << 4,
+ IsVisuallyIdle = 1 << 5,
};
typedef unsigned Flags;
static const Flags NoFlags = 0;
- static const Flags AllFlags = WindowIsActive | IsFocused | IsVisible | IsInWindow | IsVisuallyIdle;
+ static const Flags AllFlags = WindowIsActive | IsFocused | IsVisible | IsVisibleOrOccluded | IsInWindow | IsVisuallyIdle;
};
} // namespace WebCore
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index 71c3ae5..b0115c2 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,35 @@
+2014-01-29 Gavin Barraclough <barraclough@apple.com>
+
+ Add IsVisibleOrOccluded to ViewState
+ https://bugs.webkit.org/show_bug.cgi?id=127875
+
+ Reviewed by Anders Carlsson.
+
+ When the WKView associated with a plugin becomes occluded
+ we tell the plugin it is no longer visible. This is a problem
+ if the plugin is being occluded by its own fullscreen window.
+
+ Instead, consider plugins to be visible any time they are in
+ a visible window – i.e. when they are visible or occluded.
+
+ * UIProcess/API/mac/PageClientImpl.h:
+ * UIProcess/API/mac/PageClientImpl.mm:
+ (WebKit::PageClientImpl::isViewVisibleOrOccluded):
+ * UIProcess/PageClient.h:
+ (WebKit::PageClient::isViewVisibleOrOccluded):
+ - added isViewVisibleOrOccluded.
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::updateViewState):
+ - update IsVisibleOrOccluded.
+ (WebKit::WebPageProxy::viewStateDidChange):
+ - when updating IsVisible also update IsVisibleOrOccluded.
+ * WebProcess/Plugins/PluginView.cpp:
+ (WebKit::PluginView::platformViewStateDidChange):
+ - use isVisibleOrOccluded to determine plugin visibility.
+ * WebProcess/WebPage/WebPage.h:
+ (WebKit::WebPage::isVisibleOrOccluded):
+ - accessor.
+
2014-01-29 Anders Carlsson <andersca@apple.com>
Pass navigation IDs along to LoadRequest and Reload
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
index 68fd67e..bd2b512 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.h
@@ -64,6 +64,7 @@
virtual bool isViewWindowActive();
virtual bool isViewFocused();
virtual bool isViewVisible();
+ virtual bool isViewVisibleOrOccluded();
virtual bool isViewInWindow();
virtual bool isVisuallyIdle();
virtual LayerHostingMode viewLayerHostingMode() override;
diff --git a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
index 6ac5aa9..4b4b05a 100644
--- a/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
+++ b/Source/WebKit2/UIProcess/API/mac/PageClientImpl.mm
@@ -207,6 +207,11 @@
return true;
}
+bool PageClientImpl::isViewVisibleOrOccluded()
+{
+ return [[m_wkView window] isVisible];
+}
+
bool PageClientImpl::isViewInWindow()
{
return [m_wkView window];
diff --git a/Source/WebKit2/UIProcess/PageClient.h b/Source/WebKit2/UIProcess/PageClient.h
index 318afe9..1ee95c1 100644
--- a/Source/WebKit2/UIProcess/PageClient.h
+++ b/Source/WebKit2/UIProcess/PageClient.h
@@ -105,6 +105,9 @@
// Return whether the view is visible.
virtual bool isViewVisible() = 0;
+ // Return whether the view is visible, or occluded by another window.
+ virtual bool isViewVisibleOrOccluded() { return isViewVisible(); }
+
// Return whether the view is in a window.
virtual bool isViewInWindow() = 0;
diff --git a/Source/WebKit2/UIProcess/WebPageProxy.cpp b/Source/WebKit2/UIProcess/WebPageProxy.cpp
index d571a4a3..b098cf9 100644
--- a/Source/WebKit2/UIProcess/WebPageProxy.cpp
+++ b/Source/WebKit2/UIProcess/WebPageProxy.cpp
@@ -934,6 +934,8 @@
m_viewState |= ViewState::WindowIsActive;
if (flagsToUpdate & ViewState::IsVisible && m_pageClient.isViewVisible())
m_viewState |= ViewState::IsVisible;
+ if (flagsToUpdate & ViewState::IsVisibleOrOccluded && m_pageClient.isViewVisibleOrOccluded())
+ m_viewState |= ViewState::IsVisibleOrOccluded;
if (flagsToUpdate & ViewState::IsInWindow && m_pageClient.isViewInWindow())
m_viewState |= ViewState::IsInWindow;
if (flagsToUpdate & ViewState::IsVisuallyIdle && m_pageClient.isVisuallyIdle())
@@ -945,9 +947,9 @@
if (!isValid())
return;
- // If the visibility state may have changed, then so may the visually idle.
+ // If the visibility state may have changed, then so may the visually idle & occluded agnostic state.
if (mayHaveChanged & ViewState::IsVisible)
- mayHaveChanged |= ViewState::IsVisuallyIdle;
+ mayHaveChanged |= ViewState::IsVisibleOrOccluded | ViewState::IsVisuallyIdle;
// Record the prior view state, update the flags that may have changed,
// and check which flags have actually changed.
diff --git a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
index 936365a..6cc2b78 100644
--- a/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
+++ b/Source/WebKit2/WebProcess/Plugins/PluginView.cpp
@@ -509,8 +509,8 @@
if (!m_plugin || !m_isInitialized)
return;
- if (changed & ViewState::IsVisible)
- m_plugin->windowVisibilityChanged(m_webPage->isVisible());
+ if (changed & ViewState::IsVisibleOrOccluded)
+ m_plugin->windowVisibilityChanged(m_webPage->isVisibleOrOccluded());
if (changed & ViewState::WindowIsActive)
m_plugin->windowFocusChanged(m_webPage->windowIsFocused());
}
diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.h b/Source/WebKit2/WebProcess/WebPage/WebPage.h
index aa4c517..2ab4d48 100644
--- a/Source/WebKit2/WebProcess/WebPage/WebPage.h
+++ b/Source/WebKit2/WebProcess/WebPage/WebPage.h
@@ -361,6 +361,7 @@
void removePluginView(PluginView*);
bool isVisible() const { return m_viewState & WebCore::ViewState::IsVisible; }
+ bool isVisibleOrOccluded() const { return m_viewState & WebCore::ViewState::IsVisibleOrOccluded; }
LayerHostingMode layerHostingMode() const { return m_layerHostingMode; }
void setLayerHostingMode(unsigned);