Changeset 81404 in webkit


Ignore:
Timestamp:
Mar 17, 2011 4:11:48 PM (13 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/9052166> Emphasis marks appear over combined text rather than beside it
https://bugs.webkit.org/show_bug.cgi?id=56480

Reviewed by Beth Dakin.

Source/WebCore:

Test: fast/text/emphasis-combined-text.html

  • rendering/InlineTextBox.cpp:

(WebCore::rotation): Added this helper.
(WebCore::InlineTextBox::paint): Paint a single emphasis mark beside the combined text,
centered vertically.

LayoutTests:

  • fast/text/emphasis-combined-text.html: Added.
  • platform/mac/fast/text/emphasis-combined-text-expected.checksum: Added.
  • platform/mac/fast/text/emphasis-combined-text-expected.png: Added.
  • platform/mac/fast/text/emphasis-combined-text-expected.txt: Added.
Location:
trunk
Files:
4 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r81399 r81404  
     12011-03-17  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Beth Dakin.
     4
     5        <rdar://problem/9052166> Emphasis marks appear over combined text rather than beside it
     6        https://bugs.webkit.org/show_bug.cgi?id=56480
     7
     8        * fast/text/emphasis-combined-text.html: Added.
     9        * platform/mac/fast/text/emphasis-combined-text-expected.checksum: Added.
     10        * platform/mac/fast/text/emphasis-combined-text-expected.png: Added.
     11        * platform/mac/fast/text/emphasis-combined-text-expected.txt: Added.
     12
    1132011-03-17  Jian Li  <jianli@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r81399 r81404  
     12011-03-17  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Beth Dakin.
     4
     5        <rdar://problem/9052166> Emphasis marks appear over combined text rather than beside it
     6        https://bugs.webkit.org/show_bug.cgi?id=56480
     7
     8        Test: fast/text/emphasis-combined-text.html
     9
     10        * rendering/InlineTextBox.cpp:
     11        (WebCore::rotation): Added this helper.
     12        (WebCore::InlineTextBox::paint): Paint a single emphasis mark beside the combined text,
     13        centered vertically.
     14
    1152011-03-17  Jian Li  <jianli@chromium.org>
    216
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r79936 r81404  
    428428}
    429429
     430enum RotationDirection { Counterclockwise, Clockwise };
     431
     432static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirection clockwise)
     433{
     434    return clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
     435        : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
     436}
     437
    430438void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
    431439{
     
    486494    boxOrigin.move(tx, ty);   
    487495    FloatRect boxRect(boxOrigin, IntSize(logicalWidth(), logicalHeight()));
    488     FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + styleToUse->fontMetrics().ascent());
    489 
    490     RenderCombineText* combinedText = styleToUse->hasTextCombine() ? toRenderCombineText(textRenderer()) : 0;
    491     bool shouldRotate = !isHorizontal() && (!combinedText || !combinedText->isCombined());
    492     if (shouldRotate) {
    493         context->save();
    494         context->translate(boxRect.x(), boxRect.maxY());
    495         context->rotate(static_cast<float>(deg2rad(90.)));
    496         context->translate(-boxRect.x(), -boxRect.maxY());
    497     }
    498    
    499    
     496
     497    RenderCombineText* combinedText = styleToUse->hasTextCombine() && toRenderCombineText(textRenderer())->isCombined() ? toRenderCombineText(textRenderer()) : 0;
     498
     499    bool shouldRotate = !isHorizontal() && !combinedText;
     500    if (shouldRotate)
     501        context->concatCTM(rotation(boxRect, Clockwise));
     502
    500503    // Determine whether or not we have composition underlines to draw.
    501504    bool containsComposition = renderer()->node() && renderer()->frame()->editor()->compositionNode() == renderer()->node();
     
    503506
    504507    // Set our font.
    505     int d = styleToUse->textDecorationsInEffect();
    506508    const Font& font = styleToUse->font();
     509
     510    FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
    507511
    508512    if (combinedText)
     
    654658        if (!emphasisMark.isEmpty()) {
    655659            updateGraphicsContext(context, emphasisMarkColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
     660
     661            static TextRun objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);
     662            TextRun& emphasisMarkTextRun = combinedText ? objectReplacementCharacterTextRun : textRun;
     663            FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : textOrigin;
     664            if (combinedText)
     665                context->concatCTM(rotation(boxRect, Clockwise));
     666
    656667            if (!paintSelectedTextSeparately || ePos <= sPos) {
    657668                // FIXME: Truncate right-to-left text correctly.
    658                 paintTextWithShadows(context, font, textRun, emphasisMark, emphasisMarkOffset, 0, length, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
     669                paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, 0, length, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
    659670            } else
    660                 paintTextWithShadows(context, font, textRun, emphasisMark, emphasisMarkOffset, ePos, sPos, length, textOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
     671                paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, ePos, sPos, length, emphasisMarkTextOrigin, boxRect, textShadow, textStrokeWidth > 0, isHorizontal());
     672
     673            if (combinedText)
     674                context->concatCTM(rotation(boxRect, Counterclockwise));
    661675        }
    662676
     
    674688        if (!emphasisMark.isEmpty()) {
    675689            updateGraphicsContext(context, selectionEmphasisMarkColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
    676             paintTextWithShadows(context, font, textRun, emphasisMark, emphasisMarkOffset, sPos, ePos, length, textOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
     690
     691            static TextRun objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);
     692            TextRun& emphasisMarkTextRun = combinedText ? objectReplacementCharacterTextRun : textRun;
     693            FloatPoint emphasisMarkTextOrigin = combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + font.fontMetrics().ascent()) : textOrigin;
     694            if (combinedText)
     695                context->concatCTM(rotation(boxRect, Clockwise));
     696
     697            paintTextWithShadows(context, combinedText ? combinedText->originalFont() : font, emphasisMarkTextRun, emphasisMark, emphasisMarkOffset, sPos, ePos, length, emphasisMarkTextOrigin, boxRect, selectionShadow, selectionStrokeWidth > 0, isHorizontal());
     698
     699            if (combinedText)
     700                context->concatCTM(rotation(boxRect, Counterclockwise));
    677701        }
    678702        if (selectionStrokeWidth > 0)
     
    681705
    682706    // Paint decorations
    683     if (d != TDNONE && paintInfo.phase != PaintPhaseSelection) {
     707    int textDecorations = styleToUse->textDecorationsInEffect();
     708    if (textDecorations != TDNONE && paintInfo.phase != PaintPhaseSelection) {
    684709        updateGraphicsContext(context, textFillColor, textStrokeColor, textStrokeWidth, styleToUse->colorSpace());
    685         paintDecoration(context, boxOrigin, d, textShadow);
     710        paintDecoration(context, boxOrigin, textDecorations, textShadow);
    686711    }
    687712
     
    716741   
    717742    if (shouldRotate)
    718         context->restore();
     743        context->concatCTM(rotation(boxRect, Counterclockwise));
    719744}
    720745
Note: See TracChangeset for help on using the changeset viewer.