[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

hyatt at apple.com hyatt at apple.com
Wed Dec 22 14:50:26 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 7d76c8e1c5ef4c4d84df187ccdbdb73fd501b027
Author: hyatt at apple.com <hyatt at apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Oct 21 21:16:55 2010 +0000

    https://bugs.webkit.org/show_bug.cgi?id=48085
    
    Reviewed by Darin Adler.
    
    Make basic vertical text painting work.  This includes the text itself, underlines, overlines, line-throughs and shadows.
    
    Added fast/blockflow/english-lr-text.html
    
    WebCore:
    
    * rendering/InlineFlowBox.cpp:
    (WebCore::InlineFlowBox::paint):
    * rendering/InlineFlowBox.h:
    * rendering/InlineTextBox.cpp:
    (WebCore::InlineTextBox::applyShadowToGraphicsContext):
    (WebCore::paintTextWithShadows):
    (WebCore::InlineTextBox::paint):
    (WebCore::InlineTextBox::paintDecoration):
    (WebCore::InlineTextBox::paintTextMatchMarker):
    * rendering/InlineTextBox.h:
    * rendering/svg/SVGInlineTextBox.cpp:
    (WebCore::SVGInlineTextBox::paintTextWithShadows):
    
    LayoutTests:
    
    * fast/blockflow/english-lr-text.html: Added.
    * platform/mac/fast/blockflow/english-lr-text-expected.checksum: Added.
    * platform/mac/fast/blockflow/english-lr-text-expected.png: Added.
    * platform/mac/fast/blockflow/english-lr-text-expected.txt: Added.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@70263 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index d5eda2c..531007c 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,18 @@
+2010-10-21  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48085
+
+        Make basic vertical text painting work.  This includes the text itself, underlines, overlines, line-throughs and shadows.
+
+        Added fast/blockflow/english-lr-text.html
+
+        * fast/blockflow/english-lr-text.html: Added.
+        * platform/mac/fast/blockflow/english-lr-text-expected.checksum: Added.
+        * platform/mac/fast/blockflow/english-lr-text-expected.png: Added.
+        * platform/mac/fast/blockflow/english-lr-text-expected.txt: Added.
+
 2010-10-21  James Robinson  <jamesr at chromium.org>
 
         Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/blockflow/english-lr-text.html b/LayoutTests/fast/blockflow/english-lr-text.html
new file mode 100644
index 0000000..c9f5183
--- /dev/null
+++ b/LayoutTests/fast/blockflow/english-lr-text.html
@@ -0,0 +1,11 @@
+<div style="height:500px;-webkit-writing-mode:vertical-lr;font-size:18px">
+<span style="text-decoration:underline">This text should be rotated 90 degrees and underlined.</span>
+<br>
+<span style="text-decoration:overline">This text should be rotated 90 degrees and overlined.</span>
+<br>
+<span style="text-decoration:line-through">This text should be rotated 90 degrees and struck through.</span>
+<br>
+<span style="text-shadow: red 10px 0 5px">This text should have a red shadow that is offset horizontally.</span>
+<br>
+<br>
+<span style="text-shadow: green 60px 0 5px; text-decoration:overline">This text should have an overline plus horizontal green shadow</div>
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.checksum b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.checksum
new file mode 100644
index 0000000..bd9a5d5
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.checksum
@@ -0,0 +1 @@
+f877c89d5f5032abe0650a578dc81375
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.png b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.png
new file mode 100644
index 0000000..d4a31c2
Binary files /dev/null and b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.txt b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.txt
new file mode 100644
index 0000000..5b12a55
--- /dev/null
+++ b/LayoutTests/platform/mac/fast/blockflow/english-lr-text-expected.txt
@@ -0,0 +1,34 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderBlock {DIV} at (0,0) size 132x500
+        RenderInline {SPAN} at (0,0) size 395x22
+          RenderText {#text} at (0,0) size 395x22
+            text run at (0,0) width 395: "This text should be rotated 90 degrees and underlined."
+        RenderText {#text} at (0,395) size 5x22
+          text run at (0,395) width 5: " "
+        RenderBR {BR} at (5,400) size 0x0
+        RenderInline {SPAN} at (0,0) size 386x22
+          RenderText {#text} at (22,0) size 386x22
+            text run at (22,0) width 386: "This text should be rotated 90 degrees and overlined."
+        RenderText {#text} at (22,386) size 5x22
+          text run at (22,386) width 5: " "
+        RenderBR {BR} at (27,391) size 0x0
+        RenderInline {SPAN} at (0,0) size 423x22
+          RenderText {#text} at (44,0) size 423x22
+            text run at (44,0) width 423: "This text should be rotated 90 degrees and struck through."
+        RenderText {#text} at (44,423) size 5x22
+          text run at (44,423) width 5: " "
+        RenderBR {BR} at (49,428) size 0x0
+        RenderInline {SPAN} at (0,0) size 449x22
+          RenderText {#text} at (66,0) size 449x22
+            text run at (66,0) width 449: "This text should have a red shadow that is offset horizontally."
+        RenderText {#text} at (66,449) size 5x22
+          text run at (66,449) width 5: " "
+        RenderBR {BR} at (71,454) size 0x0
+        RenderBR {BR} at (88,0) size 0x22
+        RenderInline {SPAN} at (0,0) size 460x22
+          RenderText {#text} at (110,0) size 460x22
+            text run at (110,0) width 460: "This text should have an overline plus horizontal green shadow"
diff --git a/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum b/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum
index 3e6afcf..b7fdeb1 100644
--- a/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum
+++ b/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.checksum
@@ -1 +1 @@
-83a57acedeb979e93959cf59fe59cdfc
\ No newline at end of file
+386f323eb617f371186afe888df1ce4e
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.png b/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.png
index cd38515..485cb50 100644
Binary files a/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.png and b/LayoutTests/platform/mac/fast/text/international/vertical-text-glyph-test-expected.png differ
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index 861825e..a5ad514 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,26 @@
+2010-10-21  David Hyatt  <hyatt at apple.com>
+
+        Reviewed by Darin Adler.
+
+        https://bugs.webkit.org/show_bug.cgi?id=48085
+
+        Make basic vertical text painting work.  This includes the text itself, underlines, overlines, line-throughs and shadows.
+
+        Added fast/blockflow/english-lr-text.html
+
+        * rendering/InlineFlowBox.cpp:
+        (WebCore::InlineFlowBox::paint):
+        * rendering/InlineFlowBox.h:
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::applyShadowToGraphicsContext):
+        (WebCore::paintTextWithShadows):
+        (WebCore::InlineTextBox::paint):
+        (WebCore::InlineTextBox::paintDecoration):
+        (WebCore::InlineTextBox::paintTextMatchMarker):
+        * rendering/InlineTextBox.h:
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintTextWithShadows):
+
 2010-10-21  No'am Rosenthal  <noam.rosenthal at nokia.com>
 
         Reviewed by Simon Hausmann.
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 7b5af96..54d1fe5 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -21200,6 +21200,7 @@
 			isa = PBXProject;
 			buildConfigurationList = 149C284308902B11008A9EFC /* Build configuration list for PBXProject "WebCore" */;
 			compatibilityVersion = "Xcode 2.4";
+			developmentRegion = English;
 			hasScannedForEncodings = 1;
 			knownRegions = (
 				English,
diff --git a/WebCore/rendering/InlineFlowBox.cpp b/WebCore/rendering/InlineFlowBox.cpp
index 79c571d..0cab658 100644
--- a/WebCore/rendering/InlineFlowBox.cpp
+++ b/WebCore/rendering/InlineFlowBox.cpp
@@ -701,11 +701,8 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty)
             paintMask(paintInfo, tx, ty);
             return;
         } else {
-            // 1. Paint our background, border and box-shadow.
+            // Paint our background, border and box-shadow.
             paintBoxDecorations(paintInfo, tx, ty);
-
-            // 2. Paint our underline and overline.
-            paintTextDecorations(paintInfo, tx, ty, false);
         }
     }
 
@@ -717,17 +714,13 @@ void InlineFlowBox::paint(PaintInfo& paintInfo, int tx, int ty)
     childInfo.phase = paintPhase;
     childInfo.updatePaintingRootForChildren(renderer());
     
-    // 3. Paint our children.
+    // Paint our children.
     if (paintPhase != PaintPhaseSelfOutline) {
         for (InlineBox* curr = firstChild(); curr; curr = curr->nextOnLine()) {
             if (curr->renderer()->isText() || !curr->boxModelObject()->hasSelfPaintingLayer())
                 curr->paint(childInfo, tx, ty);
         }
     }
-
-    // 4. Paint our strike-through
-    if (paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection)
-        paintTextDecorations(paintInfo, tx, ty, true);
 }
 
 void InlineFlowBox::paintFillLayers(const PaintInfo& paintInfo, const Color& c, const FillLayer* fillLayer, int _tx, int _ty, int w, int h, CompositeOperator op)
@@ -930,163 +923,6 @@ void InlineFlowBox::paintMask(PaintInfo& paintInfo, int tx, int ty)
         paintInfo.context->endTransparencyLayer();
 }
 
-static bool shouldDrawTextDecoration(RenderObject* obj)
-{
-    for (RenderObject* curr = obj->firstChild(); curr; curr = curr->nextSibling()) {
-        if (curr->isRenderInline())
-            return true;
-        if (curr->isText() && !curr->isBR()) {
-            if (!curr->style()->collapseWhiteSpace())
-                return true;
-            Node* currElement = curr->node();
-            if (!currElement)
-                return true;
-            if (!currElement->isTextNode())
-                return true;
-            if (!static_cast<Text*>(currElement)->containsOnlyWhitespace())
-                return true;
-        }
-    }
-    return false;
-}
-
-void InlineFlowBox::paintTextDecorations(PaintInfo& paintInfo, int tx, int ty, bool paintedChildren)
-{
-    // Paint text decorations like underlines/overlines. We only do this if we aren't in quirks mode (i.e., in
-    // almost-strict mode or strict mode).
-    if (renderer()->document()->inQuirksMode() || !paintInfo.shouldPaintWithinRoot(renderer()) ||
-        renderer()->style()->visibility() != VISIBLE)
-        return;
-    
-    // We don't want underlines or other decorations when we're trying to draw nothing but the selection as white text.
-    if (paintInfo.phase == PaintPhaseSelection && paintInfo.forceBlackText)
-        return;
-
-    GraphicsContext* context = paintInfo.context;
-    tx += m_x;
-    ty += m_y;
-    RenderStyle* styleToUse = renderer()->style(m_firstLine);
-    int deco = parent() ? styleToUse->textDecoration() : styleToUse->textDecorationsInEffect();
-    if (deco != TDNONE && 
-        ((!paintedChildren && ((deco & UNDERLINE) || (deco & OVERLINE))) || (paintedChildren && (deco & LINE_THROUGH))) &&
-        shouldDrawTextDecoration(renderer())) {
-        int x = m_x + borderLogicalLeft() + paddingLogicalLeft();
-        int w = m_logicalWidth - (borderLogicalLeft() + paddingLogicalLeft() + borderLogicalRight() + paddingLogicalRight());
-        RootInlineBox* rootLine = root();
-        if (rootLine->ellipsisBox()) {
-            int ellipsisX = m_x + rootLine->ellipsisBox()->x();
-            int ellipsisWidth = rootLine->ellipsisBox()->logicalWidth();
-            bool ltr = renderer()->style()->isLeftToRightDirection();
-            if (rootLine == this) {
-                // Trim w and x so that the underline isn't drawn underneath the ellipsis.
-                // ltr: is our right edge farther right than the right edge of the ellipsis.
-                // rtl: is the left edge of our box farther left than the left edge of the ellipsis.
-                bool ltrTruncation = ltr && (x + w >= ellipsisX + ellipsisWidth);
-                bool rtlTruncation = !ltr && (x <= ellipsisX + ellipsisWidth);
-                if (ltrTruncation)
-                    w -= (x + w) - (ellipsisX + ellipsisWidth);
-                else if (rtlTruncation) {
-                    int dx = m_x - ((ellipsisX - m_x) + ellipsisWidth);
-                    tx -= dx;
-                    w += dx;
-                }
-            } else {
-                bool ltrPastEllipsis = ltr && x >= ellipsisX;
-                bool rtlPastEllipsis = !ltr && (x + w) <= (ellipsisX + ellipsisWidth);
-                if (ltrPastEllipsis || rtlPastEllipsis)
-                    return;
-
-                bool ltrTruncation = ltr && x + w >= ellipsisX;
-                bool rtlTruncation = !ltr && x <= ellipsisX;
-                if (ltrTruncation)
-                    w -= (x + w - ellipsisX);
-                else if (rtlTruncation) {
-                    int dx = m_x - ((ellipsisX - m_x) + ellipsisWidth);
-                    tx -= dx;
-                    w += dx;
-                }
-            }
-        }
-
-        // We must have child boxes and have decorations defined.
-        tx += borderLogicalLeft() + paddingLogicalLeft();
-
-        Color underline, overline, linethrough;
-        underline = overline = linethrough = styleToUse->visitedDependentColor(CSSPropertyColor);
-        if (!parent())
-            renderer()->getTextDecorationColors(deco, underline, overline, linethrough);
-
-        bool isPrinting = renderer()->document()->printing();
-        context->setStrokeThickness(1.0f); // FIXME: We should improve this rule and not always just assume 1.
-
-        bool paintUnderline = deco & UNDERLINE && !paintedChildren;
-        bool paintOverline = deco & OVERLINE && !paintedChildren;
-        bool paintLineThrough = deco & LINE_THROUGH && paintedChildren;
-
-        bool linesAreOpaque = !isPrinting && (!paintUnderline || underline.alpha() == 255) && (!paintOverline || overline.alpha() == 255) && (!paintLineThrough || linethrough.alpha() == 255);
-
-        int baselinePos = renderer()->style(m_firstLine)->font().ascent();
-        if (!isRootInlineBox())
-            baselinePos += boxModelObject()->borderTop() + boxModelObject()->paddingTop();
-
-        bool setClip = false;
-        int extraOffset = 0;
-        const ShadowData* shadow = styleToUse->textShadow();
-        if (!linesAreOpaque && shadow && shadow->next()) {
-            IntRect clipRect(tx, ty, w, baselinePos + 2);
-            for (const ShadowData* s = shadow; s; s = s->next()) {
-                IntRect shadowRect(tx, ty, w, baselinePos + 2);
-                shadowRect.inflate(s->blur());
-                shadowRect.move(s->x(), s->y());
-                clipRect.unite(shadowRect);
-                extraOffset = max(extraOffset, max(0, s->y()) + s->blur());
-            }
-            context->save();
-            context->clip(clipRect);
-            extraOffset += baselinePos + 2;
-            ty += extraOffset;
-            setClip = true;
-        }
-
-        ColorSpace colorSpace = renderer()->style()->colorSpace();
-        bool setShadow = false;
-        do {
-            if (shadow) {
-                if (!shadow->next()) {
-                    // The last set of lines paints normally inside the clip.
-                    ty -= extraOffset;
-                    extraOffset = 0;
-                }
-                context->setShadow(IntSize(shadow->x(), shadow->y() - extraOffset), shadow->blur(), shadow->color(), colorSpace);
-                setShadow = true;
-                shadow = shadow->next();
-            }
-
-            if (paintUnderline) {
-                context->setStrokeColor(underline, colorSpace);
-                context->setStrokeStyle(SolidStroke);
-                // Leave one pixel of white between the baseline and the underline.
-                context->drawLineForText(IntPoint(tx, ty + baselinePos + 1), w, isPrinting);
-            }
-            if (paintOverline) {
-                context->setStrokeColor(overline, colorSpace);
-                context->setStrokeStyle(SolidStroke);
-                context->drawLineForText(IntPoint(tx, ty), w, isPrinting);
-            }
-            if (paintLineThrough) {
-                context->setStrokeColor(linethrough, colorSpace);
-                context->setStrokeStyle(SolidStroke);
-                context->drawLineForText(IntPoint(tx, ty + 2 * baselinePos / 3), w, isPrinting);
-            }
-        } while (shadow);
-
-        if (setClip)
-            context->restore();
-        else if (setShadow)
-            context->clearShadow();
-    }
-}
-
 InlineBox* InlineFlowBox::firstLeafChild() const
 {
     InlineBox* leaf = 0;
diff --git a/WebCore/rendering/InlineFlowBox.h b/WebCore/rendering/InlineFlowBox.h
index ee16a0f..d8b976f 100644
--- a/WebCore/rendering/InlineFlowBox.h
+++ b/WebCore/rendering/InlineFlowBox.h
@@ -96,7 +96,6 @@ public:
     void paintFillLayers(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
     void paintFillLayer(const PaintInfo&, const Color&, const FillLayer*, int tx, int ty, int w, int h, CompositeOperator = CompositeSourceOver);
     void paintBoxShadow(GraphicsContext*, RenderStyle*, ShadowStyle, int tx, int ty, int w, int h);
-    virtual void paintTextDecorations(PaintInfo&, int tx, int ty, bool paintedChildren = false);
     virtual void paint(PaintInfo&, int tx, int ty);
     virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, int x, int y, int tx, int ty);
 
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index cf100e0..2290481 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -311,13 +311,15 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in
     return false;
 }
 
-FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque)
+FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool vertical)
 {
     if (!shadow)
         return FloatSize();
 
     FloatSize extraOffset;
-    FloatSize shadowOffset(shadow->x(), shadow->y());
+    int shadowX = vertical ? shadow->y() : shadow->x();
+    int shadowY = vertical ? -shadow->x() : shadow->y();
+    FloatSize shadowOffset(shadowX, shadowY);
     int shadowBlur = shadow->blur();
     const Color& shadowColor = shadow->color();
 
@@ -336,7 +338,8 @@ FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context,
     return extraOffset;
 }
 
-static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin, int x, int y, int w, int h, const ShadowData* shadow, bool stroked)
+static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin,
+                                 int x, int y, int w, int h, const ShadowData* shadow, bool stroked, bool vertical)
 {
     Color fillColor = context->fillColor();
     ColorSpace fillColorSpace = context->fillColorSpace();
@@ -347,7 +350,7 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
     do {
         IntSize extraOffset;
         if (shadow)
-            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque));
+            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque, vertical));
         else if (!opaque)
             context->setFillColor(fillColor, fillColorSpace);
 
