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

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

Issue 699683002: Continue with InlineBox float->LayoutUnit migration. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
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 *
11 * This library is distributed in the hope that it will be useful, 11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details. 14 * Library General Public License for more details.
15 * 15 *
16 * You should have received a copy of the GNU Library General Public License 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 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, 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02110-1301, USA. 19 * Boston, MA 02110-1301, USA.
20 * 20 *
21 */ 21 */
22 22
23 #ifndef InlineTextBox_h 23 #ifndef InlineTextBox_h
24 #define InlineTextBox_h 24 #define InlineTextBox_h
25 25
26 #include "core/rendering/FloatToLayoutUnit.h"
26 #include "core/rendering/InlineBox.h" 27 #include "core/rendering/InlineBox.h"
27 #include "core/rendering/RenderText.h" // so textRenderer() can be inline 28 #include "core/rendering/RenderText.h" // so textRenderer() can be inline
28 #include "platform/fonts/TextBlob.h" 29 #include "platform/fonts/TextBlob.h"
29 #include "platform/text/TextRun.h" 30 #include "platform/text/TextRun.h"
30 #include "wtf/Forward.h" 31 #include "wtf/Forward.h"
31 32
32 namespace blink { 33 namespace blink {
33 34
34 struct CompositionUnderline; 35 struct CompositionUnderline;
35 class DocumentMarker; 36 class DocumentMarker;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // charactersWithHyphen, if provided, must not be destroyed before the TextR un. 92 // charactersWithHyphen, if provided, must not be destroyed before the TextR un.
92 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const; 93 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const;
93 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const; 94 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const;
94 95
95 #ifndef NDEBUG 96 #ifndef NDEBUG
96 virtual void showBox(int = 0) const override; 97 virtual void showBox(int = 0) const override;
97 virtual const char* boxName() const override; 98 virtual const char* boxName() const override;
98 #endif 99 #endif
99 100
100 enum RotationDirection { Counterclockwise, Clockwise }; 101 enum RotationDirection { Counterclockwise, Clockwise };
101 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection) ; 102 static AffineTransform rotation(const FloatRectWillBeLayoutRect& boxRect, Ro tationDirection);
102 103
103 public: 104 public:
104 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const; 105 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const;
105 virtual FloatRect calculateBoundaries() const override { return FloatRect(x( ), y(), width(), height()); } 106 virtual FloatRectWillBeLayoutRect calculateBoundaries() const override { ret urn FloatRectWillBeLayoutRect(x(), y(), width(), height()); }
106 107
107 virtual LayoutRect localSelectionRect(int startPos, int endPos); 108 virtual LayoutRect localSelectionRect(int startPos, int endPos);
108 bool isSelected(int startPos, int endPos) const; 109 bool isSelected(int startPos, int endPos) const;
109 void selectionStartEnd(int& sPos, int& ePos) const; 110 void selectionStartEnd(int& sPos, int& ePos) const;
110 111
111 // These functions both paint markers and update the DocumentMarker's render edRect. 112 // These functions both paint markers and update the DocumentMarker's render edRect.
112 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig in, DocumentMarker*, RenderStyle*, const Font&, bool grammar); 113 virtual void paintDocumentMarker(GraphicsContext*, const FloatPointWillBeLay outPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
113 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri gin, DocumentMarker*, RenderStyle*, const Font&); 114 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPointWillBeLa youtPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
114 115
115 protected: 116 protected:
116 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override; 117 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override;
117 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) override; 118 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) override;
118 119
119 private: 120 private:
120 virtual void deleteLine() override final; 121 virtual void deleteLine() override final;
121 virtual void extractLine() override final; 122 virtual void extractLine() override final;
122 virtual void attachLine() override final; 123 virtual void attachLine() override final;
123 124
124 public: 125 public:
125 virtual RenderObject::SelectionState selectionState() const override final; 126 virtual RenderObject::SelectionState selectionState() const override final;
126 127
127 private: 128 private:
128 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; } 129 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; }
129 virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) ov erride final; 130 virtual FloatWillBeLayoutUnit placeEllipsisBox(bool flowIsLTR, FloatWillBeLa youtUnit visibleLeftEdge, FloatWillBeLayoutUnit visibleRightEdge, FloatWillBeLay outUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) ov erride final;
130 131
131 public: 132 public:
132 virtual bool isLineBreak() const override final; 133 virtual bool isLineBreak() const override final;
133 134
134 void setExpansion(int newExpansion) 135 void setExpansion(int newExpansion)
135 { 136 {
136 m_logicalWidth -= expansion(); 137 m_logicalWidth -= expansion();
137 InlineBox::setExpansion(newExpansion); 138 InlineBox::setExpansion(newExpansion);
138 m_logicalWidth += newExpansion; 139 m_logicalWidth += newExpansion;
139 } 140 }
140 141
141 private: 142 private:
142 virtual bool isInlineTextBox() const override final { return true; } 143 virtual bool isInlineTextBox() const override final { return true; }
143 144
144 public: 145 public:
145 virtual int caretMinOffset() const override final; 146 virtual int caretMinOffset() const override final;
146 virtual int caretMaxOffset() const override final; 147 virtual int caretMaxOffset() const override final;
147 148
148 float textPos() const; // returns the x position relative to the left start of the text line. 149 FloatWillBeLayoutUnit textPos() const; // returns the x position relative to the left start of the text line.
149 150
150 public: 151 public:
151 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con st; 152 virtual int offsetForPosition(FloatWillBeLayoutUnit x, bool includePartialGl yphs = true) const;
152 virtual float positionForOffset(int offset) const; 153 virtual FloatWillBeLayoutUnit positionForOffset(int offset) const;
153 154
154 bool containsCaretOffset(int offset) const; // false for offset after line b reak 155 bool containsCaretOffset(int offset) const; // false for offset after line b reak
155 156
156 // Fills a vector with the pixel width of each character. 157 // Fills a vector with the pixel width of each character.
157 void characterWidths(Vector<float>&) const; 158 void characterWidths(Vector<FloatWillBeLayoutUnit>&) const;
158 159
159 private: 160 private:
160 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject 161 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject
161 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t 162 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t
162 163
163 int m_start; 164 int m_start;
164 unsigned short m_len; 165 unsigned short m_len;
165 166
166 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to 167 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to
167 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all). 168 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all).
168 169
169 private: 170 private:
170 TextRun::ExpansionBehavior expansionBehavior() const 171 TextRun::ExpansionBehavior expansionBehavior() const
171 { 172 {
172 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion) 173 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion)
173 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion); 174 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
174 } 175 }
175 }; 176 };
176 177
177 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); 178 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox);
178 179
179 void alignSelectionRectToDevicePixels(FloatRect&); 180 void alignSelectionRectToDevicePixels(FloatRectWillBeLayoutRect&);
180 181
181 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio nDirection rotationDirection) 182 inline AffineTransform InlineTextBox::rotation(const FloatRectWillBeLayoutRect& boxRect, RotationDirection rotationDirection)
182 { 183 {
183 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x()) 184 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
184 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY()); 185 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
185 } 186 }
186 187
187 } // namespace blink 188 } // namespace blink
188 189
189 #endif // InlineTextBox_h 190 #endif // InlineTextBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698