| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 m_uncommittedWidth = 0; | 65 m_uncommittedWidth = 0; |
| 66 } | 66 } |
| 67 | 67 |
| 68 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRigh
t) | 68 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRigh
t) |
| 69 { | 69 { |
| 70 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); | 70 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); |
| 71 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); | 71 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); |
| 72 return std::max(0.0f, newLineRight - newLineLeft); | 72 return std::max(0.0f, newLineRight - newLineLeft); |
| 73 } | 73 } |
| 74 | 74 |
| 75 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText) | |
| 76 { | |
| 77 float newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText)
.toFloat(); | |
| 78 float newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentTex
t).toFloat(); | |
| 79 return std::max(0.0f, newLineRight - newLineLeft); | |
| 80 } | |
| 81 | |
| 82 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) | 75 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) |
| 83 { | 76 { |
| 84 if (newLineWidth <= m_availableWidth) | 77 if (newLineWidth <= m_availableWidth) |
| 85 return; | 78 return; |
| 86 | 79 |
| 87 m_block.setLogicalHeight(newLineTop); | 80 m_block.setLogicalHeight(newLineTop); |
| 88 m_availableWidth = newLineWidth.toFloat(); | 81 m_availableWidth = newLineWidth.toFloat(); |
| 89 m_left = newLineLeft; | 82 m_left = newLineLeft; |
| 90 m_right = newLineRight; | 83 m_right = newLineRight; |
| 91 } | 84 } |
| 92 | 85 |
| 93 inline static bool isWholeLineFit(const RenderBlockFlow& block, const LayoutUnit
& lineTop, LayoutUnit lineHeight, float uncommittedWidth, bool shouldIndentText) | |
| 94 { | |
| 95 for (LayoutUnit lineBottom = lineTop; lineBottom <= lineTop + lineHeight; li
neBottom++) { | |
| 96 LayoutUnit availableWidthAtBottom = availableWidthAtOffset(block, lineBo
ttom, shouldIndentText); | |
| 97 if (availableWidthAtBottom < uncommittedWidth) | |
| 98 return false; | |
| 99 } | |
| 100 return true; | |
| 101 } | |
| 102 | |
| 103 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) | |
| 104 { | |
| 105 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, HorizontalLine, Posi
tionOfInteriorLineBoxes); | |
| 106 LayoutUnit lineLogicalTop = m_block.logicalHeight(); | |
| 107 LayoutUnit newLineTop = lineLogicalTop; | |
| 108 LayoutUnit floatLogicalBottom = lineLogicalTop; | |
| 109 | |
| 110 float newLineWidth; | |
| 111 float newLineLeft = m_left; | |
| 112 float newLineRight = m_right; | |
| 113 while (true) { | |
| 114 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); | |
| 115 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) | |
| 116 break; | |
| 117 | |
| 118 if (newLineTop >= floatLogicalBottom) | |
| 119 break; | |
| 120 | |
| 121 newLineTop++; | |
| 122 } | |
| 123 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); | |
| 124 } | |
| 125 | 86 |
| 126 void LineWidth::fitBelowFloats(bool isFirstLine) | 87 void LineWidth::fitBelowFloats(bool isFirstLine) |
| 127 { | 88 { |
| 128 ASSERT(!m_committedWidth); | 89 ASSERT(!m_committedWidth); |
| 129 ASSERT(!fitsOnLine()); | 90 ASSERT(!fitsOnLine()); |
| 130 | 91 |
| 131 LayoutUnit floatLogicalBottom; | 92 LayoutUnit floatLogicalBottom; |
| 132 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); | 93 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); |
| 133 float newLineWidth = m_availableWidth; | 94 float newLineWidth = m_availableWidth; |
| 134 float newLineLeft = m_left; | 95 float newLineLeft = m_left; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 147 } | 108 } |
| 148 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 109 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 149 } | 110 } |
| 150 | 111 |
| 151 void LineWidth::computeAvailableWidthFromLeftAndRight() | 112 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 152 { | 113 { |
| 153 m_availableWidth = max(0.0f, m_right - m_left); | 114 m_availableWidth = max(0.0f, m_right - m_left); |
| 154 } | 115 } |
| 155 | 116 |
| 156 } | 117 } |
| OLD | NEW |