@@ -375,7 +378,7 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
 void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
 {
     if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE ||
-        m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline)
+        m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline || !m_len)
         return;
 
     ASSERT(paintInfo.phase != PaintPhaseSelfOutline && paintInfo.phase != PaintPhaseChildOutlines);
@@ -410,18 +413,32 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
             int widthOfVisibleText = toRenderText(renderer())->width(m_start, m_truncation, textPos(), m_firstLine);
             int widthOfHiddenText = m_logicalWidth - widthOfVisibleText;
             // FIXME: The hit testing logic also needs to take this translation int account.
-            tx += isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText;
+            if (!m_isVertical)
+                tx += isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText;
+            else
+                ty += isLeftToRightDirection() ? widthOfHiddenText : -widthOfHiddenText;
         }
     }
 
     GraphicsContext* context = paintInfo.context;
 
+    RenderStyle* styleToUse = renderer()->style(m_firstLine);
+    int baseline = styleToUse->font().ascent();
+    ty -= styleToUse->isFlippedLinesWritingMode() ? baseline : 0;
+    IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
+    
+    if (m_isVertical) {
+        context->save();
+        context->translate(textOrigin.x(), textOrigin.y());
+        context->rotate(deg2rad(90.));
+        context->translate(-textOrigin.x(), -textOrigin.y());
+    }
+    
     // Determine whether or not we have composition underlines to draw.
     bool containsComposition = renderer()->node() && renderer()->frame()->editor()->compositionNode() == renderer()->node();
     bool useCustomUnderlines = containsComposition && renderer()->frame()->editor()->compositionUsesCustomUnderlines();
 
     // Set our font.
