Changeset 292039 in webkit
- Timestamp:
- Mar 29, 2022, 10:29:46 AM (5 years ago)
- Location:
- branches/safari-614.1.8-branch/Source/WebCore
- Files:
-
- 4 edited
-
ChangeLog (modified) (1 diff)
-
rendering/TextBoxPainter.cpp (modified) (2 diffs)
-
rendering/TextPainter.cpp (modified) (6 diffs)
-
rendering/TextPainter.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/safari-614.1.8-branch/Source/WebCore/ChangeLog
r291986 r292039 1 2022-03-29 Russell Epstein <repstein@apple.com> 2 3 Cherry-pick r292026. rdar://problem/90941790 4 5 REGRESSION(r291771): [ iOS ] Text sometimes draw with incorrect color 6 https://bugs.webkit.org/show_bug.cgi?id=238466 7 rdar://90941790 8 9 Reviewed by Simon Fraser. 10 11 r291771 uncovers this bug: TextBoxPainter::paintForeground() records the 12 glyphs to a DisplayList before settings the destination GraphicsContext. 13 14 The fix is to apply all the changes to the GraphicsContext before calling 15 TextPainter::setGlyphDisplayListIfNeeded(). 16 17 Delete TextPainter::paint() because it is not used. 18 19 Initialize TextPainter with a reference to FontCascade. 20 21 * rendering/TextBoxPainter.cpp: 22 (WebCore::TextBoxPainter::paintForeground): 23 * rendering/TextPainter.cpp: 24 (WebCore::TextPainter::TextPainter): 25 (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): 26 (WebCore::TextPainter::paintRange): 27 (WebCore::TextPainter::paint): Deleted. 28 * rendering/TextPainter.h: 29 (WebCore::TextPainter::setShadowColorFilter): 30 (WebCore::TextPainter::setGlyphDisplayListIfNeeded): 31 (WebCore::TextPainter::setFont): Deleted. 32 33 34 git-svn-id: https://svn.webkit.org/repository/webkit/trunk@292026 268f45cc-cd09-0410-ab3c-d52691b4dbfc 35 36 2022-03-29 Said Abou-Hallawa <said@apple.com> 37 38 REGRESSION(r291771): [ iOS ] Text sometimes draw with incorrect color 39 https://bugs.webkit.org/show_bug.cgi?id=238466 40 rdar://90941790 41 42 Reviewed by Simon Fraser. 43 44 r291771 uncovers this bug: TextBoxPainter::paintForeground() records the 45 glyphs to a DisplayList before settings the destination GraphicsContext. 46 47 The fix is to apply all the changes to the GraphicsContext before calling 48 TextPainter::setGlyphDisplayListIfNeeded(). 49 50 Delete TextPainter::paint() because it is not used. 51 52 Initialize TextPainter with a reference to FontCascade. 53 54 * rendering/TextBoxPainter.cpp: 55 (WebCore::TextBoxPainter::paintForeground): 56 * rendering/TextPainter.cpp: 57 (WebCore::TextPainter::TextPainter): 58 (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): 59 (WebCore::TextPainter::paintRange): 60 (WebCore::TextPainter::paint): Deleted. 61 * rendering/TextPainter.h: 62 (WebCore::TextPainter::setShadowColorFilter): 63 (WebCore::TextPainter::setGlyphDisplayListIfNeeded): 64 (WebCore::TextPainter::setFont): Deleted. 65 1 66 2022-03-28 Russell Epstein <repstein@apple.com> 2 67 -
branches/safari-614.1.8-branch/Source/WebCore/rendering/TextBoxPainter.cpp
r291552 r292039 325 325 emphasisMarkOffset = *m_emphasisMarkExistsAndIsAbove ? -font.metricsOfPrimaryFont().ascent() - font.emphasisMarkDescent(emphasisMark) : font.metricsOfPrimaryFont().descent() + font.emphasisMarkAscent(emphasisMark); 326 326 327 TextPainter textPainter { context }; 328 textPainter.setFont(font); 327 TextPainter textPainter { context, font }; 329 328 textPainter.setStyle(markedText.style.textStyles); 330 329 textPainter.setIsHorizontal(textBox().isHorizontal()); … … 338 337 textPainter.setShadow(debugShadow); 339 338 339 GraphicsContextStateSaver stateSaver(context, markedText.style.textStyles.strokeWidth > 0 || markedText.type == MarkedText::DraggedContent); 340 if (markedText.type == MarkedText::DraggedContent) 341 context.setAlpha(markedText.style.alpha); 342 updateGraphicsContext(context, markedText.style.textStyles); 343 340 344 if (auto* legacyInlineBox = textBox().legacyInlineBox()) 341 textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, font, context,m_paintTextRun);345 textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, m_paintTextRun); 342 346 #if ENABLE(LAYOUT_FORMATTING_CONTEXT) 343 347 else 344 textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, font, context,m_paintTextRun);348 textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, m_paintTextRun); 345 349 #endif 346 350 347 GraphicsContextStateSaver stateSaver { context, false };348 if (markedText.type == MarkedText::DraggedContent) {349 stateSaver.save();350 context.setAlpha(markedText.style.alpha);351 }352 351 // TextPainter wants the box rectangle and text origin of the entire line box. 353 352 textPainter.paintRange(m_paintTextRun, m_paintRect, textOriginFromPaintRect(m_paintRect), markedText.startOffset, markedText.endOffset); -
branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.cpp
r288942 r292039 98 98 } 99 99 100 TextPainter::TextPainter(GraphicsContext& context )100 TextPainter::TextPainter(GraphicsContext& context, const FontCascade& font) 101 101 : m_context(context) 102 , m_font(font) 102 103 { 103 104 } … … 160 161 if (paintStyle.paintOrder == PaintOrder::Normal) { 161 162 // FIXME: Truncate right-to-left text correctly. 162 paintTextWithShadows(shadow, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);163 paintTextWithShadows(shadow, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0); 163 164 } else { 164 165 auto textDrawingMode = m_context.textDrawingMode(); … … 172 173 textDrawingModeWithoutStroke.remove(TextDrawingMode::Stroke); 173 174 m_context.setTextDrawingMode(textDrawingModeWithoutStroke); 174 paintTextWithShadows(shadowToUse, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, false);175 paintTextWithShadows(shadowToUse, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, false); 175 176 shadowToUse = nullptr; 176 177 m_context.setTextDrawingMode(textDrawingMode); … … 181 182 textDrawingModeWithoutFill.remove(TextDrawingMode::Fill); 182 183 m_context.setTextDrawingMode(textDrawingModeWithoutFill); 183 paintTextWithShadows(shadowToUse, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);184 paintTextWithShadows(shadowToUse, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0); 184 185 shadowToUse = nullptr; 185 186 m_context.setTextDrawingMode(textDrawingMode); … … 199 200 static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(StringView(&objectReplacementCharacter, 1)); 200 201 const TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : textRun; 201 FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + m_font ->metricsOfPrimaryFont().ascent()) : textOrigin;202 FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + m_font.metricsOfPrimaryFont().ascent()) : textOrigin; 202 203 if (m_combinedText) 203 204 m_context.concatCTM(rotation(boxRect, Clockwise)); 204 205 205 206 // FIXME: Truncate right-to-left text correctly. 206 paintTextWithShadows(shadow, shadowColorFilter, m_combinedText ? m_combinedText->originalFont() : *m_font, emphasisMarkTextRun, boxRect, emphasisMarkTextOrigin, startOffset, endOffset,207 paintTextWithShadows(shadow, shadowColorFilter, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, boxRect, emphasisMarkTextOrigin, startOffset, endOffset, 207 208 m_emphasisMark, m_emphasisMarkOffset, paintStyle.strokeWidth > 0); 208 209 … … 211 212 } 212 213 213 void TextPainter::paint(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin)214 {215 paintRange(textRun, boxRect, textOrigin, 0, textRun.length());216 }217 218 214 void TextPainter::paintRange(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end) 219 215 { 220 ASSERT(m_font);221 216 ASSERT(start < end); 222 223 GraphicsContextStateSaver stateSaver(m_context, m_style.strokeWidth > 0);224 updateGraphicsContext(m_context, m_style);225 217 paintTextAndEmphasisMarksIfNeeded(textRun, boxRect, textOrigin, start, end, m_style, m_shadow, m_shadowColorFilter); 226 218 } -
branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.h
r246490 r292039 50 50 class TextPainter { 51 51 public: 52 TextPainter(GraphicsContext& );52 TextPainter(GraphicsContext&, const FontCascade&); 53 53 54 54 void setStyle(const TextPaintStyle& textPaintStyle) { m_style = textPaintStyle; } 55 55 void setShadow(const ShadowData* shadow) { m_shadow = shadow; } 56 56 void setShadowColorFilter(const FilterOperations* colorFilter) { m_shadowColorFilter = colorFilter; } 57 void setFont(const FontCascade& font) { m_font = &font; }58 57 void setIsHorizontal(bool isHorizontal) { m_textBoxIsHorizontal = isHorizontal; } 59 58 void setEmphasisMark(const AtomString& mark, float offset, const RenderCombineText*); 60 59 61 void paint(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin);62 60 void paintRange(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end); 63 61 64 62 template<typename LayoutRun> 65 void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const FontCascade& font, GraphicsContext& context, constTextRun& textRun)63 void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const TextRun& textRun) 66 64 { 67 65 if (!TextPainter::shouldUseGlyphDisplayList(paintInfo)) 68 66 TextPainter::removeGlyphDisplayList(run); 69 67 else 70 m_glyphDisplayList = GlyphDisplayListCache<LayoutRun>::singleton().get(run, font,context, textRun);68 m_glyphDisplayList = GlyphDisplayListCache<LayoutRun>::singleton().get(run, m_font, m_context, textRun); 71 69 } 72 70 … … 86 84 87 85 GraphicsContext& m_context; 88 const FontCascade * m_font { nullptr };86 const FontCascade& m_font; 89 87 TextPaintStyle m_style; 90 88 AtomString m_emphasisMark;
Note:
See TracChangeset
for help on using the changeset viewer.