[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:05 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit bc5435a614b376b1d92a61dc25ba10598dc10fcd
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu May 27 06:35:59 2004 +0000

    	Added shadow support (w/ Louch).
    	Added infrastructure for drawing images.
    
    	New context methods:
    
    	setShadow
    	setShadowWithColor
    	clearShadow
    
    	Reviewed by me and Louch.
    
            * khtml/ecma/kjs_html.cpp:
            (KJS::Context2DFunction::tryCall):
            * khtml/ecma/kjs_html.h:
            (KJS::Image::image):
            (KJS::Context2D::):
            * khtml/ecma/kjs_html.lut.h:
            (KJS::):
            * kwq/KWQPainter.h:
            * kwq/KWQPainter.mm:
            (QPainter::drawPixmap):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6698 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index a36b00a..71c795f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,29 @@
 2004-05-26  Richard Williamson   <rjw at apple.com>
 
+	Added shadow support (w/ Louch).
+	Added infrastructure for drawing images.
+
+	New context methods:
+
+	setShadow
+	setShadowWithColor
+	clearShadow
+
+	Reviewed by me and Louch.
+
+        * khtml/ecma/kjs_html.cpp:
+        (KJS::Context2DFunction::tryCall):
+        * khtml/ecma/kjs_html.h:
+        (KJS::Image::image):
+        (KJS::Context2D::):
+        * khtml/ecma/kjs_html.lut.h:
+        (KJS::):
+        * kwq/KWQPainter.h:
+        * kwq/KWQPainter.mm:
+        (QPainter::drawPixmap):
+
+2004-05-26  Richard Williamson   <rjw at apple.com>
+
 	Fixed build snafu.
 
         * khtml/ecma/kjs_html.cpp:
diff --git a/WebCore/khtml/ecma/kjs_html.cpp b/WebCore/khtml/ecma/kjs_html.cpp
index 06b6af3..efccecc 100644
--- a/WebCore/khtml/ecma/kjs_html.cpp
+++ b/WebCore/khtml/ecma/kjs_html.cpp
@@ -53,6 +53,7 @@
 #include <kdebug.h>
 
 #include "qcolor.h"
+#include "qpixmap.h"
 
 #include <ApplicationServices/ApplicationServices.h>
 
@@ -3586,13 +3587,78 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
             renderer->setNeedsImageUpdate();
             break;
         }
+        case Context2D::SetShadow: {
+            if (args.size() != 3) {
+                Object err = Error::create(exec,SyntaxError);
+                exec->setException(err);
+                return err;
+            }
+            CGSize offset;
+            
+            offset.width = (float)args[0].toNumber(exec);
+            offset.height = (float)args[1].toNumber(exec);
+            float blur = (float)args[2].toNumber(exec);
+            CGContextSetShadow (drawingContext, offset, blur);
+            break;
+        }
+        
+        case Context2D::SetShadowWithColor: {
+            if (args.size() < 4) {
+                Object err = Error::create(exec,SyntaxError);
+                exec->setException(err);
+                return err;
+            }
+            CGSize offset;
+            
+            offset.width = (float)args[0].toNumber(exec);
+            offset.height = (float)args[1].toNumber(exec);
+            float blur = (float)args[2].toNumber(exec);
+            
+            QColor color = QColor(args[3].toString(exec).ascii());
+            float alpha;
+            if (args.size() > 4)
+                alpha = (float)args[4].toNumber(exec);
+            else
+                alpha = 1.;
+            
+            CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+            float components[4] = {color.red(), color.green(), color.blue(), alpha};
+            CGColorRef colorRef = CGColorCreate (colorSpace, components);
+            CGContextSetShadowWithColor (drawingContext, offset, blur, colorRef);
+            CFRelease (colorSpace);
+            CFRelease (colorRef);
+            break;
+        }
+
+        case Context2D::ClearShadow: {
+            if (args.size() != 0) {
+                Object err = Error::create(exec,SyntaxError);
+                exec->setException(err);
+                return err;
+            }
+            CGContextSetShadowWithColor (drawingContext, CGSizeMake(0, 0), 0, nil);
+            break;
+        }
         case Context2D::DrawImage: {
             if (args.size() != 6) {
                 Object err = Error::create(exec,SyntaxError);
                 exec->setException(err);
                 return err;
             }
-            // FIXME:  Implement
+            ObjectImp *o = static_cast<ObjectImp*>(args[0].imp());
+            if (!o->inherits(&Image::info)) {
+                Object err = Error::create(exec,TypeError);
+                exec->setException(err);
+                return err;
+            }
+            Image *i = static_cast<Image*>(o);
+            float x = (float)args[1].toNumber(exec);
+            float y = (float)args[2].toNumber(exec);
+            float w = (float)args[3].toNumber(exec);
+            float h = (float)args[4].toNumber(exec);
+            QString compositeOperator = args[5].toString(exec).qstring().lower();
+            QPixmap pixmap = i->image()->pixmap();
+            printf ("%s:%d  %p %f,%f,%f,%f %s\n", __FILE__, __LINE__, pixmap.image(), x, y, w, h, compositeOperator.ascii());
             renderer->setNeedsImageUpdate();
             break;
         }
