[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756

zimmermann at webkit.org zimmermann at webkit.org
Fri Feb 26 22:16:03 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit 2f8b6c1bd2204bdcc3287b1d704c7a1671e7b158
Author: zimmermann at webkit.org <zimmermann at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 9 16:53:07 2010 +0000

    2010-02-09  MORITA Hajime  <morrita at gmail.com>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG selection text foreground colour does not respect user settings
            https://bugs.webkit.org/show_bug.cgi?id=15997
    
            Add two subphases SVGTextPaintSubphaseGlyphFillSelection and
            SVGTextPaintSubphaseGlyphStrokeSelection for painting selected
            text on SVG. Selected texts are painted with style from
            getCachedPseudoStyle() instead of style().
    
            Tests: svg/text/selection-styles.xhtml
    
            * rendering/SVGCharacterLayoutInfo.h:
            (WebCore::SVGTextChunkWalker::SVGTextChunkWalker):
            (WebCore::SVGTextChunkWalker::setupFillSelection):
            (WebCore::SVGTextChunkWalker::setupStrokeSelection):
            * rendering/SVGRootInlineBox.cpp:
            (WebCore::SVGRootInlineBoxPaintWalker::mayHaveSelection):
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillSelectionCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeSelectionCallback):
            (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer):
            (WebCore::SVGRootInlineBox::paint):
            (WebCore::SVGRootInlineBox::walkTextChunks):
            * rendering/SVGInlineTextBox.h:
            (WebCore::):
            Add callback hooks and its implementation for handle new
            subphases.
    
            * rendering/SVGInlineTextBox.cpp:
            (WebCore::SVGInlineTextBox::chunkSelectionStartEnd):
            (WebCore::SVGInlineTextBox::paintCharacters):
            Split box text into selected part and non-selected part, and use
            separate subphases to paint them.
    
            * svg/SVGFont.cpp:
            (WebCore::SVGTextRunWalker::walk):
            Relax ASSERT() condition to accept a part of text.
    
            * svg/graphics/SVGPaintServer.cpp:
            (WebCore::applyStrokeStyleToContext):
            (WebCore::SVGPaintServer::setup):
            * svg/graphics/SVGPaintServer.h:
            * svg/graphics/SVGPaintServerGradient.cpp:
            (WebCore::SVGPaintServerGradient::setup):
            * svg/graphics/SVGPaintServerGradient.h:
            * svg/graphics/SVGPaintServerPattern.cpp:
            (WebCore::SVGPaintServerPattern::setup):
            * svg/graphics/SVGPaintServerPattern.h:
            * svg/graphics/SVGPaintServerSolid.cpp:
            (WebCore::SVGPaintServerSolid::setup):
            * svg/graphics/SVGPaintServerSolid.h:
            Change setup() signature to accept RenderStyle instead of always
            using RenderObject::style().
    
    2010-02-09  MORITA Hajime  <morrita at gmail.com>
    
            Reviewed by Nikolas Zimmermann.
    
            SVG selection text foreground colour does not respect user settings
            https://bugs.webkit.org/show_bug.cgi?id=15997
    
            Add two subphases SVGTextPaintSubphaseGlyphFillSelection and
            SVGTextPaintSubphaseGlyphStrokeSelection for painting SVG text
            selection. texts are painted with style from getCachedPseudoStyle() instead of style().
    
            * platform/mac/svg/text/selection-styles-expected.checksum: Added.
            * platform/mac/svg/text/selection-styles-expected.png: Added.
            * platform/mac/svg/text/selection-styles-expected.txt: Added.
            * platform/mac/svg/text/text-deco-01-b-expected.checksum: Updated pixel tests to account for marginal painting differences.
            * platform/mac/svg/text/text-deco-01-b-expected.png: Ditto.
            * platform/mac/svg/text/text-path-01-b-expected.checksum: Dito.
            * platform/mac/svg/text/text-path-01-b-expected.png: Ditto.
            * platform/mac/svg/text/text-text-03-b-expected.checksum: Ditto.
            * platform/mac/svg/text/text-text-03-b-expected.png: Ditto.
            * svg/text/selection-styles.xhtml: Added.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54556 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index cfbeda4..fdf9afb 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,25 @@
+2010-02-09  MORITA Hajime  <morrita at gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG selection text foreground colour does not respect user settings
+        https://bugs.webkit.org/show_bug.cgi?id=15997
+
+        Add two subphases SVGTextPaintSubphaseGlyphFillSelection and
+        SVGTextPaintSubphaseGlyphStrokeSelection for painting SVG text
+        selection. texts are painted with style from getCachedPseudoStyle() instead of style().
+
+        * platform/mac/svg/text/selection-styles-expected.checksum: Added.
+        * platform/mac/svg/text/selection-styles-expected.png: Added.
+        * platform/mac/svg/text/selection-styles-expected.txt: Added.
+        * platform/mac/svg/text/text-deco-01-b-expected.checksum: Updated pixel tests to account for marginal painting differences.
+        * platform/mac/svg/text/text-deco-01-b-expected.png: Ditto.
+        * platform/mac/svg/text/text-path-01-b-expected.checksum: Dito.
+        * platform/mac/svg/text/text-path-01-b-expected.png: Ditto.
+        * platform/mac/svg/text/text-text-03-b-expected.checksum: Ditto.
+        * platform/mac/svg/text/text-text-03-b-expected.png: Ditto.
+        * svg/text/selection-styles.xhtml: Added.
+
 2010-02-09  Nikolas Zimmermann  <nzimmermann at rim.com>
 
         Reviewed by Dirk Schulze.
