Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: Source/core/rendering/InlineTextBox.h

Issue 620243002: Move painting code from InlineTextBox to InlineTextBoxPainter. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Finished. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2000 Dirk Mueller (mueller@kde.org) 3 * (C) 2000 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 4 * Copyright (C) 2004, 2005, 2006, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL; 83 virtual int baselinePosition(FontBaseline) const OVERRIDE FINAL;
84 virtual LayoutUnit lineHeight() const OVERRIDE FINAL; 84 virtual LayoutUnit lineHeight() const OVERRIDE FINAL;
85 85
86 bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const; 86 bool getEmphasisMarkPosition(RenderStyle*, TextEmphasisPosition&) const;
87 87
88 LayoutRect logicalOverflowRect() const; 88 LayoutRect logicalOverflowRect() const;
89 void setLogicalOverflowRect(const LayoutRect&); 89 void setLogicalOverflowRect(const LayoutRect&);
90 LayoutUnit logicalTopVisualOverflow() const { return logicalOverflowRect().y (); } 90 LayoutUnit logicalTopVisualOverflow() const { return logicalOverflowRect().y (); }
91 LayoutUnit logicalBottomVisualOverflow() const { return logicalOverflowRect( ).maxY(); } 91 LayoutUnit logicalBottomVisualOverflow() const { return logicalOverflowRect( ).maxY(); }
92 92
93 // charactersWithHyphen, if provided, must not be destroyed before the TextR un.
94 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const;
95 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const;
96
93 #ifndef NDEBUG 97 #ifndef NDEBUG
94 virtual void showBox(int = 0) const OVERRIDE; 98 virtual void showBox(int = 0) const OVERRIDE;
95 virtual const char* boxName() const OVERRIDE; 99 virtual const char* boxName() const OVERRIDE;
96 #endif 100 #endif
97 101
98 enum RotationDirection { Counterclockwise, Clockwise }; 102 enum RotationDirection { Counterclockwise, Clockwise };
99 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection) ; 103 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection) ;
100 private: 104 private:
101 LayoutUnit selectionTop(); 105 LayoutUnit selectionTop();
jbroman 2014/10/03 17:46:17 This is missing an implementation. Did you mean t
chrishtr 2014/10/03 18:10:37 Fixed.
102 LayoutUnit selectionBottom();
103 LayoutUnit selectionHeight();
104
105 // charactersWithHyphen, if provided, must not be destroyed before the TextR un.
106 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const;
107 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const;
108 106
109 public: 107 public:
110 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const; 108 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const;
111 virtual FloatRect calculateBoundaries() const OVERRIDE { return FloatRect(x( ), y(), width(), height()); } 109 virtual FloatRect calculateBoundaries() const OVERRIDE { return FloatRect(x( ), y(), width(), height()); }
112 110
113 virtual LayoutRect localSelectionRect(int startPos, int endPos); 111 virtual LayoutRect localSelectionRect(int startPos, int endPos);
114 bool isSelected(int startPos, int endPos) const; 112 bool isSelected(int startPos, int endPos) const;
115 void selectionStartEnd(int& sPos, int& ePos) const; 113 void selectionStartEnd(int& sPos, int& ePos) const;
116 114
115 // These functions both paint markers and update the DocumentMarker's render edRect.
116 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig in, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
117 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri gin, DocumentMarker*, RenderStyle*, const Font&);
118
117 protected: 119 protected:
118 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) OVERRIDE; 120 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) OVERRIDE;
119 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE; 121 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) OVERRIDE;
120 122
121 private: 123 private:
122 virtual void deleteLine() OVERRIDE FINAL; 124 virtual void deleteLine() OVERRIDE FINAL;
123 virtual void extractLine() OVERRIDE FINAL; 125 virtual void extractLine() OVERRIDE FINAL;
124 virtual void attachLine() OVERRIDE FINAL; 126 virtual void attachLine() OVERRIDE FINAL;
125 127
126 public: 128 public:
(...skipping 13 matching lines...) Expand all
140 m_logicalWidth += newExpansion; 142 m_logicalWidth += newExpansion;
141 } 143 }
142 144
143 private: 145 private:
144 virtual bool isInlineTextBox() const OVERRIDE FINAL { return true; } 146 virtual bool isInlineTextBox() const OVERRIDE FINAL { return true; }
145 147
146 public: 148 public:
147 virtual int caretMinOffset() const OVERRIDE FINAL; 149 virtual int caretMinOffset() const OVERRIDE FINAL;
148 virtual int caretMaxOffset() const OVERRIDE FINAL; 150 virtual int caretMaxOffset() const OVERRIDE FINAL;
149 151
150 private:
151 float textPos() const; // returns the x position relative to the left start of the text line. 152 float textPos() const; // returns the x position relative to the left start of the text line.
152 153
153 public: 154 public:
154 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con st; 155 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con st;
155 virtual float positionForOffset(int offset) const; 156 virtual float positionForOffset(int offset) const;
156 157
157 bool containsCaretOffset(int offset) const; // false for offset after line b reak 158 bool containsCaretOffset(int offset) const; // false for offset after line b reak
158 159
159 // Fills a vector with the pixel width of each character. 160 // Fills a vector with the pixel width of each character.
160 void characterWidths(Vector<float>&) const; 161 void characterWidths(Vector<float>&) const;
161 162
162 private: 163 private:
163 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject 164 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject
164 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t 165 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t
165 166
166 int m_start; 167 int m_start;
167 unsigned short m_len; 168 unsigned short m_len;
168 169
169 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to 170 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to
170 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all). 171 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all).
171 172
172 unsigned underlinePaintStart(const CompositionUnderline&);
173 unsigned underlinePaintEnd(const CompositionUnderline&);
174
175 protected:
176 void paintSingleCompositionBackgroundRun(GraphicsContext*, const FloatPoint& boxOrigin, RenderStyle*, const Font&, Color backgroundColor, int startPos, int endPos);
177 void paintCompositionBackgrounds(GraphicsContext*, const FloatPoint& boxOrig in, RenderStyle*, const Font&, bool useCustomUnderlines);
178 void paintDocumentMarkers(GraphicsContext*, const FloatPoint& boxOrigin, Ren derStyle*, const Font&, bool background);
179 void paintCompositionUnderline(GraphicsContext*, const FloatPoint& boxOrigin , const CompositionUnderline&);
180
181 // These functions both paint markers and update the DocumentMarker's render edRect.
182 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig in, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
183 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri gin, DocumentMarker*, RenderStyle*, const Font&);
184
185 private: 173 private:
186 void paintDecoration(GraphicsContext*, const FloatPoint& boxOrigin, TextDeco ration);
187 void paintSelection(GraphicsContext*, const FloatPoint& boxOrigin, RenderSty le*, const Font&, Color textColor);
188
189 TextRun::ExpansionBehavior expansionBehavior() const 174 TextRun::ExpansionBehavior expansionBehavior() const
190 { 175 {
191 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion) 176 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion)
192 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion); 177 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
193 } 178 }
194 }; 179 };
195 180
196 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); 181 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox);
197 182
198 void alignSelectionRectToDevicePixels(FloatRect&); 183 void alignSelectionRectToDevicePixels(FloatRect&);
199 184
200 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio nDirection rotationDirection) 185 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio nDirection rotationDirection)
201 { 186 {
202 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x()) 187 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
203 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY()); 188 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
204 } 189 }
205 190
206 } // namespace blink 191 } // namespace blink
207 192
208 #endif // InlineTextBox_h 193 #endif // InlineTextBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698