1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
8 #include "core/rendering/style/RenderStyleConstants.h"
9 #include "platform/fonts/TextBlob.h"
10 #include "platform/geometry/FloatPoint.h"
11 #include "platform/geometry/FloatRect.h"
12 #include "platform/graphics/Color.h"
13 #include "wtf/text/AtomicString.h"
18 class GraphicsContext;
19 class GraphicsContextStateSaver;
20 class RenderCombineText;
25 struct TextRunPaintInfo;
31 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizontal);
34 void setEmphasisMark(const AtomicString&, TextEmphasisPosition);
35 void setCombinedText(RenderCombineText* combinedText) { m_combinedText = combinedText; }
37 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horizontal, GraphicsContextStateSaver&);
39 void paint(int startOffset, int endOffset, int length, const Style&, TextBlobPtr* cachedTextBlob = 0);
44 Color emphasisMarkColor;
46 const ShadowList* shadow;
48 bool operator==(const Style& other)
50 return fillColor == other.fillColor
51 && strokeColor == other.strokeColor
52 && emphasisMarkColor == other.emphasisMarkColor
53 && strokeWidth == other.strokeWidth
54 && shadow == other.shadow;
56 bool operator!=(const Style& other) { return !(*this == other); }
58 static Style textPaintingStyle(RenderObject&, RenderStyle*, bool forceBlackText, bool isPrinting);
59 static Style selectionPaintingStyle(RenderObject&, bool haveSelection, bool forceBlackText, bool isPrinting, const Style& textStyle);
62 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& saver)
64 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver);
67 enum PaintInternalStep { PaintText, PaintEmphasisMark };
69 template <PaintInternalStep step>
70 void paintInternalRun(TextRunPaintInfo&, int from, int to);
72 template <PaintInternalStep step>
73 void paintInternal(int startOffset, int endOffset, int truncationPoint, TextBlobPtr* cachedTextBlob = 0);
75 void paintEmphasisMarkForCombinedText();
77 GraphicsContext* m_graphicsContext;
80 FloatPoint m_textOrigin;
81 FloatRect m_textBounds;
83 AtomicString m_emphasisMark;
84 int m_emphasisMarkOffset;
85 RenderCombineText* m_combinedText;
90 #endif // TextPainter_h