| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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.minLineHeightForReplacedRenderer(m_isFirs
tLine, replacedHeight); | 55 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedRenderer(m_isFirs
tLine, replacedHeight); |
| 56 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); | 56 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); |
| 57 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); | 57 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); |
| 58 | 58 |
| 59 computeAvailableWidthFromLeftAndRight(); | 59 computeAvailableWidthFromLeftAndRight(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat
) | |
| 63 { | |
| 64 LayoutUnit height = m_block.logicalHeight(); | |
| 65 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic
alBottomForFloat(newFloat)) | |
| 66 return; | |
| 67 | |
| 68 ShapeOutsideDeltas shapeDeltas; | |
| 69 if (ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideI
nfo()) { | |
| 70 LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHori
zontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes
); | |
| 71 shapeDeltas = shapeOutsideInfo->computeDeltasForContainingBlockLine(m_bl
ock, *newFloat, m_block.logicalHeight(), lineHeight); | |
| 72 } | |
| 73 | |
| 74 if (newFloat->type() == FloatingObject::FloatLeft) { | |
| 75 float newLeft = m_block.logicalRightForFloat(newFloat).toFloat(); | |
| 76 if (shapeDeltas.isValid()) { | |
| 77 if (shapeDeltas.lineOverlapsShape()) | |
| 78 newLeft += shapeDeltas.rightMarginBoxDelta(); | |
| 79 else // Per the CSS Shapes spec, If the line doesn't overlap the sha
pe, then ignore this shape for this line. | |
| 80 newLeft = m_left; | |
| 81 } | |
| 82 if (shouldIndentText() && m_block.style()->isLeftToRightDirection()) | |
| 83 newLeft += floorToInt(m_block.textIndentOffset()); | |
| 84 m_left = std::max<float>(m_left, newLeft); | |
| 85 } else { | |
| 86 float newRight = m_block.logicalLeftForFloat(newFloat).toFloat(); | |
| 87 if (shapeDeltas.isValid()) { | |
| 88 if (shapeDeltas.lineOverlapsShape()) | |
| 89 newRight += shapeDeltas.leftMarginBoxDelta(); | |
| 90 else // Per the CSS Shapes spec, If the line doesn't overlap the sha
pe, then ignore this shape for this line. | |
| 91 newRight = m_right; | |
| 92 } | |
| 93 if (shouldIndentText() && !m_block.style()->isLeftToRightDirection()) | |
| 94 newRight -= floorToInt(m_block.textIndentOffset()); | |
| 95 m_right = std::min<float>(m_right, newRight); | |
| 96 } | |
| 97 | |
| 98 computeAvailableWidthFromLeftAndRight(); | |
| 99 } | |
| 100 | |
| 101 void LineWidth::commit() | 62 void LineWidth::commit() |
| 102 { | 63 { |
| 103 m_committedWidth += m_uncommittedWidth; | 64 m_committedWidth += m_uncommittedWidth; |
| 104 m_uncommittedWidth = 0; | 65 m_uncommittedWidth = 0; |
| 105 } | 66 } |
| 106 | 67 |
| 107 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) |
| 108 { | 69 { |
| 109 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); | 70 newLineLeft = block.logicalLeftOffsetForLine(offset, shouldIndentText).toFlo
at(); |
| 110 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); | 71 newLineRight = block.logicalRightOffsetForLine(offset, shouldIndentText).toF
loat(); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 137 return false; | 98 return false; |
| 138 } | 99 } |
| 139 return true; | 100 return true; |
| 140 } | 101 } |
| 141 | 102 |
| 142 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) | 103 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) |
| 143 { | 104 { |
| 144 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | 105 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); |
| 145 LayoutUnit lineLogicalTop = m_block.logicalHeight(); | 106 LayoutUnit lineLogicalTop = m_block.logicalHeight(); |
| 146 LayoutUnit newLineTop = lineLogicalTop; | 107 LayoutUnit newLineTop = lineLogicalTop; |
| 147 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); | 108 LayoutUnit floatLogicalBottom = lineLogicalTop; |
| 148 | 109 |
| 149 float newLineWidth; | 110 float newLineWidth; |
| 150 float newLineLeft = m_left; | 111 float newLineLeft = m_left; |
| 151 float newLineRight = m_right; | 112 float newLineRight = m_right; |
| 152 while (true) { | 113 while (true) { |
| 153 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); | 114 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); |
| 154 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) | 115 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) |
| 155 break; | 116 break; |
| 156 | 117 |
| 157 if (newLineTop >= floatLogicalBottom) | 118 if (newLineTop >= floatLogicalBottom) |
| 158 break; | 119 break; |
| 159 | 120 |
| 160 newLineTop++; | 121 newLineTop++; |
| 161 } | 122 } |
| 162 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); | 123 updateLineDimension(newLineTop, newLineWidth, newLineLeft, newLineRight); |
| 163 } | 124 } |
| 164 | 125 |
| 165 void LineWidth::fitBelowFloats(bool isFirstLine) | 126 void LineWidth::fitBelowFloats(bool isFirstLine) |
| 166 { | 127 { |
| 167 ASSERT(!m_committedWidth); | 128 ASSERT(!m_committedWidth); |
| 168 ASSERT(!fitsOnLine()); | 129 ASSERT(!fitsOnLine()); |
| 169 | 130 |
| 170 LayoutUnit floatLogicalBottom; | 131 LayoutUnit floatLogicalBottom; |
| 171 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); | 132 LayoutUnit lastFloatLogicalBottom = m_block.logicalHeight(); |
| 172 float newLineWidth = m_availableWidth; | 133 float newLineWidth = m_availableWidth; |
| 173 float newLineLeft = m_left; | 134 float newLineLeft = m_left; |
| 174 float newLineRight = m_right; | 135 float newLineRight = m_right; |
| 175 | 136 |
| 176 FloatingObject* lastFloatFromPreviousLine = (m_block.containsFloats() ? m_bl
ock.m_floatingObjects->set().last().get() : 0); | |
| 177 if (lastFloatFromPreviousLine && lastFloatFromPreviousLine->renderer()->
shapeOutsideInfo()) | |
| 178 return wrapNextToShapeOutside(isFirstLine); | |
| 179 | |
| 180 while (true) { | 137 while (true) { |
| 181 floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogica
lBottom, ShapeOutsideFloatShapeOffset); | 138 floatLogicalBottom = lastFloatLogicalBottom; |
| 182 if (floatLogicalBottom <= lastFloatLogicalBottom) | 139 if (floatLogicalBottom <= lastFloatLogicalBottom) |
| 183 break; | 140 break; |
| 184 | 141 |
| 185 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); | 142 newLineWidth = availableWidthAtOffset(m_block, floatLogicalBottom, shoul
dIndentText(), newLineLeft, newLineRight); |
| 186 lastFloatLogicalBottom = floatLogicalBottom; | 143 lastFloatLogicalBottom = floatLogicalBottom; |
| 187 | 144 |
| 188 if (newLineWidth >= m_uncommittedWidth) | 145 if (newLineWidth >= m_uncommittedWidth) |
| 189 break; | 146 break; |
| 190 } | 147 } |
| 191 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 148 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
| 192 } | 149 } |
| 193 | 150 |
| 194 void LineWidth::computeAvailableWidthFromLeftAndRight() | 151 void LineWidth::computeAvailableWidthFromLeftAndRight() |
| 195 { | 152 { |
| 196 m_availableWidth = max(0.0f, m_right - m_left); | 153 m_availableWidth = max(0.0f, m_right - m_left); |
| 197 } | 154 } |
| 198 | 155 |
| 199 } | 156 } |
| OLD | NEW |