| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 public: | 47 public: |
| 48 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot shouldInden
tText); | 48 LineWidth(LineLayoutBlockFlow, bool isFirstLine, IndentTextOrNot shouldInden
tText); |
| 49 | 49 |
| 50 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } | 50 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } |
| 51 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } | 51 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } |
| 52 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const | 52 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const |
| 53 { | 53 { |
| 54 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; | 54 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; |
| 55 } | 55 } |
| 56 | 56 |
| 57 // Note that m_uncommittedWidth may not be LayoutUnit-snapped at this point.
Because |
| 58 // currentWidth() is used by the code that lays out words in a single Layout
Text, it's |
| 59 // expected that offsets will not be snapped until an InlineBox boundary is
reached. |
| 57 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } | 60 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } |
| 61 |
| 58 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. | 62 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. |
| 59 float uncommittedWidth() const { return m_uncommittedWidth; } | 63 float uncommittedWidth() const { return m_uncommittedWidth; } |
| 60 float committedWidth() const { return m_committedWidth; } | 64 float committedWidth() const { return m_committedWidth; } |
| 61 float availableWidth() const { return m_availableWidth; } | 65 float availableWidth() const { return m_availableWidth; } |
| 62 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } | 66 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } |
| 63 | 67 |
| 64 void updateAvailableWidth(LayoutUnit minimumHeight = 0); | 68 void updateAvailableWidth(LayoutUnit minimumHeight = 0); |
| 65 void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&); | 69 void shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject&); |
| 66 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } | 70 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } |
| 67 void commit(); | 71 void commit(); |
| 68 void applyOverhang(LineLayoutRubyRun, LineLayoutItem startLayoutItem, LineLa
youtItem endLayoutItem); | 72 void applyOverhang(LineLayoutRubyRun, LineLayoutItem startLayoutItem, LineLa
youtItem endLayoutItem); |
| 69 void fitBelowFloats(bool isFirstLine = false); | 73 void fitBelowFloats(bool isFirstLine = false); |
| 70 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } | 74 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } |
| 75 void snapUncommittedWidth() { m_uncommittedWidth = LayoutUnit(m_uncommittedW
idth).toFloat(); } |
| 71 | 76 |
| 72 bool shouldIndentText() const { return m_shouldIndentText == IndentText; } | 77 bool shouldIndentText() const { return m_shouldIndentText == IndentText; } |
| 73 | 78 |
| 74 private: | 79 private: |
| 75 void computeAvailableWidthFromLeftAndRight(); | 80 void computeAvailableWidthFromLeftAndRight(); |
| 76 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st float& newLineLeft, const float& newLineRight); | 81 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st float& newLineLeft, const float& newLineRight); |
| 77 void wrapNextToShapeOutside(bool isFirstLine); | 82 void wrapNextToShapeOutside(bool isFirstLine); |
| 78 | 83 |
| 79 LineLayoutBlockFlow m_block; | 84 LineLayoutBlockFlow m_block; |
| 80 float m_uncommittedWidth; | 85 float m_uncommittedWidth; |
| 81 float m_committedWidth; | 86 float m_committedWidth; |
| 82 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_overhangWidth; // The amount by which |m_availableWidth| has been in
flated to account for possible contraction due to ruby overhang. |
| 83 float m_trailingWhitespaceWidth; | 88 float m_trailingWhitespaceWidth; |
| 84 float m_left; | 89 float m_left; |
| 85 float m_right; | 90 float m_right; |
| 86 float m_availableWidth; | 91 float m_availableWidth; |
| 87 bool m_isFirstLine; | 92 bool m_isFirstLine; |
| 88 IndentTextOrNot m_shouldIndentText; | 93 IndentTextOrNot m_shouldIndentText; |
| 89 }; | 94 }; |
| 90 | 95 |
| 91 } | 96 } |
| 92 | 97 |
| 93 #endif // LineWidth_h | 98 #endif // LineWidth_h |
| OLD | NEW |