Replace Page::is_hidden_ with PageVisibilityState enum
This moves content::PageVisibilityState into blink and uses this instead
of a boolean for blink::Page's visibility. A follow-up CL will use the
kPrerender state to set a Page as not hidden but not fully visible for
certain capture scenarios.
This CL is not intended to change behavior yet.
crbug.com/995131#c24 describes this series of changes.
Bug: 995131
Change-Id: I41d05228c1ca830ce57ffcb3a04735279bf324f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1898471
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#713170}
diff --git a/chrome/browser/after_startup_task_utils.cc b/chrome/browser/after_startup_task_utils.cc
index de85c99..4062162 100644
--- a/chrome/browser/after_startup_task_utils.cc
+++ b/chrome/browser/after_startup_task_utils.cc
@@ -22,10 +22,10 @@
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/navigation_handle.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
+#include "content/public/common/page_visibility_state.h"
#if !defined(OS_ANDROID)
#include "chrome/browser/ui/browser.h"
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 03fa992..f47a2ba 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -4086,7 +4086,7 @@
web_contents->GetBrowserContext());
if (prerender_manager &&
prerender_manager->IsWebContentsPrerendering(web_contents, nullptr)) {
- *visibility_state = content::PageVisibilityState::kPrerender;
+ *visibility_state = content::PageVisibilityState::kHiddenButPainting;
}
}
diff --git a/chrome/browser/notifications/notification_permission_context.cc b/chrome/browser/notifications/notification_permission_context.cc
index d072d60..adb133b 100644
--- a/chrome/browser/notifications/notification_permission_context.cc
+++ b/chrome/browser/notifications/notification_permission_context.cc
@@ -20,10 +20,10 @@
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "components/content_settings/core/common/content_settings_types.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
+#include "content/public/common/page_visibility_state.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_EXTENSIONS)
@@ -105,7 +105,7 @@
} else {
switch (contents->GetMainFrame()->GetVisibilityState()) {
case content::PageVisibilityState::kHidden:
- case content::PageVisibilityState::kPrerender:
+ case content::PageVisibilityState::kHiddenButPainting:
is_visible_ = false;
break;
case content::PageVisibilityState::kVisible:
diff --git a/chrome/browser/push_messaging/push_messaging_notification_manager.cc b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
index 5522c03b..3999243 100644
--- a/chrome/browser/push_messaging/push_messaging_notification_manager.cc
+++ b/chrome/browser/push_messaging/push_messaging_notification_manager.cc
@@ -28,13 +28,13 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/platform_notification_context.h"
#include "content/public/browser/push_messaging_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/url_constants.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "third_party/blink/public/common/notifications/notification_resources.h"
@@ -239,7 +239,7 @@
// Ignore minimized windows.
switch (active_web_contents->GetMainFrame()->GetVisibilityState()) {
case content::PageVisibilityState::kHidden:
- case content::PageVisibilityState::kPrerender:
+ case content::PageVisibilityState::kHiddenButPainting:
return false;
case content::PageVisibilityState::kVisible:
break;
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index feea8780..9d9e256 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -120,6 +120,7 @@
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/features.h"
+#include "third_party/blink/public/common/page/page_visibility_state.h"
#include "third_party/blink/public/mojom/fetch/fetch_api_request.mojom-shared.h"
#include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/scheduler/web_renderer_process_type.h"
@@ -714,7 +715,8 @@
// when hidden to allow playlist-like functionality.
//
// NOTE: This is also used to defer media loading for prerender.
- if ((render_frame->GetRenderView()->GetWebView()->IsHidden() &&
+ if ((render_frame->GetRenderView()->GetWebView()->GetVisibilityState() !=
+ blink::PageVisibilityState::kVisible &&
!has_played_media_before) ||
prerender::PrerenderHelper::IsPrerendering(render_frame)) {
new MediaLoadDeferrer(render_frame, std::move(closure));
diff --git a/content/browser/frame_host/navigation_request.cc b/content/browser/frame_host/navigation_request.cc
index a8b66c5..2683dd8 100644
--- a/content/browser/frame_host/navigation_request.cc
+++ b/content/browser/frame_host/navigation_request.cc
@@ -2170,7 +2170,7 @@
frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
report_raw_headers,
navigating_frame_host->GetVisibilityState() ==
- PageVisibilityState::kPrerender,
+ PageVisibilityState::kHiddenButPainting,
upgrade_if_insecure_,
blob_url_loader_factory_ ? blob_url_loader_factory_->Clone()
: nullptr,
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc
index 7050c3b..f71489c4 100644
--- a/content/browser/frame_host/render_frame_host_impl.cc
+++ b/content/browser/frame_host/render_frame_host_impl.cc
@@ -142,7 +142,6 @@
#include "content/public/browser/file_select_listener.h"
#include "content/public/browser/global_routing_id.h"
#include "content/public/browser/network_service_instance.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/permission_type.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -159,6 +158,7 @@
#include "content/public/common/mime_handler_view_mode.h"
#include "content/public/common/navigation_policy.h"
#include "content/public/common/network_service_util.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/referrer_type_converters.h"
#include "content/public/common/service_manager_connection.h"
#include "content/public/common/service_names.mojom.h"
diff --git a/content/browser/frame_host/render_frame_host_impl_browsertest.cc b/content/browser/frame_host/render_frame_host_impl_browsertest.cc
index a0d69de8..8f7ee167 100644
--- a/content/browser/frame_host/render_frame_host_impl_browsertest.cc
+++ b/content/browser/frame_host/render_frame_host_impl_browsertest.cc
@@ -26,12 +26,12 @@
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/frame_messages.h"
#include "content/public/browser/javascript_dialog_manager.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_features.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test.h"
#include "content/public/test/content_browser_test_utils.h"
@@ -251,8 +251,8 @@
EXPECT_EQ(PageVisibilityState::kVisible,
web_contents->GetMainFrame()->GetVisibilityState());
- new_client.EnableVisibilityOverride(PageVisibilityState::kPrerender);
- EXPECT_EQ(PageVisibilityState::kPrerender,
+ new_client.EnableVisibilityOverride(PageVisibilityState::kHiddenButPainting);
+ EXPECT_EQ(PageVisibilityState::kHiddenButPainting,
web_contents->GetMainFrame()->GetVisibilityState());
SetBrowserClientForTesting(old_client);
diff --git a/content/browser/service_worker/service_worker_client_utils.cc b/content/browser/service_worker/service_worker_client_utils.cc
index 167e091..adcadcf 100644
--- a/content/browser/service_worker/service_worker_client_utils.cc
+++ b/content/browser/service_worker/service_worker_client_utils.cc
@@ -29,7 +29,6 @@
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/page_navigator.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/browser/payment_app_provider.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_widget_host_view.h"
@@ -37,6 +36,7 @@
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/content_client.h"
+#include "content/public/common/page_visibility_state.h"
#include "third_party/blink/public/mojom/loader/request_context_frame_type.mojom.h"
#include "ui/base/window_open_disposition.h"
#include "url/gurl.h"
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index b556572..24667e2 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2554,8 +2554,10 @@
// as soon as they are shown. But the Page and other classes do not expect to
// be producing frames when the Page is hidden. So we make sure the Page is
// shown first.
- if (page_is_visible)
- SendPageMessage(new PageMsg_WasShown(MSG_ROUTING_NONE));
+ if (page_is_visible) {
+ SendPageMessage(new PageMsg_VisibilityChanged(
+ MSG_ROUTING_NONE, PageVisibilityState::kVisible));
+ }
// |GetRenderWidgetHostView()| can be null if the user middle clicks a link to
// open a tab in the background, then closes the tab before selecting it.
@@ -2589,7 +2591,8 @@
if (!page_is_visible) {
// Similar to when showing the page, we only hide the page after
// hiding the individual RenderWidgets.
- SendPageMessage(new PageMsg_WasHidden(MSG_ROUTING_NONE));
+ SendPageMessage(new PageMsg_VisibilityChanged(
+ MSG_ROUTING_NONE, PageVisibilityState::kHidden));
} else {
for (FrameTreeNode* node : frame_tree_.Nodes()) {
RenderFrameProxyHost* parent = node->render_manager()->GetProxyToParent();
diff --git a/content/common/content_param_traits_macros.h b/content/common/content_param_traits_macros.h
index 9267b6c..5a127dd4 100644
--- a/content/common/content_param_traits_macros.h
+++ b/content/common/content_param_traits_macros.h
@@ -13,6 +13,7 @@
#include "content/common/content_param_traits.h"
#include "content/common/render_widget_surface_properties.h"
#include "content/public/common/input_event_ack_state.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/resource_type.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/blink/public/mojom/csp/content_security_policy.mojom.h"
@@ -47,6 +48,8 @@
blink::WebImeTextSpan::Type::kMisspellingSuggestion)
IPC_ENUM_TRAITS_MAX_VALUE(ui::mojom::ImeTextSpanThickness,
ui::mojom::ImeTextSpanThickness::kThick)
+IPC_ENUM_TRAITS_MAX_VALUE(content::PageVisibilityState,
+ content::PageVisibilityState::kMaxValue)
IPC_STRUCT_TRAITS_BEGIN(viz::Selection<gfx::SelectionBound>)
IPC_STRUCT_TRAITS_MEMBER(start)
diff --git a/content/common/page_messages.h b/content/common/page_messages.h
index dabd487..50e77ced 100644
--- a/content/common/page_messages.h
+++ b/content/common/page_messages.h
@@ -6,6 +6,7 @@
#define CONTENT_COMMON_PAGE_MESSAGES_H_
#include "content/public/common/common_param_traits.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/screen_info.h"
#include "ipc/ipc_message_macros.h"
#include "third_party/blink/public/platform/web_text_autosizer_page_info.h"
@@ -21,11 +22,7 @@
// Messages sent from the browser to the renderer.
-// Informs the renderer that the page was hidden.
-IPC_MESSAGE_ROUTED0(PageMsg_WasHidden)
-
-// Informs the renderer that the page is no longer hidden.
-IPC_MESSAGE_ROUTED0(PageMsg_WasShown)
+IPC_MESSAGE_ROUTED1(PageMsg_VisibilityChanged, content::PageVisibilityState)
// Sent when the history for this page is altered from another process. The
// history list should be reset to |history_length| length, and the offset
diff --git a/content/public/browser/BUILD.gn b/content/public/browser/BUILD.gn
index e69d932c..c4f537c 100644
--- a/content/public/browser/BUILD.gn
+++ b/content/public/browser/BUILD.gn
@@ -251,7 +251,6 @@
"overscroll_configuration.h",
"page_navigator.cc",
"page_navigator.h",
- "page_visibility_state.h",
"payment_app_provider.h",
"peak_gpu_memory_tracker.h",
"pepper_flash_settings_helper.h",
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
index 87e4fd6..f0147c2 100644
--- a/content/public/browser/content_browser_client.h
+++ b/content/public/browser/content_browser_client.h
@@ -24,7 +24,7 @@
#include "content/common/content_export.h"
#include "content/public/browser/certificate_request_result_type.h"
#include "content/public/browser/generated_code_cache_settings.h"
-#include "content/public/browser/page_visibility_state.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/previews_state.h"
#include "content/public/common/window_container_type.mojom-forward.h"
#include "media/base/video_codecs.h"
diff --git a/content/public/browser/page_visibility_state.h b/content/public/browser/page_visibility_state.h
deleted file mode 100644
index 33a39ac..0000000
--- a/content/public/browser/page_visibility_state.h
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2018 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CONTENT_PUBLIC_BROWSER_PAGE_VISIBILITY_STATE_H_
-#define CONTENT_PUBLIC_BROWSER_PAGE_VISIBILITY_STATE_H_
-
-namespace content {
-
-enum class PageVisibilityState {
- kVisible,
- kHidden,
- kPrerender,
-};
-
-} // namespace content
-
-#endif // CONTENT_PUBLIC_BROWSER_PAGE_VISIBILITY_STATE_H_
diff --git a/content/public/browser/render_frame_host.h b/content/public/browser/render_frame_host.h
index d506e19..b8bf9f0b 100644
--- a/content/public/browser/render_frame_host.h
+++ b/content/public/browser/render_frame_host.h
@@ -14,9 +14,9 @@
#include "base/optional.h"
#include "build/build_config.h"
#include "content/common/content_export.h"
-#include "content/public/browser/page_visibility_state.h"
#include "content/public/common/browser_controls_state.h"
#include "content/public/common/isolated_world_ids.h"
+#include "content/public/common/page_visibility_state.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
diff --git a/content/public/common/BUILD.gn b/content/public/common/BUILD.gn
index 6223c89..fd22f18 100644
--- a/content/public/common/BUILD.gn
+++ b/content/public/common/BUILD.gn
@@ -172,6 +172,7 @@
"page_state.cc",
"page_state.h",
"page_type.h",
+ "page_visibility_state.h",
"page_zoom.h",
"pepper_plugin_info.cc",
"pepper_plugin_info.h",
diff --git a/content/public/common/page_visibility_state.h b/content/public/common/page_visibility_state.h
new file mode 100644
index 0000000..1b5bbc2
--- /dev/null
+++ b/content/public/common/page_visibility_state.h
@@ -0,0 +1,16 @@
+// Copyright 2018 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_PUBLIC_COMMON_PAGE_VISIBILITY_STATE_H_
+#define CONTENT_PUBLIC_COMMON_PAGE_VISIBILITY_STATE_H_
+
+#include "third_party/blink/public/common/page/page_visibility_state.h"
+
+namespace content {
+
+using PageVisibilityState = blink::PageVisibilityState;
+
+} // namespace content
+
+#endif // CONTENT_PUBLIC_COMMON_PAGE_VISIBILITY_STATE_H_
diff --git a/content/renderer/gpu_benchmarking_extension.cc b/content/renderer/gpu_benchmarking_extension.cc
index fecd4eb84..e2f38fb 100644
--- a/content/renderer/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu_benchmarking_extension.cc
@@ -46,6 +46,7 @@
#include "gpu/ipc/common/gpu_messages.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "services/service_manager/public/cpp/interface_provider.h"
+#include "third_party/blink/public/common/page/page_visibility_state.h"
#include "third_party/blink/public/platform/web_mouse_event.h"
#include "third_party/blink/public/web/blink.h"
#include "third_party/blink/public/web/web_image_cache.h"
@@ -1175,8 +1176,8 @@
GpuBenchmarkingContext context(render_frame_);
// TODO(fmeawad): Instead of forcing a visibility change, only allow
// freezing a page if it was already hidden.
- context.web_view()->SetIsHidden(/*hidden=*/true,
- /*is_initial_state=*/false);
+ context.web_view()->SetVisibilityState(PageVisibilityState::kHidden,
+ /*is_initial_state=*/false);
context.web_view()->SetPageFrozen(true);
}
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index db4f05a6..d66ff0b 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -1266,8 +1266,7 @@
IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque)
// Page messages.
- IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
- IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
+ IPC_MESSAGE_HANDLER(PageMsg_VisibilityChanged, OnPageVisibilityChanged)
IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength,
OnSetHistoryOffsetAndLength)
IPC_MESSAGE_HANDLER(PageMsg_AudioStateChanged, OnAudioStateChanged)
@@ -1622,7 +1621,7 @@
int delay;
if (send_content_state_immediately_)
delay = 0;
- else if (GetWebView()->IsHidden())
+ else if (GetWebView()->GetVisibilityState() != PageVisibilityState::kVisible)
delay = kDelaySecondsForContentStateSyncHidden;
else
delay = kDelaySecondsForContentStateSync;
@@ -1852,8 +1851,10 @@
webview()->SetPageScaleFactor(page_scale_factor);
}
-void RenderViewImpl::ApplyPageHidden(bool hidden, bool initial_setting) {
- webview()->SetIsHidden(hidden, initial_setting);
+void RenderViewImpl::ApplyPageVisibilityState(
+ PageVisibilityState visibility_state,
+ bool initial_setting) {
+ webview()->SetVisibilityState(visibility_state, initial_setting);
// Note: RenderWidget visibility is separately set from the IPC handlers, and
// does not change when tests override the visibility of the Page.
}
@@ -1979,20 +1980,14 @@
webview()->CancelPagePopup();
}
-void RenderViewImpl::OnPageWasHidden() {
+void RenderViewImpl::OnPageVisibilityChanged(
+ PageVisibilityState visibility_state) {
#if defined(OS_ANDROID)
- SuspendVideoCaptureDevices(true);
+ SuspendVideoCaptureDevices(visibility_state != PageVisibilityState::kVisible);
#endif
- ApplyPageHidden(/*hidden=*/true, /*initial_setting=*/false);
-}
-
-void RenderViewImpl::OnPageWasShown() {
-#if defined(OS_ANDROID)
- SuspendVideoCaptureDevices(false);
-#endif
-
- ApplyPageHidden(/*hidden=*/false, /*initial_setting=*/false);
+ ApplyPageVisibilityState(visibility_state,
+ /*initial_setting=*/false);
}
void RenderViewImpl::SetPageFrozen(bool frozen) {
diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h
index 82ba64f..978d8c2 100644
--- a/content/renderer/render_view_impl.h
+++ b/content/renderer/render_view_impl.h
@@ -29,6 +29,7 @@
#include "content/common/content_export.h"
#include "content/public/common/browser_controls_state.h"
#include "content/public/common/drop_data.h"
+#include "content/public/common/page_visibility_state.h"
#include "content/public/common/page_zoom.h"
#include "content/public/common/referrer.h"
#include "content/public/common/web_preferences.h"
@@ -301,7 +302,8 @@
// Called when Page visibility is changed, to update the View/Page in blink.
// This is separate from the IPC handlers as tests may call this and need to
// be able to specify |initial_setting| where IPC handlers do not.
- void ApplyPageHidden(bool hidden, bool initial_setting);
+ void ApplyPageVisibilityState(PageVisibilityState visibility_state,
+ bool initial_setting);
// Instead of creating a new RenderWidget, a RenderFrame for a main frame
// revives the undead RenderWidget;
@@ -459,8 +461,7 @@
void OnSetBackgroundOpaque(bool opaque);
// Page message handlers -----------------------------------------------------
- void OnPageWasHidden();
- void OnPageWasShown();
+ void OnPageVisibilityChanged(PageVisibilityState visibility_state);
void SetPageFrozen(bool frozen);
void PutPageIntoBackForwardCache();
void RestorePageFromBackForwardCache(base::TimeTicks navigation_start);
diff --git a/content/shell/test_runner/test_runner_for_specific_view.cc b/content/shell/test_runner/test_runner_for_specific_view.cc
index 60f753f..8e072bc 100644
--- a/content/shell/test_runner/test_runner_for_specific_view.cc
+++ b/content/shell/test_runner/test_runner_for_specific_view.cc
@@ -105,8 +105,9 @@
// LayerTreeView.
main_frame_render_widget()->layer_tree_view()->SetVisible(true);
}
- web_view_test_proxy_->ApplyPageHidden(/*hidden=*/false,
- /*initial_setting=*/true);
+ web_view_test_proxy_->ApplyPageVisibilityState(
+ content::PageVisibilityState::kVisible,
+ /*initial_setting=*/true);
}
bool TestRunnerForSpecificView::RequestPointerLock() {
@@ -488,13 +489,14 @@
void TestRunnerForSpecificView::SetPageVisibility(
const std::string& new_visibility) {
- bool hidden;
- if (new_visibility == "visible")
- hidden = false;
- else if (new_visibility == "hidden")
- hidden = true;
- else
+ content::PageVisibilityState visibility;
+ if (new_visibility == "visible") {
+ visibility = content::PageVisibilityState::kVisible;
+ } else if (new_visibility == "hidden") {
+ visibility = content::PageVisibilityState::kHidden;
+ } else {
return;
+ }
// As would the browser via IPC, set visibility on the RenderWidget then on
// the Page.
@@ -502,9 +504,10 @@
// main frame.
// TODO(danakj): This should set visible on the RenderWidget not just the
// LayerTreeView.
- main_frame_render_widget()->layer_tree_view()->SetVisible(!hidden);
- web_view_test_proxy_->ApplyPageHidden(/*hidden=*/hidden,
- /*initial_setting=*/false);
+ main_frame_render_widget()->layer_tree_view()->SetVisible(
+ visibility == content::PageVisibilityState::kVisible);
+ web_view_test_proxy_->ApplyPageVisibilityState(visibility,
+ /*initial_setting=*/false);
}
void TestRunnerForSpecificView::SetTextDirection(
diff --git a/content/shell/test_runner/web_view_test_proxy.h b/content/shell/test_runner/web_view_test_proxy.h
index 01068b7..04407bd6 100644
--- a/content/shell/test_runner/web_view_test_proxy.h
+++ b/content/shell/test_runner/web_view_test_proxy.h
@@ -85,7 +85,7 @@
void DidFocus(blink::WebLocalFrame* calling_frame) override;
// Exposed for our TestRunner harness.
- using RenderViewImpl::ApplyPageHidden;
+ using RenderViewImpl::ApplyPageVisibilityState;
WebTestDelegate* delegate() { return delegate_.get(); }
TestInterfaces* test_interfaces() { return test_interfaces_; }
diff --git a/third_party/blink/public/common/BUILD.gn b/third_party/blink/public/common/BUILD.gn
index d8f35073..1dbf29d1 100644
--- a/third_party/blink/public/common/BUILD.gn
+++ b/third_party/blink/public/common/BUILD.gn
@@ -119,6 +119,7 @@
"origin_trials/trial_token.h",
"origin_trials/trial_token_validator.h",
"page/launching_process_state.h",
+ "page/page_visibility_state.h",
"page/page_zoom.h",
"peerconnection/webrtc_ip_handling_policy.h",
"plugin/plugin_action.h",
diff --git a/third_party/blink/public/common/page/page_visibility_state.h b/third_party/blink/public/common/page/page_visibility_state.h
new file mode 100644
index 0000000..42e1ca9
--- /dev/null
+++ b/third_party/blink/public/common/page/page_visibility_state.h
@@ -0,0 +1,20 @@
+// Copyright 2019 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_PAGE_VISIBILITY_STATE_H_
+#define THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_PAGE_VISIBILITY_STATE_H_
+
+namespace blink {
+
+enum class PageVisibilityState {
+ kVisible,
+ kHidden,
+ kHiddenButPainting,
+
+ kMaxValue = kHiddenButPainting,
+};
+
+} // namespace blink
+
+#endif // THIRD_PARTY_BLINK_PUBLIC_COMMON_PAGE_PAGE_VISIBILITY_STATE_H_
diff --git a/third_party/blink/public/web/web_view.h b/third_party/blink/public/web/web_view.h
index f3c93c54..0981d5a 100644
--- a/third_party/blink/public/web/web_view.h
+++ b/third_party/blink/public/web/web_view.h
@@ -32,6 +32,7 @@
#define THIRD_PARTY_BLINK_PUBLIC_WEB_WEB_VIEW_H_
#include "base/time/time.h"
+#include "third_party/blink/public/common/page/page_visibility_state.h"
#include "third_party/blink/public/mojom/manifest/display_mode.mojom-shared.h"
#include "third_party/blink/public/platform/web_drag_operation.h"
#include "third_party/blink/public/platform/web_focus_type.h"
@@ -406,8 +407,9 @@
// Visibility -----------------------------------------------------------
// Sets the visibility of the WebView.
- virtual void SetIsHidden(bool hidden, bool is_initial_state) = 0;
- virtual bool IsHidden() = 0;
+ virtual void SetVisibilityState(PageVisibilityState visibility_state,
+ bool is_initial_state) = 0;
+ virtual PageVisibilityState GetVisibilityState() = 0;
// FrameOverlay ----------------------------------------------------------
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
index dc891f667..2556772 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -288,7 +288,9 @@
Page::CreateOrdinary(page_clients, opener ? opener->GetPage() : nullptr);
CoreInitializer::GetInstance().ProvideModulesToPage(*AsView().page,
AsView().client);
- SetIsHidden(is_hidden, /*is_initial_state=*/true);
+ SetVisibilityState(
+ is_hidden ? PageVisibilityState::kHidden : PageVisibilityState::kVisible,
+ /*is_initial_state=*/true);
// When not compositing, keep the Page in the loop so that it will paint all
// content into the root layer, as multiple layers can only be used when
@@ -3373,15 +3375,17 @@
return GetPage()->GetPageScheduler();
}
-void WebViewImpl::SetIsHidden(bool hidden, bool is_initial_state) {
+void WebViewImpl::SetVisibilityState(PageVisibilityState visibility_state,
+ bool is_initial_state) {
DCHECK(GetPage());
- GetPage()->SetIsHidden(hidden, is_initial_state);
- GetPage()->GetPageScheduler()->SetPageVisible(!hidden);
+ GetPage()->SetVisibilityState(visibility_state, is_initial_state);
+ GetPage()->GetPageScheduler()->SetPageVisible(visibility_state ==
+ PageVisibilityState::kVisible);
}
-bool WebViewImpl::IsHidden() {
+PageVisibilityState WebViewImpl::GetVisibilityState() {
DCHECK(GetPage());
- return !GetPage()->IsPageVisible();
+ return GetPage()->GetVisibilityState();
}
void WebViewImpl::ForceNextWebGLContextCreationToFail() {
@@ -3421,7 +3425,7 @@
}
void WebViewImpl::PutPageIntoBackForwardCache() {
- SetIsHidden(/*is_hidden=*/true, /*is_initial_state=*/false);
+ SetVisibilityState(PageVisibilityState::kHidden, /*is_initial_state=*/false);
Page* page = AsView().page;
if (page) {
@@ -3473,7 +3477,7 @@
}
}
}
- SetIsHidden(/*is_hidden=*/false, /*is_initial_state=*/false);
+ SetVisibilityState(PageVisibilityState::kVisible, /*is_initial_state=*/false);
}
WebWidget* WebViewImpl::MainFrameWidget() {
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h
index 1c34fb5..b90eb91 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.h
+++ b/third_party/blink/renderer/core/exported/web_view_impl.h
@@ -309,8 +309,9 @@
LocalDOMWindow* PagePopupWindow() const;
PageScheduler* Scheduler() const override;
- void SetIsHidden(bool hidden, bool is_initial_state) override;
- bool IsHidden() override;
+ void SetVisibilityState(PageVisibilityState visibility_state,
+ bool is_initial_state) override;
+ PageVisibilityState GetVisibilityState() override;
// Called by a full frame plugin inside this view to inform it that its
// zoom level has been updated. The plugin should only call this function
diff --git a/third_party/blink/renderer/core/exported/web_view_test.cc b/third_party/blink/renderer/core/exported/web_view_test.cc
index 0589ae3..2d236e4 100644
--- a/third_party/blink/renderer/core/exported/web_view_test.cc
+++ b/third_party/blink/renderer/core/exported/web_view_test.cc
@@ -497,8 +497,7 @@
frame_test_helpers::TestWebViewClient web_view_client;
frame_test_helpers::TestWebWidgetClient web_widget_client;
WebViewImpl* web_view = static_cast<WebViewImpl*>(
- WebView::Create(&web_view_client,
- /*is_hidden=*/false,
+ WebView::Create(&web_view_client, false,
/*compositing_enabled=*/true, nullptr));
EXPECT_NE(SK_ColorBLUE, web_view->BackgroundColor());
// WebView does not have a frame yet, but we should still be able to set the
@@ -2643,7 +2642,7 @@
// Note: this test doesn't use WebViewHelper since WebViewHelper creates an
// internal WebViewClient on demand if the supplied WebViewClient is null.
WebViewImpl* web_view = static_cast<WebViewImpl*>(
- WebView::Create(nullptr, /*is_hidden=*/false,
+ WebView::Create(nullptr, false,
/*compositing_enabled=*/false, nullptr));
frame_test_helpers::TestWebFrameClient web_frame_client;
frame_test_helpers::TestWebWidgetClient web_widget_client;
@@ -5455,9 +5454,11 @@
key_event2.windows_key_code = VKEY_SPACE;
key_event2.SetTimeStamp(test_task_runner_->NowTicks());
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(100));
- web_view->SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(100));
- web_view->SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(100));
// Total input delay is >300ms.
web_view->MainFrameWidget()->HandleInputEvent(
@@ -5473,7 +5474,8 @@
// calculate longest input delay.
TEST_F(WebViewTest, LongestInputDelayPageBackgroundedAtNavStart) {
WebViewImpl* web_view = web_view_helper_.Initialize();
- web_view->SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
WebURL base_url = url_test_helpers::ToKURL("http://example.com/");
frame_test_helpers::LoadHTMLString(web_view->MainFrameImpl(),
"<html><body></body></html>", base_url);
@@ -5496,7 +5498,8 @@
key_event.windows_key_code = VKEY_SPACE;
key_event.SetTimeStamp(test_task_runner_->NowTicks());
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(100));
- web_view->SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
web_view->MainFrameWidget()->HandleInputEvent(
WebCoalescedInputEvent(key_event));
@@ -5524,9 +5527,11 @@
EXPECT_TRUE(interactive_detector->GetLongestInputDelay().is_zero());
- web_view->SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(100));
- web_view->SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ web_view->SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
test_task_runner_->FastForwardBy(base::TimeDelta::FromMilliseconds(1));
WebKeyboardEvent key_event(WebInputEvent::kRawKeyDown,
diff --git a/third_party/blink/renderer/core/html/canvas/canvas_font_cache_test.cc b/third_party/blink/renderer/core/html/canvas/canvas_font_cache_test.cc
index f8fa995..09e5055 100644
--- a/third_party/blink/renderer/core/html/canvas/canvas_font_cache_test.cc
+++ b/third_party/blink/renderer/core/html/canvas/canvas_font_cache_test.cc
@@ -71,7 +71,8 @@
TEST_F(CanvasFontCacheTest, PageVisibilityChange) {
Context2D()->setFont("10px sans-serif");
EXPECT_TRUE(Cache()->IsInCache("10px sans-serif"));
- GetPage().SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
EXPECT_FALSE(Cache()->IsInCache("10px sans-serif"));
Context2D()->setFont("15px sans-serif");
@@ -82,7 +83,8 @@
EXPECT_TRUE(Cache()->IsInCache("10px sans-serif"));
EXPECT_FALSE(Cache()->IsInCache("15px sans-serif"));
- GetPage().SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ GetPage().SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
Context2D()->setFont("15px sans-serif");
Context2D()->setFont("10px sans-serif");
EXPECT_TRUE(Cache()->IsInCache("10px sans-serif"));
diff --git a/third_party/blink/renderer/core/html/media/video_wake_lock_test.cc b/third_party/blink/renderer/core/html/media/video_wake_lock_test.cc
index 3908425d..f64b8f8 100644
--- a/third_party/blink/renderer/core/html/media/video_wake_lock_test.cc
+++ b/third_party/blink/renderer/core/html/media/video_wake_lock_test.cc
@@ -109,7 +109,7 @@
video_->SetReadyState(HTMLMediaElement::ReadyState::kHaveMetadata);
video_wake_lock_ = MakeGarbageCollected<VideoWakeLock>(*video_.Get());
- GetPage().SetIsHidden(false, true);
+ GetPage().SetVisibilityState(PageVisibilityState::kVisible, true);
}
void TearDown() override {
@@ -191,32 +191,32 @@
SimulatePlaying();
EXPECT_TRUE(GetVideoWakeLock()->active_for_tests());
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
}
TEST_F(VideoWakeLockTest, PlayingWhileHiddenDoesNotRequestLock) {
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
SimulatePlaying();
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
}
TEST_F(VideoWakeLockTest, ShowingPageRequestsLock) {
SimulatePlaying();
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
- GetPage().SetIsHidden(false, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kVisible, false);
EXPECT_TRUE(GetVideoWakeLock()->active_for_tests());
}
TEST_F(VideoWakeLockTest, ShowingPageDoNotRequestsLockIfPaused) {
SimulatePlaying();
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
SimulatePause();
- GetPage().SetIsHidden(false, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kVisible, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
}
@@ -265,7 +265,7 @@
test::RunPendingTasks();
SimulatePlaying();
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
SimulateEnterPictureInPicture();
@@ -281,7 +281,7 @@
test::RunPendingTasks();
SimulatePlaying();
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
EXPECT_FALSE(GetVideoWakeLock()->active_for_tests());
SimulatePause();
@@ -298,7 +298,7 @@
test::RunPendingTasks();
SimulatePlaying();
- GetPage().SetIsHidden(true, false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden, false);
SimulateEnterPictureInPicture();
EXPECT_TRUE(GetVideoWakeLock()->active_for_tests());
diff --git a/third_party/blink/renderer/core/page/page.cc b/third_party/blink/renderer/core/page/page.cc
index af81a074..9060d1a 100644
--- a/third_party/blink/renderer/core/page/page.cc
+++ b/third_party/blink/renderer/core/page/page.cc
@@ -200,7 +200,7 @@
tab_key_cycles_through_elements_(true),
paused_(false),
device_scale_factor_(1),
- is_hidden_(false),
+ visibility_state_(PageVisibilityState::kVisible),
is_ordinary_(false),
page_lifecycle_state_(kDefaultPageLifecycleState),
is_cursor_visible_(true),
@@ -496,24 +496,29 @@
}
}
-void Page::SetIsHidden(bool hidden, bool is_initial_state) {
- if (is_hidden_ == hidden)
+void Page::SetVisibilityState(PageVisibilityState visibility_state,
+ bool is_initial_state) {
+ if (visibility_state_ == visibility_state)
return;
- is_hidden_ = hidden;
+ visibility_state_ = visibility_state;
if (is_initial_state)
return;
NotifyPageVisibilityChanged();
if (main_frame_) {
- if (IsPageVisible())
+ if (visibility_state_ == PageVisibilityState::kVisible)
RestoreSVGImageAnimations();
main_frame_->DidChangeVisibilityState();
}
}
+PageVisibilityState Page::GetVisibilityState() const {
+ return visibility_state_;
+}
+
bool Page::IsPageVisible() const {
- return !is_hidden_;
+ return visibility_state_ == PageVisibilityState::kVisible;
}
void Page::SetLifecycleState(PageLifecycleState state) {
diff --git a/third_party/blink/renderer/core/page/page.h b/third_party/blink/renderer/core/page/page.h
index e660edb6..e968b10 100644
--- a/third_party/blink/renderer/core/page/page.h
+++ b/third_party/blink/renderer/core/page/page.h
@@ -26,6 +26,7 @@
#include <memory>
#include "base/macros.h"
+#include "third_party/blink/public/common/page/page_visibility_state.h"
#include "third_party/blink/public/platform/scheduler/web_scoped_virtual_time_pauser.h"
#include "third_party/blink/public/platform/web_text_autosizer_page_info.h"
#include "third_party/blink/public/web/web_window_features.h"
@@ -262,7 +263,9 @@
static void AllVisitedStateChanged(bool invalidate_visited_link_hashes);
static void VisitedStateChanged(LinkHash visited_hash);
- void SetIsHidden(bool hidden, bool is_initial_state);
+ void SetVisibilityState(PageVisibilityState visibility_state,
+ bool is_initial_state);
+ PageVisibilityState GetVisibilityState() const;
bool IsPageVisible() const;
PageLifecycleState LifecycleState() const;
@@ -416,7 +419,7 @@
float device_scale_factor_;
- bool is_hidden_;
+ PageVisibilityState visibility_state_;
bool is_ordinary_;
diff --git a/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc b/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
index c471081..793b903 100644
--- a/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
+++ b/third_party/blink/renderer/core/svg/graphics/svg_image_test.cc
@@ -354,7 +354,8 @@
// Set page visibility to 'hidden', and then wait for the animation timer to
// fire. This should suspend the image animation. (Suspend the image's
// animation timeline.)
- WebView().SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ WebView().SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
test::RunDelayedTasks(base::TimeDelta::FromMilliseconds(1) +
timer->NextFireInterval());
@@ -362,7 +363,8 @@
// Set page visibility to 'visible' - this should schedule a new animation
// frame and resume the image animation.
- WebView().SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ WebView().SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
test::RunDelayedTasks(base::TimeDelta::FromMilliseconds(1) +
timer->NextFireInterval());
Compositor().BeginFrame();
diff --git a/third_party/blink/renderer/core/timing/performance_navigation_timing_test.cc b/third_party/blink/renderer/core/timing/performance_navigation_timing_test.cc
index c0ff332..393622c9 100644
--- a/third_party/blink/renderer/core/timing/performance_navigation_timing_test.cc
+++ b/third_party/blink/renderer/core/timing/performance_navigation_timing_test.cc
@@ -17,12 +17,14 @@
};
TEST_F(PerformanceNavigationTimingTest, GetNavigationType) {
- GetPage().SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ GetPage().SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
AtomicString returned_type =
GetNavigationType(kWebNavigationTypeBackForward, &GetDocument());
EXPECT_EQ(returned_type, "back_forward");
- GetPage().SetIsHidden(/*is_hidden=*/false, /*initial_state=*/false);
+ GetPage().SetVisibilityState(PageVisibilityState::kVisible,
+ /*initial_state=*/false);
returned_type =
GetNavigationType(kWebNavigationTypeFormResubmitted, &GetDocument());
EXPECT_EQ(returned_type, "navigate");
diff --git a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
index 4a33e8c..119e0b6 100644
--- a/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
+++ b/third_party/blink/renderer/modules/canvas/canvas2d/canvas_rendering_context_2d_test.cc
@@ -1128,8 +1128,8 @@
UpdateAllLifecyclePhasesForTest();
// Hide element to trigger hibernation (if enabled).
- GetDocument().GetPage()->SetIsHidden(/*is_hidden=*/true,
- /*is_initial_state=*/false);
+ GetDocument().GetPage()->SetVisibilityState(PageVisibilityState::kHidden,
+ /*is_initial_state=*/false);
blink::test::RunPendingTasks(); // Run hibernation task.
// If enabled, hibernation should cause compositing update.
EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED,
@@ -1143,8 +1143,8 @@
EXPECT_FALSE(layer->NeedsCompositingInputsUpdate());
// Wake up again, which should request a compositing update synchronously.
- GetDocument().GetPage()->SetIsHidden(/*is_hidden=*/false,
- /*is_initial_state=*/false);
+ GetDocument().GetPage()->SetVisibilityState(PageVisibilityState::kVisible,
+ /*is_initial_state=*/false);
EXPECT_EQ(!!CANVAS2D_HIBERNATION_ENABLED,
layer->NeedsCompositingInputsUpdate());
}
@@ -1172,8 +1172,8 @@
canvas_element_->ReplaceResourceProvider(nullptr);
// Hide element to trigger hibernation (if enabled).
- GetDocument().GetPage()->SetIsHidden(/*is_hidden=*/true,
- /*is_initial_state=*/false);
+ GetDocument().GetPage()->SetVisibilityState(PageVisibilityState::kHidden,
+ /*is_initial_state=*/false);
blink::test::RunPendingTasks(); // Run hibernation task.
// Never hibernate a canvas with no resource provider
diff --git a/third_party/blink/renderer/modules/presentation/presentation_availability_test.cc b/third_party/blink/renderer/modules/presentation/presentation_availability_test.cc
index 20adb7e1..0eebe1d 100644
--- a/third_party/blink/renderer/modules/presentation/presentation_availability_test.cc
+++ b/third_party/blink/renderer/modules/presentation/presentation_availability_test.cc
@@ -41,7 +41,8 @@
// TODO(dcheng): Why are we calling functions on Page after it's been closed?
// This case doesn't seem like it should be reachable as we should be shutting
// down communication from the embedder on context detach.
- page->SetIsHidden(/*is_hidden=*/true, /*initial_state=*/false);
+ page->SetVisibilityState(PageVisibilityState::kHidden,
+ /*initial_state=*/false);
}
} // anonymous namespace
diff --git a/third_party/blink/renderer/modules/wake_lock/wake_lock_test.cc b/third_party/blink/renderer/modules/wake_lock/wake_lock_test.cc
index 049f2e9..6bcb561 100644
--- a/third_party/blink/renderer/modules/wake_lock/wake_lock_test.cc
+++ b/third_party/blink/renderer/modules/wake_lock/wake_lock_test.cc
@@ -149,14 +149,16 @@
context.WaitForPromiseFulfillment(screen_promise);
context.WaitForPromiseFulfillment(system_promise);
- context.GetDocument()->GetPage()->SetIsHidden(true, false);
+ context.GetDocument()->GetPage()->SetVisibilityState(
+ PageVisibilityState::kHidden, false);
screen_lock.WaitForCancelation();
EXPECT_FALSE(screen_lock.is_acquired());
EXPECT_TRUE(system_lock.is_acquired());
- context.GetDocument()->GetPage()->SetIsHidden(false, false);
+ context.GetDocument()->GetPage()->SetVisibilityState(
+ PageVisibilityState::kVisible, false);
auto* other_resolver =
MakeGarbageCollected<ScriptPromiseResolver>(context.GetScriptState());
@@ -192,7 +194,8 @@
auto* wake_lock = MakeGarbageCollected<WakeLock>(*context.GetDocument());
wake_lock->DoRequest(WakeLockType::kScreen, screen_resolver);
wake_lock->DoRequest(WakeLockType::kSystem, system_resolver);
- context.GetDocument()->GetPage()->SetIsHidden(true, false);
+ context.GetDocument()->GetPage()->SetVisibilityState(
+ PageVisibilityState::kHidden, false);
context.WaitForPromiseRejection(screen_promise);
system_lock.WaitForRequest();