Modified: branches/safari-614.1.8-branch/Source/WebCore/rendering/TextBoxPainter.cpp (292038 => 292039)
--- branches/safari-614.1.8-branch/Source/WebCore/rendering/TextBoxPainter.cpp 2022-03-29 17:29:42 UTC (rev 292038)
+++ branches/safari-614.1.8-branch/Source/WebCore/rendering/TextBoxPainter.cpp 2022-03-29 17:29:46 UTC (rev 292039)
@@ -324,8 +324,7 @@
if (!emphasisMark.isEmpty())
emphasisMarkOffset = *m_emphasisMarkExistsAndIsAbove ? -font.metricsOfPrimaryFont().ascent() - font.emphasisMarkDescent(emphasisMark) : font.metricsOfPrimaryFont().descent() + font.emphasisMarkAscent(emphasisMark);
- TextPainter textPainter { context };
- textPainter.setFont(font);
+ TextPainter textPainter { context, font };
textPainter.setStyle(markedText.style.textStyles);
textPainter.setIsHorizontal(textBox().isHorizontal());
if (markedText.style.textShadow) {
@@ -337,18 +336,18 @@
if (auto* debugShadow = debugTextShadow())
textPainter.setShadow(debugShadow);
+ GraphicsContextStateSaver stateSaver(context, markedText.style.textStyles.strokeWidth > 0 || markedText.type == MarkedText::DraggedContent);
+ if (markedText.type == MarkedText::DraggedContent)
+ context.setAlpha(markedText.style.alpha);
+ updateGraphicsContext(context, markedText.style.textStyles);
+
if (auto* legacyInlineBox = textBox().legacyInlineBox())
- textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, font, context, m_paintTextRun);
+ textPainter.setGlyphDisplayListIfNeeded(*legacyInlineBox, m_paintInfo, m_paintTextRun);
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
else
- textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, font, context, m_paintTextRun);
+ textPainter.setGlyphDisplayListIfNeeded(*textBox().inlineBox(), m_paintInfo, m_paintTextRun);
#endif
- GraphicsContextStateSaver stateSaver { context, false };
- if (markedText.type == MarkedText::DraggedContent) {
- stateSaver.save();
- context.setAlpha(markedText.style.alpha);
- }
// TextPainter wants the box rectangle and text origin of the entire line box.
textPainter.paintRange(m_paintTextRun, m_paintRect, textOriginFromPaintRect(m_paintRect), markedText.startOffset, markedText.endOffset);
}
Modified: branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.cpp (292038 => 292039)
--- branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.cpp 2022-03-29 17:29:42 UTC (rev 292038)
+++ branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.cpp 2022-03-29 17:29:46 UTC (rev 292039)
@@ -97,8 +97,9 @@
m_context.clearShadow();
}
-TextPainter::TextPainter(GraphicsContext& context)
+TextPainter::TextPainter(GraphicsContext& context, const FontCascade& font)
: m_context(context)
+ , m_font(font)
{
}
@@ -159,7 +160,7 @@
{
if (paintStyle.paintOrder == PaintOrder::Normal) {
// FIXME: Truncate right-to-left text correctly.
- paintTextWithShadows(shadow, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);
+ paintTextWithShadows(shadow, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);
} else {
auto textDrawingMode = m_context.textDrawingMode();
auto paintOrder = RenderStyle::paintTypesForPaintOrder(paintStyle.paintOrder);
@@ -171,7 +172,7 @@
auto textDrawingModeWithoutStroke = textDrawingMode;
textDrawingModeWithoutStroke.remove(TextDrawingMode::Stroke);
m_context.setTextDrawingMode(textDrawingModeWithoutStroke);
- paintTextWithShadows(shadowToUse, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, false);
+ paintTextWithShadows(shadowToUse, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, false);
shadowToUse = nullptr;
m_context.setTextDrawingMode(textDrawingMode);
break;
@@ -180,7 +181,7 @@
auto textDrawingModeWithoutFill = textDrawingMode;
textDrawingModeWithoutFill.remove(TextDrawingMode::Fill);
m_context.setTextDrawingMode(textDrawingModeWithoutFill);
- paintTextWithShadows(shadowToUse, shadowColorFilter, *m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);
+ paintTextWithShadows(shadowToUse, shadowColorFilter, m_font, textRun, boxRect, textOrigin, startOffset, endOffset, nullAtom(), 0, paintStyle.strokeWidth > 0);
shadowToUse = nullptr;
m_context.setTextDrawingMode(textDrawingMode);
}
@@ -198,12 +199,12 @@
updateGraphicsContext(m_context, paintStyle, UseEmphasisMarkColor);
static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(StringView(&objectReplacementCharacter, 1));
const TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : textRun;
- FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + m_font->metricsOfPrimaryFont().ascent()) : textOrigin;
+ FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + boxRect.width() / 2, boxOrigin.y() + m_font.metricsOfPrimaryFont().ascent()) : textOrigin;
if (m_combinedText)
m_context.concatCTM(rotation(boxRect, Clockwise));
// FIXME: Truncate right-to-left text correctly.
- paintTextWithShadows(shadow, shadowColorFilter, m_combinedText ? m_combinedText->originalFont() : *m_font, emphasisMarkTextRun, boxRect, emphasisMarkTextOrigin, startOffset, endOffset,
+ paintTextWithShadows(shadow, shadowColorFilter, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, boxRect, emphasisMarkTextOrigin, startOffset, endOffset,
m_emphasisMark, m_emphasisMarkOffset, paintStyle.strokeWidth > 0);
if (m_combinedText)
@@ -210,18 +211,9 @@
m_context.concatCTM(rotation(boxRect, Counterclockwise));
}
-void TextPainter::paint(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin)
-{
- paintRange(textRun, boxRect, textOrigin, 0, textRun.length());
-}
-
void TextPainter::paintRange(const TextRun& textRun, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end)
{
- ASSERT(m_font);
ASSERT(start < end);
-
- GraphicsContextStateSaver stateSaver(m_context, m_style.strokeWidth > 0);
- updateGraphicsContext(m_context, m_style);
paintTextAndEmphasisMarksIfNeeded(textRun, boxRect, textOrigin, start, end, m_style, m_shadow, m_shadowColorFilter);
}
Modified: branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.h (292038 => 292039)
--- branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.h 2022-03-29 17:29:42 UTC (rev 292038)
+++ branches/safari-614.1.8-branch/Source/WebCore/rendering/TextPainter.h 2022-03-29 17:29:46 UTC (rev 292039)
@@ -49,25 +49,23 @@
class TextPainter {
public:
- TextPainter(GraphicsContext&);
+ TextPainter(GraphicsContext&, const FontCascade&);
void setStyle(const TextPaintStyle& textPaintStyle) { m_style = textPaintStyle; }
void setShadow(const ShadowData* shadow) { m_shadow = shadow; }
void setShadowColorFilter(const FilterOperations* colorFilter) { m_shadowColorFilter = colorFilter; }
- void setFont(const FontCascade& font) { m_font = &font; }
void setIsHorizontal(bool isHorizontal) { m_textBoxIsHorizontal = isHorizontal; }
void setEmphasisMark(const AtomString& mark, float offset, const RenderCombineText*);
- void paint(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin);
void paintRange(const TextRun&, const FloatRect& boxRect, const FloatPoint& textOrigin, unsigned start, unsigned end);
template<typename LayoutRun>
- void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const FontCascade& font, GraphicsContext& context, const TextRun& textRun)
+ void setGlyphDisplayListIfNeeded(const LayoutRun& run, const PaintInfo& paintInfo, const TextRun& textRun)
{
if (!TextPainter::shouldUseGlyphDisplayList(paintInfo))
TextPainter::removeGlyphDisplayList(run);
else
- m_glyphDisplayList = GlyphDisplayListCache<LayoutRun>::singleton().get(run, font, context, textRun);
+ m_glyphDisplayList = GlyphDisplayListCache<LayoutRun>::singleton().get(run, m_font, m_context, textRun);
}
template<typename LayoutRun>
@@ -85,7 +83,7 @@
const TextPaintStyle&, const ShadowData*, const FilterOperations*);
GraphicsContext& m_context;
- const FontCascade* m_font { nullptr };
+ const FontCascade& m_font;
TextPaintStyle m_style;
AtomString m_emphasisMark;
const ShadowData* m_shadow { nullptr };