2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
26 #include "AffineTransform.h"
27 #include "DashArray.h"
28 #include "RenderText.h"
32 class RenderCombineText;
34 struct TextPaintStyle;
36 enum RotationDirection { Counterclockwise, Clockwise };
38 static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirection clockwise)
40 return clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
41 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
44 struct SavedDrawingStateForMask {
45 SavedDrawingStateForMask(GraphicsContext* context, TextPaintStyle* textPaintStyle, TextPaintStyle* selectionPaintStyle,
46 const ShadowData* textShadow, const ShadowData* selectionShadow)
48 , m_textPaintStyle(textPaintStyle)
49 , m_selectionPaintStyle(selectionPaintStyle)
50 , m_textShadow(textShadow)
51 , m_selectionShadow(selectionShadow)
54 GraphicsContext* m_context;
55 TextPaintStyle* m_textPaintStyle;
56 TextPaintStyle* m_selectionPaintStyle;
57 const ShadowData* m_textShadow;
58 const ShadowData* m_selectionShadow;
63 TextPainter(GraphicsContext&, bool paintSelectedTextOnly, bool paintSelectedTextSeparately, const Font&,
64 int startPositionInTextRun, int endPositionInTextBoxString, int length, const AtomicString& emphasisMark, RenderCombineText*,
65 TextRun&, FloatRect& boxRect, FloatPoint& textOrigin, int emphasisMarkOffset, const ShadowData* textShadow, const ShadowData* selectionShadow,
66 bool textBoxIsHorizontal, TextPaintStyle& nonSelectionPaintStyle, TextPaintStyle& selectionPaintStyle);
69 void paintTextInContext(GraphicsContext&, float amountToIncreaseStrokeWidthBy);
71 DashArray dashesForIntersectionsWithRect(const FloatRect& lineExtents);
74 bool m_paintSelectedTextOnly;
75 bool m_paintSelectedTextSeparately;
77 int m_startPositionInTextRun;
78 int m_endPositionInTextRun;
80 const AtomicString& m_emphasisMark;
81 RenderCombineText* m_combinedText;
84 FloatPoint m_textOrigin;
85 int m_emphasisMarkOffset;
86 bool m_textBoxIsHorizontal;
87 SavedDrawingStateForMask m_savedDrawingStateForMask;
90 } // namespace WebCore
92 #endif // TextPainter_h