@@ -3614,7 +3680,7 @@ Value KJS::Context2DFunction::tryCall(ExecState *exec, Object &thisObj, const Li
 const ClassInfo KJS::Context2D::info = { "Context2D", 0, &Context2DTable, 0 };
 
 /* Source for Context2DTable. Use "make hashtables" to regenerate.
- at begin Context2DTable 20
+ at begin Context2DTable 23
   save                     Context2D::Save                        DontDelete|Function 0
   restore                  Context2D::Restore                     DontDelete|Function 0
   scale                    Context2D::Scale                       DontDelete|Function 2
@@ -3635,8 +3701,11 @@ const ClassInfo KJS::Context2D::info = { "Context2D", 0, &Context2DTable, 0 };
   addQuadraticCurveToPoint Context2D::AddQuadraticCurveToPoint    DontDelete|Function 4
   addBezierCurveToPoint    Context2D::AddBezierCurveToPoint       DontDelete|Function 6
   clearRect                Context2D::ClearRect                   DontDelete|Function 4
-  drawImage                Context2D::DrawImage                    DontDelete|Function 6
+  drawImage                Context2D::DrawImage                   DontDelete|Function 6
   drawImageFromRect        Context2D::DrawImageFromRect           DontDelete|Function 10
+  setShadow                Context2D::SetShadow                   DontDelete|Function 3
+  setShadowWithColor       Context2D::SetShadowWithColor          DontDelete|Function 4
+  clearShadow              Context2D::ClearShadow                 DontDelete|Function 0
 @end
 */
 
diff --git a/WebCore/khtml/ecma/kjs_html.h b/WebCore/khtml/ecma/kjs_html.h
index 8da4f4b..177421e 100644
--- a/WebCore/khtml/ecma/kjs_html.h
+++ b/WebCore/khtml/ecma/kjs_html.h
@@ -227,6 +227,9 @@ namespace KJS {
     virtual const ClassInfo* classInfo() const { return &info; }
     static const ClassInfo info;
     enum { Src, Complete, OnLoad };
+    
+    khtml::CachedImage* image() { return img; }
+    
   private:
     UString src;
     QGuardedPtr<DOM::DocumentImpl> doc;
@@ -256,7 +259,8 @@ namespace KJS {
         FillPath, StrokePath, 
         MoveToPoint, AddLineToPoint, AddQuadraticCurveToPoint, AddBezierCurveToPoint,
         ClearRect,
-        DrawImage, DrawImageFromRect };
+        DrawImage, DrawImageFromRect,
+        SetShadow, SetShadowWithColor, ClearShadow };
 
     DOM::HTMLElementImpl *_element;
   };