-    RenderStyle* styleToUse = renderer()->style(m_firstLine);
     int d = styleToUse->textDecorationsInEffect();
     const Font& font = styleToUse->font();
 
@@ -446,9 +463,6 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
     }
 
     // 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
-    if (m_len <= 0)
-        return;
-
     Color textFillColor;
     Color textStrokeColor;
     float textStrokeWidth = styleToUse->textStrokeWidth();
@@ -517,8 +531,6 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
     if (hasHyphen())
         adjustCharactersAndLengthForHyphen(charactersWithHyphen, styleToUse, characters, length);
 
-    int baseline = renderer()->style(m_firstLine)->font().ascent();
-    IntPoint textOrigin(m_x + tx, m_y + ty + baseline);
     TextRun textRun(characters, length, textRenderer()->allowTabs(), textPos(), m_toAdd, !isLeftToRightDirection(), m_dirOverride || styleToUse->visuallyOrdered());
 
     int sPos = 0;
@@ -541,9 +553,9 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
         updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
         if (!paintSelectedTextSeparately || ePos <= sPos) {
             // FIXME: Truncate right-to-left text correctly.
-            paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0);
+            paintTextWithShadows(context, font, textRun, 0, length, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
         } else
-            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0);
+            paintTextWithShadows(context, font, textRun, ePos, sPos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), textShadow, textStrokeWidth > 0, m_isVertical);
 
         if (textStrokeWidth > 0)
             context->restore();
