Changeset 173502 in webkit


Ignore:
Timestamp:
Sep 10, 2014 5:50:09 PM (10 years ago)
Author:
mmaxfield@apple.com
Message:

Delete class SavedDrawingStateForMask
https://bugs.webkit.org/show_bug.cgi?id=136498

Patch by Myles C. Maxfield <mmaxfield@apple.com> <litherum@gmail.com> on 2014-09-09
Reviewed by Darin Adler.

This class is left over from when text-decoration-skip: ink used
GraphicsContext masking.

No new tests because there is no behavior change.

  • rendering/InlineTextBox.cpp:

(WebCore::InlineTextBox::applyShadowToGraphicsContext):

  • rendering/InlineTextBox.h:
  • rendering/TextPainter.cpp:

(WebCore::TextPainter::TextPainter):
(WebCore::paintTextWithShadows):
(WebCore::TextPainter::paintText):

  • rendering/TextPainter.h:

(WebCore::SavedDrawingStateForMask::SavedDrawingStateForMask): Deleted.

  • rendering/svg/SVGInlineTextBox.cpp:

(WebCore::SVGInlineTextBox::paintTextWithShadows):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r173501 r173502  
     12014-09-09  Myles C. Maxfield <mmaxfield@apple.com>  <litherum@gmail.com>
     2
     3        Delete class SavedDrawingStateForMask
     4        https://bugs.webkit.org/show_bug.cgi?id=136498
     5
     6        Reviewed by Darin Adler.
     7
     8        This class is left over from when text-decoration-skip: ink used
     9        GraphicsContext masking.
     10
     11        No new tests because there is no behavior change.
     12
     13        * rendering/InlineTextBox.cpp:
     14        (WebCore::InlineTextBox::applyShadowToGraphicsContext):
     15        * rendering/InlineTextBox.h:
     16        * rendering/TextPainter.cpp:
     17        (WebCore::TextPainter::TextPainter):
     18        (WebCore::paintTextWithShadows):
     19        (WebCore::TextPainter::paintText):
     20        * rendering/TextPainter.h:
     21        (WebCore::SavedDrawingStateForMask::SavedDrawingStateForMask): Deleted.
     22        * rendering/svg/SVGInlineTextBox.cpp:
     23        (WebCore::SVGInlineTextBox::paintTextWithShadows):
     24
    1252014-09-10  Tim Horton  <timothy_horton@apple.com>
    226
  • trunk/Source/WebCore/rendering/InlineTextBox.cpp

    r173499 r173502  
    425425}
    426426
    427 FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext)
     427FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext& context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext)
    428428{
    429429    if (!shadow)
     
    441441        shadowRect.inflate(shadow->paintingExtent());
    442442        shadowRect.move(shadowOffset);
    443         context->save();
    444         context->clip(shadowRect);
     443        context.save();
     444        context.clip(shadowRect);
    445445
    446446        extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
     
    449449    }
    450450
    451     context->setShadow(shadowOffset, shadowRadius, shadowColor, context->fillColorSpace());
     451    context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace());
    452452    return extraOffset;
    453453}
  • trunk/Source/WebCore/rendering/InlineTextBox.h

    r173418 r173502  
    156156
    157157    // Needs to be public, so the static paintTextWithShadows() function can use it.
    158     static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext);
     158    static FloatSize applyShadowToGraphicsContext(GraphicsContext&, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext);
    159159
    160160protected:
  • trunk/Source/WebCore/rendering/TextPainter.cpp

    r173418 r173502  
    2828#include "RenderCombineText.h"
    2929#include "TextPaintStyle.h"
     30#include <wtf/NeverDestroyed.h>
    3031
    3132namespace WebCore {
     
    3536    FloatRect& boxRect, FloatPoint& textOrigin, int emphasisMarkOffset, const ShadowData* textShadow, const ShadowData* selectionShadow,
    3637    bool textBoxIsHorizontal, TextPaintStyle& textPaintStyle, TextPaintStyle& selectionPaintStyle)
    37     : m_paintSelectedTextOnly(paintSelectedTextOnly)
    38     , m_paintSelectedTextSeparately(paintSelectedTextSeparately)
    39     , m_font(font)
    40     , m_startPositionInTextRun(startPositionInTextRun)
    41     , m_endPositionInTextRun(endPositionInTextBoxString)
    42     , m_length(length)
    43     , m_emphasisMark(emphasisMark)
    44     , m_combinedText(combinedText)
    45     , m_textRun(textRun)
    46     , m_boxRect(boxRect)
    47     , m_textOrigin(textOrigin)
    48     , m_emphasisMarkOffset(emphasisMarkOffset)
    49     , m_textBoxIsHorizontal(textBoxIsHorizontal)
    50     , m_savedDrawingStateForMask(&context, &textPaintStyle, &selectionPaintStyle, textShadow, selectionShadow)
     38        : m_context(context)
     39        , m_textPaintStyle(textPaintStyle)
     40        , m_selectionPaintStyle(selectionPaintStyle)
     41        , m_textShadow(textShadow)
     42        , m_selectionShadow(selectionShadow)
     43        , m_paintSelectedTextOnly(paintSelectedTextOnly)
     44        , m_paintSelectedTextSeparately(paintSelectedTextSeparately)
     45        , m_font(font)
     46        , m_startPositionInTextRun(startPositionInTextRun)
     47        , m_endPositionInTextRun(endPositionInTextBoxString)
     48        , m_length(length)
     49        , m_emphasisMark(emphasisMark)
     50        , m_combinedText(combinedText)
     51        , m_textRun(textRun)
     52        , m_boxRect(boxRect)
     53        , m_textOrigin(textOrigin)
     54        , m_emphasisMarkOffset(emphasisMarkOffset)
     55        , m_textBoxIsHorizontal(textBoxIsHorizontal)
    5156{
    5257}
     
    6873}
    6974
    70 static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark,
     75static void paintTextWithShadows(GraphicsContext& context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark,
    7176    int emphasisMarkOffset, int startOffset, int endOffset, int truncationPoint, const FloatPoint& textOrigin, const FloatRect& boxRect,
    7277    const ShadowData* shadow, bool stroked, bool horizontal)
    7378{
    74     Color fillColor = context->fillColor();
    75     ColorSpace fillColorSpace = context->fillColorSpace();
     79    Color fillColor = context.fillColor();
     80    ColorSpace fillColorSpace = context.fillColorSpace();
    7681    bool opaque = !fillColor.hasAlpha();
    7782    if (!opaque)
    78         context->setFillColor(Color::black, fillColorSpace);
     83        context.setFillColor(Color::black, fillColorSpace);
    7984
    8085    do {
     
    8994            extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal, didSaveContext));
    9095        else if (!opaque)
    91             context->setFillColor(fillColor, fillColorSpace);
     96            context.setFillColor(fillColor, fillColorSpace);
    9297
    9398        if (startOffset <= endOffset)
    94             drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, endOffset);
     99            drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, endOffset);
    95100        else {
    96101            if (endOffset > 0)
    97                 drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, 0, endOffset);
     102                drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, 0, endOffset);
    98103            if (startOffset < truncationPoint)
    99                 drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, truncationPoint);
     104                drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, truncationPoint);
    100105        }
    101106
     
    104109
    105110        if (didSaveContext)
    106             context->restore();
     111            context.restore();
    107112        else
    108             context->clearShadow();
     113            context.clearShadow();
    109114
    110115        shadow = shadow->next();
     
    114119void TextPainter::paintText()
    115120{
    116     ASSERT(m_savedDrawingStateForMask.m_textPaintStyle);
    117     ASSERT(m_savedDrawingStateForMask.m_selectionPaintStyle);
    118    
    119121    FloatPoint boxOrigin = m_boxRect.location();
    120122
     
    122124        // For stroked painting, we have to change the text drawing mode. It's probably dangerous to leave that mutated as a side
    123125        // effect, so only when we know we're stroking, do a save/restore.
    124         GraphicsContextStateSaver stateSaver(*m_savedDrawingStateForMask.m_context, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0);
     126        GraphicsContextStateSaver stateSaver(m_context, m_textPaintStyle.strokeWidth > 0);
    125127
    126         updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_textPaintStyle);
     128        updateGraphicsContext(m_context, m_textPaintStyle);
    127129        if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) {
    128130            // FIXME: Truncate right-to-left text correctly.
    129             paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, 0, m_length, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
     131            paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, 0, m_length, m_length, m_textOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
    130132        } else
    131             paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, m_endPositionInTextRun, m_startPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
     133            paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, m_endPositionInTextRun, m_startPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
    132134
    133135        if (!m_emphasisMark.isEmpty()) {
    134             updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_textPaintStyle, UseEmphasisMarkColor);
     136            updateGraphicsContext(m_context, m_textPaintStyle, UseEmphasisMarkColor);
     137
     138            static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);
     139            TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : m_textRun;
     140            FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin;
     141            if (m_combinedText)
     142                m_context.concatCTM(rotation(m_boxRect, Clockwise));
     143
     144            if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) {
     145                // FIXME: Truncate right-to-left text correctly.
     146                paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, 0, m_length, m_length, emphasisMarkTextOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
     147            } else
     148                paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_endPositionInTextRun, m_startPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
     149
     150            if (m_combinedText)
     151                m_context.concatCTM(rotation(m_boxRect, Counterclockwise));
     152        }
     153    }
     154
     155    if ((m_paintSelectedTextOnly || m_paintSelectedTextSeparately) && m_startPositionInTextRun < m_endPositionInTextRun) {
     156        // paint only the text that is selected
     157        GraphicsContextStateSaver stateSaver(m_context, m_selectionPaintStyle.strokeWidth > 0);
     158
     159        updateGraphicsContext(m_context, m_selectionPaintStyle);
     160        paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, m_startPositionInTextRun, m_endPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_selectionShadow, m_selectionPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
     161        if (!m_emphasisMark.isEmpty()) {
     162            updateGraphicsContext(m_context, m_selectionPaintStyle, UseEmphasisMarkColor);
    135163
    136164            DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1));
     
    138166            FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin;
    139167            if (m_combinedText)
    140                 m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Clockwise));
     168                m_context.concatCTM(rotation(m_boxRect, Clockwise));
    141169
    142             if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) {
    143                 // FIXME: Truncate right-to-left text correctly.
    144                 paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, 0, m_length, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
    145             } else
    146                 paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_endPositionInTextRun, m_startPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
     170            paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_startPositionInTextRun, m_endPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_selectionShadow, m_selectionPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
    147171
    148172            if (m_combinedText)
    149                 m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Counterclockwise));
    150         }
    151     }
    152 
    153     if ((m_paintSelectedTextOnly || m_paintSelectedTextSeparately) && m_startPositionInTextRun < m_endPositionInTextRun) {
    154         // paint only the text that is selected
    155         GraphicsContextStateSaver stateSaver(*m_savedDrawingStateForMask.m_context, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0);
    156 
    157         updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_selectionPaintStyle);
    158         paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, m_startPositionInTextRun, m_endPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_selectionShadow, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
    159         if (!m_emphasisMark.isEmpty()) {
    160             updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_selectionPaintStyle, UseEmphasisMarkColor);
    161 
    162             DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1));
    163             TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun : m_textRun;
    164             FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin;
    165             if (m_combinedText)
    166                 m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Clockwise));
    167 
    168             paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_startPositionInTextRun, m_endPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_selectionShadow, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
    169 
    170             if (m_combinedText)
    171                 m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Counterclockwise));
     173                m_context.concatCTM(rotation(m_boxRect, Counterclockwise));
    172174        }
    173175    }
  • trunk/Source/WebCore/rendering/TextPainter.h

    r173241 r173502  
    4242}
    4343
    44 struct SavedDrawingStateForMask {
    45     SavedDrawingStateForMask(GraphicsContext* context, TextPaintStyle* textPaintStyle, TextPaintStyle* selectionPaintStyle,
    46     const ShadowData* textShadow, const ShadowData* selectionShadow)
    47         : m_context(context)
    48         , m_textPaintStyle(textPaintStyle)
    49         , m_selectionPaintStyle(selectionPaintStyle)
    50         , m_textShadow(textShadow)
    51         , m_selectionShadow(selectionShadow)
    52     {
    53     }
    54     GraphicsContext* m_context;
    55     TextPaintStyle* m_textPaintStyle;
    56     TextPaintStyle* m_selectionPaintStyle;
    57     const ShadowData* m_textShadow;
    58     const ShadowData* m_selectionShadow;
    59 };
    60 
    6144class TextPainter {
    6245public:
     
    7154
    7255private:
     56    GraphicsContext& m_context;
     57    TextPaintStyle& m_textPaintStyle;
     58    TextPaintStyle& m_selectionPaintStyle;
     59    const ShadowData* m_textShadow;
     60    const ShadowData* m_selectionShadow;
    7361    bool m_paintSelectedTextOnly;
    7462    bool m_paintSelectedTextSeparately;
     
    8472    int m_emphasisMarkOffset;
    8573    bool m_textBoxIsHorizontal;
    86     SavedDrawingStateForMask m_savedDrawingStateForMask;
    8774};
    8875
  • trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp

    r173418 r173502  
    598598        bool didSaveContext = false;
    599599        if (shadow)
    600             extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext);
     600            extraOffset = applyShadowToGraphicsContext(*context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext);
    601601
    602602        context->save();
Note: See TracChangeset for help on using the changeset viewer.