diff --git a/LayoutTests/platform/mac/svg/text/selection-styles-expected.checksum b/LayoutTests/platform/mac/svg/text/selection-styles-expected.checksum
new file mode 100644
index 0000000..90e437c
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/text/selection-styles-expected.checksum
@@ -0,0 +1 @@
+146cef6cd91a53705cec6673543b786f
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/selection-styles-expected.png b/LayoutTests/platform/mac/svg/text/selection-styles-expected.png
new file mode 100644
index 0000000..a8e397c
Binary files /dev/null and b/LayoutTests/platform/mac/svg/text/selection-styles-expected.png differ
diff --git a/LayoutTests/platform/mac/svg/text/selection-styles-expected.txt b/LayoutTests/platform/mac/svg/text/selection-styles-expected.txt
new file mode 100644
index 0000000..c12f76e
--- /dev/null
+++ b/LayoutTests/platform/mac/svg/text/selection-styles-expected.txt
@@ -0,0 +1,55 @@
+KRenderingPaintServer {id="grad1" [type=LINEAR-GRADIENT] [stops=[(0.00,#000000), (1.00,#FFFFFF)]] [transform={m=((0.71,0.71)(-0.71,0.71)) t=(0.00,0.00)}] [start=(0,0)] [end=(1,0)]}
+KRenderingPaintServer {id="grad2" [type=LINEAR-GRADIENT] [stops=[(0.00,#FF0000), (1.00,#008000)]] [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 800x504
+  RenderBlock {html} at (0,0) size 800x504
+    RenderBody {body} at (0,0) size 800x504
+      RenderSVGRoot {svg} at (0,0) size 800x500
+        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
+          RenderSVGHiddenContainer {linearGradient} at (0,0) size 0x0
+            RenderSVGGradientStop {stop} at (0,0) size 0x0
+            RenderSVGGradientStop {stop} at (0,0) size 0x0
+        RenderSVGContainer {g} at (9,12) size 591x384 [transform={m=((1.00,0.00)(0.00,1.00)) t=(10.00,0.00)}]
+          RenderSVGText {text} at (0,30) size 368x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 368x23
+              chunk 1 text run 1 at (0.00,30.00) startOffset 0 endOffset 47 width 368.00: "Selected text should be filled with solid blue."
+          RenderSVGText {text} at (0,60) size 384x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 384x23
+              chunk 1 text run 1 at (0.00,60.00) startOffset 0 endOffset 48 width 384.00: "Selected text should be stroked with solid blue."
+          RenderSVGText {text} at (0,90) size 355x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 355x23
+              chunk 1 text run 1 at (0.00,90.00) startOffset 0 endOffset 45 width 355.00: "Selected text should be filled with gradient."
+          RenderSVGText {text} at (0,120) size 371x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 371x23
+              chunk 1 text run 1 at (0.00,120.00) startOffset 0 endOffset 46 width 371.00: "Selected text should be stroked with gradient."
+          RenderSVGText {text} at (0,150) size 275x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 275x23
+              chunk 1 text run 1 at (0.00,150.00) startOffset 0 endOffset 35 width 275.00: "Selected text should get invisible."
+          RenderSVGText {text} at (0,180) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,180.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,240) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,240.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,270) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,270.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,300) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,300.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,330) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,330.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,360) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,360.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+          RenderSVGText {text} at (0,390) size 589x23 contains 1 chunk(s)
+            RenderSVGInlineText {#text} at (0,-18) size 589x23
+              chunk 1 text run 1 at (0.00,390.00) startOffset 0 endOffset 73 width 589.00: "Selected text should have both gradient fill, solid stroke and background"
+      RenderText {#text} at (0,0) size 0x0
+selection start: position 0 of child 0 {#text} of child 3 {text} of child 3 {g} of child 1 {svg} of child 3 {body} of child 0 {html} of document
+selection end:   position 73 of child 0 {#text} of child 27 {text} of child 3 {g} of child 1 {svg} 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 cb8c017..23574ea 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 @@
-84af7660597ced8a114bbdcd4972a174
\ No newline at end of file
+4f36848813cb87d756d9d1d55e96512e
\ 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 ef29a39..443ae10 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-path-01-b-expected.checksum b/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.checksum
index 8a16a00..a204973 100644
--- a/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.checksum
+++ b/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.checksum
@@ -1 +1 @@
-9d489dcf1db67dbd4eed1d02b5885e2c
\ No newline at end of file
+05a3accd486710d5a5d9cdcd47c253ae
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.png b/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.png
index ecab0ac..20b4352 100644
Binary files a/LayoutTests/platform/mac/svg/text/text-path-01-b-expected.png and b/LayoutTests/platform/mac/svg/text/text-path-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 016a99a..d9b3aa3 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 @@
-4472074ea6f69b13c6860505b59b8d4e
\ No newline at end of file
+5cbc1204e81a97fcd388f7eb175a9b29
\ 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 4dbdcd0..d988de8 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/svg/text/selection-styles.xhtml b/LayoutTests/svg/text/selection-styles.xhtml
new file mode 100644
index 0000000..0653934
--- /dev/null
+++ b/LayoutTests/svg/text/selection-styles.xhtml
@@ -0,0 +1,50 @@
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<head>
+<style>
+  body, svg { margin: 0px; padding: 0px; }
+  text#solidFill::selection, #solidFillText { fill: blue; }
+  text#solidStroke::selection, #solidStrokeText { fill: none; stroke:blue; stroke-width: 1px; }
+  text#gradFill::selection, #gradFillText { fill: url(#grad1); }
+  text#gradStroke::selection, #gradStrokeText { fill: none; stroke: url(#grad1); stroke-width: 1px; }
+  text#none::selection, #noneText { fill: none; stroke: none; }
+  text#compound::selection, text.compound::selection { fill: url(#grad1); stroke:blue; stroke-width: 1px; background-color: yellow; }
+  #compoundText { fill: url(#grad2); stroke:purple; stroke-width: 1px; }
+</style>
+<script>
+function runTests()
+{
+    document.execCommand("SelectAll");
+}
+</script>
+</head>
+<body onload="runTests()">
+  <svg xmlns="http://www.w3.org/2000/svg" font-size="20" width="800px" height="500px">
+    <defs>
+      <linearGradient id="grad1" gradientTransform="rotate(45)">
+        <stop offset="0" stop-color="black"/>
+        <stop offset="1" stop-color="white"/>
+      </linearGradient>
+      <linearGradient id="grad2" gradientTransform="rotate(45)">
+        <stop offset="0" stop-color="red"/>
+        <stop offset="1" stop-color="green"/>
+      </linearGradient>
+    </defs>
+    <g transform="translate(10,0)">
+      <!-- select with various style -->
+      <text y="30px" id="solidFill">Selected text should be filled with solid blue.</text>
+      <text y="60px" id="solidStroke">Selected text should be stroked with solid blue.</text>
+      <text y="90px" id="gradFill">Selected text should be filled with gradient.</text>
+      <text y="120px" id="gradStroke">Selected text should be stroked with gradient.</text>
+      <text y="150px" id="none">Selected text should get invisible.</text>
+      <text y="180px" id="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <!-- select various pre-styled texts with a style -->
+      <text y="240px" id="solidFillText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <text y="270px" id="solidStrokeText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <text y="300px" id="gradFillText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <text y="330px" id="gradStrokeText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <text y="360px" id="noneText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+      <text y="390px" id="compoundText" class="compound">Selected text should have both gradient fill, solid stroke and background</text>
+    </g>
+  </svg>
+</body>
+</html>
\ No newline at end of file
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 87a0b64..987c0c1 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,59 @@
+2010-02-09  MORITA Hajime  <morrita at gmail.com>
+
+        Reviewed by Nikolas Zimmermann.
+
+        SVG selection text foreground colour does not respect user settings
+        https://bugs.webkit.org/show_bug.cgi?id=15997
+
+        Add two subphases SVGTextPaintSubphaseGlyphFillSelection and
+        SVGTextPaintSubphaseGlyphStrokeSelection for painting selected
+        text on SVG. Selected texts are painted with style from
+        getCachedPseudoStyle() instead of style().
+        
+        Tests: svg/text/selection-styles.xhtml
+
+        * rendering/SVGCharacterLayoutInfo.h:
+        (WebCore::SVGTextChunkWalker::SVGTextChunkWalker):
+        (WebCore::SVGTextChunkWalker::setupFillSelection):
+        (WebCore::SVGTextChunkWalker::setupStrokeSelection):
+        * rendering/SVGRootInlineBox.cpp:
+        (WebCore::SVGRootInlineBoxPaintWalker::mayHaveSelection):
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupFillSelectionCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::chunkSetupStrokeSelectionCallback):
+        (WebCore::SVGRootInlineBoxPaintWalker::activePaintServer):
+        (WebCore::SVGRootInlineBox::paint):
+        (WebCore::SVGRootInlineBox::walkTextChunks):
+        * rendering/SVGInlineTextBox.h:
+        (WebCore::):        
+        Add callback hooks and its implementation for handle new
+        subphases.
+        
+        * rendering/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::chunkSelectionStartEnd):
+        (WebCore::SVGInlineTextBox::paintCharacters):
+        Split box text into selected part and non-selected part, and use
+        separate subphases to paint them.
+        
+        * svg/SVGFont.cpp:
+        (WebCore::SVGTextRunWalker::walk):
+        Relax ASSERT() condition to accept a part of text.
+        
+        * svg/graphics/SVGPaintServer.cpp:
+        (WebCore::applyStrokeStyleToContext):
+        (WebCore::SVGPaintServer::setup):
+        * svg/graphics/SVGPaintServer.h:
+        * svg/graphics/SVGPaintServerGradient.cpp:
+        (WebCore::SVGPaintServerGradient::setup):
+        * svg/graphics/SVGPaintServerGradient.h:
+        * svg/graphics/SVGPaintServerPattern.cpp:
+        (WebCore::SVGPaintServerPattern::setup):
+        * svg/graphics/SVGPaintServerPattern.h:
+        * svg/graphics/SVGPaintServerSolid.cpp:
+        (WebCore::SVGPaintServerSolid::setup):
+        * svg/graphics/SVGPaintServerSolid.h:
+        Change setup() signature to accept RenderStyle instead of always
+        using RenderObject::style().
+
 2010-02-09  Nikolas Zimmermann  <nzimmermann at rim.com>
 
         Reviewed by Dirk Schulze.
diff --git a/WebCore/rendering/SVGCharacterLayoutInfo.h b/WebCore/rendering/SVGCharacterLayoutInfo.h
index 3c69ac2..f80c79c 100644
--- a/WebCore/rendering/SVGCharacterLayoutInfo.h
+++ b/WebCore/rendering/SVGCharacterLayoutInfo.h
@@ -300,7 +300,9 @@ struct SVGTextChunkWalkerBase {
     
     virtual bool setupBackground(InlineBox*) = 0;
     virtual bool setupFill(InlineBox*) = 0;
+    virtual bool setupFillSelection(InlineBox*) = 0;
     virtual bool setupStroke(InlineBox*) = 0;
+    virtual bool setupStrokeSelection(InlineBox*) = 0;
     virtual bool setupForeground(InlineBox*) = 0;
 };
 
@@ -328,7 +330,9 @@ public:
                        SVGTextChunkEndCallback end = 0,
                        SVGTextChunkSetupBackgroundCallback background = 0,
                        SVGTextChunkSetupFillCallback fill = 0,
+                       SVGTextChunkSetupFillCallback fillSelection = 0,
                        SVGTextChunkSetupStrokeCallback stroke = 0,
+                       SVGTextChunkSetupStrokeCallback strokeSelection = 0,
                        SVGTextChunkSetupForegroundCallback foreground = 0)
         : m_object(object)
         , m_walkerCallback(walker)
@@ -336,7 +340,9 @@ public:
         , m_endCallback(end)
         , m_setupBackgroundCallback(background)
         , m_setupFillCallback(fill)
+        , m_setupFillSelectionCallback(fillSelection)
         , m_setupStrokeCallback(stroke)
+        , m_setupStrokeSelectionCallback(strokeSelection)
         , m_setupForegroundCallback(foreground)
     {
         ASSERT(object);
@@ -384,6 +390,15 @@ public:
         return false;
     }
 
+    virtual bool setupFillSelection(InlineBox* box)
+    {
+        if (m_setupFillSelectionCallback)
+            return (*m_object.*m_setupFillSelectionCallback)(box);
+
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
     virtual bool setupStroke(InlineBox* box)
     {
         if (m_setupStrokeCallback)
@@ -393,6 +408,15 @@ public:
         return false;
     }
 
+    virtual bool setupStrokeSelection(InlineBox* box)
+    {
+        if (m_setupStrokeSelectionCallback)
+            return (*m_object.*m_setupStrokeSelectionCallback)(box);
+
+        ASSERT_NOT_REACHED();
+        return false;
+    }
+
     virtual bool setupForeground(InlineBox* box)
     {
         if (m_setupForegroundCallback)
@@ -409,7 +433,9 @@ private:
     SVGTextChunkEndCallback m_endCallback;
     SVGTextChunkSetupBackgroundCallback m_setupBackgroundCallback;
     SVGTextChunkSetupFillCallback m_setupFillCallback;
+    SVGTextChunkSetupFillCallback m_setupFillSelectionCallback;
     SVGTextChunkSetupStrokeCallback m_setupStrokeCallback;
+    SVGTextChunkSetupStrokeCallback m_setupStrokeSelectionCallback;
     SVGTextChunkSetupForegroundCallback m_setupForegroundCallback;
 };
 
diff --git a/WebCore/rendering/SVGInlineTextBox.cpp b/WebCore/rendering/SVGInlineTextBox.cpp
index 3e2a0f8..65aa5a1 100644
--- a/WebCore/rendering/SVGInlineTextBox.cpp
+++ b/WebCore/rendering/SVGInlineTextBox.cpp
@@ -322,6 +322,32 @@ IntRect SVGInlineTextBox::selectionRect(int, int, int startPos, int endPos)
     return enclosingIntRect(walkerCallback.selectionRect());
 }
 
+bool SVGInlineTextBox::chunkSelectionStartEnd(const UChar* chunk, int chunkLength, int& selectionStart, int& selectionEnd)
+{
+    // NOTE: We ignore SVGInlineTextBox::m_start here because it is always 0.
+    //       Curently SVG doesn't use HTML block-level layout, in which m_start would be set.
+
+    int chunkStart = chunk - textRenderer()->characters();
+    ASSERT(0 <= chunkStart);    
+
+    selectionStartEnd(selectionStart, selectionEnd);
+    if (selectionEnd <= chunkStart)
+        return false;
+    if (chunkStart + chunkLength <= selectionStart)
+        return false;
+
+    // Map indices from view-global to chunk-local.
+    selectionStart -= chunkStart;
+    selectionEnd -= chunkStart;
+    // Then clamp with chunk range
+    if (selectionStart < 0)
+        selectionStart = 0;
+    if (chunkLength < selectionEnd)
+        selectionEnd = chunkLength;
+
+    return selectionStart < selectionEnd;
+}
+
 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)
@@ -374,7 +400,10 @@ void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int t
         }
     }
 
-    if  (textPaintInfo.subphase == SVGTextPaintSubphaseGlyphFill || textPaintInfo.subphase == SVGTextPaintSubphaseGlyphStroke) {
+    bool isGlyphPhase = textPaintInfo.subphase == SVGTextPaintSubphaseGlyphFill || textPaintInfo.subphase == SVGTextPaintSubphaseGlyphStroke;
+    bool isSelectionGlyphPhase = textPaintInfo.subphase == SVGTextPaintSubphaseGlyphFillSelection || textPaintInfo.subphase == SVGTextPaintSubphaseGlyphStrokeSelection;
+
+    if  (isGlyphPhase || isSelectionGlyphPhase) {
         // Set a text shadow if we have one.
         // FIXME: Support multiple shadow effects.  Need more from the CG API before
         // we can do this.
@@ -396,7 +425,21 @@ void SVGInlineTextBox::paintCharacters(RenderObject::PaintInfo& paintInfo, int t
         run.setActivePaintServer(textPaintInfo.activePaintServer);
 #endif
 
-        paintInfo.context->drawText(font, run, origin);
+        int selectionStart = 0;
+        int selectionEnd = 0;
+        bool haveSelectedRange = haveSelection && chunkSelectionStartEnd(chars, length, selectionStart, selectionEnd);
+        
+        if (isGlyphPhase) {
+            if (haveSelectedRange) {
+                paintInfo.context->drawText(font, run, origin, 0, selectionStart);
+                paintInfo.context->drawText(font, run, origin, selectionEnd, run.length());
+            } else
+                paintInfo.context->drawText(font, run, origin);
+        } else {
+            ASSERT(isSelectionGlyphPhase);
+            if (haveSelectedRange)
+                paintInfo.context->drawText(font, run, origin, selectionStart, selectionEnd);
+        }
 
         if (setShadow)
             paintInfo.context->clearShadow();
diff --git a/WebCore/rendering/SVGInlineTextBox.h b/WebCore/rendering/SVGInlineTextBox.h
index eea6744..596fdf3 100644
--- a/WebCore/rendering/SVGInlineTextBox.h
+++ b/WebCore/rendering/SVGInlineTextBox.h
@@ -35,7 +35,9 @@ namespace WebCore {
     enum SVGTextPaintSubphase {
         SVGTextPaintSubphaseBackground,
         SVGTextPaintSubphaseGlyphFill,
+        SVGTextPaintSubphaseGlyphFillSelection,
         SVGTextPaintSubphaseGlyphStroke,
+        SVGTextPaintSubphaseGlyphStrokeSelection,
         SVGTextPaintSubphaseForeground
     };
 
@@ -83,6 +85,7 @@ namespace WebCore {
     private:
         friend class RenderSVGInlineText;
         bool svgCharacterHitsPosition(int x, int y, int& offset) const;
+        bool chunkSelectionStartEnd(const UChar* chunk, int chunkLength, int& selectionStart, int& selectionEnd);
         
         int m_height;
     };
diff --git a/WebCore/rendering/SVGRootInlineBox.cpp b/WebCore/rendering/SVGRootInlineBox.cpp
index 69e1b16..3f21e64 100644
--- a/WebCore/rendering/SVGRootInlineBox.cpp
+++ b/WebCore/rendering/SVGRootInlineBox.cpp
@@ -363,6 +363,13 @@ struct SVGRootInlineBoxPaintWalker {
         ASSERT(!m_chunkStarted);
     }
 
+    bool mayHaveSelection(InlineBox* box) const
+    {
+        int selectionStart = 0, selectionEnd = 0;
+        box->renderer()->selectionStartEnd(selectionStart, selectionEnd);
+        return selectionStart < selectionEnd;
+    }
+
     void teardownFillPaintServer()
     {
         if (!m_fillPaintServer)
@@ -457,6 +464,34 @@ struct SVGRootInlineBoxPaintWalker {
         return false;
     }
 
+    bool chunkSetupFillSelectionCallback(InlineBox* box)
+    {
+        InlineFlowBox* flowBox = box->parent();
+
+        // Setup fill paint server
+        RenderObject* object = flowBox->renderer();
+        ASSERT(object);
+        RenderStyle* style = object->getCachedPseudoStyle(SELECTION);
+        if (!style)
+            style = object->style();
+
+        ASSERT(!m_strokePaintServer);
+        teardownFillPaintServer();
+
+        if (!mayHaveSelection(box))
+            return false;
+
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphFillSelection;
+        m_fillPaintServer = SVGPaintServer::fillPaintServer(style, object);
+        if (m_fillPaintServer) {
+            m_fillPaintServer->setup(m_paintInfo.context, object, style, ApplyToFillTargetType, true);
+            m_fillPaintServerObject = object;
+            return true;
+        }
+
+        return false;
+    }
+
     bool chunkSetupStrokeCallback(InlineBox* box)
     {
         InlineFlowBox* flowBox = box->parent();
@@ -481,6 +516,35 @@ struct SVGRootInlineBoxPaintWalker {
         return false;
     }
 
+    bool chunkSetupStrokeSelectionCallback(InlineBox* box)
+    {
+        InlineFlowBox* flowBox = box->parent();
+
+        // Setup stroke paint server
+        RenderObject* object = flowBox->renderer();
+        ASSERT(object);
+        RenderStyle* style = object->getCachedPseudoStyle(SELECTION);
+        if (!style)
+            style = object->style();
+
+        // If we're both stroked & filled, teardown fill paint server before stroking.
+        teardownFillPaintServer();
+        teardownStrokePaintServer();
+
+        if (!mayHaveSelection(box))
+            return false;
+
+        m_textPaintInfo.subphase = SVGTextPaintSubphaseGlyphStrokeSelection;
+        m_strokePaintServer = SVGPaintServer::strokePaintServer(style, object);
+        if (m_strokePaintServer) {
+            m_strokePaintServer->setup(m_paintInfo.context, object, style, ApplyToStrokeTargetType, true);
+            m_strokePaintServerObject = object;
+            return true;
+        }
+
+        return false;
+    }
+
     bool chunkSetupForegroundCallback(InlineBox* /*box*/)
     {
         teardownFillPaintServer();
@@ -495,9 +559,11 @@ struct SVGRootInlineBoxPaintWalker {
     {
         switch (m_textPaintInfo.subphase) {
         case SVGTextPaintSubphaseGlyphFill:
+        case SVGTextPaintSubphaseGlyphFillSelection:
             ASSERT(m_fillPaintServer);
             return m_fillPaintServer;
         case SVGTextPaintSubphaseGlyphStroke:
+        case SVGTextPaintSubphaseGlyphStrokeSelection:
             ASSERT(m_strokePaintServer);
             return m_strokePaintServer;
         case SVGTextPaintSubphaseBackground:
@@ -616,7 +682,9 @@ void SVGRootInlineBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
                                                                &SVGRootInlineBoxPaintWalker::chunkEndCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkSetupBackgroundCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkSetupFillCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupFillSelectionCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkSetupStrokeCallback,
+                                                               &SVGRootInlineBoxPaintWalker::chunkSetupStrokeSelectionCallback,
                                                                &SVGRootInlineBoxPaintWalker::chunkSetupForegroundCallback);
 
         walkTextChunks(&walker);
@@ -1719,9 +1787,15 @@ void SVGRootInlineBox::walkTextChunks(SVGTextChunkWalkerBase* walker, const SVGI
                 if (walker->setupFill(range.box))
                     (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
 
+                if (walker->setupFillSelection(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->setupStrokeSelection(range.box))
+                    (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
+
                 if (walker->setupForeground(range.box))
                     (*walker)(rangeTextBox, range.startOffset, curChunk.ctm, itCharBegin, itCharEnd);
 
diff --git a/WebCore/svg/SVGFont.cpp b/WebCore/svg/SVGFont.cpp
index d978328..b7ca5f2 100644
--- a/WebCore/svg/SVGFont.cpp
+++ b/WebCore/svg/SVGFont.cpp
@@ -240,8 +240,7 @@ struct SVGTextRunWalker {
 
     void walk(const TextRun& run, bool isVerticalText, const String& language, int from, int to)
     {
-        // Should hold true for SVG text, otherwhise sth. is wrong
-        ASSERT(to - from == run.length());
+        ASSERT(0 <= from && from <= to && to - from <= run.length());
 
         const String text = Font::normalizeSpaces(String(run.data(from), run.length()));
         Vector<SVGGlyphIdentifier::ArabicForm> chars(charactersWithArabicForm(text, run.rtl()));
diff --git a/WebCore/svg/graphics/SVGPaintServer.cpp b/WebCore/svg/graphics/SVGPaintServer.cpp
index 6703ed6..ed5486f 100644
--- a/WebCore/svg/graphics/SVGPaintServer.cpp
+++ b/WebCore/svg/graphics/SVGPaintServer.cpp
@@ -151,7 +151,7 @@ SVGPaintServer* SVGPaintServer::strokePaintServer(const RenderStyle* style, cons
     return strokePaintServer;
 }
 
-void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, const RenderObject* object)
+void applyStrokeStyleToContext(GraphicsContext* context, const RenderStyle* style, const RenderObject* object)
 {
     context->setStrokeThickness(SVGRenderStyle::cssPrimitiveToLength(object, style->svgStyle()->strokeWidth(), 1.0f));
     context->setLineCap(style->svgStyle()->capStyle());
@@ -164,6 +164,11 @@ void applyStrokeStyleToContext(GraphicsContext* context, RenderStyle* style, con
     context->setLineDash(dashes, dashOffset);
 }
 
+bool SVGPaintServer::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+{
+    return setup(context, object, object ? object->style() : 0, type, isPaintingText);
+}
+
 void SVGPaintServer::draw(GraphicsContext*& context, const RenderObject* path, SVGPaintTargetType type) const
 {
     if (!setup(context, path, type))
diff --git a/WebCore/svg/graphics/SVGPaintServer.h b/WebCore/svg/graphics/SVGPaintServer.h
index 6e8997c..d9d2218 100644
--- a/WebCore/svg/graphics/SVGPaintServer.h
+++ b/WebCore/svg/graphics/SVGPaintServer.h
@@ -71,7 +71,9 @@ namespace WebCore {
         virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const;
         virtual void renderPath(GraphicsContext*&, const RenderObject*, SVGPaintTargetType) const;
 
-        virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const = 0;
+        virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText = false) const = 0;
+
+        bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText = false) const;
 
         static SVGPaintServer* strokePaintServer(const RenderStyle*, const RenderObject*);
         static SVGPaintServer* fillPaintServer(const RenderStyle*, const RenderObject*);
@@ -85,7 +87,7 @@ namespace WebCore {
 
     SVGPaintServer* getPaintServerById(Document*, const AtomicString&, const RenderObject*);
 
-    void applyStrokeStyleToContext(GraphicsContext*, RenderStyle*, const RenderObject*);
+    void applyStrokeStyleToContext(GraphicsContext*, const RenderStyle*, const RenderObject*);
     DashArray dashArrayFromRenderingStyle(const RenderStyle* style, RenderStyle* rootStyle);
 } // namespace WebCore
 
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.cpp b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
index 8a56624..c4ed95b 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.cpp
@@ -189,13 +189,13 @@ static inline AffineTransform clipToTextMask(GraphicsContext* context,
 }
 #endif
 
-bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle*style, SVGPaintTargetType type, bool isPaintingText) const
 {
     m_ownerElement->buildGradient();
 
-    const SVGRenderStyle* style = object->style()->svgStyle();
-    bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
-    bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+    const SVGRenderStyle* svgStyle = style->svgStyle();
+    bool isFilled = (type & ApplyToFillTargetType) && svgStyle->hasFill();
+    bool isStroked = (type & ApplyToStrokeTargetType) && svgStyle->hasStroke();
 
     ASSERT((isFilled && !isStroked) || (!isFilled && isStroked));
 
@@ -212,14 +212,14 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
     }
 
     if (isFilled) {
-        context->setAlpha(style->fillOpacity());
+        context->setAlpha(svgStyle->fillOpacity());
         context->setFillGradient(m_gradient);
-        context->setFillRule(style->fillRule());
+        context->setFillRule(svgStyle->fillRule());
     }
     if (isStroked) {
-        context->setAlpha(style->strokeOpacity());
+        context->setAlpha(svgStyle->strokeOpacity());
         context->setStrokeGradient(m_gradient);
-        applyStrokeStyleToContext(context, object->style(), object);
+        applyStrokeStyleToContext(context, style, object);
     }
 
     AffineTransform matrix;
@@ -237,7 +237,7 @@ bool SVGPaintServerGradient::setup(GraphicsContext*& context, const RenderObject
         // lines or rectangles without width or height.
         if (bbox.width() == 0 || bbox.height() == 0) {
             Color color(0, 0, 0);
-            context->setStrokeColor(color, object->style()->colorSpace());
+            context->setStrokeColor(color, style->colorSpace());
             return true;
         }
         matrix.translate(bbox.x(), bbox.y());
diff --git a/WebCore/svg/graphics/SVGPaintServerGradient.h b/WebCore/svg/graphics/SVGPaintServerGradient.h
index d643b3b..953b0d9 100644
--- a/WebCore/svg/graphics/SVGPaintServerGradient.h
+++ b/WebCore/svg/graphics/SVGPaintServerGradient.h
@@ -66,7 +66,7 @@ namespace WebCore {
 
         virtual TextStream& externalRepresentation(TextStream&) const;
 
-        virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+        virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
         virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
 
     protected:
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.cpp b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
index d029f8f..7fc75fb 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.cpp
@@ -95,13 +95,13 @@ TextStream& SVGPaintServerPattern::externalRepresentation(TextStream& ts) const
     return ts;
 }
 
-bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle* style, SVGPaintTargetType type, bool isPaintingText) const
 {
     FloatRect targetRect = object->objectBoundingBox();
 
-    const SVGRenderStyle* style = object->style()->svgStyle();
-    bool isFilled = (type & ApplyToFillTargetType) && style->hasFill();
-    bool isStroked = (type & ApplyToStrokeTargetType) && style->hasStroke();
+    const SVGRenderStyle* svgStyle = style->svgStyle();
+    bool isFilled = (type & ApplyToFillTargetType) && svgStyle->hasFill();
+    bool isStroked = (type & ApplyToStrokeTargetType) && svgStyle->hasStroke();
 
     ASSERT((isFilled && !isStroked) || (!isFilled && isStroked));
 
@@ -131,7 +131,7 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject*
             tileImageContext->translate(0, patternBoundaries().height());
             for (int j = numX; j > 0; j--) {
                 tileImageContext->translate(patternBoundaries().width(), 0);
-                tileImageContext->drawImage(tile()->image(), object->style()->colorSpace(), tileRect, tileRect);
+                tileImageContext->drawImage(tile()->image(), style->colorSpace(), tileRect, tileRect);
             }
             tileImageContext->translate(-patternBoundaries().width() * numX, 0);
         }
@@ -143,14 +143,14 @@ bool SVGPaintServerPattern::setup(GraphicsContext*& context, const RenderObject*
         m_pattern = Pattern::create(tile()->image(), true, true);
 
     if (isFilled) {
-        context->setAlpha(style->fillOpacity());
+        context->setAlpha(svgStyle->fillOpacity());
         context->setFillPattern(m_pattern);
-        context->setFillRule(style->fillRule());
+        context->setFillRule(svgStyle->fillRule());
     }
     if (isStroked) {
-        context->setAlpha(style->strokeOpacity());
+        context->setAlpha(svgStyle->strokeOpacity());
         context->setStrokePattern(m_pattern);
-        applyStrokeStyleToContext(context, object->style(), object);
+        applyStrokeStyleToContext(context, style, object);
     }
 
     AffineTransform matrix;
diff --git a/WebCore/svg/graphics/SVGPaintServerPattern.h b/WebCore/svg/graphics/SVGPaintServerPattern.h
index cda07c5..3d3da49 100644
--- a/WebCore/svg/graphics/SVGPaintServerPattern.h
+++ b/WebCore/svg/graphics/SVGPaintServerPattern.h
@@ -64,7 +64,7 @@ namespace WebCore {
 
         virtual TextStream& externalRepresentation(TextStream&) const;
 
-        virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+        virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
         virtual void teardown(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
 
     private:
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.cpp b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
index 72baad2..8921bb0 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.cpp
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.cpp
@@ -60,9 +60,8 @@ TextStream& SVGPaintServerSolid::externalRepresentation(TextStream& ts) const
     return ts;
 }
 
-bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, SVGPaintTargetType type, bool isPaintingText) const
+bool SVGPaintServerSolid::setup(GraphicsContext*& context, const RenderObject* object, const RenderStyle* style, SVGPaintTargetType type, bool isPaintingText) const
 {
-    RenderStyle* style = object ? object->style() : 0;
     const SVGRenderStyle* svgStyle = style ? style->svgStyle() : 0;
     ColorSpace colorSpace = style ? style->colorSpace() : DeviceColorSpace;
 
diff --git a/WebCore/svg/graphics/SVGPaintServerSolid.h b/WebCore/svg/graphics/SVGPaintServerSolid.h
index 0166c87..680b0fe 100644
--- a/WebCore/svg/graphics/SVGPaintServerSolid.h
+++ b/WebCore/svg/graphics/SVGPaintServerSolid.h
@@ -45,7 +45,7 @@ namespace WebCore {
 
         virtual TextStream& externalRepresentation(TextStream&) const;
 
-        virtual bool setup(GraphicsContext*&, const RenderObject*, SVGPaintTargetType, bool isPaintingText) const;
+        virtual bool setup(GraphicsContext*&, const RenderObject*, const RenderStyle*, SVGPaintTargetType, bool isPaintingText) const;
 
     private:
         SVGPaintServerSolid();

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list