summaryrefslogtreecommitdiffstats
path: root/WebCore/rendering/SVGInlineTextBox.cpp
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-07-08 12:51:48 +0100
committerSteve Block <steveblock@google.com>2010-07-09 15:33:40 +0100
commitca9cb53ed1119a3fd98fafa0972ffeb56dee1c24 (patch)
treebb45155550ec013adc0ad10f4d7d354c6469b022 /WebCore/rendering/SVGInlineTextBox.cpp
parentd4b24d9a829ed7de70381c8b99fb75a07ab40466 (diff)
downloadexternal_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.zip
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.gz
external_webkit-ca9cb53ed1119a3fd98fafa0972ffeb56dee1c24.tar.bz2
Merge WebKit at r62496: Initial merge by git
Change-Id: Ie3da0770eca22a70a632e3571f31cfabc80facb2
Diffstat (limited to 'WebCore/rendering/SVGInlineTextBox.cpp')
-rw-r--r--WebCore/rendering/SVGInlineTextBox.cpp67
1 files changed, 40 insertions, 27 deletions
diff --git a/WebCore/rendering/SVGInlineTextBox.cpp b/WebCore/rendering/SVGInlineTextBox.cpp
index 68b4fd0..8e498ad 100644
--- a/WebCore/rendering/SVGInlineTextBox.cpp
+++ b/WebCore/rendering/SVGInlineTextBox.cpp
@@ -124,8 +124,9 @@ int SVGInlineTextBox::offsetForPosition(int xCoordinate, bool includePartialGlyp
m_currentChunkPart = SVGTextChunkPart();
// Eventually handle lengthAdjust="spacingAndGlyphs".
+ // FIXME: Need to revisit the whole offsetForPosition concept for vertical text selection.
if (!m_chunkTransformation.isIdentity())
- textRun.setGlyphScale(narrowPrecisionToFloat(isVerticalWritingMode(style->svgStyle()) ? m_chunkTransformation.d() : m_chunkTransformation.a()));
+ textRun.setHorizontalGlyphStretch(narrowPrecisionToFloat(m_chunkTransformation.a()));
return hitPart.offset + style->font().offsetForPosition(textRun, x, includePartialGlyphs);
}
@@ -189,9 +190,9 @@ IntRect SVGInlineTextBox::selectionRect(int, int, int startPos, int endPos)
return enclosingIntRect(m_chunkTransformation.mapRect(selectionRect));
}
-void SVGInlineTextBox::paint(RenderObject::PaintInfo& paintInfo, int, int)
+void SVGInlineTextBox::paint(PaintInfo& paintInfo, int, int)
{
- ASSERT(renderer()->shouldPaintWithinRoot(paintInfo));
+ ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
ASSERT(truncation() == cNoTruncation);
@@ -562,6 +563,35 @@ void SVGInlineTextBox::paintSelection(GraphicsContext* context, const FloatPoint
context->restore();
}
+void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, const FloatPoint& textOrigin, RenderStyle* style, TextRun& textRun, int startPos, int endPos)
+{
+ const Font& font = style->font();
+ const ShadowData* shadow = style->textShadow();
+
+ FloatRect shadowRect(FloatPoint(textOrigin.x(), textOrigin.y() - font.ascent()), FloatSize(m_currentChunkPart.width, m_currentChunkPart.height));
+ do {
+ if (!prepareGraphicsContextForTextPainting(context, textRun, style))
+ break;
+
+ FloatSize extraOffset;
+ if (shadow)
+ extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */);
+
+ font.drawText(context, textRun, textOrigin + extraOffset, startPos, endPos);
+ restoreGraphicsContextAfterTextPainting(context, textRun);
+
+ if (!shadow)
+ break;
+
+ if (shadow->next())
+ context->restore();
+ else
+ context->clearShadow();
+
+ shadow = shadow->next();
+ } while (shadow);
+}
+
void SVGInlineTextBox::paintText(GraphicsContext* context, const FloatPoint& textOrigin, RenderStyle* style, RenderStyle* selectionStyle, bool hasSelection, bool paintSelectedTextOnly)
{
ASSERT(style);
@@ -572,41 +602,24 @@ void SVGInlineTextBox::paintText(GraphicsContext* context, const FloatPoint& tex
int endPos = 0;
selectionStartEnd(startPos, endPos);
- const Font& font = style->font();
- TextRun textRun(constructTextRun(style));
-
// Fast path if there is no selection, just draw the whole chunk part using the regular style
+ TextRun textRun(constructTextRun(style));
if (!hasSelection || startPos >= endPos) {
- if (prepareGraphicsContextForTextPainting(context, textRun, style)) {
- font.drawText(context, textRun, textOrigin, 0, m_currentChunkPart.length);
- restoreGraphicsContextAfterTextPainting(context, textRun);
- }
-
+ paintTextWithShadows(context, textOrigin, style, textRun, 0, m_currentChunkPart.length);
return;
}
// Eventually draw text using regular style until the start position of the selection
- if (startPos > 0 && !paintSelectedTextOnly) {
- if (prepareGraphicsContextForTextPainting(context, textRun, style)) {
- font.drawText(context, textRun, textOrigin, 0, startPos);
- restoreGraphicsContextAfterTextPainting(context, textRun);
- }
- }
+ if (startPos > 0 && !paintSelectedTextOnly)
+ paintTextWithShadows(context, textOrigin, style, textRun, 0, startPos);
// Draw text using selection style from the start to the end position of the selection
TextRun selectionTextRun(constructTextRun(selectionStyle));
- if (prepareGraphicsContextForTextPainting(context, selectionTextRun, selectionStyle)) {
- selectionStyle->font().drawText(context, selectionTextRun, textOrigin, startPos, endPos);
- restoreGraphicsContextAfterTextPainting(context, selectionTextRun);
- }
+ paintTextWithShadows(context, textOrigin, selectionStyle, textRun, startPos, endPos);
// Eventually draw text using regular style from the end position of the selection to the end of the current chunk part
- if (endPos < m_currentChunkPart.length && !paintSelectedTextOnly) {
- if (prepareGraphicsContextForTextPainting(context, textRun, style)) {
- font.drawText(context, textRun, textOrigin, endPos, m_currentChunkPart.length);
- restoreGraphicsContextAfterTextPainting(context, textRun);
- }
- }
+ if (endPos < m_currentChunkPart.length && !paintSelectedTextOnly)
+ paintTextWithShadows(context, textOrigin, style, textRun, endPos, m_currentChunkPart.length);
}
void SVGInlineTextBox::buildLayoutInformation(SVGCharacterLayoutInfo& info, SVGLastGlyphInfo& lastGlyph)