@@ -555,15 +567,15 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
             context->save();
 
         updateGraphicsContext(context, selectionFillColor, selectionStrokeColor, selectionStrokeWidth, styleToUse->colorSpace());
-        paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), selectionShadow, selectionStrokeWidth > 0);
+        paintTextWithShadows(context, font, textRun, sPos, ePos, length, textOrigin, m_x + tx, m_y + ty, logicalWidth(), logicalHeight(), selectionShadow, selectionStrokeWidth > 0, m_isVertical);
 
         if (selectionStrokeWidth > 0)
             context->restore();
     }
 
     // Paint decorations
-    if (d != TDNONE && paintInfo.phase != PaintPhaseSelection && renderer()->document()->inQuirksMode()) {
-        context->setStrokeColor(styleToUse->visitedDependentColor(CSSPropertyColor), styleToUse->colorSpace());
+    if (d != TDNONE && paintInfo.phase != PaintPhaseSelection) {
+        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
         paintDecoration(context, tx, ty, d, textShadow);
     }
 
@@ -595,6 +607,9 @@ void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
             }
         }
     }
+    
+    if (m_isVertical)
+        context->restore();
 }
 
 void InlineTextBox::selectionStartEnd(int& sPos, int& ePos)
@@ -723,7 +738,8 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
 
     bool linesAreOpaque = !isPrinting && (!(deco & UNDERLINE) || underline.alpha() == 255) && (!(deco & OVERLINE) || overline.alpha() == 255) && (!(deco & LINE_THROUGH) || linethrough.alpha() == 255);
 
