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

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: nit 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
« no previous file with comments | « Source/core/rendering/InlineFlowBox.cpp ('k') | Source/core/rendering/InlineTextBox.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class DocumentMarker; 35 class DocumentMarker;
35 class GraphicsContext; 36 class GraphicsContext;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 // charactersWithHyphen, if provided, must not be destroyed before the TextR un. 91 // charactersWithHyphen, if provided, must not be destroyed before the TextR un.
91 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const; 92 TextRun constructTextRun(RenderStyle*, const Font&, StringBuilder* character sWithHyphen = 0) const;
92 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const; 93 TextRun constructTextRun(RenderStyle*, const Font&, StringView, int maximumL ength, StringBuilder* charactersWithHyphen = 0) const;
93 94
94 #ifndef NDEBUG 95 #ifndef NDEBUG
95 virtual void showBox(int = 0) const override; 96 virtual void showBox(int = 0) const override;
96 virtual const char* boxName() const override; 97 virtual const char* boxName() const override;
97 #endif 98 #endif
98 99
99 enum RotationDirection { Counterclockwise, Clockwise }; 100 enum RotationDirection { Counterclockwise, Clockwise };
100 static AffineTransform rotation(const FloatRect& boxRect, RotationDirection) ; 101 static AffineTransform rotation(const FloatRectWillBeLayoutRect& boxRect, Ro tationDirection);
101 102
102 public: 103 public:
103 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const; 104 TextRun constructTextRunForInspector(RenderStyle*, const Font&) const;
104 virtual FloatRect calculateBoundaries() const override { return FloatRect(x( ), y(), width(), height()); } 105 virtual FloatRectWillBeLayoutRect calculateBoundaries() const override { ret urn FloatRectWillBeLayoutRect(x(), y(), width(), height()); }
105 106
106 virtual LayoutRect localSelectionRect(int startPos, int endPos); 107 virtual LayoutRect localSelectionRect(int startPos, int endPos);
107 bool isSelected(int startPos, int endPos) const; 108 bool isSelected(int startPos, int endPos) const;
108 void selectionStartEnd(int& sPos, int& ePos) const; 109 void selectionStartEnd(int& sPos, int& ePos) const;
109 110
110 // These functions both paint markers and update the DocumentMarker's render edRect. 111 // These functions both paint markers and update the DocumentMarker's render edRect.
111 virtual void paintDocumentMarker(GraphicsContext*, const FloatPoint& boxOrig in, DocumentMarker*, RenderStyle*, const Font&, bool grammar); 112 virtual void paintDocumentMarker(GraphicsContext*, const FloatPointWillBeLay outPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&, bool grammar);
112 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPoint& boxOri gin, DocumentMarker*, RenderStyle*, const Font&); 113 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPointWillBeLa youtPoint& boxOrigin, DocumentMarker*, RenderStyle*, const Font&);
113 114
114 protected: 115 protected:
115 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override; 116 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override;
116 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) override; 117 virtual bool nodeAtPoint(const HitTestRequest&, HitTestResult&, const HitTes tLocation& locationInContainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit lineBottom) override;
117 118
118 private: 119 private:
119 virtual void deleteLine() override final; 120 virtual void deleteLine() override final;
120 virtual void extractLine() override final; 121 virtual void extractLine() override final;
121 virtual void attachLine() override final; 122 virtual void attachLine() override final;
122 123
123 public: 124 public:
124 virtual RenderObject::SelectionState selectionState() const override final; 125 virtual RenderObject::SelectionState selectionState() const override final;
125 126
126 private: 127 private:
127 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; } 128 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; }
128 virtual float placeEllipsisBox(bool flowIsLTR, float visibleLeftEdge, float visibleRightEdge, float ellipsisWidth, float &truncatedWidth, bool& foundBox) ov erride final; 129 virtual FloatWillBeLayoutUnit placeEllipsisBox(bool flowIsLTR, FloatWillBeLa youtUnit visibleLeftEdge, FloatWillBeLayoutUnit visibleRightEdge, FloatWillBeLay outUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) ov erride final;
129 130
130 public: 131 public:
131 virtual bool isLineBreak() const override final; 132 virtual bool isLineBreak() const override final;
132 133
133 void setExpansion(int newExpansion) 134 void setExpansion(int newExpansion)
134 { 135 {
135 m_logicalWidth -= expansion(); 136 m_logicalWidth -= expansion();
136 InlineBox::setExpansion(newExpansion); 137 InlineBox::setExpansion(newExpansion);
137 m_logicalWidth += newExpansion; 138 m_logicalWidth += newExpansion;
138 } 139 }
139 140
140 private: 141 private:
141 virtual bool isInlineTextBox() const override final { return true; } 142 virtual bool isInlineTextBox() const override final { return true; }
142 143
143 public: 144 public:
144 virtual int caretMinOffset() const override final; 145 virtual int caretMinOffset() const override final;
145 virtual int caretMaxOffset() const override final; 146 virtual int caretMaxOffset() const override final;
146 147
147 float textPos() const; // returns the x position relative to the left start of the text line. 148 FloatWillBeLayoutUnit textPos() const; // returns the x position relative to the left start of the text line.
148 149
149 public: 150 public:
150 virtual int offsetForPosition(float x, bool includePartialGlyphs = true) con st; 151 virtual int offsetForPosition(FloatWillBeLayoutUnit x, bool includePartialGl yphs = true) const;
151 virtual float positionForOffset(int offset) const; 152 virtual FloatWillBeLayoutUnit positionForOffset(int offset) const;
152 153
153 bool containsCaretOffset(int offset) const; // false for offset after line b reak 154 bool containsCaretOffset(int offset) const; // false for offset after line b reak
154 155
155 // Fills a vector with the pixel width of each character. 156 // Fills a vector with the pixel width of each character.
156 void characterWidths(Vector<float>&) const; 157 void characterWidths(Vector<FloatWillBeLayoutUnit>&) const;
157 158
158 private: 159 private:
159 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject 160 InlineTextBox* m_prevTextBox; // The previous box that also uses our RenderO bject
160 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t 161 InlineTextBox* m_nextTextBox; // The next box that also uses our RenderObjec t
161 162
162 int m_start; 163 int m_start;
163 unsigned short m_len; 164 unsigned short m_len;
164 165
165 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to 166 unsigned short m_truncation; // Where to truncate when text overflow is appl ied. We use special constants to
166 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all). 167 // denote no truncation (the whole run paints) and full tr uncation (nothing paints at all).
167 168
168 private: 169 private:
169 TextRun::ExpansionBehavior expansionBehavior() const 170 TextRun::ExpansionBehavior expansionBehavior() const
170 { 171 {
171 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion) 172 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion)
172 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion); 173 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
173 } 174 }
174 }; 175 };
175 176
176 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); 177 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox);
177 178
178 void alignSelectionRectToDevicePixels(FloatRect&); 179 void alignSelectionRectToDevicePixels(FloatRectWillBeLayoutRect&);
179 180
180 inline AffineTransform InlineTextBox::rotation(const FloatRect& boxRect, Rotatio nDirection rotationDirection) 181 inline AffineTransform InlineTextBox::rotation(const FloatRectWillBeLayoutRect& boxRect, RotationDirection rotationDirection)
181 { 182 {
182 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x()) 183 return rotationDirection == Clockwise ? AffineTransform(0, 1, -1, 0, boxRect .x() + boxRect.maxY(), boxRect.maxY() - boxRect.x())
183 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY()); 184 : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
184 } 185 }
185 186
186 } // namespace blink 187 } // namespace blink
187 188
188 #endif // InlineTextBox_h 189 #endif // InlineTextBox_h
OLDNEW
« no previous file with comments | « Source/core/rendering/InlineFlowBox.cpp ('k') | Source/core/rendering/InlineTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698