diff options
author | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 19:58:26 +0000 |
---|---|---|
committer | stuartmorgan@chromium.org <stuartmorgan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-14 19:58:26 +0000 |
commit | d17054237974d50db49c10d18a05a42048478db7 (patch) | |
tree | dbe3ea846711da710dffea1b36b98cd5a0205048 /chrome/renderer | |
parent | 400cc493fc8e0bc6205381426afea8011b1b4041 (diff) | |
download | chromium_src-d17054237974d50db49c10d18a05a42048478db7.zip chromium_src-d17054237974d50db49c10d18a05a42048478db7.tar.gz chromium_src-d17054237974d50db49c10d18a05a42048478db7.tar.bz2 |
Only mark Silverlight instances as transparent if they actually are
Parse the value of Silverlight "background" values to determine transparancy, rather than treating all backgrounds as transparent.
BUG=41370
TEST=Transparent Silverlight (see bug 36691 for examples) should still be transparent.
Review URL: http://codereview.chromium.org/1582027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44521 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/webplugin_delegate_proxy.cc | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/chrome/renderer/webplugin_delegate_proxy.cc b/chrome/renderer/webplugin_delegate_proxy.cc index 5049bf4..59843ad 100644 --- a/chrome/renderer/webplugin_delegate_proxy.cc +++ b/chrome/renderer/webplugin_delegate_proxy.cc @@ -214,6 +214,33 @@ void WebPluginDelegateProxy::PluginDestroyed() { MessageLoop::current()->DeleteSoon(FROM_HERE, this); } +// Returns true if the given Silverlight 'background' value corresponds to +// one that should make the plugin transparent. See: +// http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx +// for possible values. +static bool SilverlightColorIsTransparent(const std::string& color) { + if (StartsWithASCII(color, "#", false)) { + // If it's #ARGB or #AARRGGBB check the alpha; if not it's an RGB form and + // it's not transparent. + if ((color.length() == 5 && !StartsWithASCII(color, "#F", false)) || + (color.length() == 9 && !StartsWithASCII(color, "#FF", false))) + return true; + } else if (StartsWithASCII(color, "sc#", false)) { + // It's either sc#A,R,G,B or sc#R,G,B; if the former, check the alpha. + if (color.length() < 3) + return false; + std::string value_string = color.substr(3, std::string::npos); + std::vector<std::string> components; + SplitString(value_string, ',', &components); + if (components.size() == 4 && !StartsWithASCII(components[0], "1", false)) + return true; + } else if (LowerCaseEqualsASCII(color, "transparent")) { + return true; + } + // Anything else is a named, opaque color or an RGB form with no alpha. + return false; +} + bool WebPluginDelegateProxy::Initialize(const GURL& url, const std::vector<std::string>& arg_names, const std::vector<std::string>& arg_values, @@ -279,7 +306,8 @@ bool WebPluginDelegateProxy::Initialize(const GURL& url, for (size_t i = 0; i < arg_names.size(); ++i) { if ((flash && LowerCaseEqualsASCII(arg_names[i], "wmode") && LowerCaseEqualsASCII(arg_values[i], "transparent")) || - (silverlight && LowerCaseEqualsASCII(arg_names[i], "background"))) { + (silverlight && LowerCaseEqualsASCII(arg_names[i], "background") && + SilverlightColorIsTransparent(arg_values[i]))) { transparent_ = true; } } |