Commit d8ed6354 authored by hush@chromium.org's avatar hush@chromium.org

backgroundColor with 0 alpha is still valid, and FrameView should set the color.

For example, android can set the background color of a WebView to be
transparent. This sets the mainframe base background color to be transparent.

The internal bug is b/15373310
BUG=375864

Review URL: https://codereview.chromium.org/315763003

git-svn-id: svn://svn.chromium.org/blink/trunk@175586 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7f9ac13f
...@@ -384,8 +384,7 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background ...@@ -384,8 +384,7 @@ void LocalFrame::createView(const IntSize& viewportSize, const Color& background
setView(frameView); setView(frameView);
if (backgroundColor.alpha()) frameView->updateBackgroundRecursively(backgroundColor, transparent);
frameView->updateBackgroundRecursively(backgroundColor, transparent);
if (isMainFrame) if (isMainFrame)
frameView->setParentVisible(true); frameView->setParentVisible(true);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "core/dom/Document.h" #include "core/dom/Document.h"
#include "core/dom/Element.h" #include "core/dom/Element.h"
#include "core/frame/FrameView.h" #include "core/frame/FrameView.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/Settings.h" #include "core/frame/Settings.h"
#include "core/html/HTMLDocument.h" #include "core/html/HTMLDocument.h"
#include "core/html/HTMLIFrameElement.h" #include "core/html/HTMLIFrameElement.h"
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
#include "core/rendering/RenderLayer.h" #include "core/rendering/RenderLayer.h"
#include "core/rendering/RenderView.h" #include "core/rendering/RenderView.h"
#include "platform/KeyboardCodes.h" #include "platform/KeyboardCodes.h"
#include "platform/geometry/IntSize.h"
#include "platform/graphics/Color.h" #include "platform/graphics/Color.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
#include "public/platform/WebDragData.h" #include "public/platform/WebDragData.h"
...@@ -217,8 +219,9 @@ TEST_F(WebViewTest, SetBaseBackgroundColor) ...@@ -217,8 +219,9 @@ TEST_F(WebViewTest, SetBaseBackgroundColor)
const WebColor kBlue = 0xFF0000FF; const WebColor kBlue = 0xFF0000FF;
const WebColor kDarkCyan = 0xFF227788; const WebColor kDarkCyan = 0xFF227788;
const WebColor kTranslucentPutty = 0x80BFB196; const WebColor kTranslucentPutty = 0x80BFB196;
const WebColor kTransparent = 0x00000000;
WebView* webView = m_webViewHelper.initialize(); WebViewImpl* webView = m_webViewHelper.initialize();
EXPECT_EQ(kWhite, webView->backgroundColor()); EXPECT_EQ(kWhite, webView->backgroundColor());
webView->setBaseBackgroundColor(kBlue); webView->setBaseBackgroundColor(kBlue);
...@@ -235,6 +238,21 @@ TEST_F(WebViewTest, SetBaseBackgroundColor) ...@@ -235,6 +238,21 @@ TEST_F(WebViewTest, SetBaseBackgroundColor)
webView->setBaseBackgroundColor(kTranslucentPutty); webView->setBaseBackgroundColor(kTranslucentPutty);
// Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha. // Expected: red (50% alpha) blended atop kTranslucentPutty. Note the alpha.
EXPECT_EQ(0xBFE93B32, webView->backgroundColor()); EXPECT_EQ(0xBFE93B32, webView->backgroundColor());
webView->setBaseBackgroundColor(kTransparent);
FrameTestHelpers::loadHTMLString(webView->mainFrame(), "<html><head><style>body {background-color:transparent}</style></head></html>", baseURL);
// Expected: transparent on top of kTransparent will still be transparent.
EXPECT_EQ(kTransparent, webView->backgroundColor());
WebCore::LocalFrame* frame = webView->mainFrameImpl()->frame();
// Creating a new frame view with the background color having 0 alpha.
frame->createView(WebCore::IntSize(1024, 768), WebCore::Color::transparent, true);
EXPECT_EQ(kTransparent, frame->view()->baseBackgroundColor());
WebCore::Color kTransparentRed(100, 0, 0, 0);
frame->createView(WebCore::IntSize(1024, 768), kTransparentRed, true);
EXPECT_EQ(kTransparentRed, frame->view()->baseBackgroundColor());
} }
TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame) TEST_F(WebViewTest, SetBaseBackgroundColorBeforeMainFrame)
......
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