-    int baseline = renderer()->style(m_firstLine)->font().ascent();
+    RenderStyle* styleToUse = renderer()->style(m_firstLine);
+    int baseline = styleToUse->font().ascent();
 
     bool setClip = false;
     int extraOffset = 0;
@@ -733,9 +749,11 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
         for (const ShadowData* s = shadow; s; s = s->next()) {
             IntRect shadowRect(tx, ty, width, baseline + 2);
             shadowRect.inflate(s->blur());
-            shadowRect.move(s->x(), s->y());
+            int shadowX = m_isVertical ? s->y() : s->x();
+            int shadowY = m_isVertical ? -s->x() : s->y();
+            shadowRect.move(shadowX, shadowY);
             clipRect.unite(shadowRect);
-            extraOffset = max(extraOffset, max(0, s->y()) + s->blur());
+            extraOffset = max(extraOffset, max(0, shadowY) + s->blur());
         }
         context->save();
         context->clip(clipRect);
@@ -754,7 +772,9 @@ void InlineTextBox::paintDecoration(GraphicsContext* context, int tx, int ty, in
                 ty -= extraOffset;
                 extraOffset = 0;
             }
-            context->setShadow(IntSize(shadow->x(), shadow->y() - extraOffset), shadow->blur(), shadow->color(), colorSpace);
+            int shadowX = m_isVertical ? shadow->y() : shadow->x();
+            int shadowY = m_isVertical ? -shadow->x() : shadow->y();
+            context->setShadow(IntSize(shadowX, shadowY - extraOffset), shadow->blur(), shadow->color(), colorSpace);
             setShadow = true;
             shadow = shadow->next();
         }
