| 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 28 matching lines...) Expand all Loading... |
| 39 class FloatingObject; | 39 class FloatingObject; |
| 40 class LineLayoutRubyRun; | 40 class LineLayoutRubyRun; |
| 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 { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } | 49 bool fitsOnLine() const |
| 50 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } | 50 { |
| 51 return LayoutUnit::fromFloatFloor(currentWidth()) <= m_availableWidth; |
| 52 } |
| 53 bool fitsOnLine(float extra) const |
| 54 { |
| 55 float totalWidth = currentWidth() + extra; |
| 56 return LayoutUnit::fromFloatFloor(totalWidth) <= m_availableWidth; |
| 57 } |
| 51 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const | 58 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const |
| 52 { | 59 { |
| 53 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; | 60 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; |
| 54 } | 61 } |
| 55 | 62 |
| 56 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because | 63 // 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 | 64 // 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. | 65 // expected that offsets will not be snapped until an InlineBox boundary is
reached. |
| 59 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } | 66 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } |
| 60 | 67 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 88 float m_left; | 95 float m_left; |
| 89 float m_right; | 96 float m_right; |
| 90 float m_availableWidth; | 97 float m_availableWidth; |
| 91 bool m_isFirstLine; | 98 bool m_isFirstLine; |
| 92 IndentTextOrNot m_indentText; | 99 IndentTextOrNot m_indentText; |
| 93 }; | 100 }; |
| 94 | 101 |
| 95 } // namespace blink | 102 } // namespace blink |
| 96 | 103 |
| 97 #endif // LineWidth_h | 104 #endif // LineWidth_h |
| OLD | NEW |