| 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/layout/line/FloatToLayoutUnit.h" | 8 #include "core/layout/line/FloatToLayoutUnit.h" |
| 9 #include "core/layout/style/LayoutStyleConstants.h" | 9 #include "core/layout/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/graphics/Color.h" | 13 #include "platform/graphics/Color.h" |
| 14 #include "platform/transforms/AffineTransform.h" | 14 #include "platform/transforms/AffineTransform.h" |
| 15 #include "wtf/text/AtomicString.h" | 15 #include "wtf/text/AtomicString.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 class Font; | 19 class Font; |
| 20 class GraphicsContext; | 20 class GraphicsContext; |
| 21 class GraphicsContextStateSaver; | 21 class GraphicsContextStateSaver; |
| 22 class LayoutTextCombine; | 22 class LayoutTextCombine; |
| 23 class LayoutObject; | 23 class LayoutObject; |
| 24 class LayoutStyle; | 24 class ComputedStyle; |
| 25 class ShadowList; | 25 class ShadowList; |
| 26 class TextRun; | 26 class TextRun; |
| 27 struct TextRunPaintInfo; | 27 struct TextRunPaintInfo; |
| 28 | 28 |
| 29 class TextPainter { | 29 class TextPainter { |
| 30 public: | 30 public: |
| 31 struct Style; | 31 struct Style; |
| 32 | 32 |
| 33 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint&
textOrigin, const FloatRect& textBounds, bool horizontal); | 33 TextPainter(GraphicsContext*, const Font&, const TextRun&, const FloatPoint&
textOrigin, const FloatRect& textBounds, bool horizontal); |
| 34 ~TextPainter(); | 34 ~TextPainter(); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 50 bool operator==(const Style& other) | 50 bool operator==(const Style& other) |
| 51 { | 51 { |
| 52 return fillColor == other.fillColor | 52 return fillColor == other.fillColor |
| 53 && strokeColor == other.strokeColor | 53 && strokeColor == other.strokeColor |
| 54 && emphasisMarkColor == other.emphasisMarkColor | 54 && emphasisMarkColor == other.emphasisMarkColor |
| 55 && strokeWidth == other.strokeWidth | 55 && strokeWidth == other.strokeWidth |
| 56 && shadow == other.shadow; | 56 && shadow == other.shadow; |
| 57 } | 57 } |
| 58 bool operator!=(const Style& other) { return !(*this == other); } | 58 bool operator!=(const Style& other) { return !(*this == other); } |
| 59 }; | 59 }; |
| 60 static Style textPaintingStyle(LayoutObject&, const LayoutStyle&, bool force
BlackText, bool isPrinting); | 60 static Style textPaintingStyle(LayoutObject&, const ComputedStyle&, bool for
ceBlackText, bool isPrinting); |
| 61 static Style selectionPaintingStyle(LayoutObject&, bool haveSelection, bool
forceBlackText, bool isPrinting, const Style& textStyle); | 61 static Style selectionPaintingStyle(LayoutObject&, bool haveSelection, bool
forceBlackText, bool isPrinting, const Style& textStyle); |
| 62 | 62 |
| 63 enum RotationDirection { Counterclockwise, Clockwise }; | 63 enum RotationDirection { Counterclockwise, Clockwise }; |
| 64 static AffineTransform rotation(const FloatRectWillBeLayoutRect& boxRect, Ro
tationDirection); | 64 static AffineTransform rotation(const FloatRectWillBeLayoutRect& boxRect, Ro
tationDirection); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) | 67 void updateGraphicsContext(const Style& style, GraphicsContextStateSaver& sa
ver) |
| 68 { | 68 { |
| 69 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); | 69 updateGraphicsContext(m_graphicsContext, style, m_horizontal, saver); |
| 70 } | 70 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) | 103 // 5. Therefore the translation from (3) to (4) is (x(), y()) - (-maxY(), x(
)) = (x() + maxY(), y() - x()) |
| 104 | 104 |
| 105 // A similar argument derives the counter-clockwise case. | 105 // A similar argument derives the counter-clockwise case. |
| 106 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) | 106 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect
.x() + boxRect.maxY(), boxRect.y() - boxRect.x()) |
| 107 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); | 107 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.y(), boxRect.x() +
boxRect.maxY()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 } // namespace blink | 110 } // namespace blink |
| 111 | 111 |
| 112 #endif // TextPainter_h | 112 #endif // TextPainter_h |
| OLD | NEW |