[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 08:42:56 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 173305cdc23761b29be1ffe83cbde96e3ccc9742
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri May 28 21:40:42 2004 +0000

    	setStrokeColor and setFillColor now support
    	old school web color string, oswcs+alpha, gray, gray+alpha,
    	rgba, and cmyka.
    
            Reviewed by jay-lo.
    
            * khtml/css/cssparser.cpp:
            (CSSParser::parseColor):
            (CSSParser::parseColorFromValue):
            * khtml/css/cssparser.h: Made parseColor static public class method
            * khtml/ecma/kjs_html.cpp:
            (KJS::Context2DFunction::tryCall):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6730 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 435ef6c..275ec84 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,18 @@
+2004-05-28  Richard Williamson   <rjw at apple.com>
+
+	setStrokeColor and setFillColor now support
+	old school web color string, oswcs+alpha, gray, gray+alpha,
+	rgba, and cmyka.
+
+        Reviewed by jay-lo.
+
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseColor):
+        (CSSParser::parseColorFromValue):
+        * khtml/css/cssparser.h: Made parseColor static public class method
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::Context2DFunction::tryCall):
+
 2004-05-28  David Hyatt  <hyatt at apple.com>
 
 	Implement -khtml-user-select and add support for the property -khtml-user-drag (although someone will still
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 83bd992..76efa6a 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -1662,7 +1662,7 @@ CSSValueListImpl *CSSParser::parseFontFamily()
 }
 
 
