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 30 matching lines...) Expand all Loading... |
41 | 41 |
42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; | 42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; |
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 | 49 bool fitsOnLine() const |
50 { | 50 { |
51 return LayoutUnit::fromFloatFloor(currentWidth()) <= m_availableWidth; | 51 return LayoutUnit::fromFloatFloor(currentWidth()) <= m_availableWidth +
LayoutUnit::epsilon(); |
52 } | 52 } |
53 bool fitsOnLine(float extra) const | 53 bool fitsOnLine(float extra) const |
54 { | 54 { |
55 float totalWidth = currentWidth() + extra; | 55 float totalWidth = currentWidth() + extra; |
56 return LayoutUnit::fromFloatFloor(totalWidth) <= m_availableWidth; | 56 return LayoutUnit::fromFloatFloor(totalWidth) <= m_availableWidth + Layo
utUnit::epsilon(); |
57 } | 57 } |
58 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const | 58 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const |
59 { | 59 { |
60 LayoutUnit w = LayoutUnit::fromFloatFloor(currentWidth() + extra); | 60 LayoutUnit w = LayoutUnit::fromFloatFloor(currentWidth() + extra); |
61 if (whitespaceTreatment == ExcludeWhitespace) | 61 if (whitespaceTreatment == ExcludeWhitespace) |
62 w -= LayoutUnit::fromFloatCeil(trailingWhitespaceWidth()); | 62 w -= LayoutUnit::fromFloatCeil(trailingWhitespaceWidth()); |
63 return w <= m_availableWidth; | 63 return w <= m_availableWidth; |
64 } | 64 } |
65 | 65 |
66 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because | 66 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 LayoutUnit m_left; | 98 LayoutUnit m_left; |
99 LayoutUnit m_right; | 99 LayoutUnit m_right; |
100 LayoutUnit m_availableWidth; | 100 LayoutUnit m_availableWidth; |
101 bool m_isFirstLine; | 101 bool m_isFirstLine; |
102 IndentTextOrNot m_indentText; | 102 IndentTextOrNot m_indentText; |
103 }; | 103 }; |
104 | 104 |
105 } // namespace blink | 105 } // namespace blink |
106 | 106 |
107 #endif // LineWidth_h | 107 #endif // LineWidth_h |
OLD | NEW |