2006-01-19 Eric Seidel <eseidel@apple.com>
authoreseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2006 09:20:50 +0000 (09:20 +0000)
committereseidel <eseidel@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2006 09:20:50 +0000 (09:20 +0000)
        Reviewed by darin & anders.

        Fix opacity crasher for <text> and <image>.
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6668
        Even though the crash is fixed, opacity still doesn't work.
        http://bugzilla.opendarwin.org/show_bug.cgi?id=6669

        * kcanvas/RenderSVGImage.cpp:
        (RenderSVGImage::paint):
        * kcanvas/RenderSVGText.cpp:
        (RenderSVGText::paint):

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

LayoutTests/ChangeLog
LayoutTests/svg/custom/text-image-opacity-expected.checksum [new file with mode: 0644]
LayoutTests/svg/custom/text-image-opacity-expected.png [new file with mode: 0644]
LayoutTests/svg/custom/text-image-opacity-expected.txt [new file with mode: 0644]
LayoutTests/svg/custom/text-image-opacity.svg [new file with mode: 0644]
WebCore/ChangeLog
WebCore/kcanvas/RenderSVGImage.cpp
WebCore/kcanvas/RenderSVGImage.h
WebCore/kcanvas/RenderSVGText.cpp

index a10c68c..2bfdd47 100644 (file)
@@ -1,3 +1,17 @@
+2006-01-19  Eric Seidel  <eseidel@apple.com>
+
+        Reviewed by darin & anders.
+
+        Fix opacity crasher for <text> and <image>.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6668
+        Even though the crash is fixed, opacity still doesn't work.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6669
+
+        * svg/custom/text-image-opacity-expected.checksum: Added.
+        * svg/custom/text-image-opacity-expected.png: Added.
+        * svg/custom/text-image-opacity-expected.txt: Added.
+        * svg/custom/text-image-opacity.svg: Added.
+
 2006-01-18  Mitz Pettel  <opendarwin.org@mitzpettel.com>
 
         Reviewed by Hyatt.
diff --git a/LayoutTests/svg/custom/text-image-opacity-expected.checksum b/LayoutTests/svg/custom/text-image-opacity-expected.checksum
new file mode 100644 (file)
index 0000000..a2e1b88
--- /dev/null
@@ -0,0 +1 @@
+4e3556185f05f4c6dd8abcc854e6f04f
\ No newline at end of file
diff --git a/LayoutTests/svg/custom/text-image-opacity-expected.png b/LayoutTests/svg/custom/text-image-opacity-expected.png
new file mode 100644 (file)
index 0000000..4ece62d
Binary files /dev/null and b/LayoutTests/svg/custom/text-image-opacity-expected.png differ
diff --git a/LayoutTests/svg/custom/text-image-opacity-expected.txt b/LayoutTests/svg/custom/text-image-opacity-expected.txt
new file mode 100644 (file)
index 0000000..1e5888b
--- /dev/null
@@ -0,0 +1,23 @@
+layer at (0,0) size 800x600
+  RenderCanvas at (0,0) size 800x600
+    KCanvasContainer {svg} at (0,0) size 0x0
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {TEXT} at (0,0) size 29x18
+          text run at (0,0) width 29: "Fail!"
+      RenderSVGText {text} at (0,0) size 785x18
+        RenderText {TEXT} at (0,0) size 379x18
+          text run at (0,0) width 379: "Success! (should be half opacity as should the image below)"
+      RenderImage {image} at (0,0) size 100x100
+      RenderImage {image} at (0,0) size 100x100
+layer at (0,0) size 785x18
+  RenderSVGText {text} at (0,0) size 785x18
+    RenderText {TEXT} at (0,0) size 29x18
+      text run at (0,0) width 29: "Fail!"
+layer at (0,0) size 785x18
+  RenderSVGText {text} at (0,0) size 785x18
+    RenderText {TEXT} at (0,0) size 379x18
+      text run at (0,0) width 379: "Success! (should be half opacity as should the image below)"
+layer at (0,0) size 100x100
+  RenderImage {image} at (0,0) size 100x100
+layer at (0,0) size 100x100
+  RenderImage {image} at (0,0) size 100x100
diff --git a/LayoutTests/svg/custom/text-image-opacity.svg b/LayoutTests/svg/custom/text-image-opacity.svg
new file mode 100644 (file)
index 0000000..8ef2c55
--- /dev/null
@@ -0,0 +1,6 @@
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <text style="opacity:0.0;" y="25" fill="red" >Fail!</text>
+    <text style="opacity:0.5;" y="50" fill="green">Success! (should be half opacity as should the image below)</text>
+    <image xlink:href="resources/green-checker.png" y="55" height="100" width="100" style="opacity:0.5;"/>
+    <image xlink:href="resources/red-checker.png" y="55" height="100" width="100" style="opacity:0.0;"/>
+</svg>
index 8251018..64605f2 100644 (file)
 
 2006-01-19  Eric Seidel  <eseidel@apple.com>
 
