| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 , m_isFirstLine(isFirstLine) | 46 , m_isFirstLine(isFirstLine) |
| 47 , m_shouldIndentText(shouldIndentText) | 47 , m_shouldIndentText(shouldIndentText) |
| 48 { | 48 { |
| 49 updateAvailableWidth(); | 49 updateAvailableWidth(); |
| 50 } | 50 } |
| 51 | 51 |
| 52 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight) | 52 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight) |
| 53 { | 53 { |
| 54 LayoutUnit height = m_block.logicalHeight(); | 54 LayoutUnit height = m_block.logicalHeight(); |
| 55 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedObject(m_isFirstL
ine, replacedHeight); | 55 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedObject(m_isFirstL
ine, replacedHeight); |
| 56 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); | 56 m_left = m_block.logicalLeftOffsetForLine(height, indentText(), logicalHeigh
t).toFloat(); |
| 57 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); | 57 m_right = m_block.logicalRightOffsetForLine(height, indentText(), logicalHei
ght).toFloat(); |
| 58 | 58 |
| 59 computeAvailableWidthFromLeftAndRight(); | 59 computeAvailableWidthFromLeftAndRight(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject& ne
wFloat) | 62 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(const FloatingObject& ne
wFloat) |
| 63 { | 63 { |
| 64 LayoutUnit height = m_block.logicalHeight(); | 64 LayoutUnit height = m_block.logicalHeight(); |
| 65 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic
alBottomForFloat(newFloat)) | 65 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic
alBottomForFloat(newFloat)) |
| 66 return; | 66 return; |
| 67 | 67 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 rubyRun.getOverhang(m_isFirstLine, startLayoutItem, endLayoutItem, startOver
hang, endOverhang); | 111 rubyRun.getOverhang(m_isFirstLine, startLayoutItem, endLayoutItem, startOver
hang, endOverhang); |
| 112 | 112 |
| 113 startOverhang = std::min<int>(startOverhang, m_committedWidth); | 113 startOverhang = std::min<int>(startOverhang, m_committedWidth); |
| 114 m_availableWidth += startOverhang; | 114 m_availableWidth += startOverhang; |
| 115 | 115 |
| 116 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); | 116 endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - current
Width()), 0); |
| 117 m_availableWidth += endOverhang; | 117 m_availableWidth += endOverhang; |
| 118 m_overhangWidth += startOverhang + endOverhang; | 118 m_overhangWidth += startOverhang + endOverhang; |
| 119 } | 119 } |
| 120 | 120 |
| 121 inline static float availableWidthAtOffset(LineLayoutBlockFlow block, const Layo
utUnit& offset, bool shouldIndentText, float& newLineLeft, | 121 inline static float availableWidthAtOffset(LineLayoutBlockFlow block, const Layo
utUnit& offset, IndentTextOrNot shouldIndentText, float& newLineLeft, |
| 122 float& newLineRight, const LayoutUnit& lineHeight = 0) | 122 float& newLineRight, const LayoutUnit& lineHeight = 0) |
| 123 { | 123 { |
| 124 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineH
eight).toFloat(); | 124 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText, lineH
eight).toFloat(); |
| 125 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lin
eHeight).toFloat(); | 125 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText, lin
eHeight).toFloat(); |
| 126 return std::max(0.0f, newLineRight - newLineLeft); | 126 return std::max(0.0f, newLineRight - newLineLeft); |
| 127 } | 127 } |
| 128 | 128 |
| 129 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) | 129 void LineWidth::updateLineDimension(LayoutUnit newLineTop, LayoutUnit newLineWid
th, const float& newLineLeft, const float& newLineRight) |
| 130 { | 130 { |
| 131 if (newLineWidth <= m_availableWidth) | 131 if (newLineWidth <= m_availableWidth) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 m_block.setLogicalHeight(newLineTop); | 134 m_block.setLogicalHeight(newLineTop); |
| 135 m_availableWidth = newLineWidth + m_overhangWidth; | 135 m_availableWidth = newLineWidth + m_overhangWidth; |
| 136 m_left = newLineLeft; | 136 m_left = newLineLeft; |
| 137 m_right = newLineRight; | 137 m_right = newLineRight; |
| 138 } | 138 } |
| 139 | 139 |
| 140 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) | 140 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) |
| 141 { | 141 { |
| 142 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | 142 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); |
| 143 LayoutUnit lineLogicalTop = m_block.logicalHeight(); | 143 LayoutUnit lineLogicalTop = m_block.logicalHeight(); |
| 144 LayoutUnit newLineTop = lineLogicalTop; | 144 LayoutUnit newLineTop = lineLogicalTop; |
| 145 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); | 145 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); |
| 146 | 146 |
| 147 float newLineWidth; | 147 float newLineWidth; |
| 148 float newLineLeft = m_left; | 148 float newLineLeft = m_left; |
| 149 float newLineRight = m_right; | 149 float newLineRight = m_right; |
| 150 while (true) { | 150 while (true) { |
| 151 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight, lineHeight); | 151 newLineWidth = availableWidthAtOffset(m_block, newLineTop, indentText(),
newLineLeft, newLineRight, lineHeight); |
| 152 if (newLineWidth >= m_uncommittedWidth) | 152 if (newLineWidth >= m_uncommittedWidth) |
| 153 break; | 153 break; |
| 154 | 154 |
| 155 if (newLineTop >= floatLogicalBottom) | 155 if (newLineTop >= floatLogicalBottom) |
| 156 break; | 156 break; |
| 157 | 157 |
| 158 newLineTop++; | 158 newLineTop++; |
| 159 } | 159 } |
| 160 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); | 160 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); |
| 161 } | 161 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 174 | 174 |
| 175 FloatingObject* lastFloatFromPreviousLine = m_block.lastFloatFromPreviousLin
e(); | 175 FloatingObject* lastFloatFromPreviousLine = m_block.lastFloatFromPreviousLin
e(); |
| 176 if (lastFloatFromPreviousLine && lastFloatFromPreviousLine->layoutObject
()->shapeOutsideInfo()) | 176 if (lastFloatFromPreviousLine && lastFloatFromPreviousLine->layoutObject
()->shapeOutsideInfo()) |
| 177 return wrapNextToShapeOutside(isFirstLine); | 177 return wrapNextToShapeOutside(isFirstLine); |
| 178 | 178 |
| 179 while (true) { | 179 while (true) { |
| 180 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogica
lBottom, ShapeOutsideFloatShapeOffset); | 180 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogica
lBottom, ShapeOutsideFloatShapeOffset); |
| 181 if (floatLogicalBottom <= lastFloatLogicalBottom) | 181 if (floatLogicalBottom <= lastFloatLogicalBottom) |
| 182 break; | 182 break; |
| 183 | 183 |
| 184 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); | 184 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, inden
tText(), newLineLeft, newLineRight); |
| 185 lastFloatLogicalBottom = floatLogicalBottom; | 185 lastFloatLogicalBottom = floatLogicalBottom; |
| 186 | 186 |
| 187 if (newLineWidth >= m_uncommittedWidth) | 187 if (newLineWidth >= m_uncommittedWidth) |
| 188 break; | 188 break; |
| 189 } | 189 } |
| 190 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 190 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 191 } | 191 } |
| 192 | 192 |
| 193 void LineWidth::computeAvailableWidthFromLeftAndRight() | 193 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 194 { | 194 { |
| 195 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; | 195 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; |
| 196 } | 196 } |
| 197 | 197 |
| 198 } | 198 } |
| OLD | NEW |