390 static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark, int emphasisMarkOffset, int startOffset, int endOffset, int truncationPoint, const FloatPoint& textOrigin,
391 const FloatRect& boxRect, const ShadowData* shadow, bool stroked, bool horizontal)
392 {
393 Color fillColor = context->fillColor();
394 ColorSpace fillColorSpace = context->fillColorSpace();
395 bool opaque = fillColor.alpha() == 255;
396 if (!opaque)
397 context->setFillColor(Color::black, fillColorSpace);
398
399 do {
400 IntSize extraOffset;
401 if (shadow)
402 extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal));
403 else if (!opaque)
404 context->setFillColor(fillColor, fillColorSpace);
405
406 if (startOffset <= endOffset) {
407 if (emphasisMark.isEmpty())
408 context->drawText(font, textRun, textOrigin + extraOffset, startOffset, endOffset);
409 else
410 context->drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset), startOffset, endOffset);
411 } else {
412 if (endOffset > 0) {
413 if (emphasisMark.isEmpty())
414 context->drawText(font, textRun, textOrigin + extraOffset, 0, endOffset);
415 else
416 context->drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset), 0, endOffset);
417 } if (startOffset < truncationPoint) {
418 if (emphasisMark.isEmpty())
419 context->drawText(font, textRun, textOrigin + extraOffset, startOffset, truncationPoint);
420 else
421 context->drawEmphasisMarks(font, textRun, emphasisMark, textOrigin + extraOffset + IntSize(0, emphasisMarkOffset), startOffset, truncationPoint);
422 }
423 }
424
425 if (!shadow)
426 break;
427
428 if (shadow->next() || stroked || !opaque)
429 context->restore();
430 else
431 context->clearShadow();
432
433 shadow = shadow->next();
434 } while (shadow || stroked || !opaque);
435 }