Changeset 173502 in webkit
- Timestamp:
- Sep 10, 2014 5:50:09 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r173501 r173502 1 2014-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 1 25 2014-09-10 Tim Horton <timothy_horton@apple.com> 2 26 -
trunk/Source/WebCore/rendering/InlineTextBox.cpp
r173499 r173502 425 425 } 426 426 427 FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext *context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext)427 FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext& context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext) 428 428 { 429 429 if (!shadow) … … 441 441 shadowRect.inflate(shadow->paintingExtent()); 442 442 shadowRect.move(shadowOffset); 443 context ->save();444 context ->clip(shadowRect);443 context.save(); 444 context.clip(shadowRect); 445 445 446 446 extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius); … … 449 449 } 450 450 451 context ->setShadow(shadowOffset, shadowRadius, shadowColor, context->fillColorSpace());451 context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace()); 452 452 return extraOffset; 453 453 } -
trunk/Source/WebCore/rendering/InlineTextBox.h
r173418 r173502 156 156 157 157 // 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); 159 159 160 160 protected: -
trunk/Source/WebCore/rendering/TextPainter.cpp
r173418 r173502 28 28 #include "RenderCombineText.h" 29 29 #include "TextPaintStyle.h" 30 #include <wtf/NeverDestroyed.h> 30 31 31 32 namespace WebCore { … … 35 36 FloatRect& boxRect, FloatPoint& textOrigin, int emphasisMarkOffset, const ShadowData* textShadow, const ShadowData* selectionShadow, 36 37 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) 51 56 { 52 57 } … … 68 73 } 69 74 70 static void paintTextWithShadows(GraphicsContext *context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark,75 static void paintTextWithShadows(GraphicsContext& context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark, 71 76 int emphasisMarkOffset, int startOffset, int endOffset, int truncationPoint, const FloatPoint& textOrigin, const FloatRect& boxRect, 72 77 const ShadowData* shadow, bool stroked, bool horizontal) 73 78 { 74 Color fillColor = context ->fillColor();75 ColorSpace fillColorSpace = context ->fillColorSpace();79 Color fillColor = context.fillColor(); 80 ColorSpace fillColorSpace = context.fillColorSpace(); 76 81 bool opaque = !fillColor.hasAlpha(); 77 82 if (!opaque) 78 context ->setFillColor(Color::black, fillColorSpace);83 context.setFillColor(Color::black, fillColorSpace); 79 84 80 85 do { … … 89 94 extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal, didSaveContext)); 90 95 else if (!opaque) 91 context ->setFillColor(fillColor, fillColorSpace);96 context.setFillColor(fillColor, fillColorSpace); 92 97 93 98 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); 95 100 else { 96 101 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); 98 103 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); 100 105 } 101 106 … … 104 109 105 110 if (didSaveContext) 106 context ->restore();111 context.restore(); 107 112 else 108 context ->clearShadow();113 context.clearShadow(); 109 114 110 115 shadow = shadow->next(); … … 114 119 void TextPainter::paintText() 115 120 { 116 ASSERT(m_savedDrawingStateForMask.m_textPaintStyle);117 ASSERT(m_savedDrawingStateForMask.m_selectionPaintStyle);118 119 121 FloatPoint boxOrigin = m_boxRect.location(); 120 122 … … 122 124 // For stroked painting, we have to change the text drawing mode. It's probably dangerous to leave that mutated as a side 123 125 // 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); 125 127 126 updateGraphicsContext( *m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_textPaintStyle);128 updateGraphicsContext(m_context, m_textPaintStyle); 127 129 if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) { 128 130 // 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); 130 132 } 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); 132 134 133 135 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); 135 163 136 164 DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1)); … … 138 166 FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin; 139 167 if (m_combinedText) 140 m_ savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Clockwise));168 m_context.concatCTM(rotation(m_boxRect, Clockwise)); 141 169 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); 147 171 148 172 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)); 172 174 } 173 175 } -
trunk/Source/WebCore/rendering/TextPainter.h
r173241 r173502 42 42 } 43 43 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 61 44 class TextPainter { 62 45 public: … … 71 54 72 55 private: 56 GraphicsContext& m_context; 57 TextPaintStyle& m_textPaintStyle; 58 TextPaintStyle& m_selectionPaintStyle; 59 const ShadowData* m_textShadow; 60 const ShadowData* m_selectionShadow; 73 61 bool m_paintSelectedTextOnly; 74 62 bool m_paintSelectedTextSeparately; … … 84 72 int m_emphasisMarkOffset; 85 73 bool m_textBoxIsHorizontal; 86 SavedDrawingStateForMask m_savedDrawingStateForMask;87 74 }; 88 75 -
trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp
r173418 r173502 598 598 bool didSaveContext = false; 599 599 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); 601 601 602 602 context->save();
Note: See TracChangeset
for help on using the changeset viewer.