⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 292039 in webkit


Ignore:
Timestamp:
Mar 29, 2022, 10:29:46 AM (5 years ago)
Author:
Russell Epstein
Message:

Cherry-pick r292026. rdar://problem/90941790

REGRESSION(r291771): [ iOS ] Text sometimes draw with incorrect color
​https://bugs.webkit.org/show_bug.cgi?id=238466
rdar://90941790

Reviewed by Simon Fraser.

r291771 uncovers this bug: TextBoxPainter::paintForeground() records the
glyphs to a DisplayList before settings the destination GraphicsContext.

The fix is to apply all the changes to the GraphicsContext before calling
TextPainter::setGlyphDisplayListIfNeeded().

Delete TextPainter::paint() because it is not used.

Initialize TextPainter with a reference to FontCascade.

  • rendering/TextBoxPainter.cpp: (WebCore::TextBoxPainter::paintForeground):
  • rendering/TextPainter.cpp: (WebCore::TextPainter::TextPainter): (WebCore::TextPainter::paintTextAndEmphasisMarksIfNeeded): (WebCore::TextPainter::paintRange): (WebCore::TextPainter::paint): Deleted.
  • rendering/TextPainter.h: (WebCore::TextPainter::setShadowColorFilter): (WebCore::TextPainter::setGlyphDisplayListIfNeeded): (WebCore::TextPainter::setFont): Deleted.

git-svn-id: ​https://svn.webkit.org/repository/webkit/trunk@292026 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Location:
branches/safari-614.1.8-branch/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-614.1.8-branch/Source/WebCore/ChangeLog

    r291986 r292039  
     12022-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
    1662022-03-28  Russell Epstein  <repstein@apple.com>
    267
  • branches/safari-614.1.8-branch/Source/WebCore/rendering/TextBoxPainter.cpp

    r291552 r292039  
    325325        emphasisMarkOffset = *m_emphasisMarkExistsAndIsAbove ? -font.metricsOfPrimaryFont().ascent() - font.emphasisMarkDescent(emphasisMark) : font.metricsOfPrimaryFont().descent() + font.emphasisMarkAscent(emphasisMark);
    326326
    327     TextPainter textPainter { context };
    328     textPainter.setFont(font);
     327    TextPainter textPainter { context, font };
    329328    textPainter.setStyle(markedText.style.textStyles);
    330329    textPainter.setIsHorizontal(textBox().isHorizontal());
    … …  
    338337        textPainter.setShadow(debugShadow);
    339338
     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
    340344    if (auto* legacyInlineBox = textBox().legacyInlineBox())
    341         textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, font, context, m_paintTextRun);
     345        textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, m_paintTextRun);
    342346#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
    343347    else
    344         textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, font, context, m_paintTextRun);
     348        textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, m_paintTextRun);
    345349#endif
    346350
    347     GraphicsContextStateSaver stateSaver { context, false };
    348     if (markedText.type == MarkedText::DraggedContent) {
    349         stateSaver.save();
    350         context.setAlpha(markedText.style.alpha);
    351     }
    352351    // TextPainter wants the box rectangle and text origin of the entire line box.
    353352    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  
    9898}
    9999
    100 TextPainter::TextPainter(GraphicsContext& context)
     100TextPainter::TextPainter(GraphicsContext& context, const FontCascade& font)
    101101    : m_context(context)
     102    , m_font(font)
    102103{
    103104}
    … …  
    160161    if (paintStyle.paintOrder == PaintOrder::Normal) {
    161162        // 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);
    163164    } else {
    164165        auto textDrawingMode = m_context.textDrawingMode();
    … …  
    172173                textDrawingModeWithoutStroke.remove(TextDrawingMode::Stroke);
    173174                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);
    175176                shadowToUse = nullptr;
    176177                m_context.setTextDrawingMode(textDrawingMode);
    … …  
    181182                textDrawingModeWithoutFill.remove(TextDrawingMode::Fill);
    182183                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);
    184185                shadowToUse = nullptr;
    185186                m_context.setTextDrawingMode(textDrawingMode);
    … …  
    199200    static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(StringView(&objectReplacementCharacter, 1));
    200201    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;
    202203    if (m_combinedText)
    203204        m_context.concatCTM(rotation(boxRect, Clockwise));
    204205
    205206    // 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,
    207208        m_emphasisMark, m_emphasisMarkOffset, paintStyle.strokeWidth > 0);
    208209
    … …  
    211212}
    212213
    213 void TextPainter::paint(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin)
    214 {
    215     paintRange(textRun, boxRect, textOrigin, 0, textRun.length());
    216 }
    217 
    218214void TextPainter::paintRange(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end)
    219215{
    220     ASSERT(m_font);
    221216    ASSERT(start < end);
    222 
    223     GraphicsContextStateSaver stateSaver(m_context, m_style.strokeWidth > 0);
    224     updateGraphicsContext(m_context, m_style);
    225217    paintTextAndEmphasisMarksIfNeeded(textRun, boxRect, textOrigin, start, end, m_style, m_shadow, m_shadowColorFilter);
    226218}
  • branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.h

    r246490 r292039  
    5050class TextPainter {
    5151public:
    52     TextPainter(GraphicsContext&);
     52    TextPainter(GraphicsContext&, const FontCascade&);
    5353
    5454    void setStyle(const TextPaintStyle& textPaintStyle) { m_style = textPaintStyle; }
    5555    void setShadow(const ShadowData* shadow) { m_shadow = shadow; }
    5656    void setShadowColorFilter(const FilterOperations* colorFilter) { m_shadowColorFilter = colorFilter; }
    57     void setFont(const FontCascade& font) { m_font = &font; }
    5857    void setIsHorizontal(bool isHorizontal) { m_textBoxIsHorizontal = isHorizontal; }
    5958    void setEmphasisMark(const AtomString& mark, float offset, const RenderCombineText*);
    6059
    61     void paint(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin);
    6260    void paintRange(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end);
    6361
    6462    template<typename LayoutRun>
    65     void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const FontCascade& font, GraphicsContext& context, const TextRun& textRun)
     63    void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const TextRun& textRun)
    6664    {
    6765        if (!TextPainter::shouldUseGlyphDisplayList(paintInfo))
    6866            TextPainter::removeGlyphDisplayList(run);
    6967        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);
    7169    }
    7270
    … …  
    8684
    8785    GraphicsContext& m_context;
    88     const FontCascade* m_font { nullptr };
     86    const FontCascade& m_font;
    8987    TextPaintStyle m_style;
    9088    AtomString m_emphasisMark;
Note: See TracChangeset for help on using the changeset viewer.