[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Thu Apr 8 00:56:45 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 73f30781a2a98d5032a61b96e0cbe6da38e26e8f
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Jan 7 08:06:01 2010 +0000

    2010-01-06  MORITA Hajime  <morrita at gmail.com>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG background color on selected text goes wrong when text has
            gradient stroke.
            https://bugs.webkit.org/show_bug.cgi?id=33069
    
            Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
            and paint background and foreground in separate subphase.
    
            * svg/text/selection-background-color.xhtml: Added.
            * platform/mac/svg/text/selection-background-color-expected.checksum: Added.
            * platform/mac/svg/text/selection-background-color-expected.png: Added.
            * platform/mac/svg/text/selection-background-color-expected.txt: Added.
    
            * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum:
            * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png:
            * platform/mac/svg/batik/text/textDecoration2-expected.checksum:
            * platform/mac/svg/batik/text/textDecoration2-expected.png:
            * platform/mac/svg/text/text-deco-01-b-expected.checksum:
            * platform/mac/svg/text/text-deco-01-b-expected.png:
            * platform/mac/svg/text/text-spacing-01-b-expected.checksum:
            * platform/mac/svg/text/text-spacing-01-b-expected.png:
            * platform/mac/svg/text/text-text-03-b-expected.checksum:
            * platform/mac/svg/text/text-text-03-b-expected.png:
            * platform/mac/svg/text/text-text-08-b-expected.checksum:
            * platform/mac/svg/text/text-text-08-b-expected.png:
            Re-baselined due to painting algorithm change.
    2010-01-06  MORITA Hajime  <morrita at gmail.com>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG background color on selected text goes wrong when text has
            gradient stroke.
            https://bugs.webkit.org/show_bug.cgi?id=33069
    
            Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
            and paint background and foreground in separate subphase.
    
            Test: svg/text/selection-background-color.xhtml
    
            * rendering/SVGCharacterLayoutInfo.h:
            (WebCore::SVGTextChunkWalker::SVGTextChunkWalker):
            Added m_setupBackgroundCallback, m_setupForegroundCallback
            (WebCore::SVGTextChunkWalker::setupBackground):
            (WebCore::SVGTextChunkWalker::setupForeground):
            Added.
            * rendering/SVGInlineTextBox.cpp:
            (WebCore::SVGInlineTextBox::paintCharacters):
            pass SVGTextPaintInfo instead of SVGPaintServer
            * rendering/SVGInlineTextBox.h:
            (WebCore::SVGTextPaintSubphase):
            (WebCore::SVGTextPaintInfo::SVGTextPaintInfo):
            Added.
            * rendering/SVGRootInlineBox.cpp:
            (WebCore::SVGRootInlineBox::walkTextChunks):
            Invoke setupBackground() and setupForeground()
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer):
            Added.
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback):
            (WebCore::SVGRootInlineBox::paint):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@52904 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 470c395..c9be487 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,33 @@
+2010-01-06  MORITA Hajime  <morrita at gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG background color on selected text goes wrong when text has
+        gradient stroke.
+        https://bugs.webkit.org/show_bug.cgi?id=33069
+
+        Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
+        and paint background and foreground in separate subphase.
+
+        * svg/text/selection-background-color.xhtml: Added.        
+        * platform/mac/svg/text/selection-background-color-expected.checksum: Added.
+        * platform/mac/svg/text/selection-background-color-expected.png: Added.
+        * platform/mac/svg/text/selection-background-color-expected.txt: Added.
+        
+        * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum:
+        * platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png:
+        * platform/mac/svg/batik/text/textDecoration2-expected.checksum:
+        * platform/mac/svg/batik/text/textDecoration2-expected.png:
+        * platform/mac/svg/text/text-deco-01-b-expected.checksum:
+        * platform/mac/svg/text/text-deco-01-b-expected.png:
+        * platform/mac/svg/text/text-spacing-01-b-expected.checksum:
+        * platform/mac/svg/text/text-spacing-01-b-expected.png:
+        * platform/mac/svg/text/text-text-03-b-expected.checksum:
+        * platform/mac/svg/text/text-text-03-b-expected.png:
+        * platform/mac/svg/text/text-text-08-b-expected.checksum:
+        * platform/mac/svg/text/text-text-08-b-expected.png:
+        Re-baselined due to painting algorithm change.
+
 2010-01-06  Kinuko Yasuda  <kinuko at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum
