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

Side by Side Diff: third_party/WebKit/Source/core/layout/line/InlineBox.h

Issue 2536453002: Rename some functions about layout locations (Closed)
Patch Set: Add test Created 4 years 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
OLDNEW
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
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
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 left side of the box in the containing block's "physical
227 // system. 227 // coordinates with flipped blocks direction".
szager1 2016/11/28 23:03:09 This needs a more detailed explanation.
wkorman 2016/11/29 00:02:13 Agree, we can add a brief description here and cou
Xianzhu 2016/11/29 01:44:17 Done.
228 void setX(LayoutUnit x) { m_topLeft.setX(x); } 228 void setX(LayoutUnit x) { m_location.setX(x); }
229 LayoutUnit x() const { return m_topLeft.x(); } 229 LayoutUnit x() const { return m_location.x(); }
230 LayoutUnit left() const { return m_topLeft.x(); }
231 230
232 // y() is the top side of the box in the containing block's coordinate system. 231 // y() is the top side of the box in the containing block's physical
233 void setY(LayoutUnit y) { m_topLeft.setY(y); } 232 // coordinates.
wkorman 2016/11/29 00:02:13 Comment should fit with the one for x() above, is
Xianzhu 2016/11/29 01:44:17 Added: It's actually in the same coordinate space
234 LayoutUnit y() const { return m_topLeft.y(); } 233 void setY(LayoutUnit y) { m_location.setY(y); }
235 LayoutUnit top() const { return m_topLeft.y(); } 234 LayoutUnit y() const { return m_location.y(); }
235 LayoutUnit top() const { return m_location.y(); }
wkorman 2016/11/29 00:17:00 Do we still need this? Why do we need this but not
Xianzhu 2016/11/29 01:44:17 Removed.
236 236
237 const LayoutPoint& topLeft() const { return m_topLeft; } 237 const LayoutPoint& location() const { return m_location; }
wkorman 2016/11/29 00:02:13 And we should comment this similarly.
Xianzhu 2016/11/29 01:44:17 Done.
238 238
239 LayoutUnit width() const { 239 LayoutUnit width() const {
240 return isHorizontal() ? logicalWidth() : logicalHeight(); 240 return isHorizontal() ? logicalWidth() : logicalHeight();
241 } 241 }
242 LayoutUnit height() const { 242 LayoutUnit height() const {
243 return isHorizontal() ? logicalHeight() : logicalWidth(); 243 return isHorizontal() ? logicalHeight() : logicalWidth();
244 } 244 }
245 LayoutSize size() const { return LayoutSize(width(), height()); } 245 LayoutSize size() const { return LayoutSize(width(), height()); }
246 LayoutUnit right() const { return left() + width(); }
247 LayoutUnit bottom() const { return top() + height(); }
248 246
249 // The logicalLeft position is the left edge of the line box in a horizontal 247 // The logicalLeft position is the left edge of the line box in a horizontal
250 // line and the top edge in a vertical line. 248 // line and the top edge in a vertical line.
251 LayoutUnit logicalLeft() const { 249 LayoutUnit logicalLeft() const {
252 return isHorizontal() ? m_topLeft.x() : m_topLeft.y(); 250 return isHorizontal() ? m_location.x() : m_location.y();
253 } 251 }
254 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); } 252 LayoutUnit logicalRight() const { return logicalLeft() + logicalWidth(); }
255 void setLogicalLeft(LayoutUnit left) { 253 void setLogicalLeft(LayoutUnit left) {
256 if (isHorizontal()) 254 if (isHorizontal())
257 setX(left); 255 setX(left);
258 else 256 else
259 setY(left); 257 setY(left);
260 } 258 }
261 int pixelSnappedLogicalLeft() const { return logicalLeft().toInt(); } 259 int pixelSnappedLogicalLeft() const { return logicalLeft().toInt(); }
262 int pixelSnappedLogicalRight() const { return logicalRight().ceil(); } 260 int pixelSnappedLogicalRight() const { return logicalRight().ceil(); }
263 int pixelSnappedLogicalTop() const { return logicalTop().toInt(); } 261 int pixelSnappedLogicalTop() const { return logicalTop().toInt(); }
264 int pixelSnappedLogicalBottom() const { return logicalBottom().ceil(); } 262 int pixelSnappedLogicalBottom() const { return logicalBottom().ceil(); }
265 263
266 // The logicalTop[ position is the top edge of the line box in a horizontal 264 // The logicalTop[ position is the top edge of the line box in a horizontal
267 // line and the left edge in a vertical line. 265 // line and the left edge in a vertical line.
268 LayoutUnit logicalTop() const { 266 LayoutUnit logicalTop() const {
269 return isHorizontal() ? m_topLeft.y() : m_topLeft.x(); 267 return isHorizontal() ? m_location.y() : m_location.x();
270 } 268 }
271 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); } 269 LayoutUnit logicalBottom() const { return logicalTop() + logicalHeight(); }
272 void setLogicalTop(LayoutUnit top) { 270 void setLogicalTop(LayoutUnit top) {
273 if (isHorizontal()) 271 if (isHorizontal())
274 setY(top); 272 setY(top);
275 else 273 else
276 setX(top); 274 setX(top);
277 } 275 }
278 276
279 // The logical width is our extent in the line's overall inline direction, 277 // 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. 278 // i.e., width for horizontal text and height for vertical text.
281 void setLogicalWidth(LayoutUnit w) { m_logicalWidth = w; } 279 void setLogicalWidth(LayoutUnit w) { m_logicalWidth = w; }
282 LayoutUnit logicalWidth() const { return m_logicalWidth; } 280 LayoutUnit logicalWidth() const { return m_logicalWidth; }
283 281
284 // The logical height is our extent in the block flow direction, i.e., height 282 // The logical height is our extent in the block flow direction, i.e., height
285 // for horizontal text and width for vertical text. 283 // for horizontal text and width for vertical text.
286 LayoutUnit logicalHeight() const; 284 LayoutUnit logicalHeight() const;
287 285
288 LayoutRect logicalFrameRect() const { 286 LayoutRect logicalFrameRect() const {
289 return isHorizontal() ? LayoutRect(m_topLeft.x(), m_topLeft.y(), 287 return isHorizontal() ? LayoutRect(m_location.x(), m_location.y(),
290 m_logicalWidth, logicalHeight()) 288 m_logicalWidth, logicalHeight())
291 : LayoutRect(m_topLeft.y(), m_topLeft.x(), 289 : LayoutRect(m_location.y(), m_location.x(),
292 m_logicalWidth, logicalHeight()); 290 m_logicalWidth, logicalHeight());
293 } 291 }
294 292
295 virtual int baselinePosition(FontBaseline baselineType) const; 293 virtual int baselinePosition(FontBaseline baselineType) const;
296 virtual LayoutUnit lineHeight() const; 294 virtual LayoutUnit lineHeight() const;
297 295
298 virtual int caretMinOffset() const; 296 virtual int caretMinOffset() const;
299 virtual int caretMaxOffset() const; 297 virtual int caretMaxOffset() const;
300 298
301 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); } 299 unsigned char bidiLevel() const { return m_bitfields.bidiEmbeddingLevel(); }
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ->verticalAlign(); 351 ->verticalAlign();
354 } 352 }
355 353
356 // Use with caution! The type is not checked! 354 // Use with caution! The type is not checked!
357 LineLayoutBoxModel boxModelObject() const { 355 LineLayoutBoxModel boxModelObject() const {
358 if (!getLineLayoutItem().isText()) 356 if (!getLineLayoutItem().isText())
359 return LineLayoutBoxModel(m_lineLayoutItem); 357 return LineLayoutBoxModel(m_lineLayoutItem);
360 return LineLayoutBoxModel(nullptr); 358 return LineLayoutBoxModel(nullptr);
361 } 359 }
362 360
363 LayoutPoint locationIncludingFlipping() const; 361 LayoutPoint physicalLocation() const;
wkorman 2016/11/29 00:02:13 And comment this.
Xianzhu 2016/11/29 01:44:17 Done.
364 362
365 // Converts from a rect in the logical space of the InlineBox to one in the 363 // 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 364 // 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. 365 // may be transposed for vertical text and flipped for right-to-left text.
368 void logicalRectToPhysicalRect(LayoutRect&) const; 366 void logicalRectToPhysicalRect(LayoutRect&) const;
369 367
370 // TODO(szager): The Rect versions should return a rect, not modify the 368 // TODO(szager): The Rect versions should return a rect, not modify the
371 // argument. 369 // argument.
372 void flipForWritingMode(FloatRect&) const; 370 void flipForWritingMode(FloatRect&) const;
373 FloatPoint flipForWritingMode(const FloatPoint&) const; 371 FloatPoint flipForWritingMode(const FloatPoint&) const;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 private: 486 private:
489 unsigned m_expansion : 12; // for justified text 487 unsigned m_expansion : 12; // for justified text
490 488
491 public: 489 public:
492 signed expansion() const { return m_expansion; } 490 signed expansion() const { return m_expansion; }
493 void setExpansion(signed expansion) { m_expansion = expansion; } 491 void setExpansion(signed expansion) { m_expansion = expansion; }
494 }; 492 };
495 #undef ADD_BOOLEAN_BITFIELD 493 #undef ADD_BOOLEAN_BITFIELD
496 494
497 private: 495 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(); 496 void setLineLayoutItemShouldDoFullPaintInvalidationIfNeeded();
505 497
506 InlineBoxBitfields m_bitfields; 498 InlineBoxBitfields m_bitfields;
507 499
508 InlineBox* m_next; // The next element on the same line as us. 500 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. 501 InlineBox* m_prev; // The previous element on the same line as us.
510 502
511 InlineFlowBox* m_parent; // The box that contains us. 503 InlineFlowBox* m_parent; // The box that contains us.
512 LineLayoutItem m_lineLayoutItem; 504 LineLayoutItem m_lineLayoutItem;
513 505
(...skipping 26 matching lines...) Expand all
540 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) { 532 void setCanHaveLeadingExpansion(bool canHaveLeadingExpansion) {
541 m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion( 533 m_bitfields.setHasSelectedChildrenOrCanHaveLeadingExpansion(
542 canHaveLeadingExpansion); 534 canHaveLeadingExpansion);
543 } 535 }
544 signed expansion() { return m_bitfields.expansion(); } 536 signed expansion() { return m_bitfields.expansion(); }
545 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); } 537 void setExpansion(signed expansion) { m_bitfields.setExpansion(expansion); }
546 538
547 // For InlineFlowBox and InlineTextBox 539 // For InlineFlowBox and InlineTextBox
548 bool extracted() const { return m_bitfields.extracted(); } 540 bool extracted() const { return m_bitfields.extracted(); }
549 541
550 LayoutPoint m_topLeft; 542 LayoutPoint m_location;
551 LayoutUnit m_logicalWidth; 543 LayoutUnit m_logicalWidth;
552 544
553 private: 545 private:
554 #if ENABLE(ASSERT) 546 #if ENABLE(ASSERT)
555 bool m_hasBadParent; 547 bool m_hasBadParent;
556 #endif 548 #endif
557 }; 549 };
558 550
559 #if !ENABLE(ASSERT) 551 #if !ENABLE(ASSERT)
560 inline InlineBox::~InlineBox() {} 552 inline InlineBox::~InlineBox() {}
(...skipping 15 matching lines...) Expand all
576 568
577 } // namespace blink 569 } // namespace blink
578 570
579 #ifndef NDEBUG 571 #ifndef NDEBUG
580 // Outside the WebCore namespace for ease of invocation from gdb. 572 // Outside the WebCore namespace for ease of invocation from gdb.
581 void showTree(const blink::InlineBox*); 573 void showTree(const blink::InlineBox*);
582 void showLineTree(const blink::InlineBox*); 574 void showLineTree(const blink::InlineBox*);
583 #endif 575 #endif
584 576
585 #endif // InlineBox_h 577 #endif // InlineBox_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698