OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef TextPainter_h | 5 #ifndef TextPainter_h |
6 #define TextPainter_h | 6 #define TextPainter_h |
7 | 7 |
8 #include "core/CoreExport.h" | 8 #include "core/CoreExport.h" |
9 #include "core/style/ComputedStyleConstants.h" | 9 #include "core/style/ComputedStyleConstants.h" |
10 #include "platform/fonts/TextBlob.h" | 10 #include "platform/fonts/TextBlob.h" |
11 #include "platform/geometry/FloatPoint.h" | 11 #include "platform/geometry/FloatPoint.h" |
12 #include "platform/geometry/FloatRect.h" | 12 #include "platform/geometry/FloatRect.h" |
13 #include "platform/geometry/LayoutRect.h" | 13 #include "platform/geometry/LayoutRect.h" |
14 #include "platform/graphics/Color.h" | 14 #include "platform/graphics/Color.h" |
15 #include "platform/transforms/AffineTransform.h" | 15 #include "platform/transforms/AffineTransform.h" |
16 #include "wtf/Allocator.h" | 16 #include "wtf/Allocator.h" |
17 #include "wtf/text/AtomicString.h" | 17 #include "wtf/text/AtomicString.h" |
18 | 18 |
19 namespace blink { | 19 namespace blink { |
20 | 20 |
21 class ComputedStyle; | 21 class ComputedStyle; |
22 class Font; | 22 class Font; |
23 class GraphicsContext; | 23 class GraphicsContext; |
24 class GraphicsContextStateSaver; | 24 class GraphicsContextStateSaver; |
25 class LayoutTextCombine; | 25 class LayoutTextCombine; |
26 class LayoutObject; | 26 class LayoutObject; |
| 27 class LineLayoutItem; |
27 struct PaintInfo; | 28 struct PaintInfo; |
28 class ShadowList; | 29 class ShadowList; |
29 class TextRun; | 30 class TextRun; |
30 struct TextRunPaintInfo; | 31 struct TextRunPaintInfo; |
31 | 32 |
32 class CORE_EXPORT TextPainter { | 33 class CORE_EXPORT TextPainter { |
33 STACK_ALLOCATED(); | 34 STACK_ALLOCATED(); |
34 public: | 35 public: |
35 struct Style; | 36 struct Style; |
36 | 37 |
(...skipping 20 matching lines...) Expand all Loading... |
57 { | 58 { |
58 return currentColor == other.currentColor | 59 return currentColor == other.currentColor |
59 && fillColor == other.fillColor | 60 && fillColor == other.fillColor |
60 && strokeColor == other.strokeColor | 61 && strokeColor == other.strokeColor |
61 && emphasisMarkColor == other.emphasisMarkColor | 62 && emphasisMarkColor == other.emphasisMarkColor |
62 && strokeWidth == other.strokeWidth | 63 && strokeWidth == other.strokeWidth |
63 && shadow == other.shadow; | 64 && shadow == other.shadow; |
64 } | 65 } |
65 bool operator!=(const Style& other) { return !(*this == other); } | 66 bool operator!=(const Style& other) { return !(*this == other); } |
66 }; | 67 }; |
67 static Style textPaintingStyle(const LayoutObject&, const ComputedStyle&, co
nst PaintInfo&); | 68 static Style textPaintingStyle(LineLayoutItem, const ComputedStyle&, const P
aintInfo&); |
68 static Style selectionPaintingStyle(const LayoutObject&, bool haveSelection,
const PaintInfo&, const Style& textStyle); | 69 static Style selectionPaintingStyle(LineLayoutItem, bool haveSelection, cons
t PaintInfo&, const Style& textStyle); |
69 | 70 |
70 enum RotationDirection { Counterclockwise, Clockwise }; | 71 enum RotationDirection { Counterclockwise, Clockwise }; |
71 static AffineTransform rotation(const LayoutRect& boxRect, RotationDirection
); | 72 static AffineTransform rotation(const LayoutRect& boxRect, RotationDirection
); |
72 | 73 |
73 private: | 74 private: |
74 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) | 75 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) |
75 { | 76 { |
76 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); | 77 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); |
77 } | 78 } |
78 | 79 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) | 111 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) |
111 | 112 |
112 // A similar argument derives the counter-clockwise case. | 113 // A similar argument derives the counter-clockwise case. |
113 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) | 114 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) |
114 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); | 115 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); |
115 } | 116 } |
116 | 117 |
117 } // namespace blink | 118 } // namespace blink |
118 | 119 |
119 #endif // TextPainter_h | 120 #endif // TextPainter_h |
OLD | NEW |