summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/InlineTextBox.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/rendering/InlineTextBox.cpp')
-rw-r--r--WebCore/rendering/InlineTextBox.cpp50
1 files changed, 30 insertions, 20 deletions
diff --git a/WebCore/rendering/InlineTextBox.cpp b/WebCore/rendering/InlineTextBox.cpp
index 09825b6..d6bd70c 100644
--- a/WebCore/rendering/InlineTextBox.cpp
+++ b/WebCore/rendering/InlineTextBox.cpp
@@ -306,6 +306,31 @@ bool InlineTextBox::nodeAtPoint(const HitTestRequest&, HitTestResult& result, in
return false;
}
+FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque)
+{
+ if (!shadow)
+ return FloatSize();
+
+ FloatSize extraOffset;
+ FloatSize shadowOffset(shadow->x(), shadow->y());
+ int shadowBlur = shadow->blur();
+ const Color& shadowColor = shadow->color();
+
+ if (shadow->next() || stroked || !opaque) {
+ FloatRect shadowRect(textRect);
+ shadowRect.inflate(shadowBlur);
+ shadowRect.move(shadowOffset);
+ context->save();
+ context->clip(shadowRect);
+
+ extraOffset = FloatSize(0, 2 * textRect.height() + max(0.0f, shadowOffset.height()) + shadowBlur);
+ shadowOffset -= extraOffset;
+ }
+
+ context->setShadow(shadowOffset, shadowBlur, shadowColor, context->fillColorSpace());
+ return extraOffset;
+}
+
static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, int startOffset, int endOffset, int truncationPoint, const IntPoint& textOrigin, int x, int y, int w, int h, const ShadowData* shadow, bool stroked)
{
Color fillColor = context->fillColor();
@@ -316,24 +341,9 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
do {
IntSize extraOffset;
-
- if (shadow) {
- IntSize shadowOffset(shadow->x(), shadow->y());
- int shadowBlur = shadow->blur();
- const Color& shadowColor = shadow->color();
-
- if (shadow->next() || stroked || !opaque) {
- IntRect shadowRect(x, y, w, h);
- shadowRect.inflate(shadowBlur);
- shadowRect.move(shadowOffset);
- context->save();
- context->clip(shadowRect);
-
- extraOffset = IntSize(0, 2 * h + max(0, shadowOffset.height()) + shadowBlur);
- shadowOffset -= extraOffset;
- }
- context->setShadow(shadowOffset, shadowBlur, shadowColor, fillColorSpace);
- } else if (!opaque)
+ if (shadow)
+ extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, FloatRect(x, y, w, h), stroked, opaque));
+ else if (!opaque)
context->setFillColor(fillColor, fillColorSpace);
if (startOffset <= endOffset)
@@ -357,9 +367,9 @@ static void paintTextWithShadows(GraphicsContext* context, const Font& font, con
} while (shadow || stroked || !opaque);
}
-void InlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int tx, int ty)
+void InlineTextBox::paint(PaintInfo& paintInfo, int tx, int ty)
{
- if (isLineBreak() || !renderer()->shouldPaintWithinRoot(paintInfo) || renderer()->style()->visibility() != VISIBLE ||
+ if (isLineBreak() || !paintInfo.shouldPaintWithinRoot(renderer()) || renderer()->style()->visibility() != VISIBLE ||
m_truncation == cFullTruncation || paintInfo.phase == PaintPhaseOutline)
return;