index 27c0491..0d2dfe4 100644
--- a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.checksum
@@ -1 +1 @@
-ed64b2908c6fd5df02a15fad56f67f34
\ No newline at end of file
+79668d80dfb1484b12447c78a0c9a53a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png
index facb55c..d37d1cc 100644
Binary files a/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png and b/LayoutTests/platform/mac/svg/W3C-SVG-1.1/text-text-03-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.checksum b/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.checksum
index 3589658..169dfc1 100644
--- a/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.checksum
+++ b/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.checksum
@@ -1 +1 @@
-1f13a12e4ab2a348b2614a3c70d0546d
\ No newline at end of file
+593fd59c2f58e622f04fb9c00d7714b3
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.png b/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.png
index 56b80a9..559cd56 100644
Binary files a/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.png and b/LayoutTests/platform/mac/svg/batik/text/textDecoration2-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum
new file mode 100644
index 0000000..ab13e7e
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.checksum
@@ -0,0 +1 @@
+9a2639e9bf7c6f36e5f763df17693af3
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png
new file mode 100644
index 0000000..8f58872
Binary files /dev/null and b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/selection-background-color-expected.txt b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.txt
new file mode 100644
index 0000000..f327f52
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/text/selection-background-color-expected.txt
@@ -0,0 +1,22 @@
+KRenderingPaintServer {id="gradient" [type=LINEAR-GRADIENT] [stops=[(0.00,#000000), (1.00,#FF0000)]] [transform={m=((0.71,0.71)(-0.71,0.71)) t=(0.00,0.00)}] [start=(0,0)] [end=(1,0)]}
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x236
+  RenderBlock {html} at (0,0) size 800x236
+    RenderBody {body} at (8,16) size 784x204
+      RenderBlock {p} at (0,0) size 784x204
+        RenderSVGRoot {svg} at (6.67,26.67) size 247.67x55.67
+          RenderSVGHiddenContainer {defs} at (0,0) size 0x0
+            RenderSVGHiddenContainer {linearGradient} at (0,0) size 0x0
+              RenderSVGGradientStop {stop} at (0,0) size 0x0
+              RenderSVGGradientStop {stop} at (0,0) size 0x0
+          RenderSVGContainer {g} at (6.67,26.67) size 247.67x55.67
+            RenderSVGText {text} at (0,30) size 245x23 contains 1 chunk(s)
+              RenderSVGInlineText {#text} at (0,-18) size 245x23
+                chunk 1 text run 1 at (0.00,30.00) startOffset 0 endOffset 28 width 245.00: "Should have blue background."
+            RenderSVGText {text} at (0,60) size 245x23 contains 1 chunk(s)
+              RenderSVGInlineText {#text} at (0,-18) size 245x23
+                chunk 1 text run 1 at (0.00,60.00) startOffset 0 endOffset 28 width 245.00: "Should have blue background."
+        RenderText {#text} at (0,0) size 0x0
+selection start: position 0 of child 0 {#text} of child 1 {text} of child 3 {g} of child 1 {svg} of child 1 {p} of child 3 {body} of child 0 {html} of document
+selection end:   position 28 of child 0 {#text} of child 3 {text} of child 3 {g} of child 1 {svg} of child 1 {p} of child 3 {body} of child 0 {html} of document
diff --git a/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.checksum b/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.checksum
index c8d0ef3..8be28ac 100644
--- a/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.checksum
@@ -1 +1 @@
-a46864e6b6d1cea350560ea244072f85
\ No newline at end of file
+97154819a65cda5e8b6257183b7a90e1
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.png b/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.png
index e4a7528..afd83f1 100644
Binary files a/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.png and b/LayoutTests/platform/mac/svg/text/text-deco-01-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.checksum b/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.checksum
index 8829a06..81cf00b 100644
--- a/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.checksum
@@ -1 +1 @@
-ace025910b4ff42dd0bee9701efc4b63
\ No newline at end of file
+c1e3a98345d7a6b13e2928da86fbc55f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.png b/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.png
index a7d0a1e..0b23e27 100644
Binary files a/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.png and b/LayoutTests/platform/mac/svg/text/text-spacing-01-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.checksum b/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.checksum
index 814aa33..c689785 100644
--- a/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.checksum
@@ -1 +1 @@
-31029bbce66db9348cd8953d473f7b30
\ No newline at end of file
+dc67e8cf3194af25f470c49b7e9b600a
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.png b/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.png
index 71703fd..2ba8ef8 100644
Binary files a/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.png and b/LayoutTests/platform/mac/svg/text/text-text-03-b-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.checksum b/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.checksum
index a00bbea..d8b3c54 100644
--- a/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.checksum
@@ -1 +1 @@
-9265c96312cfa4f95c85dd52edf268b5
\ No newline at end of file
+a48969c2ed5c0596624855a08b116447
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.png b/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.png
index 158c4ca..5a4989f 100644
Binary files a/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.png and b/LayoutTests/platform/mac/svg/text/text-text-08-b-expected.png differ
diff --git a/LayoutTests/svg/text/selection-background-color.xhtml b/LayoutTests/svg/text/selection-background-color.xhtml
new file mode 100644
index 0000000..411c038
--- /dev/null
+++ b/LayoutTests/svg/text/selection-background-color.xhtml
@@ -0,0 +1,28 @@
+<html xmlns="http://www.w3.org/1999/xhtml" >
+  <head>
+    <style>
+      text#solidStroke { fill: green; stroke: white; stroke-width: 1pt; }
+      text#gradStroke { fill: green; stroke: url(#gradient); stroke-width: 1pt; }
+      text::selection { background-color: blue; }
+    </style>
+    <script>
+      function selectAll() { document.execCommand("SelectAll"); }
+    </script>
+  </head>
+  <body onload="selectAll();">
+    <p>
+      <svg xmlns="http://www.w3.org/2000/svg" font-size="20" width="600px" height="200px">
+        <defs>
+          <linearGradient id="gradient" gradientTransform="rotate(45)">
+             <stop offset="0" stop-color="yello"/>
+             <stop offset="1" stop-color="red"/>
+          </linearGradient>
+        </defs>
+        <g>
+          <text id="solidStroke" y="30px">Should have blue background.</text>
+          <text id="gradStroke" y="60px">Should have blue background.</text>
+        </g>
+      </svg>
+    </p>
+  </body>
+</html>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index e739293..0c9aab7 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,41 @@
+2010-01-06  MORITA Hajime  <morrita at gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG background color on selected text goes wrong when text has
+        gradient stroke.
+        https://bugs.webkit.org/show_bug.cgi?id=33069
+
+        Introduced SVGTextPaintSubphase like as PaintPhase on html painting,
+        and paint background and foreground in separate subphase.
+        
+        Test: svg/text/selection-background-color.xhtml
+        
+        * rendering/SVGCharacterLayoutInfo.h:
+        (WebCore::SVGTextChunkWalker::SVGTextChunkWalker):
+        Added m_setupBackgroundCallback, m_setupForegroundCallback
+        (WebCore::SVGTextChunkWalker::setupBackground):
+        (WebCore::SVGTextChunkWalker::setupForeground):
+        Added.
+        * rendering/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintCharacters):
+        pass SVGTextPaintInfo instead of SVGPaintServer
+        * rendering/SVGInlineTextBox.h:
+        (WebCore::SVGTextPaintSubphase):
+        (WebCore::SVGTextPaintInfo::SVGTextPaintInfo):
+        Added.
+        * rendering/SVGRootInlineBox.cpp:
+        (WebCore::SVGRootInlineBox::walkTextChunks):
+        Invoke setupBackground() and setupForeground()
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer):        
+        Added.
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkPortionCallback):
+        (WebCore::SVGRootInlineBox::paint):
+        
 2010-01-06  Kinuko Yasuda  <kinuko at chromium.org>
 
         Reviewed by Eric Seidel.
diff --git a/WebCore/rendering/SVGCharacterLayoutInfo.h b/WebCore/rendering/SVGCharacterLayoutInfo.h
index b5b4f3e..fb29110 100644
--- a/WebCore/rendering/SVGCharacterLayoutInfo.h
+++ b/WebCore/rendering/SVGCharacterLayoutInfo.h
@@ -298,8 +298,10 @@ struct SVGTextChunkWalkerBase {
     virtual void start(InlineBox*) = 0;
     virtual void end(InlineBox*) = 0;
     
+    virtual bool setupBackground(InlineBox*) = 0;
     virtual bool setupFill(InlineBox*) = 0;
     virtual bool setupStroke(InlineBox*) = 0;
+    virtual bool setupForeground(InlineBox*) = 0;
 };
 
 template<typename CallbackClass>
@@ -315,21 +317,27 @@ public:
     typedef void (CallbackClass::*SVGTextChunkStartCallback)(InlineBox* box);
     typedef void (CallbackClass::*SVGTextChunkEndCallback)(InlineBox* box);
 
+    typedef bool (CallbackClass::*SVGTextChunkSetupBackgroundCallback)(InlineBox* box);
     typedef bool (CallbackClass::*SVGTextChunkSetupFillCallback)(InlineBox* box);
     typedef bool (CallbackClass::*SVGTextChunkSetupStrokeCallback)(InlineBox* box);
+    typedef bool (CallbackClass::*SVGTextChunkSetupForegroundCallback)(InlineBox* box);
 
     SVGTextChunkWalker(CallbackClass* object,
                        SVGTextChunkWalkerCallback walker,
                        SVGTextChunkStartCallback start = 0,
                        SVGTextChunkEndCallback end = 0,
+                       SVGTextChunkSetupBackgroundCallback background = 0,
                        SVGTextChunkSetupFillCallback fill = 0,
-                       SVGTextChunkSetupStrokeCallback stroke = 0)
+                       SVGTextChunkSetupStrokeCallback stroke = 0,
+                       SVGTextChunkSetupForegroundCallback foreground = 0)
         : m_object(object)
         , m_walkerCallback(walker)
         , m_startCallback(start)
         , m_endCallback(end)
+        , m_setupBackgroundCallback(background)
         , m_setupFillCallback(fill)
         , m_setupStrokeCallback(stroke)
+        , m_setupForegroundCallback(foreground)
     {
         ASSERT(object);
         ASSERT(walker);
@@ -358,6 +366,15 @@ public:
             ASSERT_NOT_REACHED();
     }
 
+    virtual bool setupBackground(InlineBox* box)
+    {
+        if (m_setupBackgroundCallback)
+            return (*m_object.*m_setupBackgroundCallback)(box);
+
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
     virtual bool setupFill(InlineBox* box)
     {
         if (m_setupFillCallback)
@@ -376,13 +393,24 @@ public:
         return false;
     }
 
+    virtual bool setupForeground(InlineBox* box)
+    {
+        if (m_setupForegroundCallback)
+            return (*m_object.*m_setupForegroundCallback)(box);
+
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
 private:
     CallbackClass* m_object;
     SVGTextChunkWalkerCallback m_walkerCallback;
     SVGTextChunkStartCallback m_startCallback;
     SVGTextChunkEndCallback m_endCallback;
+    SVGTextChunkSetupBackgroundCallback m_setupBackgroundCallback;
     SVGTextChunkSetupFillCallback m_setupFillCallback;
     SVGTextChunkSetupStrokeCallback m_setupStrokeCallback;
+    SVGTextChunkSetupForegroundCallback m_setupForegroundCallback;
 };
 
 struct SVGTextChunkLayoutInfo {
diff --git a/WebCore/rendering/SVGInlineTextBox.cpp b/WebCore/rendering/SVGInlineTextBox.cpp
index cf8464e..2f56e68 100644
--- a/WebCore/rendering/SVGInlineTextBox.cpp
+++ b/WebCore/rendering/SVGInlineTextBox.cpp
@@ -324,7 +324,7 @@ IntRect SVGInlineTextBox::selectionRect(int, int, int startPos, int endPos)
     return enclosingIntRect(walkerCallback.selectionRect());
 }
 
-void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int tx, int ty, const SVGChar& svgChar, const UChar* chars, int length, SVGPaintServer* activePaintServer)
+void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int tx, int ty, const SVGChar& svgChar, const UChar* chars, int length, SVGTextPaintInfo& textPaintInfo)
 {
     if (renderer()->style()->visibility() != VISIBLE || paintInfo.phase == PaintPhaseOutline)
         return;
@@ -356,7 +356,7 @@ void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int t
 
     // 1. Paint backgrounds behind text if needed.  Examples of such backgrounds include selection
     // and marked text.
-    if (paintInfo.phase != PaintPhaseSelection && !isPrinting) {
+    if (paintInfo.phase != PaintPhaseSelection && !isPrinting && textPaintInfo.subphase == SVGTextPaintSubphaseBackground) {
 #if PLATFORM(MAC)
         // Custom highlighters go behind everything else.
         if (styleToUse->highlight() != nullAtom && !paintInfo.context->paintingDisabled())
@@ -376,29 +376,35 @@ void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int t
         }
     }
 
-    // Set a text shadow if we have one.
-    // FIXME: Support multiple shadow effects.  Need more from the CG API before
-    // we can do this.
-    bool setShadow = false;
-    if (styleToUse->textShadow()) {
-        paintInfo.context->setShadow(IntSize(styleToUse->textShadow()->x, styleToUse->textShadow()->y),
-                                     styleToUse->textShadow()->blur, styleToUse->textShadow()->color,
-                                     styleToUse->colorSpace());
-        setShadow = true;
-    }
+    if  (textPaintInfo.subphase == SVGTextPaintSubphaseGlyphFill || textPaintInfo.subphase == SVGTextPaintSubphaseGlyphStroke) {
+        // Set a text shadow if we have one.
+        // FIXME: Support multiple shadow effects.  Need more from the CG API before
+        // we can do this.
+        bool setShadow = false;
+        if (styleToUse->textShadow()) {
+            paintInfo.context->setShadow(IntSize(styleToUse->textShadow()->x, styleToUse->textShadow()->y),
+                                         styleToUse->textShadow()->blur, styleToUse->textShadow()->color,
+                                         styleToUse->colorSpace());
+            setShadow = true;
+        }
 
-    IntPoint origin((int) svgChar.x, (int) svgChar.y);
-    TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
+        IntPoint origin((int) svgChar.x, (int) svgChar.y);
+        TextRun run = svgTextRunForInlineTextBox(chars, length, styleToUse, this, svgChar.x);
 
 #if ENABLE(SVG_FONTS)
-    // SVG Fonts need access to the paint server used to draw the current text chunk.
-    // They need to be able to call renderPath() on a SVGPaintServer object.
-    run.setActivePaintServer(activePaintServer);
+        // SVG Fonts need access to the paint server used to draw the current text chunk.
+        // They need to be able to call renderPath() on a SVGPaintServer object.
+        ASSERT(textPaintInfo.activePaintServer);
+        run.setActivePaintServer(textPaintInfo.activePaintServer);
 #endif
 
-    paintInfo.context->drawText(font, run, origin);
+        paintInfo.context->drawText(font, run, origin);
 
-    if (paintInfo.phase != PaintPhaseSelection) {
+        if (setShadow)
+            paintInfo.context->clearShadow();
+    }
+
+    if (paintInfo.phase != PaintPhaseSelection && textPaintInfo.subphase == SVGTextPaintSubphaseForeground) {
         paintDocumentMarkers(paintInfo.context, tx, ty, styleToUse, font, false);
 
         if (useCustomUnderlines) {
@@ -428,9 +434,6 @@ void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int t
         
     }
 
-    if (setShadow)
-        paintInfo.context->clearShadow();
-
     if (!ctm.isIdentity())
         paintInfo.context->concatCTM(ctm.inverse());
 }
diff --git a/WebCore/rendering/SVGInlineTextBox.h b/WebCore/rendering/SVGInlineTextBox.h
index ad39aab..eea6744 100644
--- a/WebCore/rendering/SVGInlineTextBox.h
+++ b/WebCore/rendering/SVGInlineTextBox.h
@@ -32,6 +32,20 @@ namespace WebCore {
     struct SVGChar;
     struct SVGTextDecorationInfo;
 
+    enum SVGTextPaintSubphase {
+        SVGTextPaintSubphaseBackground,
+        SVGTextPaintSubphaseGlyphFill,
+        SVGTextPaintSubphaseGlyphStroke,
+        SVGTextPaintSubphaseForeground
+    };
+
+    struct SVGTextPaintInfo {
+        SVGTextPaintInfo() : activePaintServer(0), subphase(SVGTextPaintSubphaseBackground) {}
+
+        SVGPaintServer* activePaintServer;
+        SVGTextPaintSubphase subphase;
+    };
+
     class SVGInlineTextBox : public InlineTextBox {
     public:
         SVGInlineTextBox(RenderObject* obj);
@@ -49,7 +63,7 @@ namespace WebCore {
         virtual IntRect selectionRect(int absx, int absy, int startPos, int endPos);
 
         // SVGs custom paint text method
-        void paintCharacters(RenderObject::PaintInfo&, int tx, int ty, const SVGChar&, const UChar* chars, int length, SVGPaintServer*);
+        void paintCharacters(RenderObject::PaintInfo&, int tx, int ty, const SVGChar&, const UChar* chars, int length, SVGTextPaintInfo&);
 
         // SVGs custom paint selection method
         void paintSelection(int boxStartOffset, const SVGChar&, const UChar*, int length, GraphicsContext*, RenderStyle*, const Font&);
diff --git a/WebCore/rendering/SVGRootInlineBox.cpp b/WebCore/rendering/SVGRootInlineBox.cpp
index aac723b..9152885 100644
--- a/WebCore/rendering/SVGRootInlineBox.cpp
+++ b/WebCore/rendering/SVGRootInlineBox.cpp
@@ -429,6 +429,12 @@ struct SVGRootInlineBoxPaintWalker {
         m_paintInfo.rect = m_savedInfo.rect;
     }
 
+    bool chunkSetupBackgroundCallback(InlineBox* /*box*/)
+    {
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseBackground;
+        return true;
+    }
+
     bool chunkSetupFillCallback(InlineBox* box)
     {
         InlineFlowBox* flowBox = box->parent();
@@ -440,6 +446,7 @@ struct SVGRootInlineBoxPaintWalker {
         ASSERT(!m_strokePaintServer);
         teardownFillPaintServer();
 
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphFill;
         m_fillPaintServer = SVGPaintServer::fillPaintServer(object->style(), object);
         if (m_fillPaintServer) {
             m_fillPaintServer->setup(m_paintInfo.context, object, ApplyToFillTargetType, true);
@@ -462,6 +469,7 @@ struct SVGRootInlineBoxPaintWalker {
         teardownFillPaintServer();
         teardownStrokePaintServer();
 
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphStroke;
         m_strokePaintServer = SVGPaintServer::strokePaintServer(object->style(), object);
 
         if (m_strokePaintServer) {
@@ -473,6 +481,32 @@ struct SVGRootInlineBoxPaintWalker {
         return false;
     }
 
+    bool chunkSetupForegroundCallback(InlineBox* /*box*/)
+    {
+        teardownFillPaintServer();
+        teardownStrokePaintServer();
+
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseForeground;
+
+        return true;
+    }
+
+    SVGPaintServer* activePaintServer() const
+    {
+        switch (m_textPaintInfo.subphase) {
+        case SVGTextPaintSubphaseGlyphFill:
+            ASSERT(m_fillPaintServer);
+            return m_fillPaintServer;
+        case SVGTextPaintSubphaseGlyphStroke:
+            ASSERT(m_strokePaintServer);
+            return m_strokePaintServer;
+        case SVGTextPaintSubphaseBackground:
+        case SVGTextPaintSubphaseForeground:
+        default:
+            return 0;
+        }
+    }
+
     void chunkPortionCallback(SVGInlineTextBox* textBox, int startOffset, const TransformationMatrix& chunkCtm,
                               const Vector<SVGChar>::iterator& start, const Vector<SVGChar>::iterator& end)
     {
@@ -523,12 +557,8 @@ struct SVGRootInlineBoxPaintWalker {
                 textBox->paintDecoration(OVERLINE, m_paintInfo.context, decorationOrigin.x(), decorationOrigin.y(), textWidth, *it, info);
 
             // Paint text
-            SVGPaintServer* activePaintServer = m_fillPaintServer;
-            if (!activePaintServer)
-                activePaintServer = m_strokePaintServer;
-
-            ASSERT(activePaintServer);
-            textBox->paintCharacters(m_paintInfo, m_tx, m_ty, *it, stringStart, stringLength, activePaintServer);
+            m_textPaintInfo.activePaintServer = activePaintServer();
+            textBox->paintCharacters(m_paintInfo, m_tx, m_ty, *it, stringStart, stringLength, m_textPaintInfo);
 
             // Paint decorations, that have to be drawn afterwards
             if (textDecorations & LINE_THROUGH && textWidth != 0.0f)
@@ -561,6 +591,8 @@ private:
 
     int m_tx;
     int m_ty;
+
+    SVGTextPaintInfo m_textPaintInfo;
 };
 
 void SVGRootInlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
@@ -582,8 +614,10 @@ void SVGRootInlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
                                                                &SVGRootInlineBoxPaintWalker::chunkPortionCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkStartCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkEndCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkSetupFillCallback,
-                                                               &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback);
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback);
 
         walkTextChunks(&walker);
     }
@@ -1680,11 +1714,18 @@ void SVGRootInlineBox::walkTextChunks(SVGTextChunkWalkerBase* walker, const SVGI
             if (textBox)
                 (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
             else {
+                if (walker->setupBackground(range.box))
+                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
+
                 if (walker->setupFill(range.box))
                     (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
 
                 if (walker->setupStroke(range.box))
                     (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
+
+                if (walker->setupForeground(range.box))
+                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
+
             }
 
             chunkOffset += length;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list