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

Side by Side Diff: Source/core/rendering/InlineFlowBox.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 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 * 18 *
19 */ 19 */
20 20
21 #ifndef InlineFlowBox_h 21 #ifndef InlineFlowBox_h
22 #define InlineFlowBox_h 22 #define InlineFlowBox_h
23 23
24 #include "core/rendering/FloatToLayoutUnit.h"
24 #include "core/rendering/InlineBox.h" 25 #include "core/rendering/InlineBox.h"
25 #include "core/rendering/RenderObjectInlines.h" 26 #include "core/rendering/RenderObjectInlines.h"
26 #include "core/rendering/RenderOverflow.h" 27 #include "core/rendering/RenderOverflow.h"
27 #include "core/rendering/style/ShadowData.h" 28 #include "core/rendering/style/ShadowData.h"
28 29
29 namespace blink { 30 namespace blink {
30 31
31 class HitTestRequest; 32 class HitTestRequest;
32 class HitTestResult; 33 class HitTestResult;
33 class InlineTextBox; 34 class InlineTextBox;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 { 99 {
99 InlineBox::setConstructed(); 100 InlineBox::setConstructed();
100 for (InlineBox* child = firstChild(); child; child = child->nextOnLine() ) 101 for (InlineBox* child = firstChild(); child; child = child->nextOnLine() )
101 child->setConstructed(); 102 child->setConstructed();
102 } 103 }
103 104
104 void addToLine(InlineBox* child); 105 void addToLine(InlineBox* child);
105 virtual void deleteLine() override final; 106 virtual void deleteLine() override final;
106 virtual void extractLine() override final; 107 virtual void extractLine() override final;
107 virtual void attachLine() override final; 108 virtual void attachLine() override final;
108 virtual void adjustPosition(float dx, float dy) override; 109 virtual void adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit dy) override;
109 110
110 virtual void extractLineBoxFromRenderObject(); 111 virtual void extractLineBoxFromRenderObject();
111 virtual void attachLineBoxToRenderObject(); 112 virtual void attachLineBoxToRenderObject();
112 virtual void removeLineBoxFromRenderObject(); 113 virtual void removeLineBoxFromRenderObject();
113 114
114 virtual void clearTruncation() override; 115 virtual void clearTruncation() override;
115 116
116 IntRect roundedFrameRect() const; 117 IntRect roundedFrameRect() const;
117 118
118 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override; 119 virtual void paint(PaintInfo&, const LayoutPoint&, LayoutUnit lineTop, Layou tUnit lineBottom) override;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 bool includeLogicalRightEdge() const { return m_includeLogicalRightEdge; } 167 bool includeLogicalRightEdge() const { return m_includeLogicalRightEdge; }
167 void setEdges(bool includeLeft, bool includeRight) 168 void setEdges(bool includeLeft, bool includeRight)
168 { 169 {
169 m_includeLogicalLeftEdge = includeLeft; 170 m_includeLogicalLeftEdge = includeLeft;
170 m_includeLogicalRightEdge = includeRight; 171 m_includeLogicalRightEdge = includeRight;
171 } 172 }
172 173
173 // Helper functions used during line construction and placement. 174 // Helper functions used during line construction and placement.
174 void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrap ped, RenderObject* logicallyLastRunRenderer); 175 void determineSpacingForFlowBoxes(bool lastLine, bool isLogicallyLastRunWrap ped, RenderObject* logicallyLastRunRenderer);
175 LayoutUnit getFlowSpacingLogicalWidth(); 176 LayoutUnit getFlowSpacingLogicalWidth();
176 float placeBoxesInInlineDirection(float logicalLeft, bool& needsWordSpacing) ; 177 FloatWillBeLayoutUnit placeBoxesInInlineDirection(FloatWillBeLayoutUnit logi calLeft, bool& needsWordSpacing);
177 float placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastC hild, 178 FloatWillBeLayoutUnit placeBoxRangeInInlineDirection(InlineBox* firstChild, InlineBox* lastChild,
178 float& logicalLeft, float& minLogicalLeft, float& maxLogicalRight, bool& needsWordSpacing); 179 FloatWillBeLayoutUnit& logicalLeft, FloatWillBeLayoutUnit& minLogicalLef t, FloatWillBeLayoutUnit& maxLogicalRight, bool& needsWordSpacing);
179 void beginPlacingBoxRangesInInlineDirection(float logicalLeft) { setLogicalL eft(logicalLeft); } 180 void beginPlacingBoxRangesInInlineDirection(FloatWillBeLayoutUnit logicalLef t) { setLogicalLeft(logicalLeft); }
180 void endPlacingBoxRangesInInlineDirection(float logicalLeft, float logicalRi ght, float minLogicalLeft, float maxLogicalRight) 181 void endPlacingBoxRangesInInlineDirection(FloatWillBeLayoutUnit logicalLeft, FloatWillBeLayoutUnit logicalRight, FloatWillBeLayoutUnit minLogicalLeft, Float WillBeLayoutUnit maxLogicalRight)
181 { 182 {
182 setLogicalWidth(logicalRight - logicalLeft); 183 setLogicalWidth(logicalRight - logicalLeft);
183 if (knownToHaveNoOverflow() && (minLogicalLeft < logicalLeft || maxLogic alRight > logicalRight)) 184 if (knownToHaveNoOverflow() && (minLogicalLeft < logicalLeft || maxLogic alRight > logicalRight))
184 clearKnownToHaveNoOverflow(); 185 clearKnownToHaveNoOverflow();
185 } 186 }
186 187
187 void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, La youtUnit& maxPositionBottom, 188 void computeLogicalBoxHeights(RootInlineBox*, LayoutUnit& maxPositionTop, La youtUnit& maxPositionBottom,
188 int& maxAscent, int& maxDescent, bool& setMaxA scent, bool& setMaxDescent, 189 int& maxAscent, int& maxDescent, bool& setMaxA scent, bool& setMaxDescent,
189 bool strictMode, GlyphOverflowAndFallbackFonts Map&, FontBaseline, VerticalPositionCache&); 190 bool strictMode, GlyphOverflowAndFallbackFonts Map&, FontBaseline, VerticalPositionCache&);
190 void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent, 191 void adjustMaxAscentAndDescent(int& maxAscent, int& maxDescent,
191 int maxPositionTop, int maxPositionBottom); 192 int maxPositionTop, int maxPositionBottom);
192 void placeBoxesInBlockDirection(LayoutUnit logicalTop, LayoutUnit maxHeight, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, La youtUnit& selectionBottom, bool& setLineTop, 193 void placeBoxesInBlockDirection(LayoutUnit logicalTop, LayoutUnit maxHeight, int maxAscent, bool strictMode, LayoutUnit& lineTop, LayoutUnit& lineBottom, La youtUnit& selectionBottom, bool& setLineTop,
193 LayoutUnit& lineTopIncludingMargins, LayoutU nit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotation sAfter, FontBaseline); 194 LayoutUnit& lineTopIncludingMargins, LayoutU nit& lineBottomIncludingMargins, bool& hasAnnotationsBefore, bool& hasAnnotation sAfter, FontBaseline);
194 void flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lineBottom); 195 void flipLinesInBlockDirection(LayoutUnit lineTop, LayoutUnit lineBottom);
195 bool requiresIdeographicBaseline(const GlyphOverflowAndFallbackFontsMap&) co nst; 196 bool requiresIdeographicBaseline(const GlyphOverflowAndFallbackFontsMap&) co nst;
196 197
197 LayoutUnit computeOverAnnotationAdjustment(LayoutUnit allowedPosition) const ; 198 LayoutUnit computeOverAnnotationAdjustment(LayoutUnit allowedPosition) const ;
198 LayoutUnit computeUnderAnnotationAdjustment(LayoutUnit allowedPosition) cons t; 199 LayoutUnit computeUnderAnnotationAdjustment(LayoutUnit allowedPosition) cons t;
199 200
200 void computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, GlyphOverflo wAndFallbackFontsMap&); 201 void computeOverflow(LayoutUnit lineTop, LayoutUnit lineBottom, GlyphOverflo wAndFallbackFontsMap&);
201 202
202 void removeChild(InlineBox* child, MarkLineBoxes); 203 void removeChild(InlineBox* child, MarkLineBoxes);
203 204
204 virtual RenderObject::SelectionState selectionState() const override; 205 virtual RenderObject::SelectionState selectionState() const override;
205 206
206 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWid th) const override final; 207 virtual bool canAccommodateEllipsis(bool ltr, int blockEdge, int ellipsisWid th) const override final;
207 virtual float placeEllipsisBox(bool ltr, float blockLeftEdge, float blockRig htEdge, float ellipsisWidth, float &truncatedWidth, bool&) override; 208 virtual FloatWillBeLayoutUnit placeEllipsisBox(bool ltr, FloatWillBeLayoutUn it blockLeftEdge, FloatWillBeLayoutUnit blockRightEdge, FloatWillBeLayoutUnit el lipsisWidth, FloatWillBeLayoutUnit &truncatedWidth, bool&) override;
208 209
209 bool hasTextChildren() const { return m_hasTextChildren; } 210 bool hasTextChildren() const { return m_hasTextChildren; }
210 bool hasTextDescendants() const { return m_hasTextDescendants; } 211 bool hasTextDescendants() const { return m_hasTextDescendants; }
211 void setHasTextDescendants() { m_hasTextDescendants = true; } 212 void setHasTextDescendants() { m_hasTextDescendants = true; }
212 213
213 void checkConsistency() const; 214 void checkConsistency() const;
214 void setHasBadChildList(); 215 void setHasBadChildList();
215 216
216 // Line visual and layout overflow are in the coordinate space of the block. This means that they aren't purely physical directions. 217 // Line visual and layout overflow are in the coordinate space of the block. This means that they aren't purely physical directions.
217 // For horizontal-tb and vertical-lr they will match physical directions, bu t for horizontal-bt and vertical-rl, the top/bottom and left/right 218 // For horizontal-tb and vertical-lr they will match physical directions, bu t for horizontal-bt and vertical-rl, the top/bottom and left/right
(...skipping 20 matching lines...) Expand all
238 if (!renderer().isHorizontalWritingMode()) 239 if (!renderer().isHorizontalWritingMode())
239 result = result.transposedRect(); 240 result = result.transposedRect();
240 return result; 241 return result;
241 } 242 }
242 243
243 LayoutRect visualOverflowRect(LayoutUnit lineTop, LayoutUnit lineBottom) con st 244 LayoutRect visualOverflowRect(LayoutUnit lineTop, LayoutUnit lineBottom) con st
244 { 245 {
245 return m_overflow ? m_overflow->visualOverflowRect() : enclosingLayoutRe ct(frameRectIncludingLineHeight(lineTop, lineBottom)); 246 return m_overflow ? m_overflow->visualOverflowRect() : enclosingLayoutRe ct(frameRectIncludingLineHeight(lineTop, lineBottom));
246 } 247 }
247 LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizo ntal() ? m_overflow->visualOverflowRect().x() : m_overflow->visualOverflowRect() .y()) : static_cast<LayoutUnit>(logicalLeft()); } 248 LayoutUnit logicalLeftVisualOverflow() const { return m_overflow ? (isHorizo ntal() ? m_overflow->visualOverflowRect().x() : m_overflow->visualOverflowRect() .y()) : static_cast<LayoutUnit>(logicalLeft()); }
248 LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHoriz ontal() ? m_overflow->visualOverflowRect().maxX() : m_overflow->visualOverflowRe ct().maxY()) : static_cast<LayoutUnit>(ceilf(logicalRight())); } 249 LayoutUnit logicalRightVisualOverflow() const { return m_overflow ? (isHoriz ontal() ? m_overflow->visualOverflowRect().maxX() : m_overflow->visualOverflowRe ct().maxY()) : static_cast<LayoutUnit>(LAYOUT_UNIT_CEIL(logicalRight())); }
249 LayoutUnit logicalTopVisualOverflow(LayoutUnit lineTop) const 250 LayoutUnit logicalTopVisualOverflow(LayoutUnit lineTop) const
250 { 251 {
251 if (m_overflow) 252 if (m_overflow)
252 return isHorizontal() ? m_overflow->visualOverflowRect().y() : m_ove rflow->visualOverflowRect().x(); 253 return isHorizontal() ? m_overflow->visualOverflowRect().y() : m_ove rflow->visualOverflowRect().x();
253 return lineTop; 254 return lineTop;
254 } 255 }
255 LayoutUnit logicalBottomVisualOverflow(LayoutUnit lineBottom) const 256 LayoutUnit logicalBottomVisualOverflow(LayoutUnit lineBottom) const
256 { 257 {
257 if (m_overflow) 258 if (m_overflow)
258 return isHorizontal() ? m_overflow->visualOverflowRect().maxY() : m_ overflow->visualOverflowRect().maxX(); 259 return isHorizontal() ? m_overflow->visualOverflowRect().maxY() : m_ overflow->visualOverflowRect().maxX();
259 return lineBottom; 260 return lineBottom;
260 } 261 }
261 LayoutRect logicalVisualOverflowRect(LayoutUnit lineTop, LayoutUnit lineBott om) const 262 LayoutRect logicalVisualOverflowRect(LayoutUnit lineTop, LayoutUnit lineBott om) const
262 { 263 {
263 LayoutRect result = visualOverflowRect(lineTop, lineBottom); 264 LayoutRect result = visualOverflowRect(lineTop, lineBottom);
264 if (!renderer().isHorizontalWritingMode()) 265 if (!renderer().isHorizontalWritingMode())
265 result = result.transposedRect(); 266 result = result.transposedRect();
266 return result; 267 return result;
267 } 268 }
268 269
269 void setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, co nst LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom ); 270 void setOverflowFromLogicalRects(const LayoutRect& logicalLayoutOverflow, co nst LayoutRect& logicalVisualOverflow, LayoutUnit lineTop, LayoutUnit lineBottom );
270 271
271 FloatRect frameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBo ttom) const 272 FloatRectWillBeLayoutRect frameRectIncludingLineHeight(LayoutUnit lineTop, L ayoutUnit lineBottom) const
272 { 273 {
273 if (isHorizontal()) 274 if (isHorizontal())
274 return FloatRect(m_topLeft.x(), lineTop.toFloat(), width(), (lineBot tom - lineTop).toFloat()); 275 return FloatRectWillBeLayoutRect(m_topLeft.x(), LAYOUT_UNIT_TO_FLOAT (lineTop), width(), LAYOUT_UNIT_TO_FLOAT(lineBottom - lineTop));
275 return FloatRect(lineTop.toFloat(), m_topLeft.y(), (lineBottom - lineTop ).toFloat(), height()); 276 return FloatRectWillBeLayoutRect(LAYOUT_UNIT_TO_FLOAT(lineTop), m_topLef t.y(), LAYOUT_UNIT_TO_FLOAT(lineBottom - lineTop), height());
276 } 277 }
277 278
278 FloatRect logicalFrameRectIncludingLineHeight(LayoutUnit lineTop, LayoutUnit lineBottom) const 279 FloatRectWillBeLayoutRect logicalFrameRectIncludingLineHeight(LayoutUnit lin eTop, LayoutUnit lineBottom) const
279 { 280 {
280 return FloatRect(logicalLeft(), lineTop.toFloat(), logicalWidth(), (line Bottom - lineTop).toFloat()); 281 return FloatRectWillBeLayoutRect(logicalLeft(), LAYOUT_UNIT_TO_FLOAT(lin eTop), logicalWidth(), LAYOUT_UNIT_TO_FLOAT(lineBottom - lineTop));
281 } 282 }
282 283
283 bool descendantsHaveSameLineHeightAndBaseline() const { return m_descendants HaveSameLineHeightAndBaseline; } 284 bool descendantsHaveSameLineHeightAndBaseline() const { return m_descendants HaveSameLineHeightAndBaseline; }
284 void clearDescendantsHaveSameLineHeightAndBaseline() 285 void clearDescendantsHaveSameLineHeightAndBaseline()
285 { 286 {
286 m_descendantsHaveSameLineHeightAndBaseline = false; 287 m_descendantsHaveSameLineHeightAndBaseline = false;
287 if (parent() && parent()->descendantsHaveSameLineHeightAndBaseline()) 288 if (parent() && parent()->descendantsHaveSameLineHeightAndBaseline())
288 parent()->clearDescendantsHaveSameLineHeightAndBaseline(); 289 parent()->clearDescendantsHaveSameLineHeightAndBaseline();
289 } 290 }
290 291
(...skipping 13 matching lines...) Expand all
304 virtual bool isInlineFlowBox() const override final { return true; } 305 virtual bool isInlineFlowBox() const override final { return true; }
305 306
306 InlineBox* m_firstChild; 307 InlineBox* m_firstChild;
307 InlineBox* m_lastChild; 308 InlineBox* m_lastChild;
308 309
309 InlineFlowBox* m_prevLineBox; // The previous box that also uses our RenderO bject 310 InlineFlowBox* m_prevLineBox; // The previous box that also uses our RenderO bject
310 InlineFlowBox* m_nextLineBox; // The next box that also uses our RenderObjec t 311 InlineFlowBox* m_nextLineBox; // The next box that also uses our RenderObjec t
311 312
312 // Maximum logicalTop among all children of an InlineFlowBox. Used to 313 // Maximum logicalTop among all children of an InlineFlowBox. Used to
313 // calculate the offset for TextUnderlinePositionUnder. 314 // calculate the offset for TextUnderlinePositionUnder.
314 void computeMaxLogicalTop(float& maxLogicalTop) const; 315 void computeMaxLogicalTop(FloatWillBeLayoutUnit& maxLogicalTop) const;
315 316
316 private: 317 private:
317 unsigned m_includeLogicalLeftEdge : 1; 318 unsigned m_includeLogicalLeftEdge : 1;
318 unsigned m_includeLogicalRightEdge : 1; 319 unsigned m_includeLogicalRightEdge : 1;
319 unsigned m_hasTextChildren : 1; 320 unsigned m_hasTextChildren : 1;
320 unsigned m_hasTextDescendants : 1; 321 unsigned m_hasTextDescendants : 1;
321 unsigned m_descendantsHaveSameLineHeightAndBaseline : 1; 322 unsigned m_descendantsHaveSameLineHeightAndBaseline : 1;
322 323
323 protected: 324 protected:
324 // The following members are only used by RootInlineBox but moved here to ke ep the bits packed. 325 // The following members are only used by RootInlineBox but moved here to ke ep the bits packed.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 359 }
359 360
360 } // namespace blink 361 } // namespace blink
361 362
362 #ifndef NDEBUG 363 #ifndef NDEBUG
363 // Outside the WebCore namespace for ease of invocation from gdb. 364 // Outside the WebCore namespace for ease of invocation from gdb.
364 void showTree(const blink::InlineFlowBox*); 365 void showTree(const blink::InlineFlowBox*);
365 #endif 366 #endif
366 367
367 #endif // InlineFlowBox_h 368 #endif // InlineFlowBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698