+        Reviewed by darin & anders.
+
+        Fix opacity crasher for <text> and <image>.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6668
+        Even though the crash is fixed, opacity still doesn't work.
+        http://bugzilla.opendarwin.org/show_bug.cgi?id=6669
+
+        * kcanvas/RenderSVGImage.cpp:
+        (RenderSVGImage::paint):
+        * kcanvas/RenderSVGText.cpp:
+        (RenderSVGText::paint):
+
+2006-01-19  Eric Seidel  <eseidel@apple.com>
+
         Reviewed by darin.
 
         Remove CFDictionary usage from KWQObject.*
index fea53e3..4145a8d 100644 (file)
@@ -1,5 +1,6 @@
 /*
     Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
+    Copyright (C) 2006 Apple Computer, Inc.
 
     This file is part of the WebKit project
 
@@ -49,15 +50,20 @@ RenderSVGImage::~RenderSVGImage()
 
 void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY)
 {
-    if (paintInfo.p->paintingDisabled())
-        return;
-    
     if (paintInfo.p->paintingDisabled() || (paintInfo.phase != PaintActionForeground) || style()->visibility() == khtml::HIDDEN)
         return;
+    
+    KRenderingDevice *renderingDevice = QPainter::renderingDevice();
+    KRenderingDeviceContext *context = renderingDevice->currentContext();
+    bool shouldPopContext = false;
+    if (!context) {
+        // Need to push a device context on the stack if empty.
+        context = paintInfo.p->createRenderingDeviceContext();
+        renderingDevice->pushContext(context);
+        shouldPopContext = true;
+    } else
+        paintInfo.p->save();
 
-    paintInfo.p->save();
-
-    KRenderingDeviceContext *context = QPainter::renderingDevice()->currentContext();
     context->concatCTM(QMatrix().translate(parentX, parentY));
     context->concatCTM(localTransform());
     translateForAttributes();
@@ -80,7 +86,12 @@ void RenderSVGImage::paint(PaintInfo& paintInfo, int parentX, int parentY)
     if (filter)
         filter->applyFilter(boundingBox);
 
-    paintInfo.p->restore();
+    // restore drawing state
+    if (shouldPopContext) {
+        renderingDevice->popContext();
+        delete context;
+    } else
+        paintInfo.p->restore();
 }
 
 void RenderSVGImage::translateForAttributes()
index 46ffd7e..e5e8ddb 100644 (file)
@@ -1,7 +1,8 @@
 /*
     Copyright (C) 2006 Alexander Kellett <lypanov@kde.org>
+    Copyright (C) 2006 Apple Computer, Inc.
 
-    This file is part of the WebKit project
+    This file is part of the WebKit project.
 
     This library is free software; you can redistribute it and/or
     modify it under the terms of the GNU Library General Public
index a48f1f7..8879a14 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * This file is part of the KDE project.
+ * This file is part of the WebKit project.
  *
  * Copyright (C) 2006 Apple Computer, Inc.
  *
@@ -54,9 +54,17 @@ void RenderSVGText::paint(PaintInfo& paintInfo, int parentX, int parentY)
     if (paintInfo.p->paintingDisabled())
         return;
 
-    paintInfo.p->save();
+    KRenderingDevice *renderingDevice = QPainter::renderingDevice();
+    KRenderingDeviceContext *context = renderingDevice->currentContext();
+    bool shouldPopContext = false;
+    if (!context) {
+        // Need to push a device context on the stack if empty.
+        context = paintInfo.p->createRenderingDeviceContext();
+        renderingDevice->pushContext(context);
+        shouldPopContext = true;
+    } else
+        paintInfo.p->save();
 
-    KRenderingDeviceContext *context = QPainter::renderingDevice()->currentContext();
     context->concatCTM(localTransform());
     context->concatCTM(QMatrix().translate(parentX, parentY));
     context->concatCTM(translationForAttributes());
@@ -80,7 +88,12 @@ void RenderSVGText::paint(PaintInfo& paintInfo, int parentX, int parentY)
     if (filter)
         filter->applyFilter(boundingBox);
 
-    paintInfo.p->restore();
+    // restore drawing state
+    if (shouldPopContext) {
+        renderingDevice->popContext();
+        delete context;
+    } else
+        paintInfo.p->restore();
 }
 
 bool RenderSVGText::nodeAtPoint(NodeInfo& info, int _x, int _y, int _tx, int _ty, WebCore::HitTestAction hitTestAction)