@@ -879,7 +899,7 @@ void InlineTextBox::paintTextMatchMarker(GraphicsContext* pt, int tx, int ty, co
     IntRect markerRect = enclosingIntRect(font.selectionRectForText(run, IntPoint(m_x, y), h, sPos, ePos));
     markerRect = renderer()->localToAbsoluteQuad(FloatRect(markerRect)).enclosingBoundingBox();
     renderer()->document()->markers()->setRenderedRectForMarker(renderer()->node(), marker, markerRect);
-     
+    
     // Optionally highlight the text
     if (renderer()->frame()->editor()->markedTextMatchesAreHighlighted()) {
         Color color = marker.activeMatch ?
diff --git a/WebCore/rendering/InlineTextBox.h b/WebCore/rendering/InlineTextBox.h
index f010c39..175c5fe 100644
--- a/WebCore/rendering/InlineTextBox.h
+++ b/WebCore/rendering/InlineTextBox.h
@@ -127,7 +127,7 @@ public:
     bool containsCaretOffset(int offset) const; // false for offset after line break
 
     // Needs to be public, so the static paintTextWithShadows() function can use it.
-    static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque);
+    static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool vertical);
 
 private:
     InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderObject
diff --git a/WebCore/rendering/svg/SVGInlineTextBox.cpp b/WebCore/rendering/svg/SVGInlineTextBox.cpp
index 0458af5..7dd779a 100644
--- a/WebCore/rendering/svg/SVGInlineTextBox.cpp
+++ b/WebCore/rendering/svg/SVGInlineTextBox.cpp
@@ -523,7 +523,7 @@ void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyl
 
         FloatSize extraOffset;
         if (shadow)
-            extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */);
+            extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, false /* vertical */);
 
         font.drawText(context, textRun, textOrigin + extraOffset, startPosition, endPosition);
         restoreGraphicsContextAfterTextPainting(context, textRun);

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list