Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Unified Diff: content/renderer/webplugin_delegate_proxy.cc

Issue 12487003: Fix painting glitch with text and NPAPI plugins. This was a regression from r167042. The problem wa… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/webplugin_delegate_proxy.cc
===================================================================
--- content/renderer/webplugin_delegate_proxy.cc (revision 186240)
+++ content/renderer/webplugin_delegate_proxy.cc (working copy)
@@ -195,6 +195,33 @@
bool multibyte_response_expected_;
};
+// 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() < 4)
+ return false;
+ std::string value_string = color.substr(3, std::string::npos);
+ std::vector<std::string> components;
+ base::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;
+}
+
} // namespace
WebPluginDelegateProxy::WebPluginDelegateProxy(
@@ -214,6 +241,7 @@
npobject_(NULL),
sad_plugin_(NULL),
invalidate_pending_(false),
+ transparent_(false),
front_buffer_index_(0),
page_url_(render_view_->webview()->mainFrame()->document().url()) {
}
@@ -372,6 +400,18 @@
plugin_ = plugin;
+ bool flash = LowerCaseEqualsASCII(mime_type_, kFlashPluginSwfMimeType);
+ bool silverlight =
+ StartsWithASCII(mime_type_, "application/x-silverlight", false);
+ 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") &&
+ SilverlightColorIsTransparent(arg_values[i]))) {
+ transparent_ = true;
+ }
+ }
piman 2013/03/06 00:58:57 Do we really need all that logic? The plugin shoul
jam 2013/03/06 01:58:36 good point, switched to it. we used to default to
+
result = false;
Send(new PluginMsg_Init(instance_id_, params, &result));
@@ -725,7 +765,8 @@
const SkBitmap& bitmap =
front_buffer_canvas()->getDevice()->accessBitmap(false);
SkPaint paint;
- paint.setXfermodeMode(SkXfermode::kSrcATop_Mode);
+ paint.setXfermodeMode(
+ transparent_ ? SkXfermode::kSrcATop_Mode : SkXfermode::kSrc_Mode);
SkIRect src_rect = gfx::RectToSkIRect(offset_rect);
canvas->drawBitmapRect(bitmap,
&src_rect,
« no previous file with comments | « content/renderer/webplugin_delegate_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698