Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: Source/core/rendering/TextPainter.h

Issue 538663002: Move InlineTextBox::paint guts into blink::TextPainter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/TextPainter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #ifndef TextPainter_h
6 #define TextPainter_h
7
8 #include "core/rendering/style/RenderStyleConstants.h"
9 #include "platform/geometry/FloatPoint.h"
10 #include "platform/geometry/FloatRect.h"
11 #include "platform/graphics/Color.h"
12 #include "wtf/text/AtomicString.h"
13
14 namespace blink {
15
16 class Font;
17 class GraphicsContext;
18 class GraphicsContextStateSaver;
19 class RenderCombineText;
20 class ShadowList;
21 class TextRun;
22 struct TextRunPaintInfo;
23
24 class TextPainter {
25 public:
26 struct Style;
27
28 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint& textOrigin, const FloatRect& textBounds, bool horizontal);
29 ~TextPainter();
30
31 void setEmphasisMark(const AtomicString&, TextEmphasisPosition);
32 void setCombinedText(RenderCombineText* combinedText) { m_combinedText = com binedText; }
33
34 static void updateGraphicsContext(GraphicsContext*, const Style&, bool horiz ontal, GraphicsContextStateSaver&);
35
36 void paint(int startOffset, int endOffset, int length, const Style&);
37
38 struct Style {
39 Color fillColor;
40 Color strokeColor;
41 Color emphasisMarkColor;
42 float strokeWidth;
43 const ShadowList* shadow;
44
45 bool operator==(const Style& other)
46 {
47 return fillColor == other.fillColor
48 && strokeColor == other.strokeColor
49 && emphasisMarkColor == other.emphasisMarkColor
50 && strokeWidth == other.strokeWidth
51 && shadow == other.shadow;
52 }
53 bool operator!=(const Style& other) { return !(*this == other); }
54 };
55
56 private:
57 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa ver)
58 {
59 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver);
60 }
61
62 enum PaintInternalStep { PaintText, PaintEmphasisMark };
63
64 template <PaintInternalStep step>
65 void paintInternalRun(TextRunPaintInfo&, int from, int to);
66
67 template <PaintInternalStep step>
68 void paintInternal(int startOffset, int endOffset, int truncationPoint);
69
70 void paintEmphasisMarkForCombinedText();
71
72 GraphicsContext* m_graphicsContext;
73 const Font& m_font;
74 const TextRun& m_run;
75 FloatPoint m_textOrigin;
76 FloatRect m_textBounds;
77 bool m_horizontal;
78 AtomicString m_emphasisMark;
79 int m_emphasisMarkOffset;
80 RenderCombineText* m_combinedText;
81 };
82
83 } // namespace blink
84
85 #endif // TextPainter_h
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineTextBox.cpp ('k') | Source/core/rendering/TextPainter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698