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 "RenderText.h"
31 class RenderCombineText;
33 struct TextPaintStyle;
35 enum RotationDirection { Counterclockwise, Clockwise };
37 static inline AffineTransform rotation(const FloatRect& boxRect, RotationDirection clockwise)
39 return clockwise ? AffineTransform(0, 1, -1, 0, boxRect.x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
40 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
43 struct SavedDrawingStateForMask {
44 SavedDrawingStateForMask(GraphicsContext* context, TextPaintStyle* textPaintStyle, TextPaintStyle* selectionPaintStyle,
45 const ShadowData* textShadow, const ShadowData* selectionShadow)
47 , m_textPaintStyle(textPaintStyle)
48 , m_selectionPaintStyle(selectionPaintStyle)
49 , m_textShadow(textShadow)
50 , m_selectionShadow(selectionShadow)
53 GraphicsContext* m_context;
54 TextPaintStyle* m_textPaintStyle;
55 TextPaintStyle* m_selectionPaintStyle;
56 const ShadowData* m_textShadow;
57 const ShadowData* m_selectionShadow;
62 TextPainter(GraphicsContext&, bool paintSelectedTextOnly, bool paintSelectedTextSeparately, const Font&,
63 int startPositionInTextRun, int endPositionInTextBoxString, int length, const AtomicString& emphasisMark, RenderCombineText*,
64 TextRun&, FloatRect& boxRect, FloatPoint& textOrigin, int emphasisMarkOffset, const ShadowData* textShadow, const ShadowData* selectionShadow,
65 bool textBoxIsHorizontal, TextPaintStyle& nonSelectionPaintStyle, TextPaintStyle& selectionPaintStyle);
67 const FloatRect& boxRect() const { return m_boxRect; }
69 void paintTextInContext(GraphicsContext&, float amountToIncreaseStrokeWidthBy);
72 bool m_paintSelectedTextOnly;
73 bool m_paintSelectedTextSeparately;
75 int m_startPositionInTextRun;
76 int m_endPositionInTextRun;
78 const AtomicString& m_emphasisMark;
79 RenderCombineText* m_combinedText;
82 FloatPoint& m_textOrigin;
83 int m_emphasisMarkOffset;
84 bool m_textBoxIsHorizontal;
85 SavedDrawingStateForMask m_savedDrawingStateForMask;
88 } // namespace WebCore
90 #endif // TextPainter_h