Commit 5ee8b41f authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Avoid a flash when the fullscreen element is sometimes resized.

The background can be painted underneath occasionally. When we have
a fullscreen element indicate the backdrop's color.

BUG=886544, 785001

Change-Id: I17d2533779abc68b14bc8af732f182dd32e963f0
Reviewed-on: https://chromium-review.googlesource.com/1234232
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#593193}
parent ff1be83f
...@@ -2363,6 +2363,28 @@ TEST_F(WebViewTest, FullscreenNoResetScroll) { ...@@ -2363,6 +2363,28 @@ TEST_F(WebViewTest, FullscreenNoResetScroll) {
EXPECT_EQ(2100, web_view_impl->MainFrameImpl()->GetScrollOffset().height); EXPECT_EQ(2100, web_view_impl->MainFrameImpl()->GetScrollOffset().height);
} }
// Tests that background color is read from the backdrop on fullscreen.
TEST_F(WebViewTest, FullscreenBackgroundColor) {
RegisterMockedHttpURLLoad("fullscreen_style.html");
WebViewImpl* web_view_impl =
web_view_helper_.InitializeAndLoad(base_url_ + "fullscreen_style.html");
web_view_impl->Resize(WebSize(800, 600));
web_view_impl->UpdateAllLifecyclePhases();
EXPECT_EQ(SK_ColorWHITE, web_view_impl->BackgroundColor());
// Enter fullscreen.
LocalFrame* frame = web_view_impl->MainFrameImpl()->GetFrame();
Element* element = frame->GetDocument()->getElementById("fullscreenElement");
ASSERT_TRUE(element);
std::unique_ptr<UserGestureIndicator> gesture =
Frame::NotifyUserActivation(frame);
Fullscreen::RequestFullscreen(*element);
web_view_impl->DidEnterFullscreen();
web_view_impl->UpdateAllLifecyclePhases();
EXPECT_EQ(SK_ColorYELLOW, web_view_impl->BackgroundColor());
}
class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient { class PrintWebViewClient : public FrameTestHelpers::TestWebViewClient {
public: public:
PrintWebViewClient() : print_called_(false) {} PrintWebViewClient() : print_called_(false) {}
......
...@@ -2151,6 +2151,18 @@ Color LocalFrameView::DocumentBackgroundColor() const { ...@@ -2151,6 +2151,18 @@ Color LocalFrameView::DocumentBackgroundColor() const {
// background color of the LocalFrameView. This should match the color drawn // background color of the LocalFrameView. This should match the color drawn
// by ViewPainter::paintBoxDecorationBackground. // by ViewPainter::paintBoxDecorationBackground.
Color result = BaseBackgroundColor(); Color result = BaseBackgroundColor();
// If we have a fullscreen element grab the fullscreen color from the
// backdrop.
if (Document* doc = frame_->GetDocument()) {
if (Element* element = Fullscreen::FullscreenElementFrom(*doc)) {
if (LayoutObject* layout_object =
element->PseudoElementLayoutObject(kPseudoIdBackdrop)) {
return result.Blend(
layout_object->ResolveColor(GetCSSPropertyBackgroundColor()));
}
}
}
auto* layout_view = GetLayoutView(); auto* layout_view = GetLayoutView();
if (layout_view) { if (layout_view) {
result = result.Blend( result = result.Blend(
......
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
<html> <html>
<head> <head>
<style> <style>
::backdrop {
background: yellow;
}
body, html { body, html {
height: 100%; height: 100%;
margin: 0px; margin: 0px;
......
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