-static bool parseColor(const QString &name, QRgb& rgb)
+bool CSSParser::parseColor(const QString &name, QRgb& rgb)
 {
     int len = name.length();
 
@@ -1714,12 +1714,12 @@ CSSPrimitiveValueImpl *CSSParser::parseColorFromValue(Value* value)
         value->fValue >= 0. && value->fValue < 1000000. ) {
         QString str;
         str.sprintf( "%06d", (int)(value->fValue+.5) );
-        if (!::parseColor( str, c ))
+        if (!CSSParser::parseColor( str, c ))
             return 0;
     } else if ( value->unit == CSSPrimitiveValue::CSS_RGBCOLOR ||
                 value->unit == CSSPrimitiveValue::CSS_IDENT ||
                 value->unit == CSSPrimitiveValue::CSS_DIMENSION ) {
-	if (!::parseColor( qString( value->string ), c))
+	if (!CSSParser::parseColor( qString( value->string ), c))
             return 0;
     }
     else if ( value->unit == Value::Function &&
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index 10b82e9..e2b4b35 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -24,6 +24,7 @@
 #define _CSS_cssparser_h_
 
 #include <qstring.h>
+#include <qcolor.h>
 #include <dom/dom_string.h>
 #include "xml/dom_atomicstring.h"
 
@@ -131,6 +132,8 @@ namespace DOM {
         CSSPrimitiveValueImpl *parseColor();
 	CSSPrimitiveValueImpl *parseColorFromValue(Value* val);
 
+        static bool parseColor(const QString &name, QRgb& rgb);
+
         // CSS3 Parsing Routines (for properties specific to CSS3)
         bool parseShadow(int propId, bool important);
         
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index 2683703..95708cc 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -52,6 +52,8 @@
 
 #include <kdebug.h>
 
+#include "cssparser.h"
+
 #include "qcolor.h"
 #include "qpixmap.h"
 
@@ -3384,37 +3386,123 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
             break;
         }
         case Context2D::SetStrokeColor: {
-            if (args.size() < 1 || args.size() > 2) {
-                Object err = Error::create(exec,SyntaxError);
-                exec->setException(err);
-                return err;
+            // string arg = named color
+            // string arg, number arg = named color, alpha
+            // number arg = gray color
+            // number arg, number arg = gray color, alpha
+            // 4 args (string or number) = r, g, b, a
+            // 5 args (string or number) = c, m, y, k, a
+            int numArgs = args.size();
+            switch (numArgs) {
+                case 1: {
+                    if (args[0].type() == StringType) {
+                        QRgb rgb = 0;
+                        DOM::CSSParser::parseColor(args[0].toString(exec).qstring(), rgb);
+                        QColor color(rgb);
+                        CGContextSetRGBStrokeColor(drawingContext, color.red(), color.green(), color.blue(), 1.);
+                    }
+                    else {
+                        float g = (float)args[0].toNumber(exec);
+                        CGContextSetGrayStrokeColor(drawingContext, g, 1.);
+                    }
+                }
+                break;
+                case 2: {
+                    float a = args[1].toNumber(exec);
+                    if (args[0].type() == StringType) {
+                        QRgb rgb = 0;
+                        DOM::CSSParser::parseColor(args[0].toString(exec).qstring(), rgb);
+                        QColor color(rgb);
+                        CGContextSetRGBStrokeColor(drawingContext, color.red(), color.green(), color.blue(), a);
+                    }
+                    else {
+                        float g = (float)args[0].toNumber(exec);
+                        CGContextSetGrayStrokeColor(drawingContext, g, a);
+                    }
+                }
+                break;
+                case 4: {
+                    float r = (float)args[0].toNumber(exec);
+                    float g = (float)args[1].toNumber(exec);
+                    float b = (float)args[2].toNumber(exec);
+                    float a = (float)args[3].toNumber(exec);
+                    CGContextSetRGBStrokeColor(drawingContext, r, g, b, a);
+                }
+                break;
+                case 5: {
+                    float c = (float)args[0].toNumber(exec);
+                    float m = (float)args[1].toNumber(exec);
+                    float y = (float)args[2].toNumber(exec);
+                    float k = (float)args[3].toNumber(exec);
+                    float a = (float)args[4].toNumber(exec);
+                    CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
+                }
+                default: {
+                    Object err = Error::create(exec,SyntaxError);
+                    exec->setException(err);
+                    return err;
+                }
             }
-            QColor color;
-            if (args.size() > 0)
-                color = QColor(args[0].toString(exec).ascii());
-            float alpha;
-            if (args.size() > 1)
-                alpha = (float)args[1].toNumber(exec);
-            else
-                alpha = 1.;
-            CGContextSetRGBStrokeColor(drawingContext, color.red(), color.green(), color.blue(), alpha);
             break;
         }
         case Context2D::SetFillColor: {
-            if (args.size() < 1 || args.size() > 2) {
-                Object err = Error::create(exec,SyntaxError);
-                exec->setException(err);
-                return err;
+            // string arg = named color
+            // string arg, number arg = named color, alpha
+            // number arg = gray color
+            // number arg, number arg = gray color, alpha
+            // 4 args (string or number) = r, g, b, a
+            // 5 args (string or number) = c, m, y, k, a
+            int numArgs = args.size();
+            switch (numArgs) {
+                case 1: {
+                    if (args[0].type() == StringType) {
+                        QRgb rgb = 0;
+                        DOM::CSSParser::parseColor(args[0].toString(exec).qstring(), rgb);
+                        QColor color(rgb);
+                        CGContextSetRGBFillColor(drawingContext, color.red(), color.green(), color.blue(), 1.);
+                    }
+                    else {
+                        float g = (float)args[0].toNumber(exec);
+                        CGContextSetGrayFillColor(drawingContext, g, 1.);
+                    }
+                }
+                break;
+                case 2: {
+                    float a = args[1].toNumber(exec);
+                    if (args[0].type() == StringType) {
+                        QRgb rgb = 0;
+                        DOM::CSSParser::parseColor(args[0].toString(exec).qstring(), rgb);
+                        QColor color(rgb);
+                        CGContextSetRGBFillColor(drawingContext, color.red(), color.green(), color.blue(), a);
+                    }
+                    else {
+                        float g = (float)args[0].toNumber(exec);
+                        CGContextSetGrayFillColor(drawingContext, g, a);
+                    }
+                }
+                break;
+                case 4: {
+                    float r = (float)args[0].toNumber(exec);
+                    float g = (float)args[1].toNumber(exec);
+                    float b = (float)args[2].toNumber(exec);
+                    float a = (float)args[3].toNumber(exec);
+                    CGContextSetRGBFillColor(drawingContext, r, g, b, a);
+                }
+                break;
+                case 5: {
+                    float c = (float)args[0].toNumber(exec);
+                    float m = (float)args[1].toNumber(exec);
+                    float y = (float)args[2].toNumber(exec);
+                    float k = (float)args[3].toNumber(exec);
+                    float a = (float)args[4].toNumber(exec);
+                    CGContextSetCMYKStrokeColor(drawingContext, c, m, y, k, a);
+                }
+                default: {
+                    Object err = Error::create(exec,SyntaxError);
+                    exec->setException(err);
+                    return err;
+                }
             }
-            QColor color;
-            if (args.size() > 0)
-                color = QColor(args[0].toString(exec).ascii());
-            float alpha;
-            if (args.size() > 1)
-                alpha = (float)args[1].toNumber(exec);
-            else
-                alpha = 1.;
-            CGContextSetRGBFillColor(drawingContext, color.red(), color.green(), color.blue(), alpha);
             break;
         }
         case Context2D::SetLineWidth: {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list