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

Side by Side Diff: Source/core/layout/line/InlineTextBox.h

Issue 1043643002: Switch line layout to LayoutUnit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: More TestExpectations tweaks Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/layout/line/InlineFlowBox.cpp ('k') | Source/core/layout/line/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/layout/LayoutText.h" // so textLayoutObject() can be inline 26 #include "core/layout/LayoutText.h" // so textLayoutObject() can be inline
27 #include "core/layout/line/FloatToLayoutUnit.h"
28 #include "core/layout/line/InlineBox.h" 27 #include "core/layout/line/InlineBox.h"
29 #include "platform/text/TextRun.h" 28 #include "platform/text/TextRun.h"
30 #include "wtf/Forward.h" 29 #include "wtf/Forward.h"
31 30
32 namespace blink { 31 namespace blink {
33 32
34 class DocumentMarker; 33 class DocumentMarker;
35 class GraphicsContext; 34 class GraphicsContext;
36 35
37 const unsigned short cNoTruncation = USHRT_MAX; 36 const unsigned short cNoTruncation = USHRT_MAX;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #ifndef NDEBUG 93 #ifndef NDEBUG
95 virtual void showBox(int = 0) const override; 94 virtual void showBox(int = 0) const override;
96 #endif 95 #endif
97 virtual const char* boxName() const override; 96 virtual const char* boxName() const override;
98 virtual String debugName() const override; 97 virtual String debugName() const override;
99 98
100 String text() const; 99 String text() const;
101 100
102 public: 101 public:
103 TextRun constructTextRunForInspector(const ComputedStyle&, const Font&) cons t; 102 TextRun constructTextRunForInspector(const ComputedStyle&, const Font&) cons t;
104 virtual FloatRectWillBeLayoutRect calculateBoundaries() const override { ret urn FloatRectWillBeLayoutRect(x(), y(), width(), height()); } 103 virtual LayoutRect calculateBoundaries() const override { return LayoutRect( x(), y(), width(), height()); }
105 104
106 virtual LayoutRect localSelectionRect(int startPos, int endPos); 105 virtual LayoutRect localSelectionRect(int startPos, int endPos);
107 bool isSelected(int startPos, int endPos) const; 106 bool isSelected(int startPos, int endPos) const;
108 void selectionStartEnd(int& sPos, int& ePos) const; 107 void selectionStartEnd(int& sPos, int& ePos) const;
109 108
110 // These functions both paint markers and update the DocumentMarker's render edRect. 109 // These functions both paint markers and update the DocumentMarker's render edRect.
111 virtual void paintDocumentMarker(GraphicsContext*, const FloatPointWillBeLay outPoint& boxOrigin, DocumentMarker*, const ComputedStyle&, const Font&, bool gr ammar); 110 virtual void paintDocumentMarker(GraphicsContext*, const LayoutPoint& boxOri gin, DocumentMarker*, const ComputedStyle&, const Font&, bool grammar);
112 virtual void paintTextMatchMarker(GraphicsContext*, const FloatPointWillBeLa youtPoint& boxOrigin, DocumentMarker*, const ComputedStyle&, const Font&); 111 virtual void paintTextMatchMarker(GraphicsContext*, const LayoutPoint& boxOr igin, DocumentMarker*, const ComputedStyle&, const Font&);
113 112
114 protected: 113 protected:
115 virtual void paint(const PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override; 114 virtual void paint(const PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, LayoutUnit lineBottom) override;
116 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInCo ntainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit li neBottom) override; 115 virtual bool nodeAtPoint(HitTestResult&, const HitTestLocation& locationInCo ntainer, const LayoutPoint& accumulatedOffset, LayoutUnit lineTop, LayoutUnit li neBottom) override;
117 116
118 private: 117 private:
119 virtual void deleteLine() override final; 118 virtual void deleteLine() override final;
120 virtual void extractLine() override final; 119 virtual void extractLine() override final;
121 virtual void attachLine() override final; 120 virtual void attachLine() override final;
122 121
123 public: 122 public:
124 virtual LayoutObject::SelectionState selectionState() const override final; 123 virtual LayoutObject::SelectionState selectionState() const override final;
125 124
126 private: 125 private:
127 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; } 126 virtual void clearTruncation() override final { m_truncation = cNoTruncation ; }
128 virtual FloatWillBeLayoutUnit placeEllipsisBox(bool flowIsLTR, FloatWillBeLa youtUnit visibleLeftEdge, FloatWillBeLayoutUnit visibleRightEdge, FloatWillBeLay outUnit ellipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool& foundBox) ov erride final; 127 virtual LayoutUnit placeEllipsisBox(bool flowIsLTR, LayoutUnit visibleLeftEd ge, LayoutUnit visibleRightEdge, LayoutUnit ellipsisWidth, LayoutUnit &truncated Width, bool& foundBox) override final;
129 128
130 public: 129 public:
131 virtual bool isLineBreak() const override final; 130 virtual bool isLineBreak() const override final;
132 131
133 void setExpansion(int newExpansion) 132 void setExpansion(int newExpansion)
134 { 133 {
135 m_logicalWidth -= expansion(); 134 m_logicalWidth -= expansion();
136 InlineBox::setExpansion(newExpansion); 135 InlineBox::setExpansion(newExpansion);
137 m_logicalWidth += newExpansion; 136 m_logicalWidth += newExpansion;
138 } 137 }
139 138
140 private: 139 private:
141 virtual bool isInlineTextBox() const override final { return true; } 140 virtual bool isInlineTextBox() const override final { return true; }
142 141
143 public: 142 public:
144 virtual int caretMinOffset() const override final; 143 virtual int caretMinOffset() const override final;
145 virtual int caretMaxOffset() const override final; 144 virtual int caretMaxOffset() const override final;
146 145
147 FloatWillBeLayoutUnit textPos() const; // returns the x position relative to the left start of the text line. 146 LayoutUnit textPos() const; // returns the x position relative to the left s tart of the text line.
148 147
149 public: 148 public:
150 virtual int offsetForPosition(FloatWillBeLayoutUnit x, bool includePartialGl yphs = true) const; 149 virtual int offsetForPosition(LayoutUnit x, bool includePartialGlyphs = true ) const;
151 virtual FloatWillBeLayoutUnit positionForOffset(int offset) const; 150 virtual LayoutUnit positionForOffset(int offset) const;
152 151
153 bool containsCaretOffset(int offset) const; // false for offset after line b reak 152 bool containsCaretOffset(int offset) const; // false for offset after line b reak
154 153
155 // Fills a vector with the pixel width of each character. 154 // Fills a vector with the pixel width of each character.
156 void characterWidths(Vector<FloatWillBeLayoutUnit>&) const; 155 void characterWidths(Vector<float>&) const;
157 156
158 private: 157 private:
159 InlineTextBox* m_prevTextBox; // The previous box that also uses our LayoutO bject 158 InlineTextBox* m_prevTextBox; // The previous box that also uses our LayoutO bject
160 InlineTextBox* m_nextTextBox; // The next box that also uses our LayoutObjec t 159 InlineTextBox* m_nextTextBox; // The next box that also uses our LayoutObjec t
161 160
162 int m_start; 161 int m_start;
163 unsigned short m_len; 162 unsigned short m_len;
164 163
165 // Where to truncate when text overflow is applied. We use special constant s to denote 164 // Where to truncate when text overflow is applied. We use special constant s to denote
166 // no truncation (the whole run paints) and full truncation (nothing paints at all). 165 // no truncation (the whole run paints) and full truncation (nothing paints at all).
167 unsigned short m_truncation; 166 unsigned short m_truncation;
168 167
169 private: 168 private:
170 TextRun::ExpansionBehavior expansionBehavior() const 169 TextRun::ExpansionBehavior expansionBehavior() const
171 { 170 {
172 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion) 171 return (canHaveLeadingExpansion() ? TextRun::AllowLeadingExpansion : Tex tRun::ForbidLeadingExpansion)
173 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion); 172 | (expansion() && nextLeafChild() ? TextRun::AllowTrailingExpansion : TextRun::ForbidTrailingExpansion);
174 } 173 }
175 }; 174 };
176 175
177 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox); 176 DEFINE_INLINE_BOX_TYPE_CASTS(InlineTextBox);
178 177
179 void alignSelectionRectToDevicePixels(FloatRectWillBeLayoutRect&); 178 void alignSelectionRectToDevicePixels(LayoutRect&);
180 179
181 } // namespace blink 180 } // namespace blink
182 181
183 #endif // InlineTextBox_h 182 #endif // InlineTextBox_h
OLDNEW
« no previous file with comments | « Source/core/layout/line/InlineFlowBox.cpp ('k') | Source/core/layout/line/InlineTextBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698