Title: [125096] branches/safari-536.26-branch/Source/WebKit2

Diff

Modified: branches/safari-536.26-branch/Source/WebKit2/ChangeLog (125095 => 125096)


--- branches/safari-536.26-branch/Source/WebKit2/ChangeLog	2012-08-08 21:57:53 UTC (rev 125095)
+++ branches/safari-536.26-branch/Source/WebKit2/ChangeLog	2012-08-08 22:05:10 UTC (rev 125096)
@@ -1,5 +1,39 @@
 2012-08-07  Lucas Forschler  <[email protected]>
 
+    Merge 125081
+
+    2012-08-08  Anders Carlsson  <[email protected]>
+
+            Make the Silverlight CAOpenGLLayer opaque if we know the plug-in contents is opaque to reduce blending
+            https://bugs.webkit.org/show_bug.cgi?id=93508
+            <rdar://problem/12056765>
+
+            Reviewed by Simon Fraser.
+
+            * Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm:
+            (WebKit::NetscapePluginModule::determineQuirks):
+            * Shared/Plugins/PluginQuirks.h:
+            Rename the MakeTransparentIfBackgroundAttributeExists quirk to MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists
+            since we'll explicitly check for opaque background colors (at least one opaque background color for now), instead of just making the
+            plug-in transparent whenever there's a background specified.
+
+            * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+            (WebKit::isTransparentSilverlightBackgroundValue):
+            Helper function for determining if a background value is transparent. Just check for opaque black now and treat everything else as transparent.
+
+            (WebKit::NetscapePlugin::initialize):
+            Call isTransparentSilverlightBackgroundValue.
+
+            * WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm:
+            (WebKit::makeCGLPresentLayerOpaque):
+            Helper function for grabbing the CGLPresentLayer from the layer hierarchy and setting it to be opaque.
+
+            (WebKit::NetscapePlugin::updatePluginLayer):
+            Call makeCGLPresentLayerOpaque if the plug-in has the MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists quirk and
+            the plug-in is not transparent.
+
+2012-08-07  Lucas Forschler  <[email protected]>
+
     Merge 124815
 
     2012-08-03  Brady Eidson  <[email protected]>

Modified: branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm (125095 => 125096)


--- branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2012-08-08 21:57:53 UTC (rev 125095)
+++ branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/Netscape/mac/NetscapePluginModuleMac.mm	2012-08-08 22:05:10 UTC (rev 125096)
@@ -475,8 +475,8 @@
 
     if (plugin.bundleIdentifier == "com.microsoft.SilverlightPlugin") {
         // Silverlight doesn't explicitly opt into transparency, so we'll do it whenever
-        // there's a 'background' attribute.
-        m_pluginQuirks.add(PluginQuirks::MakeTransparentIfBackgroundAttributeExists);
+        // there's a 'background' attribute that's set to a transparent color.
+        m_pluginQuirks.add(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists);
 
         // Silverlight has a workaround for a leak in Safari 2. This workaround is
         // applied when the user agent does not contain "Version/3" so we append it

Modified: branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h (125095 => 125096)


--- branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2012-08-08 21:57:53 UTC (rev 125095)
+++ branches/safari-536.26-branch/Source/WebKit2/Shared/Plugins/PluginQuirks.h	2012-08-08 22:05:10 UTC (rev 125096)
@@ -40,13 +40,13 @@
         // Supports receiving a paint event, even when using CoreAnimation rendering.
         SupportsSnapshotting,
 
-        // Make the plug-in transparent if it has a "background" attribute set.
+        // Make the plug-in opaque unless it has a "background" attribute set to a transparent color
+        // according to http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx
+        // A non-existent "background" attribute is interpreted as the named color White which is opaque.
         // Microsoft Silverlight doesn't opt into transparency using NPN_SetValue and
-        // NPPVpluginTransparentBool, so we'll always force if the plug-in has a "background"
-        // attribute specified, regardless of it's value.
-        // FIXME: We could get more fancy here and check for specific values that we know are
-        // transparent.
-        MakeTransparentIfBackgroundAttributeExists,
+        // NPPVpluginTransparentBool, so we'll always force it unless the plug-in has a "background"
+        // attribute that specifies a opaque color.
+        MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists,
 
         // Whether calling NPP_GetValue with NPPVpluginCoreAnimationLayer returns a retained Core Animation
         // layer or not. According to the NPAPI specifications, plug-in shouldn't return a retained layer but

Modified: branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp (125095 => 125096)


--- branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-08-08 21:57:53 UTC (rev 125095)
+++ branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp	2012-08-08 22:05:10 UTC (rev 125096)
@@ -546,6 +546,18 @@
     return false;
 }
 
+#if PLUGIN_ARCHITECTURE(MAC)
+static bool isTransparentSilverlightBackgroundValue(const String& backgroundValue)
+{
+    // FIXME: We should handle all the cases from http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx here
+    // instead of just hard-coding black.
+    if (backgroundValue == "#000000")
+        return false;
+
+    return true;
+}
+#endif
+
 bool NetscapePlugin::initialize(const Parameters& parameters)
 {
     uint16_t mode = parameters.isFullFramePlugin ? NP_FULL : NP_EMBED;
@@ -579,10 +591,10 @@
     }
 
 #if PLUGIN_ARCHITECTURE(MAC)
-    if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeTransparentIfBackgroundAttributeExists)) {
+    if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists)) {
         for (size_t i = 0; i < parameters.names.size(); ++i) {
             if (equalIgnoringCase(parameters.names[i], "background")) {
-                setIsTransparent(true);
+                setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i]));
                 break;
             }
         }

Modified: branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm (125095 => 125096)


--- branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2012-08-08 21:57:53 UTC (rev 125095)
+++ branches/safari-536.26-branch/Source/WebKit2/WebProcess/Plugins/Netscape/mac/NetscapePluginMac.mm	2012-08-08 22:05:10 UTC (rev 125096)
@@ -1055,6 +1055,27 @@
     return static_cast<PlatformLayer*>(m_pluginLayer.get());
 }
 
+static void makeCGLPresentLayerOpaque(CALayer *pluginRootLayer)
+{
+    // We look for a layer that's the only sublayer of the root layer that is an instance
+    // of the CGLPresentLayer class which in turn is a subclass of CAOpenGLLayer and make
+    // it opaque if all these conditions hold.
+
+    NSArray *sublayers = [pluginRootLayer sublayers];
+    if ([sublayers count] != 1)
+        return;
+
+    Class cglPresentLayerClass = NSClassFromString(@"CGLPresentLayer");
+    if (![cglPresentLayerClass isSubclassOfClass:[CAOpenGLLayer class]])
+        return;
+
+    CALayer *layer = [sublayers objectAtIndex:0];
+    if (![layer isKindOfClass:cglPresentLayerClass])
+        return;
+
+    [layer setOpaque:YES];
+}
+
 void NetscapePlugin::updatePluginLayer()
 {
     if (m_drawingModel != NPDrawingModelCoreAnimation)
@@ -1084,6 +1105,10 @@
         m_pluginLayer = reinterpret_cast<CALayer *>(value);
     else
         m_pluginLayer.adoptNS(reinterpret_cast<CALayer *>(value));
+
+    if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists) &&
+        !m_isTransparent)
+        makeCGLPresentLayerOpaque(m_pluginLayer.get());
 }
 
 #ifndef NP_NO_CARBON
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to