diff --git a/WebCore/khtml/ecma/kjs_html.lut.h b/WebCore/khtml/ecma/kjs_html.lut.h
index b50f915..7f63173 100644
--- a/WebCore/khtml/ecma/kjs_html.lut.h
+++ b/WebCore/khtml/ecma/kjs_html.lut.h
@@ -1037,39 +1037,43 @@ const struct HashTable ImageTable = { 2, 4, ImageTableEntries, 3 };
 namespace KJS {
 
 const struct HashEntry Context2DTableEntries[] = {
-   { "scale", Context2D::Scale, DontDelete|Function, 2, &Context2DTableEntries[24] },
-   { "strokePath", Context2D::StrokePath, DontDelete|Function, 0, 0 },
    { 0, 0, 0, 0, 0 },
+   { "addBezierCurveToPoint", Context2D::AddBezierCurveToPoint, DontDelete|Function, 6, 0 },
+   { 0, 0, 0, 0, 0 },
+   { "setStrokeColor", Context2D::SetStrokeColor, DontDelete|Function, 1, &Context2DTableEntries[28] },
    { 0, 0, 0, 0, 0 },
-   { "setLineJoin", Context2D::SetLineJoin, DontDelete|Function, 1, 0 },
    { 0, 0, 0, 0, 0 },
-   { "addLineToPoint", Context2D::AddLineToPoint, DontDelete|Function, 2, 0 },
+   { "moveToPoint", Context2D::MoveToPoint, DontDelete|Function, 2, &Context2DTableEntries[33] },
    { 0, 0, 0, 0, 0 },
+   { "translate", Context2D::Translate, DontDelete|Function, 1, 0 },
    { 0, 0, 0, 0, 0 },
    { 0, 0, 0, 0, 0 },
+   { "rotate", Context2D::Rotate, DontDelete|Function, 2, &Context2DTableEntries[24] },
    { 0, 0, 0, 0, 0 },
-   { "save", Context2D::Save, DontDelete|Function, 0, &Context2DTableEntries[21] },
-   { "restore", Context2D::Restore, DontDelete|Function, 0, 0 },
+   { "restore", Context2D::Restore, DontDelete|Function, 0, &Context2DTableEntries[31] },
+   { "scale", Context2D::Scale, DontDelete|Function, 2, 0 },
+   { "setFillColor", Context2D::SetFillColor, DontDelete|Function, 1, &Context2DTableEntries[27] },
    { "drawImage", Context2D::DrawImage, DontDelete|Function, 6, 0 },
-   { "translate", Context2D::Translate, DontDelete|Function, 1, &Context2DTableEntries[20] },
-   { "rotate", Context2D::Rotate, DontDelete|Function, 2, &Context2DTableEntries[22] },
-   { "setLineWidth", Context2D::SetLineWidth, DontDelete|Function, 1, &Context2DTableEntries[25] },
-   { "addQuadraticCurveToPoint", Context2D::AddQuadraticCurveToPoint, DontDelete|Function, 4, &Context2DTableEntries[29] },
-   { 0, 0, 0, 0, 0 },
-   { 0, 0, 0, 0, 0 },
-   { "beginPath", Context2D::BeginPath, DontDelete|Function, 0, &Context2DTableEntries[23] },
-   { "closePath", Context2D::ClosePath, DontDelete|Function, 0, 0 },
-   { "setStrokeColor", Context2D::SetStrokeColor, DontDelete|Function, 1, &Context2DTableEntries[30] },
-   { "setFillColor", Context2D::SetFillColor, DontDelete|Function, 1, 0 },
-   { "setLineCap", Context2D::SetLineCap, DontDelete|Function, 1, &Context2DTableEntries[26] },
-   { "setMiterLimit", Context2D::SetMiterLimit, DontDelete|Function, 1, &Context2DTableEntries[27] },
-   { "fillPath", Context2D::FillPath, DontDelete|Function, 0, &Context2DTableEntries[28] },
-   { "moveToPoint", Context2D::MoveToPoint, DontDelete|Function, 2, 0 },
-   { "addBezierCurveToPoint", Context2D::AddBezierCurveToPoint, DontDelete|Function, 6, 0 },
+   { "save", Context2D::Save, DontDelete|Function, 0, &Context2DTableEntries[23] },
+   { 0, 0, 0, 0, 0 },
+   { "addQuadraticCurveToPoint", Context2D::AddQuadraticCurveToPoint, DontDelete|Function, 4, 0 },
+   { "setLineJoin", Context2D::SetLineJoin, DontDelete|Function, 1, &Context2DTableEntries[30] },
+   { 0, 0, 0, 0, 0 },
+   { "setMiterLimit", Context2D::SetMiterLimit, DontDelete|Function, 1, 0 },
+   { "beginPath", Context2D::BeginPath, DontDelete|Function, 0, &Context2DTableEntries[25] },
+   { "closePath", Context2D::ClosePath, DontDelete|Function, 0, &Context2DTableEntries[26] },
+   { "setLineWidth", Context2D::SetLineWidth, DontDelete|Function, 1, 0 },
+   { "setLineCap", Context2D::SetLineCap, DontDelete|Function, 1, 0 },
+   { "fillPath", Context2D::FillPath, DontDelete|Function, 0, 0 },
+   { "strokePath", Context2D::StrokePath, DontDelete|Function, 0, &Context2DTableEntries[29] },
+   { "addLineToPoint", Context2D::AddLineToPoint, DontDelete|Function, 2, &Context2DTableEntries[32] },
    { "clearRect", Context2D::ClearRect, DontDelete|Function, 4, 0 },
-   { "drawImageFromRect", Context2D::DrawImageFromRect, DontDelete|Function, 10, 0 }
+   { "drawImageFromRect", Context2D::DrawImageFromRect, DontDelete|Function, 10, 0 },
+   { "setShadow", Context2D::SetShadow, DontDelete|Function, 3, 0 },
+   { "setShadowWithColor", Context2D::SetShadowWithColor, DontDelete|Function, 4, &Context2DTableEntries[34] },
+   { "clearShadow", Context2D::ClearShadow, DontDelete|Function, 0, 0 }
 };
 
-const struct HashTable Context2DTable = { 2, 31, Context2DTableEntries, 20 };
+const struct HashTable Context2DTable = { 2, 35, Context2DTableEntries, 23 };
 
 } // namespace
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 1d5c0c8..6366f17 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -88,7 +88,7 @@ public:
     void drawPixmap(const QPoint &, const QPixmap &, const QRect &);
     void drawPixmap(const QPoint &, const QPixmap &, const QRect &, const QString &);
     void drawPixmap( int x, int y, const QPixmap &,
-			    int sx=0, int sy=0, int sw=-1, int sh=-1, int compositeOperator=-1);
+			    int sx=0, int sy=0, int sw=-1, int sh=-1, int compositeOperator=-1, CGContextRef context=0);
     void drawTiledPixmap(int, int, int, int, const QPixmap &, int sx=0, int sy=0);
 
     void addClip(const QRect &);
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index bd2f884..91394f3 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -482,11 +482,17 @@ void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix, const QRect &r, c
 }
 
 void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
-                           int sx, int sy, int sw, int sh, int compositeOperator )
+                           int sx, int sy, int sw, int sh, int compositeOperator, CGContextRef context)
 {
     if (data->state.paintingDisabled)
         return;
         
+    NSGraphicsContext *oldContext = 0;
+    if (context) {
+        oldContext = [NSGraphicsContext currentContext];
+        // Somehow set up a NSGraphicsContext using the context parameter.
+    }
+    
     if (sw == -1)
         sw = pixmap.width();
     if (sh == -1)
@@ -499,6 +505,8 @@ void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
     [pixmap.imageRenderer drawImageInRect:inRect
                                       fromRect:fromRect compositeOperator:(NSCompositingOperation)compositeOperator];
     KWQ_UNBLOCK_EXCEPTIONS;
+
+    [NSGraphicsContext setCurrentContext:oldContext];
 }
 
 void QPainter::drawTiledPixmap( int x, int y, int w, int h,

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list