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 | 65 |
66 computeAvailableWidthFromLeftAndRight(); | 66 computeAvailableWidthFromLeftAndRight(); |
67 } | 67 } |
68 | 68 |
69 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat ) | 69 void LineWidth::shrinkAvailableWidthForNewFloatIfNeeded(FloatingObject* newFloat ) |
70 { | 70 { |
71 LayoutUnit height = m_block.logicalHeight(); | 71 LayoutUnit height = m_block.logicalHeight(); |
72 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic alBottomForFloat(newFloat)) | 72 if (height < m_block.logicalTopForFloat(newFloat) || height >= m_block.logic alBottomForFloat(newFloat)) |
73 return; | 73 return; |
74 | 74 |
75 // When floats with shape outside are stacked, the floats are positioned bas ed on the margin box of the float, | 75 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo( ); |
76 // not the shape's contour. Since we computed the width based on the shape c ontour when we added the float, | 76 if (shapeOutsideInfo) { |
77 // when we add a subsequent float on the same line, we need to undo the shap e delta in order to position | 77 LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHori zontalWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes ); |
78 // based on the margin box. In order to do this, we need to walk back throug h the floating object list to find | 78 shapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), lineHeight); |
79 // the first previous float that is on the same side as our newFloat. | |
80 ShapeOutsideInfo* previousShapeOutsideInfo = 0; | |
81 const FloatingObjectSet& floatingObjectSet = m_block.m_floatingObjects->set( ); | |
82 FloatingObjectSetIterator it = floatingObjectSet.end(); | |
83 FloatingObjectSetIterator begin = floatingObjectSet.begin(); | |
84 LayoutUnit lineHeight = m_block.lineHeight(m_isFirstLine, m_block.isHorizont alWritingMode() ? HorizontalLine : VerticalLine, PositionOfInteriorLineBoxes); | |
85 for (--it; it != begin; --it) { | |
86 FloatingObject* previousFloat = *it; | |
87 if (previousFloat != newFloat && previousFloat->type() == newFloat->type ()) { | |
88 previousShapeOutsideInfo = previousFloat->renderer()->shapeOutsideIn fo(); | |
89 if (previousShapeOutsideInfo) | |
90 previousShapeOutsideInfo->updateDeltasForContainingBlockLine(&m_ block, previousFloat, m_block.logicalHeight(), lineHeight); | |
91 break; | |
92 } | |
93 } | 79 } |
94 | 80 |
95 ShapeOutsideInfo* shapeOutsideInfo = newFloat->renderer()->shapeOutsideInfo( ); | |
96 if (shapeOutsideInfo) | |
97 shapeOutsideInfo->updateDeltasForContainingBlockLine(&m_block, newFloat, m_block.logicalHeight(), lineHeight); | |
98 | |
99 if (newFloat->type() == FloatingObject::FloatLeft) { | 81 if (newFloat->type() == FloatingObject::FloatLeft) { |
100 float newLeft = m_block.logicalRightForFloat(newFloat); | 82 float newLeft = m_block.logicalRightForFloat(newFloat); |
101 if (previousShapeOutsideInfo) | 83 if (shapeOutsideInfo) { |
102 newLeft -= previousShapeOutsideInfo->rightMarginBoxDelta(); | 84 if (shapeOutsideInfo->lineOverlapsShape()) |
103 if (shapeOutsideInfo) | 85 newLeft += shapeOutsideInfo->rightMarginBoxDelta(); |
104 newLeft += shapeOutsideInfo->rightMarginBoxDelta(); | 86 else // If the line doesn't overlap the shape, then we need to act a s if this float didn't exist. |
105 | 87 newLeft = m_left; |
88 } | |
106 if (shouldIndentText() && m_block.style()->isLeftToRightDirection()) | 89 if (shouldIndentText() && m_block.style()->isLeftToRightDirection()) |
107 newLeft += floorToInt(m_block.textIndentOffset()); | 90 newLeft += floorToInt(m_block.textIndentOffset()); |
108 m_left = std::max<float>(m_left, newLeft); | 91 m_left = std::max<float>(m_left, newLeft); |
109 } else { | 92 } else { |
110 float newRight = m_block.logicalLeftForFloat(newFloat); | 93 float newRight = m_block.logicalLeftForFloat(newFloat); |
111 if (previousShapeOutsideInfo) | 94 if (shapeOutsideInfo) { |
112 newRight -= previousShapeOutsideInfo->leftMarginBoxDelta(); | 95 if (shapeOutsideInfo->lineOverlapsShape()) |
113 if (shapeOutsideInfo) | 96 newRight += shapeOutsideInfo->leftMarginBoxDelta(); |
114 newRight += shapeOutsideInfo->leftMarginBoxDelta(); | 97 else // If the line doesn't overlap the shape, then we need to act a s if this float didn't exist. |
leviw_travelin_and_unemployed
2014/02/27 21:59:06
I could go so far as to suggest linking to the spe
| |
115 | 98 newRight = m_right; |
99 } | |
116 if (shouldIndentText() && !m_block.style()->isLeftToRightDirection()) | 100 if (shouldIndentText() && !m_block.style()->isLeftToRightDirection()) |
117 newRight -= floorToInt(m_block.textIndentOffset()); | 101 newRight -= floorToInt(m_block.textIndentOffset()); |
118 m_right = std::min<float>(m_right, newRight); | 102 m_right = std::min<float>(m_right, newRight); |
119 } | 103 } |
120 | 104 |
121 computeAvailableWidthFromLeftAndRight(); | 105 computeAvailableWidthFromLeftAndRight(); |
122 } | 106 } |
123 | 107 |
124 void LineWidth::commit() | 108 void LineWidth::commit() |
125 { | 109 { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 if (ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo()) | 172 if (ShapeInsideInfo* shapeInsideInfo = m_block.layoutShapeInsideInfo()) |
189 m_segment = shapeInsideInfo->currentSegment(); | 173 m_segment = shapeInsideInfo->currentSegment(); |
190 } | 174 } |
191 | 175 |
192 void LineWidth::computeAvailableWidthFromLeftAndRight() | 176 void LineWidth::computeAvailableWidthFromLeftAndRight() |
193 { | 177 { |
194 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; | 178 m_availableWidth = max(0.0f, m_right - m_left) + m_overhangWidth; |
195 } | 179 } |
196 | 180 |
197 } | 181 } |
OLD | NEW |