| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 #ifndef SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ | 30 #ifndef SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ |
| 31 #define SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ | 31 #define SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ |
| 32 | 32 |
| 33 #include "sky/engine/platform/LayoutUnit.h" | 33 #include "sky/engine/platform/LayoutUnit.h" |
| 34 | 34 |
| 35 namespace blink { | 35 namespace blink { |
| 36 | 36 |
| 37 class FloatingObject; | 37 class FloatingObject; |
| 38 class RenderObject; | 38 class RenderObject; |
| 39 class RenderBlockFlow; | 39 class RenderParagraph; |
| 40 | 40 |
| 41 enum IndentTextOrNot { DoNotIndentText, IndentText }; | 41 enum IndentTextOrNot { DoNotIndentText, IndentText }; |
| 42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; | 42 enum WhitespaceTreatment { ExcludeWhitespace, IncludeWhitespace }; |
| 43 | 43 |
| 44 class LineWidth { | 44 class LineWidth { |
| 45 public: | 45 public: |
| 46 LineWidth(RenderBlockFlow&, bool isFirstLine, IndentTextOrNot shouldIndentTe
xt); | 46 LineWidth(RenderParagraph&, bool isFirstLine, IndentTextOrNot shouldIndentTe
xt); |
| 47 | 47 |
| 48 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } | 48 bool fitsOnLine() const { return currentWidth() <= (m_availableWidth + Layou
tUnit::epsilon()); } |
| 49 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } | 49 bool fitsOnLine(float extra) const { return currentWidth() + extra <= (m_ava
ilableWidth + LayoutUnit::epsilon()); } |
| 50 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const | 50 bool fitsOnLine(float extra, WhitespaceTreatment whitespaceTreatment) const |
| 51 { | 51 { |
| 52 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; | 52 return currentWidth() - (whitespaceTreatment == ExcludeWhitespace ? trai
lingWhitespaceWidth() : 0) + extra <= (m_availableWidth + LayoutUnit::epsilon())
; |
| 53 } | 53 } |
| 54 | 54 |
| 55 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } | 55 float currentWidth() const { return m_committedWidth + m_uncommittedWidth; } |
| 56 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. | 56 // FIXME: We should eventually replace these three functions by ones that wo
rk on a higher abstraction. |
| 57 float uncommittedWidth() const { return m_uncommittedWidth; } | 57 float uncommittedWidth() const { return m_uncommittedWidth; } |
| 58 float committedWidth() const { return m_committedWidth; } | 58 float committedWidth() const { return m_committedWidth; } |
| 59 float availableWidth() const { return m_availableWidth; } | 59 float availableWidth() const { return m_availableWidth; } |
| 60 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } | 60 float trailingWhitespaceWidth() const { return m_trailingWhitespaceWidth; } |
| 61 | 61 |
| 62 void updateAvailableWidth(); | 62 void updateAvailableWidth(); |
| 63 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } | 63 void addUncommittedWidth(float delta) { m_uncommittedWidth += delta; } |
| 64 void commit(); | 64 void commit(); |
| 65 void fitBelowFloats(bool isFirstLine = false); | 65 void fitBelowFloats(bool isFirstLine = false); |
| 66 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } | 66 void setTrailingWhitespaceWidth(float width) { m_trailingWhitespaceWidth = w
idth; } |
| 67 | 67 |
| 68 bool shouldIndentText() const { return m_shouldIndentText == IndentText; } | 68 bool shouldIndentText() const { return m_shouldIndentText == IndentText; } |
| 69 | 69 |
| 70 private: | 70 private: |
| 71 void computeAvailableWidthFromLeftAndRight(); | 71 void computeAvailableWidthFromLeftAndRight(); |
| 72 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st float& newLineLeft, const float& newLineRight); | 72 void updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWidth, con
st float& newLineLeft, const float& newLineRight); |
| 73 | 73 |
| 74 RenderBlockFlow& m_block; | 74 RenderParagraph& m_block; |
| 75 float m_uncommittedWidth; | 75 float m_uncommittedWidth; |
| 76 float m_committedWidth; | 76 float m_committedWidth; |
| 77 float m_trailingWhitespaceWidth; | 77 float m_trailingWhitespaceWidth; |
| 78 float m_left; | 78 float m_left; |
| 79 float m_right; | 79 float m_right; |
| 80 float m_availableWidth; | 80 float m_availableWidth; |
| 81 IndentTextOrNot m_shouldIndentText; | 81 IndentTextOrNot m_shouldIndentText; |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 } | 84 } |
| 85 | 85 |
| 86 #endif // SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ | 86 #endif // SKY_ENGINE_CORE_RENDERING_LINE_LINEWIDTH_H_ |
| OLD | NEW |