| 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 18 matching lines...) Expand all  Loading... | 
| 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/frame/UseCounter.h" | 34 #include "core/frame/UseCounter.h" | 
| 35 #include "core/paint/BlockPainter.h" | 35 #include "core/paint/BlockPainter.h" | 
| 36 #include "core/rendering/RenderLayer.h" | 36 #include "core/rendering/RenderLayer.h" | 
| 37 #include "core/rendering/RenderView.h" | 37 #include "core/rendering/RenderView.h" | 
| 38 #include "core/rendering/TextAutosizer.h" | 38 #include "core/rendering/TextAutosizer.h" | 
|  | 39 #include "core/rendering/style/RenderStyle.h" | 
| 39 #include "platform/LengthFunctions.h" | 40 #include "platform/LengthFunctions.h" | 
| 40 #include "wtf/MathExtras.h" | 41 #include "wtf/MathExtras.h" | 
| 41 #include <limits> | 42 #include <limits> | 
| 42 | 43 | 
| 43 namespace blink { | 44 namespace blink { | 
| 44 | 45 | 
| 45 struct RenderFlexibleBox::LineContext { | 46 struct RenderFlexibleBox::LineContext { | 
| 46     LineContext(LayoutUnit crossAxisOffset, LayoutUnit crossAxisExtent, size_t n
      umberOfChildren, LayoutUnit maxAscent) | 47     LineContext(LayoutUnit crossAxisOffset, LayoutUnit crossAxisExtent, size_t n
      umberOfChildren, LayoutUnit maxAscent) | 
| 47         : crossAxisOffset(crossAxisOffset) | 48         : crossAxisOffset(crossAxisOffset) | 
| 48         , crossAxisExtent(crossAxisExtent) | 49         , crossAxisExtent(crossAxisExtent) | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 186 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const | 187 int RenderFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const | 
| 187 { | 188 { | 
| 188     int baseline = firstLineBoxBaseline(); | 189     int baseline = firstLineBoxBaseline(); | 
| 189     if (baseline != -1) | 190     if (baseline != -1) | 
| 190         return baseline; | 191         return baseline; | 
| 191 | 192 | 
| 192     int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
      ; | 193     int marginAscent = direction == HorizontalLine ? marginTop() : marginRight()
      ; | 
| 193     return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; | 194     return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; | 
| 194 } | 195 } | 
| 195 | 196 | 
| 196 static ItemPosition resolveAlignment(const RenderStyle* parentStyle, const Rende
      rStyle* childStyle) |  | 
| 197 { |  | 
| 198     ItemPosition align = childStyle->alignSelf(); |  | 
| 199     if (align == ItemPositionAuto) |  | 
| 200         align = (parentStyle->alignItems() == ItemPositionAuto) ? ItemPositionSt
      retch : parentStyle->alignItems(); |  | 
| 201     return align; |  | 
| 202 } |  | 
| 203 |  | 
| 204 void RenderFlexibleBox::removeChild(RenderObject* child) | 197 void RenderFlexibleBox::removeChild(RenderObject* child) | 
| 205 { | 198 { | 
| 206     RenderBlock::removeChild(child); | 199     RenderBlock::removeChild(child); | 
| 207     m_intrinsicSizeAlongMainAxis.remove(child); | 200     m_intrinsicSizeAlongMainAxis.remove(child); | 
| 208 } | 201 } | 
| 209 | 202 | 
| 210 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle* 
      oldStyle) | 203 void RenderFlexibleBox::styleDidChange(StyleDifference diff, const RenderStyle* 
      oldStyle) | 
| 211 { | 204 { | 
| 212     RenderBlock::styleDidChange(diff, oldStyle); | 205     RenderBlock::styleDidChange(diff, oldStyle); | 
| 213 | 206 | 
| 214     if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF
      ullLayout()) { | 207     if (oldStyle && oldStyle->alignItems() == ItemPositionStretch && diff.needsF
      ullLayout()) { | 
| 215         // Flex items that were previously stretching need to be relayed out so 
      we can compute new available cross axis space. | 208         // Flex items that were previously stretching need to be relayed out so 
      we can compute new available cross axis space. | 
| 216         // This is only necessary for stretching since other alignment values do
      n't change the size of the box. | 209         // This is only necessary for stretching since other alignment values do
      n't change the size of the box. | 
| 217         for (RenderBox* child = firstChildBox(); child; child = child->nextSibli
      ngBox()) { | 210         for (RenderBox* child = firstChildBox(); child; child = child->nextSibli
      ngBox()) { | 
| 218             ItemPosition previousAlignment = resolveAlignment(oldStyle, child->s
      tyle()); | 211             ItemPosition previousAlignment = RenderStyle::resolveAlignment(oldSt
      yle, child->style()); | 
| 219             if (previousAlignment == ItemPositionStretch && previousAlignment !=
       resolveAlignment(style(), child->style())) | 212             if (previousAlignment == ItemPositionStretch && previousAlignment !=
       RenderStyle::resolveAlignment(style(), child->style())) | 
| 220                 child->setChildNeedsLayout(MarkOnlyThis); | 213                 child->setChildNeedsLayout(MarkOnlyThis); | 
| 221         } | 214         } | 
| 222     } | 215     } | 
| 223 } | 216 } | 
| 224 | 217 | 
| 225 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) | 218 void RenderFlexibleBox::layoutBlock(bool relayoutChildren) | 
| 226 { | 219 { | 
| 227     ASSERT(needsLayout()); | 220     ASSERT(needsLayout()); | 
| 228 | 221 | 
| 229     if (!relayoutChildren && simplifiedLayout()) | 222     if (!relayoutChildren && simplifiedLayout()) | 
| (...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1004     LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
      Offset; | 997     LayoutUnit staticBlockPosition = isColumnFlow() ? mainAxisOffset : crossAxis
      Offset; | 
| 1005     if (childLayer->staticBlockPosition() != staticBlockPosition) { | 998     if (childLayer->staticBlockPosition() != staticBlockPosition) { | 
| 1006         childLayer->setStaticBlockPosition(staticBlockPosition); | 999         childLayer->setStaticBlockPosition(staticBlockPosition); | 
| 1007         if (child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMo
      de())) | 1000         if (child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMo
      de())) | 
| 1008             child.setChildNeedsLayout(MarkOnlyThis); | 1001             child.setChildNeedsLayout(MarkOnlyThis); | 
| 1009     } | 1002     } | 
| 1010 } | 1003 } | 
| 1011 | 1004 | 
| 1012 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const | 1005 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const | 
| 1013 { | 1006 { | 
| 1014     ItemPosition align = resolveAlignment(style(), child.style()); | 1007     ItemPosition align = RenderStyle::resolveAlignment(style(), child.style()); | 
| 1015 | 1008 | 
| 1016     if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) | 1009     if (align == ItemPositionBaseline && hasOrthogonalFlow(child)) | 
| 1017         align = ItemPositionFlexStart; | 1010         align = ItemPositionFlexStart; | 
| 1018 | 1011 | 
| 1019     if (style()->flexWrap() == FlexWrapReverse) { | 1012     if (style()->flexWrap() == FlexWrapReverse) { | 
| 1020         if (align == ItemPositionFlexStart) | 1013         if (align == ItemPositionFlexStart) | 
| 1021             align = ItemPositionFlexEnd; | 1014             align = ItemPositionFlexEnd; | 
| 1022         else if (align == ItemPositionFlexEnd) | 1015         else if (align == ItemPositionFlexEnd) | 
| 1023             align = ItemPositionFlexStart; | 1016             align = ItemPositionFlexStart; | 
| 1024     } | 1017     } | 
| (...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1399             ASSERT(child); | 1392             ASSERT(child); | 
| 1400             LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
      xtent; | 1393             LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE
      xtent; | 
| 1401             LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
       - crossAxisStartEdge; | 1394             LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset
       - crossAxisStartEdge; | 
| 1402             LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
      sExtent; | 1395             LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi
      sExtent; | 
| 1403             adjustAlignmentForChild(*child, newOffset - originalOffset); | 1396             adjustAlignmentForChild(*child, newOffset - originalOffset); | 
| 1404         } | 1397         } | 
| 1405     } | 1398     } | 
| 1406 } | 1399 } | 
| 1407 | 1400 | 
| 1408 } | 1401 } | 
| OLD | NEW | 
|---|