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_availableWidth(0) | 46 , m_availableWidth(0) |
47 , m_isFirstLine(isFirstLine) | 47 , m_isFirstLine(isFirstLine) |
48 , m_shouldIndentText(shouldIndentText) | 48 , m_shouldIndentText(shouldIndentText) |
49 { | 49 { |
50 updateAvailableWidth(); | 50 updateAvailableWidth(); |
51 } | 51 } |
52 | 52 |
53 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight) | 53 void LineWidth::updateAvailableWidth(LayoutUnit replacedHeight) |
54 { | 54 { |
55 LayoutUnit height = m_block.logicalHeight(); | 55 LayoutUnit height = m_block.logicalHeight(); |
56 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedRenderer(m_isFirs
tLine, replacedHeight); | 56 LayoutUnit logicalHeight = m_block.minLineHeightForReplacedRenderer(m_isFirs
tLine ? FirstLineStyle : OwnStyle, replacedHeight); |
57 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); | 57 m_left = m_block.logicalLeftOffsetForLine(height, shouldIndentText(), logica
lHeight).toFloat(); |
58 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); | 58 m_right = m_block.logicalRightOffsetForLine(height, shouldIndentText(), logi
calHeight).toFloat(); |
59 | 59 |
60 computeAvailableWidthFromLeftAndRight(); | 60 computeAvailableWidthFromLeftAndRight(); |
61 } | 61 } |
62 | 62 |
63 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat
) | 63 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat
) |
64 { | 64 { |
65 LayoutUnit height = m_block.logicalHeight(); | 65 LayoutUnit height = m_block.logicalHeight(); |
66 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic
alBottomForFloat(newFloat)) | 66 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic
alBottomForFloat(newFloat)) |
67 return; | 67 return; |
68 | 68 |
69 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo(
); | 69 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo(
); |
70 if (shapeOutsideInfo) { | 70 if (shapeOutsideInfo) { |
71 LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHori
zontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes
); | 71 LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine ? FirstLineStyl
e : OwnStyle, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine,
PositionOfInteriorLineBoxes); |
72 shapeOutsideInfo->updateDeltasForContainingBlockLine(m_block, *newFloat,
m_block.logicalHeight(), lineHeight); | 72 shapeOutsideInfo->updateDeltasForContainingBlockLine(m_block, *newFloat,
m_block.logicalHeight(), lineHeight); |
73 } | 73 } |
74 | 74 |
75 if (newFloat->type() == FloatingObject::FloatLeft) { | 75 if (newFloat->type() == FloatingObject::FloatLeft) { |
76 float newLeft = m_block.logicalRightForFloat(newFloat).toFloat(); | 76 float newLeft = m_block.logicalRightForFloat(newFloat).toFloat(); |
77 if (shapeOutsideInfo) { | 77 if (shapeOutsideInfo) { |
78 if (shapeOutsideInfo->lineOverlapsShape()) | 78 if (shapeOutsideInfo->lineOverlapsShape()) |
79 newLeft += shapeOutsideInfo->rightMarginBoxDelta(); | 79 newLeft += shapeOutsideInfo->rightMarginBoxDelta(); |
80 else // Per the CSS Shapes spec, If the line doesn't overlap the sha
pe, then ignore this shape for this line. | 80 else // Per the CSS Shapes spec, If the line doesn't overlap the sha
pe, then ignore this shape for this line. |
81 newLeft = m_left; | 81 newLeft = m_left; |
(...skipping 20 matching lines...) Expand all Loading... |
102 void LineWidth::commit() | 102 void LineWidth::commit() |
103 { | 103 { |
104 m_committedWidth += m_uncommittedWidth; | 104 m_committedWidth += m_uncommittedWidth; |
105 m_uncommittedWidth = 0; | 105 m_uncommittedWidth = 0; |
106 } | 106 } |
107 | 107 |
108 void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRendere
r, RenderObject* endRenderer) | 108 void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRendere
r, RenderObject* endRenderer) |
109 { | 109 { |
110 int startOverhang; | 110 int startOverhang; |
111 int endOverhang; | 111 int endOverhang; |
112 rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhan
g, endOverhang); | 112 rubyRun->getOverhang(m_isFirstLine ? FirstLineStyle : OwnStyle, startRendere
r, endRenderer, startOverhang, 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, float& newLineRigh
t) |
(...skipping 26 matching lines...) Expand all Loading... |
149 for (LayoutUnit lineBottom = lineTop; lineBottom <= lineTop + lineHeight; li
neBottom++) { | 149 for (LayoutUnit lineBottom = lineTop; lineBottom <= lineTop + lineHeight; li
neBottom++) { |
150 LayoutUnit availableWidthAtBottom = availableWidthAtOffset(block, lineBo
ttom, shouldIndentText); | 150 LayoutUnit availableWidthAtBottom = availableWidthAtOffset(block, lineBo
ttom, shouldIndentText); |
151 if (availableWidthAtBottom < uncommittedWidth) | 151 if (availableWidthAtBottom < uncommittedWidth) |
152 return false; | 152 return false; |
153 } | 153 } |
154 return true; | 154 return true; |
155 } | 155 } |
156 | 156 |
157 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) | 157 void LineWidth::wrapNextToShapeOutside(bool isFirstLine) |
158 { | 158 { |
159 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine, m_block.isHorizontal
WritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | 159 LayoutUnit lineHeight = m_block.lineHeight(isFirstLine ? FirstLineStyle : Ow
nStyle, m_block.isHorizontalWritingMode() ? HorizontalLine : VerticalLine, Posit
ionOfInteriorLineBoxes); |
160 LayoutUnit lineLogicalTop = m_block.logicalHeight(); | 160 LayoutUnit lineLogicalTop = m_block.logicalHeight(); |
161 LayoutUnit newLineTop = lineLogicalTop; | 161 LayoutUnit newLineTop = lineLogicalTop; |
162 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); | 162 LayoutUnit floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lineLogi
calTop); |
163 | 163 |
164 float newLineWidth; | 164 float newLineWidth; |
165 float newLineLeft = m_left; | 165 float newLineLeft = m_left; |
166 float newLineRight = m_right; | 166 float newLineRight = m_right; |
167 while (true) { | 167 while (true) { |
168 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); | 168 newLineWidth = availableWidthAtOffset(m_block, newLineTop, shouldIndentT
ext(), newLineLeft, newLineRight); |
169 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) | 169 if (newLineWidth >= m_uncommittedWidth && isWholeLineFit(m_block, newLin
eTop, lineHeight, m_uncommittedWidth, shouldIndentText())) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 } | 205 } |
206 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); | 206 updateLineDimension(lastFloatLogicalBottom, newLineWidth, newLineLeft, newLi
neRight); |
207 } | 207 } |
208 | 208 |
209 void LineWidth::computeAvailableWidthFromLeftAndRight() | 209 void LineWidth::computeAvailableWidthFromLeftAndRight() |
210 { | 210 { |
211 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; | 211 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; |
212 } | 212 } |
213 | 213 |
214 } | 214 } |
OLD | NEW |