OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 class LineWidth { | 44 class LineWidth { |
45 STACK_ALLOCATED(); | 45 STACK_ALLOCATED(); |
46 public: | 46 public: |
47 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot); | 47 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot); |
48 | 48 |
49 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } | 49 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } |
50 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } | 50 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } |
51 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const | 51 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const |
52 { | 52 { |
53 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; | 53 LayoutUnit w = LayoutUnit::fromFloatFloor(currentWidth() + extra); |
| 54 if (whitespaceTreatment == ExcludeWhitespace) |
| 55 w -= LayoutUnit::fromFloatCeil(trailingWhitespaceWidth()); |
| 56 return w <= m_availableWidth; |
54 } | 57 } |
55 | 58 |
56 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because | 59 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because |
57 // currentWidth() is used by the code that lays out words in a single Layout
Text, it's | 60 // currentWidth() is used by the code that lays out words in a single Layout
Text, it's |
58 // expected that offsets will not be snapped until an InlineBox boundary is
reached. | 61 // expected that offsets will not be snapped until an InlineBox boundary is
reached. |
59 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } | 62 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } |
60 | 63 |
61 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. | 64 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. |
62 float uncommittedWidth() const { return m_uncommittedWidth; } | 65 float uncommittedWidth() const { return m_uncommittedWidth; } |
63 float committedWidth() const { return m_committedWidth; } | 66 float committedWidth() const { return m_committedWidth; } |
64 float availableWidth() const { return m_availableWidth; } | 67 float availableWidth() const { return m_availableWidth; } |
65 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } | 68 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } |
66 | 69 |
67 void updateAvailableWidth(LayoutUnit minimumHeight = LayoutUnit()); | 70 void updateAvailableWidth(LayoutUnit minimumHeight = LayoutUnit()); |
68 void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&); | 71 void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&); |
69 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } | 72 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } |
70 void commit(); | 73 void commit(); |
71 void applyOverhang(LineLayoutRubyRun, LineLayoutItem startLayoutItem, LineLa
youtItem endLayoutItem); | 74 void applyOverhang(LineLayoutRubyRun, LineLayoutItem startLayoutItem, LineLa
youtItem endLayoutItem); |
72 void fitBelowFloats(bool isFirstLine = false); | 75 void fitBelowFloats(bool isFirstLine = false); |
73 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } | 76 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } |
74 void snapUncommittedWidth() { m_uncommittedWidth = LayoutUnit::fromFloatCeil
(m_uncommittedWidth).toFloat(); } | 77 void snapUncommittedWidth() { m_uncommittedWidth = LayoutUnit::fromFloatCeil
(m_uncommittedWidth).toFloat(); } |
75 | 78 |
76 IndentTextOrNot indentText() const { return m_indentText; } | 79 IndentTextOrNot indentText() const { return m_indentText; } |
77 | 80 |
78 private: | 81 private: |
79 void computeAvailableWidthFromLeftAndRight(); | 82 void computeAvailableWidthFromLeftAndRight(); |
80 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st float& newLineLeft, const float& newLineRight); | 83 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st LayoutUnit& newLineLeft, const LayoutUnit& newLineRight); |
81 void wrapNextToShapeOutside(bool isFirstLine); | 84 void wrapNextToShapeOutside(bool isFirstLine); |
82 | 85 |
83 LineLayoutBlockFlow m_block; | 86 LineLayoutBlockFlow m_block; |
84 float m_uncommittedWidth; | 87 float m_uncommittedWidth; |
85 float m_committedWidth; | 88 float m_committedWidth; |
86 float m_overhangWidth; // The amount by which |m_availableWidth| has been in
flated to account for possible contraction due to ruby overhang. | 89 float m_overhangWidth; // The amount by which |m_availableWidth| has been in
flated to account for possible contraction due to ruby overhang. |
87 float m_trailingWhitespaceWidth; | 90 float m_trailingWhitespaceWidth; |
88 float m_left; | 91 LayoutUnit m_left; |
89 float m_right; | 92 LayoutUnit m_right; |
90 float m_availableWidth; | 93 LayoutUnit m_availableWidth; |
91 bool m_isFirstLine; | 94 bool m_isFirstLine; |
92 IndentTextOrNot m_indentText; | 95 IndentTextOrNot m_indentText; |
93 }; | 96 }; |
94 | 97 |
95 } // namespace blink | 98 } // namespace blink |
96 | 99 |
97 #endif // LineWidth_h | 100 #endif // LineWidth_h |
OLD | NEW |