OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 13 matching lines...) Expand all Loading... |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #include "config.h" | 31 #include "config.h" |
32 #include "core/rendering/RenderFlexibleBox.h" | 32 #include "core/rendering/RenderFlexibleBox.h" |
33 | 33 |
| 34 #include "core/css/resolver/StyleAdjuster.h" |
34 #include "core/frame/UseCounter.h" | 35 #include "core/frame/UseCounter.h" |
35 #include "core/rendering/RenderLayer.h" | 36 #include "core/rendering/RenderLayer.h" |
36 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" |
37 #include "core/rendering/TextAutosizer.h" | 38 #include "core/rendering/TextAutosizer.h" |
38 #include "platform/LengthFunctions.h" | 39 #include "platform/LengthFunctions.h" |
39 #include "wtf/MathExtras.h" | 40 #include "wtf/MathExtras.h" |
40 #include <limits> | 41 #include <limits> |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const | 186 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const |
186 { | 187 { |
187 int baseline = firstLineBoxBaseline(); | 188 int baseline = firstLineBoxBaseline(); |
188 if (baseline != -1) | 189 if (baseline != -1) |
189 return baseline; | 190 return baseline; |
190 | 191 |
191 int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
; | 192 int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
; |
192 return synthesizedBaselineFromContentBox(this, direction) + marginAscent; | 193 return synthesizedBaselineFromContentBox(this, direction) + marginAscent; |
193 } | 194 } |
194 | 195 |
195 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
rStyle* childStyle) | |
196 { | |
197 ItemPosition align = childStyle->alignSelf(); | |
198 if (align == ItemPositionAuto) | |
199 align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
retch : parentStyle->alignItems(); | |
200 return align; | |
201 } | |
202 | |
203 void RenderFlexibleBox::removeChild(RenderObject* child) | 196 void RenderFlexibleBox::removeChild(RenderObject* child) |
204 { | 197 { |
205 RenderBlock::removeChild(child); | 198 RenderBlock::removeChild(child); |
206 m_intrinsicSizeAlongMainAxis.remove(child); | 199 m_intrinsicSizeAlongMainAxis.remove(child); |
207 } | 200 } |
208 | 201 |
209 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) | 202 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle*
oldStyle) |
210 { | 203 { |
211 RenderBlock::styleDidChange(diff, oldStyle); | 204 RenderBlock::styleDidChange(diff, oldStyle); |
212 | 205 |
213 if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF
ullLayout()) { | 206 if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF
ullLayout()) { |
214 // Flex items that were previously stretching need to be relayed out so
we can compute new available cross axis space. | 207 // Flex items that were previously stretching need to be relayed out so
we can compute new available cross axis space. |
215 // This is only necessary for stretching since other alignment values do
n't change the size of the box. | 208 // This is only necessary for stretching since other alignment values do
n't change the size of the box. |
216 for (RenderBox* child = firstChildBox(); child; child = child->nextSibli
ngBox()) { | 209 for (RenderBox* child = firstChildBox(); child; child = child->nextSibli
ngBox()) { |
217 ItemPosition previousAlignment = resolveAlignment(oldStyle, child->s
tyle()); | 210 ItemPosition previousAlignment = StyleAdjuster::resolveAlignment(old
Style, child->style()); |
218 if (previousAlignment == ItemPositionStretch && previousAlignment !=
resolveAlignment(style(), child->style())) | 211 if (previousAlignment == ItemPositionStretch && previousAlignment !=
StyleAdjuster::resolveAlignment(style(), child->style())) |
219 child->setChildNeedsLayout(MarkOnlyThis); | 212 child->setChildNeedsLayout(MarkOnlyThis); |
220 } | 213 } |
221 } | 214 } |
222 } | 215 } |
223 | 216 |
224 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) | 217 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) |
225 { | 218 { |
226 ASSERT(needsLayout()); | 219 ASSERT(needsLayout()); |
227 | 220 |
228 if (!relayoutChildren && simplifiedLayout()) | 221 if (!relayoutChildren && simplifiedLayout()) |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1006 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; | 999 LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
Offset; |
1007 if (childLayer->staticBlockPosition() != staticBlockPosition) { | 1000 if (childLayer->staticBlockPosition() != staticBlockPosition) { |
1008 childLayer->setStaticBlockPosition(staticBlockPosition); | 1001 childLayer->setStaticBlockPosition(staticBlockPosition); |
1009 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) | 1002 if (child->style()->hasStaticBlockPosition(style()->isHorizontalWritingM
ode())) |
1010 child->setChildNeedsLayout(MarkOnlyThis); | 1003 child->setChildNeedsLayout(MarkOnlyThis); |
1011 } | 1004 } |
1012 } | 1005 } |
1013 | 1006 |
1014 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox* child) const | 1007 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox* child) const |
1015 { | 1008 { |
1016 ItemPosition align = resolveAlignment(style(), child->style()); | 1009 ItemPosition align = StyleAdjuster::resolveAlignment(style(), child->style()
); |
1017 | 1010 |
1018 if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) | 1011 if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) |
1019 align = ItemPositionFlexStart; | 1012 align = ItemPositionFlexStart; |
1020 | 1013 |
1021 if (style()->flexWrap() == FlexWrapReverse) { | 1014 if (style()->flexWrap() == FlexWrapReverse) { |
1022 if (align == ItemPositionFlexStart) | 1015 if (align == ItemPositionFlexStart) |
1023 align = ItemPositionFlexEnd; | 1016 align = ItemPositionFlexEnd; |
1024 else if (align == ItemPositionFlexEnd) | 1017 else if (align == ItemPositionFlexEnd) |
1025 align = ItemPositionFlexStart; | 1018 align = ItemPositionFlexStart; |
1026 } | 1019 } |
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1401 ASSERT(child); | 1394 ASSERT(child); |
1402 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; | 1395 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
xtent; |
1403 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; | 1396 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
- crossAxisStartEdge; |
1404 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; | 1397 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
sExtent; |
1405 adjustAlignmentForChild(child, newOffset - originalOffset); | 1398 adjustAlignmentForChild(child, newOffset - originalOffset); |
1406 } | 1399 } |
1407 } | 1400 } |
1408 } | 1401 } |
1409 | 1402 |
1410 } | 1403 } |
OLD | NEW |