OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. | 2 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009, 2010, 2011 Apple Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 bool extracted, | 66 bool extracted, |
67 bool isHorizontal, | 67 bool isHorizontal, |
68 InlineBox* next, | 68 InlineBox* next, |
69 InlineBox* prev, | 69 InlineBox* prev, |
70 InlineFlowBox* parent) | 70 InlineFlowBox* parent) |
71 : m_bitfields(firstLine, constructed, dirty, extracted, isHorizontal), | 71 : m_bitfields(firstLine, constructed, dirty, extracted, isHorizontal), |
72 m_next(next), | 72 m_next(next), |
73 m_prev(prev), | 73 m_prev(prev), |
74 m_parent(parent), | 74 m_parent(parent), |
75 m_lineLayoutItem(item), | 75 m_lineLayoutItem(item), |
76 m_topLeft(topLeft), | 76 m_location(topLeft), |
77 m_logicalWidth(logicalWidth) | 77 m_logicalWidth(logicalWidth) |
78 #if ENABLE(ASSERT) | 78 #if ENABLE(ASSERT) |
79 , | 79 , |
80 m_hasBadParent(false) | 80 m_hasBadParent(false) |
81 #endif | 81 #endif |
82 { | 82 { |
83 } | 83 } |
84 | 84 |
85 virtual ~InlineBox(); | 85 virtual ~InlineBox(); |
86 | 86 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 InlineFlowBox* parent() const { | 217 InlineFlowBox* parent() const { |
218 ASSERT(!m_hasBadParent); | 218 ASSERT(!m_hasBadParent); |
219 return m_parent; | 219 return m_parent; |
220 } | 220 } |
221 void setParent(InlineFlowBox* par) { m_parent = par; } | 221 void setParent(InlineFlowBox* par) { m_parent = par; } |
222 | 222 |
223 const RootInlineBox& root() const; | 223 const RootInlineBox& root() const; |
224 RootInlineBox& root(); | 224 RootInlineBox& root(); |
225 | 225 |
226 // x() is the left side of the box in the containing block's coordinate | 226 // x() is the location of the box in the containing block's "physical |
227 // system. | 227 // coordinates with flipped block-flow direction". |
228 void setX(LayoutUnit x) { m_topLeft.setX(x); } | 228 // See../README.md#Coordinate-Spaces for the definition. |
229 LayoutUnit x() const { return m_topLeft.x(); } | 229 void setX(LayoutUnit x) { m_location.setX(x); } |
230 LayoutUnit left() const { return m_topLeft.x(); } | 230 LayoutUnit x() const { return m_location.x(); } |
231 | 231 |
232 // y() is the top side of the box in the containing block's coordinate system. | 232 // y() is the top side of the box in the containing block's physical |
233 void setY(LayoutUnit y) { m_topLeft.setY(y); } | 233 // coordinates. It's actually in the same coordinate space as x() but for y() |
234 LayoutUnit y() const { return m_topLeft.y(); } | 234 // physical coordinates and "physical coordinates with flipped block-flow |
235 LayoutUnit top() const { return m_topLeft.y(); } | 235 // direction" are the same. |
| 236 void setY(LayoutUnit y) { m_location.setY(y); } |
| 237 LayoutUnit y() const { return m_location.y(); } |
236 | 238 |
237 const LayoutPoint& topLeft() const { return m_topLeft; } | 239 // x() and y() in one LayoutPoint, in the containing block's "physical |
| 240 // coordinates with flipped block-flow direction". |
| 241 const LayoutPoint& location() const { return m_location; } |
238 | 242 |
239 LayoutUnit width() const { | 243 LayoutUnit width() const { |
240 return isHorizontal() ? logicalWidth() : logicalHeight(); | 244 return isHorizontal() ? logicalWidth() : logicalHeight(); |
241 } | 245 } |
242 LayoutUnit height() const { | 246 LayoutUnit height() const { |
243 return isHorizontal() ? logicalHeight() : logicalWidth(); | 247 return isHorizontal() ? logicalHeight() : logicalWidth(); |
244 } | 248 } |
245 LayoutSize size() const { return LayoutSize(width(), height()); } | 249 LayoutSize size() const { return LayoutSize(width(), height()); } |
246 LayoutUnit right() const { return left() + width(); } | |
247 LayoutUnit bottom() const { return top() + height(); } | |
248 | 250 |
249 // The logicalLeft position is the left edge of the line box in a horizontal | 251 // The logicalLeft position is the left edge of the line box in a horizontal |
250 // line and the top edge in a vertical line. | 252 // line and the top edge in a vertical line. |
251 LayoutUnit logicalLeft() const { | 253 LayoutUnit logicalLeft() const { |
252 return isHorizontal() ? m_topLeft.x() : m_topLeft.y(); | 254 return isHorizontal() ? m_location.x() : m_location.y(); |
253 } | 255 } |
254 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } | 256 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } |
255 void setLogicalLeft(LayoutUnit left) { | 257 void setLogicalLeft(LayoutUnit left) { |
256 if (isHorizontal()) | 258 if (isHorizontal()) |
257 setX(left); | 259 setX(left); |
258 else | 260 else |
259 setY(left); | 261 setY(left); |
260 } | 262 } |
261 int pixelSnappedLogicalLeft() const { return logicalLeft().toInt(); } | 263 int pixelSnappedLogicalLeft() const { return logicalLeft().toInt(); } |
262 int pixelSnappedLogicalRight() const { return logicalRight().ceil(); } | 264 int pixelSnappedLogicalRight() const { return logicalRight().ceil(); } |
263 int pixelSnappedLogicalTop() const { return logicalTop().toInt(); } | 265 int pixelSnappedLogicalTop() const { return logicalTop().toInt(); } |
264 int pixelSnappedLogicalBottom() const { return logicalBottom().ceil(); } | 266 int pixelSnappedLogicalBottom() const { return logicalBottom().ceil(); } |
265 | 267 |
266 // The logicalTop[ position is the top edge of the line box in a horizontal | 268 // The logicalTop[ position is the top edge of the line box in a horizontal |
267 // line and the left edge in a vertical line. | 269 // line and the left edge in a vertical line. |
268 LayoutUnit logicalTop() const { | 270 LayoutUnit logicalTop() const { |
269 return isHorizontal() ? m_topLeft.y() : m_topLeft.x(); | 271 return isHorizontal() ? m_location.y() : m_location.x(); |
270 } | 272 } |
271 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } | 273 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } |
272 void setLogicalTop(LayoutUnit top) { | 274 void setLogicalTop(LayoutUnit top) { |
273 if (isHorizontal()) | 275 if (isHorizontal()) |
274 setY(top); | 276 setY(top); |
275 else | 277 else |
276 setX(top); | 278 setX(top); |
277 } | 279 } |
278 | 280 |
279 // The logical width is our extent in the line's overall inline direction, | 281 // The logical width is our extent in the line's overall inline direction, |
280 // i.e., width for horizontal text and height for vertical text. | 282 // i.e., width for horizontal text and height for vertical text. |
281 void setLogicalWidth(LayoutUnit w) { m_logicalWidth = w; } | 283 void setLogicalWidth(LayoutUnit w) { m_logicalWidth = w; } |
282 LayoutUnit logicalWidth() const { return m_logicalWidth; } | 284 LayoutUnit logicalWidth() const { return m_logicalWidth; } |
283 | 285 |
284 // The logical height is our extent in the block flow direction, i.e., height | 286 // The logical height is our extent in the block flow direction, i.e., height |
285 // for horizontal text and width for vertical text. | 287 // for horizontal text and width for vertical text. |
286 LayoutUnit logicalHeight() const; | 288 LayoutUnit logicalHeight() const; |
287 | 289 |
288 LayoutRect logicalFrameRect() const { | 290 LayoutRect logicalFrameRect() const { |
289 return isHorizontal() ? LayoutRect(m_topLeft.x(), m_topLeft.y(), | 291 return isHorizontal() ? LayoutRect(m_location.x(), m_location.y(), |
290 m_logicalWidth, logicalHeight()) | 292 m_logicalWidth, logicalHeight()) |
291 : LayoutRect(m_topLeft.y(), m_topLeft.x(), | 293 : LayoutRect(m_location.y(), m_location.x(), |
292 m_logicalWidth, logicalHeight()); | 294 m_logicalWidth, logicalHeight()); |
293 } | 295 } |
294 | 296 |
295 virtual int baselinePosition(FontBaseline baselineType) const; | 297 virtual int baselinePosition(FontBaseline baselineType) const; |
296 virtual LayoutUnit lineHeight() const; | 298 virtual LayoutUnit lineHeight() const; |
297 | 299 |
298 virtual int caretMinOffset() const; | 300 virtual int caretMinOffset() const; |
299 virtual int caretMaxOffset() const; | 301 virtual int caretMaxOffset() const; |
300 | 302 |
301 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); } | 303 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 ->verticalAlign(); | 355 ->verticalAlign(); |
354 } | 356 } |
355 | 357 |
356 // Use with caution! The type is not checked! | 358 // Use with caution! The type is not checked! |
357 LineLayoutBoxModel boxModelObject() const { | 359 LineLayoutBoxModel boxModelObject() const { |
358 if (!getLineLayoutItem().isText()) | 360 if (!getLineLayoutItem().isText()) |
359 return LineLayoutBoxModel(m_lineLayoutItem); | 361 return LineLayoutBoxModel(m_lineLayoutItem); |
360 return LineLayoutBoxModel(nullptr); | 362 return LineLayoutBoxModel(nullptr); |
361 } | 363 } |
362 | 364 |
363 LayoutPoint locationIncludingFlipping() const; | 365 // Physical location of the top-left corner of the box in the containing |
| 366 // block. |
| 367 LayoutPoint physicalLocation() const; |
364 | 368 |
365 // Converts from a rect in the logical space of the InlineBox to one in the | 369 // Converts from a rect in the logical space of the InlineBox to one in the |
366 // physical space of the containing block. The logical space of an InlineBox | 370 // physical space of the containing block. The logical space of an InlineBox |
367 // may be transposed for vertical text and flipped for right-to-left text. | 371 // may be transposed for vertical text and flipped for right-to-left text. |
368 void logicalRectToPhysicalRect(LayoutRect&) const; | 372 void logicalRectToPhysicalRect(LayoutRect&) const; |
369 | 373 |
370 // TODO(szager): The Rect versions should return a rect, not modify the | 374 // TODO(szager): The Rect versions should return a rect, not modify the |
371 // argument. | 375 // argument. |
372 void flipForWritingMode(FloatRect&) const; | 376 void flipForWritingMode(FloatRect&) const; |
373 FloatPoint flipForWritingMode(const FloatPoint&) const; | 377 FloatPoint flipForWritingMode(const FloatPoint&) const; |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 private: | 492 private: |
489 unsigned m_expansion : 12; // for justified text | 493 unsigned m_expansion : 12; // for justified text |
490 | 494 |
491 public: | 495 public: |
492 signed expansion() const { return m_expansion; } | 496 signed expansion() const { return m_expansion; } |
493 void setExpansion(signed expansion) { m_expansion = expansion; } | 497 void setExpansion(signed expansion) { m_expansion = expansion; } |
494 }; | 498 }; |
495 #undef ADD_BOOLEAN_BITFIELD | 499 #undef ADD_BOOLEAN_BITFIELD |
496 | 500 |
497 private: | 501 private: |
498 // Converts the given (top-left) position from the logical space of the | |
499 // InlineBox to the physical space of the containing block. The size indicates | |
500 // the size of the box whose point is being flipped. | |
501 LayoutPoint logicalPositionToPhysicalPoint(const LayoutPoint&, | |
502 const LayoutSize&) const; | |
503 | |
504 void setLineLayoutItemShouldDoFullPaintInvalidationIfNeeded(); | 502 void setLineLayoutItemShouldDoFullPaintInvalidationIfNeeded(); |
505 | 503 |
506 InlineBoxBitfields m_bitfields; | 504 InlineBoxBitfields m_bitfields; |
507 | 505 |
508 InlineBox* m_next; // The next element on the same line as us. | 506 InlineBox* m_next; // The next element on the same line as us. |
509 InlineBox* m_prev; // The previous element on the same line as us. | 507 InlineBox* m_prev; // The previous element on the same line as us. |
510 | 508 |
511 InlineFlowBox* m_parent; // The box that contains us. | 509 InlineFlowBox* m_parent; // The box that contains us. |
512 LineLayoutItem m_lineLayoutItem; | 510 LineLayoutItem m_lineLayoutItem; |
513 | 511 |
(...skipping 26 matching lines...) Expand all Loading... |
540 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { | 538 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { |
541 m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion( | 539 m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion( |
542 canHaveLeadingExpansion); | 540 canHaveLeadingExpansion); |
543 } | 541 } |
544 signed expansion() { return m_bitfields.expansion(); } | 542 signed expansion() { return m_bitfields.expansion(); } |
545 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); } | 543 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); } |
546 | 544 |
547 // For InlineFlowBox and InlineTextBox | 545 // For InlineFlowBox and InlineTextBox |
548 bool extracted() const { return m_bitfields.extracted(); } | 546 bool extracted() const { return m_bitfields.extracted(); } |
549 | 547 |
550 LayoutPoint m_topLeft; | 548 LayoutPoint m_location; |
551 LayoutUnit m_logicalWidth; | 549 LayoutUnit m_logicalWidth; |
552 | 550 |
553 private: | 551 private: |
554 #if ENABLE(ASSERT) | 552 #if ENABLE(ASSERT) |
555 bool m_hasBadParent; | 553 bool m_hasBadParent; |
556 #endif | 554 #endif |
557 }; | 555 }; |
558 | 556 |
559 #if !ENABLE(ASSERT) | 557 #if !ENABLE(ASSERT) |
560 inline InlineBox::~InlineBox() {} | 558 inline InlineBox::~InlineBox() {} |
(...skipping 15 matching lines...) Expand all Loading... |
576 | 574 |
577 } // namespace blink | 575 } // namespace blink |
578 | 576 |
579 #ifndef NDEBUG | 577 #ifndef NDEBUG |
580 // Outside the WebCore namespace for ease of invocation from gdb. | 578 // Outside the WebCore namespace for ease of invocation from gdb. |
581 void showTree(const blink::InlineBox*); | 579 void showTree(const blink::InlineBox*); |
582 void showLineTree(const blink::InlineBox*); | 580 void showLineTree(const blink::InlineBox*); |
583 #endif | 581 #endif |
584 | 582 |
585 #endif // InlineBox_h | 583 #endif // InlineBox_h |
OLD | NEW |