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

Side by Side Diff: Source/core/layout/line/InlineBox.cpp

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/InlineBox.h ('k') | Source/core/layout/line/InlineFlowBox.h » ('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 * 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
(...skipping 21 matching lines...) Expand all
32 32
33 #ifndef NDEBUG 33 #ifndef NDEBUG
34 #include <stdio.h> 34 #include <stdio.h>
35 #endif 35 #endif
36 36
37 namespace blink { 37 namespace blink {
38 38
39 struct SameSizeAsInlineBox { 39 struct SameSizeAsInlineBox {
40 virtual ~SameSizeAsInlineBox() { } 40 virtual ~SameSizeAsInlineBox() { }
41 void* a[4]; 41 void* a[4];
42 FloatPointWillBeLayoutPoint b; 42 LayoutPoint b;
43 FloatWillBeLayoutUnit c; 43 LayoutUnit c;
44 uint32_t d : 32; 44 uint32_t d : 32;
45 #if ENABLE(ASSERT) 45 #if ENABLE(ASSERT)
46 bool f; 46 bool f;
47 #endif 47 #endif
48 }; 48 };
49 49
50 static_assert(sizeof(InlineBox) == sizeof(SameSizeAsInlineBox), "InlineBox shoul d stay small"); 50 static_assert(sizeof(InlineBox) == sizeof(SameSizeAsInlineBox), "InlineBox shoul d stay small");
51 51
52 #if ENABLE(ASSERT) 52 #if ENABLE(ASSERT)
53 53
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 printedCharacters += fprintf(stderr, "%s %p", boxName(), this); 122 printedCharacters += fprintf(stderr, "%s %p", boxName(), this);
123 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++) 123 for (; printedCharacters < showTreeCharacterOffset; printedCharacters++)
124 fputc(' ', stderr); 124 fputc(' ', stderr);
125 fprintf(stderr, "\t%s %p {pos=%g,%g size=%g,%g} baseline=%i/%i\n", 125 fprintf(stderr, "\t%s %p {pos=%g,%g size=%g,%g} baseline=%i/%i\n",
126 layoutObject().decoratedName().ascii().data(), &layoutObject(), 126 layoutObject().decoratedName().ascii().data(), &layoutObject(),
127 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(), 127 x().toFloat(), y().toFloat(), width().toFloat(), height().toFloat(),
128 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli ne)); 128 baselinePosition(AlphabeticBaseline), baselinePosition(IdeographicBaseli ne));
129 } 129 }
130 #endif 130 #endif
131 131
132 FloatWillBeLayoutUnit InlineBox::logicalHeight() const 132 LayoutUnit InlineBox::logicalHeight() const
133 { 133 {
134 if (hasVirtualLogicalHeight()) 134 if (hasVirtualLogicalHeight())
135 return virtualLogicalHeight(); 135 return virtualLogicalHeight();
136 136
137 if (layoutObject().isText()) 137 if (layoutObject().isText())
138 return m_bitfields.isText() ? FloatWillBeLayoutUnit(layoutObject().style (isFirstLineStyle())->fontMetrics().height()) : FloatWillBeLayoutUnit(); 138 return m_bitfields.isText() ? LayoutUnit(layoutObject().style(isFirstLin eStyle())->fontMetrics().height()) : LayoutUnit();
139 if (layoutObject().isBox() && parent()) 139 if (layoutObject().isBox() && parent())
140 return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : to LayoutBox(layoutObject()).size().width(); 140 return isHorizontal() ? toLayoutBox(layoutObject()).size().height() : to LayoutBox(layoutObject()).size().width();
141 141
142 ASSERT(isInlineFlowBox()); 142 ASSERT(isInlineFlowBox());
143 LayoutBoxModelObject* flowObject = boxModelObject(); 143 LayoutBoxModelObject* flowObject = boxModelObject();
144 const FontMetrics& fontMetrics = layoutObject().style(isFirstLineStyle())->f ontMetrics(); 144 const FontMetrics& fontMetrics = layoutObject().style(isFirstLineStyle())->f ontMetrics();
145 FloatWillBeLayoutUnit result = fontMetrics.height(); 145 LayoutUnit result = fontMetrics.height();
146 if (parent()) 146 if (parent())
147 result += flowObject->borderAndPaddingLogicalHeight(); 147 result += flowObject->borderAndPaddingLogicalHeight();
148 return result; 148 return result;
149 } 149 }
150 150
151 int InlineBox::baselinePosition(FontBaseline baselineType) const 151 int InlineBox::baselinePosition(FontBaseline baselineType) const
152 { 152 {
153 return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLin e(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine); 153 return boxModelObject()->baselinePosition(baselineType, m_bitfields.firstLin e(), isHorizontal() ? HorizontalLine : VerticalLine, PositionOnContainingLine);
154 } 154 }
155 155
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 toLayoutBox(layoutObject()).setInlineBoxWrapper(0); 189 toLayoutBox(layoutObject()).setInlineBoxWrapper(0);
190 } 190 }
191 191
192 void InlineBox::attachLine() 192 void InlineBox::attachLine()
193 { 193 {
194 m_bitfields.setExtracted(false); 194 m_bitfields.setExtracted(false);
195 if (layoutObject().isBox()) 195 if (layoutObject().isBox())
196 toLayoutBox(layoutObject()).setInlineBoxWrapper(this); 196 toLayoutBox(layoutObject()).setInlineBoxWrapper(this);
197 } 197 }
198 198
199 void InlineBox::adjustPosition(FloatWillBeLayoutUnit dx, FloatWillBeLayoutUnit d y) 199 void InlineBox::adjustPosition(LayoutUnit dx, LayoutUnit dy)
200 { 200 {
201 m_topLeft.move(dx, dy); 201 m_topLeft.move(dx, dy);
202 202
203 if (layoutObject().isReplaced()) 203 if (layoutObject().isReplaced())
204 toLayoutBox(layoutObject()).move(dx, dy); 204 toLayoutBox(layoutObject()).move(dx, dy);
205 } 205 }
206 206
207 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset , LayoutUnit /* lineTop */, LayoutUnit /* lineBottom */) 207 void InlineBox::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset , LayoutUnit /* lineTop */, LayoutUnit /* lineBottom */)
208 { 208 {
209 // Text clips are painted only for the direct inline children of the object that has a text clip style on it, not block children. 209 // Text clips are painted only for the direct inline children of the object that has a text clip style on it, not block children.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 { 307 {
308 // Non-replaced elements can always accommodate an ellipsis. 308 // Non-replaced elements can always accommodate an ellipsis.
309 if (!layoutObject().isReplaced()) 309 if (!layoutObject().isReplaced())
310 return true; 310 return true;
311 311
312 IntRect boxRect(left(), 0, m_logicalWidth, 10); 312 IntRect boxRect(left(), 0, m_logicalWidth, 10);
313 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi sWidth, 10); 313 IntRect ellipsisRect(ltr ? blockEdge - ellipsisWidth : blockEdge, 0, ellipsi sWidth, 10);
314 return !(boxRect.intersects(ellipsisRect)); 314 return !(boxRect.intersects(ellipsisRect));
315 } 315 }
316 316
317 FloatWillBeLayoutUnit InlineBox::placeEllipsisBox(bool, FloatWillBeLayoutUnit, F loatWillBeLayoutUnit, FloatWillBeLayoutUnit, FloatWillBeLayoutUnit& truncatedWid th, bool&) 317 LayoutUnit InlineBox::placeEllipsisBox(bool, LayoutUnit, LayoutUnit, LayoutUnit, LayoutUnit& truncatedWidth, bool&)
318 { 318 {
319 // Use -1 to mean "we didn't set the position." 319 // Use -1 to mean "we didn't set the position."
320 truncatedWidth += logicalWidth(); 320 truncatedWidth += logicalWidth();
321 return -1; 321 return -1;
322 } 322 }
323 323
324 void InlineBox::clearKnownToHaveNoOverflow() 324 void InlineBox::clearKnownToHaveNoOverflow()
325 { 325 {
326 m_bitfields.setKnownToHaveNoOverflow(false); 326 m_bitfields.setKnownToHaveNoOverflow(false);
327 if (parent() && parent()->knownToHaveNoOverflow()) 327 if (parent() && parent()->knownToHaveNoOverflow())
328 parent()->clearKnownToHaveNoOverflow(); 328 parent()->clearKnownToHaveNoOverflow();
329 } 329 }
330 330
331 FloatPointWillBeLayoutPoint InlineBox::locationIncludingFlipping() 331 LayoutPoint InlineBox::locationIncludingFlipping()
332 { 332 {
333 return logicalPositionToPhysicalPoint(m_topLeft.toFloatPoint(), size().toFlo atSize()); 333 return logicalPositionToPhysicalPoint(m_topLeft, size());
334 } 334 }
335 335
336 FloatPointWillBeLayoutPoint InlineBox::logicalPositionToPhysicalPoint(const Floa tPoint& point, const FloatSize& size) 336 LayoutPoint InlineBox::logicalPositionToPhysicalPoint(const LayoutPoint& point, const LayoutSize& size)
337 { 337 {
338 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) 338 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode()))
339 return FloatPointWillBeLayoutPoint(point.x(), point.y()); 339 return LayoutPoint(point.x(), point.y());
340 340
341 LayoutBlockFlow& block = root().block(); 341 LayoutBlockFlow& block = root().block();
342 if (block.style()->isHorizontalWritingMode()) 342 if (block.style()->isHorizontalWritingMode())
343 return FloatPointWillBeLayoutPoint(point.x(), block.size().height() - si ze.height() - point.y()); 343 return LayoutPoint(point.x(), block.size().height() - size.height() - po int.y());
344 344
345 return FloatPointWillBeLayoutPoint(block.size().width() - size.width() - poi nt.x(), point.y()); 345 return LayoutPoint(block.size().width() - size.width() - point.x(), point.y( ));
346 } 346 }
347 347
348 LayoutRect InlineBox::logicalRectToPhysicalRect(const LayoutRect& current) 348 LayoutRect InlineBox::logicalRectToPhysicalRect(const LayoutRect& current)
349 { 349 {
350 LayoutRect retval = current; 350 LayoutRect retval = current;
351 if (!isHorizontal()) { 351 if (!isHorizontal()) {
352 retval = retval.transposedRect(); 352 retval = retval.transposedRect();
353 } 353 }
354 retval.setLocation(logicalPositionToPhysicalPoint(FloatPoint(retval.location ()), FloatSize(retval.size())).toLayoutPoint()); 354 retval.setLocation(logicalPositionToPhysicalPoint(retval.location(), retval. size()));
355 return retval; 355 return retval;
356 } 356 }
357 357
358 void InlineBox::flipForWritingMode(FloatRect& rect) 358 void InlineBox::flipForWritingMode(FloatRect& rect)
359 { 359 {
360 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode())) 360 if (!UNLIKELY(layoutObject().hasFlippedBlocksWritingMode()))
361 return; 361 return;
362 root().block().flipForWritingMode(rect); 362 root().block().flipForWritingMode(rect);
363 } 363 }
364 364
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 397
398 void showLineTree(const blink::InlineBox* b) 398 void showLineTree(const blink::InlineBox* b)
399 { 399 {
400 if (b) 400 if (b)
401 b->showLineTreeForThis(); 401 b->showLineTreeForThis();
402 else 402 else
403 fprintf(stderr, "Cannot showLineTree for (nil) InlineBox.\n"); 403 fprintf(stderr, "Cannot showLineTree for (nil) InlineBox.\n");
404 } 404 }
405 405
406 #endif 406 #endif
OLDNEW
« no previous file with comments | « Source/core/layout/line/InlineBox.h ('k') | Source/core/layout/line/InlineFlowBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698