Changeset 292026 in webkit
- Timestamp:
- Mar 29, 2022, 2:43:07 AM (5 years ago)
- Location:
- trunk/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
-
trunk/Source/WebCore/ChangeLog
r292025 r292026 1 2022-03-29 Said Abou-Hallawa <said@apple.com> 2 3 REGRESSION(r291771): [ iOS ] Text sometimes draw with incorrect color 4 https://bugs.webkit.org/show_bug.cgi?id=238466 5 rdar://90941790 6 7 Reviewed by Simon Fraser. 8 9 r291771 uncovers this bug: TextBoxPainter::paintForeground() records the 10 glyphs to a DisplayList before settings the destination GraphicsContext. 11 12 The fix is to apply all the changes to the GraphicsContext before calling 13 TextPainter::setGlyphDisplayListIfNeeded(). 14 15 Delete TextPainter::paint() because it is not used. 16 17 Initialize TextPainter with a reference to FontCascade. 18 19 * rendering/TextBoxPainter.cpp: 20 (WebCore::TextBoxPainter::paintForeground): 21 * rendering/TextPainter.cpp: 22 (WebCore::TextPainter::TextPainter): 23 (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): 24 (WebCore::TextPainter::paintRange): 25 (WebCore::TextPainter::paint): Deleted. 26 * rendering/TextPainter.h: 27 (WebCore::TextPainter::setShadowColorFilter): 28 (WebCore::TextPainter::setGlyphDisplayListIfNeeded): 29 (WebCore::TextPainter::setFont): Deleted. 30 1 31 2022-03-29 Zan Dobersek <zdobersek@igalia.com> 2 32 -
trunk/Source/WebCore/rendering/TextBoxPainter.cpp
r291552 r292026 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); -
trunk/Source/WebCore/rendering/TextPainter.cpp
r288942 r292026 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 } -
trunk/Source/WebCore/rendering/TextPainter.h
r246490 r292026 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.