Make isTransparentSilverlightBackgroundValue handle all the possible transparent...
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 22:12:39 +0000 (22:12 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 8 Aug 2012 22:12:39 +0000 (22:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=93532

Reviewed by Simon Fraser.

* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::isTransparentSilverlightBackgroundValue):
Check for all the possible transparent colors and assume that the color is opaque otherwise.

(WebKit::NetscapePlugin::initialize):
Pass the lowercase string to isTransparentSilverlightBackgroundValue.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@125098 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp

index fd0abae..5d80ffe 100644 (file)
@@ -1,3 +1,17 @@
+2012-08-08  Anders Carlsson  <andersca@apple.com>
+
+        Make isTransparentSilverlightBackgroundValue handle all the possible transparent colors
+        https://bugs.webkit.org/show_bug.cgi?id=93532
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::isTransparentSilverlightBackgroundValue):
+        Check for all the possible transparent colors and assume that the color is opaque otherwise.
+
+        (WebKit::NetscapePlugin::initialize):
+        Pass the lowercase string to isTransparentSilverlightBackgroundValue.
+
 2012-08-08  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=92275
 2012-08-08  Beth Dakin  <bdakin@apple.com>
 
         https://bugs.webkit.org/show_bug.cgi?id=92275
index a86e583..b207432 100644 (file)
@@ -549,14 +549,34 @@ bool NetscapePlugin::allowPopups() const
 }
 
 #if PLUGIN_ARCHITECTURE(MAC)
 }
 
 #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;
+static bool isTransparentSilverlightBackgroundValue(const String& lowercaseBackgroundValue)
+{
+    // This checks if the background color value is transparent, according to
+    // the forumat documented at http://msdn.microsoft.com/en-us/library/cc838148(VS.95).aspx
+    if (lowercaseBackgroundValue.startsWith('#')) {
+        if (lowercaseBackgroundValue.length() == 5 && lowercaseBackgroundValue[1] != 'f') {
+            // An 8-bit RGB value with alpha transparency, in the form #ARGB.
+            return true;
+        }
 
 
-    return true;
+        if (lowercaseBackgroundValue.length() == 9 && !(lowercaseBackgroundValue[1] == 'f' && lowercaseBackgroundValue[2] == 'f')) {
+            // A 16-bit RGB value with alpha transparency, in the form #AARRGGBB.
+            return true;
+        }
+    } else if (lowercaseBackgroundValue.startsWith("sc#")) {
+        Vector<String> components;
+        lowercaseBackgroundValue.substring(3).split(",", components);
+
+        // An ScRGB value with alpha transparency, in the form sc#A,R,G,B.
+        if (components.size() == 4) {
+            if (components[0].toDouble() < 1)
+                return true;
+        }
+    } else if (lowercaseBackgroundValue == "transparent")
+        return true;
+
+    // This is an opaque color.
+    return false;
 }
 #endif
 
 }
 #endif
 
@@ -596,7 +616,7 @@ bool NetscapePlugin::initialize(const Parameters& parameters)
     if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists)) {
         for (size_t i = 0; i < parameters.names.size(); ++i) {
             if (equalIgnoringCase(parameters.names[i], "background")) {
     if (m_pluginModule->pluginQuirks().contains(PluginQuirks::MakeOpaqueUnlessTransparentSilverlightBackgroundAttributeExists)) {
         for (size_t i = 0; i < parameters.names.size(); ++i) {
             if (equalIgnoringCase(parameters.names[i], "background")) {
-                setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i]));
+                setIsTransparent(isTransparentSilverlightBackgroundValue(parameters.values[i].lower()));
                 break;
             }
         }
                 break;
             }
         }