| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhan
g, endOverhang); | 112 rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhan
g, endOverhang); |
| 113 | 113 |
| 114 startOverhang = std::min<int>(startOverhang, m_committedWidth); | 114 startOverhang = std::min<int>(startOverhang, m_committedWidth); |
| 115 m_availableWidth += startOverhang; | 115 m_availableWidth += startOverhang; |
| 116 | 116 |
| 117 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); | 117 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); |
| 118 m_availableWidth += endOverhang; | 118 m_availableWidth += endOverhang; |
| 119 m_overhangWidth += startOverhang + endOverhang; | 119 m_overhangWidth += startOverhang + endOverhang; |
| 120 } | 120 } |
| 121 | 121 |
| 122 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, float& newLineRigh
t) | 122 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText, float& newLineLeft, |
| 123 float& newLineRight, const LayoutUnit& lineHeight = 0) |
| 123 { | 124 { |
| 124 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); | 125 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineH
eight).toFloat(); |
| 125 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); | 126 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lin
eHeight).toFloat(); |
| 126 return std::max(0.0f, newLineRight - newLineLeft); | 127 return std::max(0.0f, newLineRight - newLineLeft); |
| 127 } | 128 } |
| 128 | 129 |
| 129 inline static float availableWidthAtOffset(const RenderBlockFlow& block, const L
ayoutUnit& offset, bool shouldIndentText) | |
| 130 { | |
| 131 float newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText)
.toFloat(); | |
| 132 float newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentTex
t).toFloat(); | |
| 133 return std::max(0.0f, newLineRight - newLineLeft); | |
| 134 } | |
| 135 | |
| 136 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) | 130 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) |
| 137 { | 131 { |
| 138 if (newLineWidth <= m_availableWidth) | 132 if (newLineWidth <= m_availableWidth) |
| 139 return; | 133 return; |
| 140 | 134 |
| 141 m_block.setLogicalHeight(newLineTop); | 135 m_block.setLogicalHeight(newLineTop); |
| 142 m_availableWidth = newLineWidth + m_overhangWidth; | 136 m_availableWidth = newLineWidth + m_overhangWidth; |
| 143 m_left = newLineLeft; | 137 m_left = newLineLeft; |
| 144 m_right = newLineRight; | 138 m_right = newLineRight; |
| 145 } | 139 } |
| 146 | 140 |
| 147 inline static bool isWholeLineFit(const RenderBlockFlow& block, const LayoutUnit
& lineTop, LayoutUnit lineHeight, float uncommittedWidth, bool shouldIndentText) | |
| 148 { | |
| 149 for (LayoutUnit lineBottom = lineTop; lineBottom <= lineTop + lineHeight; li
neBottom++) { | |
| 150 LayoutUnit availableWidthAtBottom = availableWidthAtOffset(block, lineBo
ttom, shouldIndentText); | |
| 151 if (availableWidthAtBottom < uncommittedWidth) | |
| 152 return false; | |
| 153 } | |
| 154 return true; | |
| 155 } | |
| 156 | |
| 157 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) | 141 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) |
| 158 { | 142 { |
| 159 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | 143 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); |
| 160 LayoutUnit lineLogicalTop = m_block.logicalHeight(); | 144 LayoutUnit lineLogicalTop = m_block.logicalHeight(); |
| 161 LayoutUnit newLineTop = lineLogicalTop; | 145 LayoutUnit newLineTop = lineLogicalTop; |
| 162 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); | 146 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); |
| 163 | 147 |
| 164 float newLineWidth; | 148 float newLineWidth; |
| 165 float newLineLeft = m_left; | 149 float newLineLeft = m_left; |
| 166 float newLineRight = m_right; | 150 float newLineRight = m_right; |
| 167 while (true) { | 151 while (true) { |
| 168 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); | 152 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight, lineHeight); |
| 169 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) | 153 if (newLineWidth >= m_uncommittedWidth) |
| 170 break; | 154 break; |
| 171 | 155 |
| 172 if (newLineTop >= floatLogicalBottom) | 156 if (newLineTop >= floatLogicalBottom) |
| 173 break; | 157 break; |
| 174 | 158 |
| 175 newLineTop++; | 159 newLineTop++; |
| 176 } | 160 } |
| 177 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); | 161 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); |
| 178 } | 162 } |
| 179 | 163 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 206 } | 190 } |
| 207 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 191 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 208 } | 192 } |
| 209 | 193 |
| 210 void LineWidth::computeAvailableWidthFromLeftAndRight() | 194 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 211 { | 195 { |
| 212 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; | 196 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; |
| 213 } | 197 } |
| 214 | 198 |
| 215 } | 199 } |
| OLD | NEW |