]>
git.saurik.com Git - iphone-api.git/blob - WebCore/InlineTextBox.h
2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2009 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.
23 #ifndef InlineTextBox_h
24 #define InlineTextBox_h
26 #include "InlineRunBox.h"
27 #include "RenderText.h" // so textObject() can be inline
31 struct CompositionUnderline
;
33 const unsigned short cNoTruncation
= USHRT_MAX
;
34 const unsigned short cFullTruncation
= USHRT_MAX
- 1;
36 // Helper functions shared by InlineTextBox / SVGRootInlineBox
37 void updateGraphicsContext(GraphicsContext
* context
, const Color
& fillColor
, const Color
& strokeColor
, float strokeThickness
);
38 Color
correctedTextColor(Color textColor
, Color backgroundColor
);
40 class InlineTextBox
: public InlineRunBox
{
42 InlineTextBox(RenderObject
* obj
)
46 , m_truncation(cNoTruncation
)
50 InlineTextBox
* nextTextBox() const { return static_cast<InlineTextBox
*>(nextLineBox()); }
51 InlineTextBox
* prevTextBox() const { return static_cast<InlineTextBox
*>(prevLineBox()); }
53 unsigned start() const { return m_start
; }
54 unsigned end() const { return m_len
? m_start
+ m_len
- 1 : m_start
; }
55 unsigned len() const { return m_len
; }
57 void setStart(unsigned start
) { m_start
= start
; }
58 void setLen(unsigned len
) { m_len
= len
; }
60 void offsetRun(int d
) { m_start
+= d
; }
63 virtual int selectionTop();
64 virtual int selectionHeight();
67 virtual IntRect
selectionRect(int absx
, int absy
, int startPos
, int endPos
);
68 bool isSelected(int startPos
, int endPos
) const;
69 void selectionStartEnd(int& sPos
, int& ePos
);
72 virtual void paint(RenderObject::PaintInfo
&, int tx
, int ty
);
73 virtual bool nodeAtPoint(const HitTestRequest
&, HitTestResult
&, int x
, int y
, int tx
, int ty
);
76 RenderText
* textObject() const;
79 virtual void deleteLine(RenderArena
*);
80 virtual void extractLine();
81 virtual void attachLine();
84 virtual RenderObject::SelectionState
selectionState();
87 virtual void clearTruncation() { m_truncation
= cNoTruncation
; }
88 virtual int placeEllipsisBox(bool ltr
, int blockEdge
, int ellipsisWidth
, bool& foundBox
);
91 virtual bool isLineBreak() const;
93 void setSpaceAdd(int add
) { m_width
-= m_toAdd
; m_toAdd
= add
; m_width
+= m_toAdd
; }
96 virtual bool isInlineTextBox() { return true; }
99 virtual bool isText() const { return m_treatAsText
; }
100 void setIsText(bool b
) { m_treatAsText
= b
; }
102 virtual int caretMinOffset() const;
103 virtual int caretMaxOffset() const;
106 virtual unsigned caretMaxRenderedOffset() const;
111 virtual int offsetForPosition(int x
, bool includePartialGlyphs
= true) const;
112 virtual int positionForOffset(int offset
) const;
114 bool containsCaretOffset(int offset
) const; // false for offset after line break
118 unsigned short m_len
;
120 unsigned short m_truncation
; // Where to truncate when text overflow is applied. We use special constants to
121 // denote no truncation (the whole run paints) and full truncation (nothing paints at all).
124 void paintCompositionBackground(GraphicsContext
*, int tx
, int ty
, RenderStyle
*, const Font
&, int startPos
, int endPos
);
125 void paintDocumentMarkers(GraphicsContext
*, int tx
, int ty
, RenderStyle
*, const Font
&, bool background
);
126 void paintCompositionUnderline(GraphicsContext
*, int tx
, int ty
, const CompositionUnderline
&);
128 void paintCustomHighlight(int tx
, int ty
, const AtomicString
& type
);
132 void paintDecoration(GraphicsContext
*, int tx
, int ty
, int decoration
, ShadowData
*);
133 void paintSelection(GraphicsContext
*, int tx
, int ty
, RenderStyle
*, const Font
&);
134 void paintSpellingOrGrammarMarker(GraphicsContext
*, int tx
, int ty
, DocumentMarker
, RenderStyle
*, const Font
&, bool grammar
);
135 void paintTextMatchMarker(GraphicsContext
*, int tx
, int ty
, DocumentMarker
, RenderStyle
*, const Font
&);
138 inline RenderText
* InlineTextBox::textObject() const
140 return toRenderText(m_object
);
143 } // namespace WebCore
145 #endif // InlineTextBox_h