Home | History | Annotate | Download | only in rendering

Lines Matching refs:child

61     Violation(RenderBox* child, LayoutUnit childSize)
62 : child(child)
67 RenderBox* child;
101 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
102 if (child->isOutOfFlowPositioned())
105 LayoutUnit margin = marginIntrinsicLogicalWidthForChild(child);
106 bool hasOrthogonalWritingMode = child->isHorizontalWritingMode() != isHorizontalWritingMode();
107 LayoutUnit minPreferredLogicalWidth = hasOrthogonalWritingMode ? child->logicalHeight() : child->minPreferredLogicalWidth();
108 LayoutUnit maxPreferredLogicalWidth = hasOrthogonalWritingMode ? child->logicalHeight() : child->maxPreferredLogicalWidth();
152 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {
153 if (child->isOutOfFlowPositioned())
155 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMarginsInCrossAxis(*child)) {
156 baselineChild = child;
160 baselineChild = child;
204 void RenderFlexibleBox::removeChild(RenderObject* child)
206 RenderBlock::removeChild(child);
207 m_intrinsicSizeAlongMainAxis.remove(child);
217 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
218 ItemPosition previousAlignment = resolveAlignment(oldStyle, child->style());
219 if (previousAlignment == ItemPositionStretch && previousAlignment != resolveAlignment(style(), child->style()))
220 child->setChildNeedsLayout(MarkOnlyThis);
275 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {
276 if (!child->isOutOfFlowPositioned())
277 childFrameRects.append(child->frameRect());
303 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
304 if (child->isOutOfFlowPositioned())
306 LayoutUnit childLogicalBottom = logicalTopForChild(child) + logicalHeightForChild(child) + marginAfterForChild(child);
312 bool RenderFlexibleBox::hasOrthogonalFlow(RenderBox& child) const
314 // FIXME: If the child is a flexbox, then we need to check isHorizontalFlow.
315 return isHorizontalFlow() != child.isHorizontalWritingMode();
342 Length RenderFlexibleBox::flexBasisForChild(RenderBox& child) const
344 Length flexLength = child.style()->flexBasis();
346 flexLength = isHorizontalFlow() ? child.style()->width() : child.style()->height();
350 LayoutUnit RenderFlexibleBox::crossAxisExtentForChild(RenderBox& child) const
352 return isHorizontalFlow() ? child.height() : child.width();
355 static inline LayoutUnit constrainedChildIntrinsicContentLogicalHeight(RenderBox& child)
357 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogicalHeight();
358 return child.constrainLogicalHeightByMinMax(childIntrinsicContentLogicalHeight + child.borderAndPaddingLogicalHeight(), childIntrinsicContentLogicalHeight);
361 LayoutUnit RenderFlexibleBox::childIntrinsicHeight(RenderBox& child) const
363 if (child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child))
364 return constrainedChildIntrinsicContentLogicalHeight(child);
365 return child.height();
368 LayoutUnit RenderFlexibleBox::childIntrinsicWidth(RenderBox& child) const
370 if (!child.isHorizontalWritingMode() && needToStretchChildLogicalHeight(child))
371 return constrainedChildIntrinsicContentLogicalHeight(child);
372 return child.width();
375 LayoutUnit RenderFlexibleBox::crossAxisIntrinsicExtentForChild(RenderBox& child) const
377 return isHorizontalFlow() ? childIntrinsicHeight(child) : childIntrinsicWidth(child);
380 LayoutUnit RenderFlexibleBox::mainAxisExtentForChild(RenderBox& child) const
382 return isHorizontalFlow() ? child.width() : child.height();
414 LayoutUnit RenderFlexibleBox::computeMainAxisExtentForChild(RenderBox& child, SizeType sizeType, const Length& size)
416 // FIXME: This is wrong for orthogonal flows. It should use the flexbox's writing-mode, not the child's in order
421 child.layoutIfNeeded();
422 return child.computeContentLogicalHeight(size, child.logicalHeight() - child.borderAndPaddingLogicalHeight()) + child.scrollbarLogicalHeight();
424 return child.computeLogicalWidthUsing(sizeType, size, contentLogicalWidth(), this) - child.borderAndPaddingLogicalWidth();
537 LayoutUnit RenderFlexibleBox::flowAwareMarginStartForChild(RenderBox& child) const
540 return isLeftToRightFlow() ? child.marginLeft() : child.marginRight();
541 return isLeftToRightFlow() ? child.marginTop() : child.marginBottom();
544 LayoutUnit RenderFlexibleBox::flowAwareMarginEndForChild(RenderBox& child) const
547 return isLeftToRightFlow() ? child.marginRight() : child.marginLeft();
548 return isLeftToRightFlow() ? child.marginBottom() : child.marginTop();
551 LayoutUnit RenderFlexibleBox::flowAwareMarginBeforeForChild(RenderBox& child) const
555 return child.marginTop();
557 return child.marginBottom();
559 return child.marginLeft();
561 return child.marginRight();
567 LayoutUnit RenderFlexibleBox::crossAxisMarginExtentForChild(RenderBox& child) const
569 return isHorizontalFlow() ? child.marginHeight() : child.marginWidth();
577 LayoutUnit RenderFlexibleBox::crossAxisScrollbarExtentForChild(RenderBox& child) const
579 return isHorizontalFlow() ? child.horizontalScrollbarHeight() : child.verticalScrollbarWidth();
582 LayoutPoint RenderFlexibleBox::flowAwareLocationForChild(RenderBox& child) const
584 return isHorizontalFlow() ? child.location() : child.location().transposedPoint();
587 void RenderFlexibleBox::setFlowAwareLocationForChild(RenderBox& child, const LayoutPoint& location)
590 child.setLocation(location);
592 child.setLocation(location.transposedPoint());
595 LayoutUnit RenderFlexibleBox::mainAxisBorderAndPaddingExtentForChild(RenderBox& child) const
597 return isHorizontalFlow() ? child.borderAndPaddingWidth() : child.borderAndPaddingHeight();
605 bool RenderFlexibleBox::childPreferredMainAxisContentExtentRequiresLayout(RenderBox& child, bool hasInfiniteLineLength) const
607 return preferredMainAxisExtentDependsOnLayout(flexBasisForChild(child), hasInfiniteLineLength) && hasOrthogonalFlow(child);
610 LayoutUnit RenderFlexibleBox::preferredMainAxisContentExtentForChild(RenderBox& child, bool hasInfiniteLineLength, bool relayoutChildren)
612 child.clearOverrideSize();
614 if (child.style()->hasAspectRatio() || child.isImage() || child.isVideo() || child.isCanvas())
617 Length flexBasis = flexBasisForChild(child);
620 if (hasOrthogonalFlow(child)) {
621 if (child.needsLayout() || relayoutChildren) {
622 m_intrinsicSizeAlongMainAxis.remove(&child);
623 child.forceChildLayout();
624 m_intrinsicSizeAlongMainAxis.set(&child, child.logicalHeight());
626 ASSERT(m_intrinsicSizeAlongMainAxis.contains(&child));
627 mainAxisExtent = m_intrinsicSizeAlongMainAxis.get(&child);
629 mainAxisExtent = child.maxPreferredLogicalWidth();
631 ASSERT(mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child) >= 0);
632 return mainAxisExtent - mainAxisBorderAndPaddingExtentForChild(child);
634 return std::max(LayoutUnit(0), computeMainAxisExtentForChild(child, MainOrPreferredSize, flexBasis));
688 RenderBox* child = children[i];
689 if (child->isOutOfFlowPositioned())
692 if (child->style()->marginLeft().isAuto())
694 if (child->style()->marginRight().isAuto())
697 if (child->style()->marginTop().isAuto())
699 if (child->style()->marginBottom().isAuto())
711 void RenderFlexibleBox::updateAutoMarginsInMainAxis(RenderBox& child, LayoutUnit autoMarginOffset)
716 if (child.style()->marginLeft().isAuto())
717 child.setMarginLeft(autoMarginOffset);
718 if (child.style()->marginRight().isAuto())
719 child.setMarginRight(autoMarginOffset);
721 if (child.style()->marginTop().isAuto())
722 child.setMarginTop(autoMarginOffset);
723 if (child.style()->marginBottom().isAuto())
724 child.setMarginBottom(autoMarginOffset);
728 bool RenderFlexibleBox::hasAutoMarginsInCrossAxis(RenderBox& child) const
731 return child.style()->marginTop().isAuto() || child.style()->marginBottom().isAuto();
732 return child.style()->marginLeft().isAuto() || child.style()->marginRight().isAuto();
735 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChild(LayoutUnit lineCrossAxisExtent, RenderBox& child)
737 ASSERT(!child.isOutOfFlowPositioned());
738 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAxisExtentForChild(child);
742 LayoutUnit RenderFlexibleBox::availableAlignmentSpaceForChildBeforeStretching(LayoutUnit lineCrossAxisExtent, RenderBox& child)
744 ASSERT(!child.isOutOfFlowPositioned());
745 LayoutUnit childCrossExtent = crossAxisMarginExtentForChild(child) + crossAxisIntrinsicExtentForChild(child);
749 bool RenderFlexibleBox::updateAutoMarginsInCrossAxis(RenderBox& child, LayoutUnit availableAlignmentSpace)
751 ASSERT(!child.isOutOfFlowPositioned());
755 Length topOrLeft = isHorizontal ? child.style()->marginTop() : child.style()->marginLeft();
756 Length bottomOrRight = isHorizontal ? child.style()->marginBottom() : child.style()->marginRight();
758 adjustAlignmentForChild(child, availableAlignmentSpace / 2);
760 child.setMarginTop(availableAlignmentSpace / 2);
761 child.setMarginBottom(availableAlignmentSpace / 2);
763 child.setMarginLeft(availableAlignmentSpace / 2);
764 child.setMarginRight(availableAlignmentSpace / 2);
769 if (isColumnFlow() && !child.style()->isLeftToRightDirection()) {
774 if (!isColumnFlow() && child.style()->isFlippedBlocksWritingMode()) {
782 adjustAlignmentForChild(child, availableAlignmentSpace);
785 child.setMarginTop(availableAlignmentSpace);
787 child.setMarginLeft(availableAlignmentSpace);
792 adjustAlignmentForChild(child, availableAlignmentSpace);
795 child.setMarginBottom(availableAlignmentSpace);
797 child.setMarginRight(availableAlignmentSpace);
803 LayoutUnit RenderFlexibleBox::marginBoxAscentForChild(RenderBox& child)
805 LayoutUnit ascent = child.firstLineBoxBaseline();
807 ascent = crossAxisExtentForChild(child);
808 return ascent + flowAwareMarginBeforeForChild(child);
823 for (RenderBox* child = firstChildBox(); child; child = child->nextSiblingBox()) {
824 populator.collectChild(child);
826 if (child->isOutOfFlowPositioned())
832 child->setMarginLeft(computeChildMarginValue(child->style()->marginLeft()));
833 child->setMarginRight(computeChildMarginValue(child->style()->marginRight()));
835 child->setMarginTop(computeChildMarginValue(child->style()->marginTop()));
836 child->setMarginBottom(computeChildMarginValue(child->style()->marginBottom()));
841 LayoutUnit RenderFlexibleBox::adjustChildSizeForMinAndMax(RenderBox& child, LayoutUnit childSize)
843 Length max = isHorizontalFlow() ? child.style()->maxWidth() : child.style()->maxHeight();
845 LayoutUnit maxExtent = computeMainAxisExtentForChild(child, MaxSize, max);
850 Length min = isHorizontalFlow() ? child.style()->minWidth() : child.style()->minHeight();
853 minExtent = computeMainAxisExtentForChild(child, MinSize, min);
872 for (RenderBox* child = m_orderIterator.currentChild(); child; child = m_orderIterator.next()) {
873 if (child->isOutOfFlowPositioned()) {
874 orderedChildren.append(child);
878 LayoutUnit childMainAxisExtent = preferredMainAxisContentExtentForChild(*child, hasInfiniteLineLength, relayoutChildren);
879 LayoutUnit childMainAxisMarginBorderPadding = mainAxisBorderAndPaddingExtentForChild(*child)
880 + (isHorizontalFlow() ? child->marginWidth() : child->marginHeight());
883 LayoutUnit childMinMaxAppliedMainAxisExtent = adjustChildSizeForMinAndMax(*child, childMainAxisExtent);
888 orderedChildren.append(child);
891 totalFlexGrow += child->style()->flexGrow();
892 totalWeightedFlexShrink += child->style()->flexShrink() * childMainAxisExtent;
901 RenderBox* child = violations[i].child;
903 LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(*child, hasInfiniteLineLength);
905 totalFlexGrow -= child->style()->flexGrow();
906 totalWeightedFlexShrink -= child->style()->flexShrink() * preferredChildSize;
907 inflexibleItems.set(child, childSize);
920 RenderBox* child = children[i];
921 if (child->isOutOfFlowPositioned()) {
926 if (inflexibleItems.contains(child))
927 childSizes.append(inflexibleItems.get(child));
929 LayoutUnit preferredChildSize = preferredMainAxisContentExtentForChild(*child, hasInfiniteLineLength);
933 extraSpace = availableFreeSpace * child->style()->flexGrow() / totalFlexGrow;
935 extraSpace = availableFreeSpace * child->style()->flexShrink() * preferredChildSize / totalWeightedFlexShrink;
939 LayoutUnit adjustedChildSize = adjustChildSizeForMinAndMax(*child, childSize);
945 minViolations.append(Violation(child, adjustedChildSize));
947 maxViolations.append(Violation(child, adjustedChildSize));
986 void RenderFlexibleBox::setLogicalOverrideSize(RenderBox& child, LayoutUnit childPreferredSize)
988 if (hasOrthogonalFlow(child))
989 child.setOverrideLogicalContentHeight(childPreferredSize - child.borderAndPaddingLogicalHeight());
991 child.setOverrideLogicalContentWidth(childPreferredSize - child.borderAndPaddingLogicalWidth());
994 void RenderFlexibleBox::prepareChildForPositionedLayout(RenderBox& child, LayoutUnit mainAxisOffset, LayoutUnit crossAxisOffset, PositionedLayoutMode layoutMode)
996 ASSERT(child.isOutOfFlowPositioned());
997 child.containingBlock()->insertPositionedObject(&child);
998 RenderLayer* childLayer = child.layer();
1007 if (child.style()->hasStaticBlockPosition(style()->isHorizontalWritingMode()))
1008 child.setChildNeedsLayout(MarkOnlyThis);
1012 ItemPosition RenderFlexibleBox::alignmentForChild(RenderBox& child) const
1014 ItemPosition align = resolveAlignment(style(), child.style());
1016 if (align == ItemPositionBaseline && hasOrthogonalFlow(child))
1033 RenderBox* child = children[i];
1034 if (!child->isOutOfFlowPositioned())
1040 void RenderFlexibleBox::resetAutoMarginsAndLogicalTopInCrossAxis(RenderBox& child)
1042 if (hasAutoMarginsInCrossAxis(child)) {
1043 child.updateLogicalHeight();
1045 if (child.style()->marginTop().isAuto())
1046 child.setMarginTop(0);
1047 if (child.style()->marginBottom().isAuto())
1048 child.setMarginBottom(0);
1050 if (child.style()->marginLeft().isAuto())
1051 child.setMarginLeft(0);
1052 if (child.style()->marginRight().isAuto())
1053 child.setMarginRight(0);
1058 bool RenderFlexibleBox::needToStretchChildLogicalHeight(RenderBox& child) const
1060 if (alignmentForChild(child) != ItemPositionStretch)
1063 return isHorizontalFlow() && child.style()->height().isAuto();
1083 RenderBox* child = children[i];
1085 if (child->isOutOfFlowPositioned()) {
1086 prepareChildForPositionedLayout(*child, mainAxisOffset, crossAxisOffset, FlipForRowReverse);
1091 child->setMayNeedPaintInvalidation(true);
1093 LayoutUnit childPreferredSize = childSizes[i] + mainAxisBorderAndPaddingExtentForChild(*child);
1094 setLogicalOverrideSize(*child, childPreferredSize);
1095 if (childPreferredSize != mainAxisExtentForChild(*child)) {
1096 child->setChildNeedsLayout(MarkOnlyThis);
1099 resetAutoMarginsAndLogicalTopInCrossAxis(*child);
1102 bool forceChildRelayout = relayoutChildren && !childPreferredMainAxisContentExtentRequiresLayout(*child, hasInfiniteLineLength);
1103 updateBlockChildDirtyBitsBeforeLayout(forceChildRelayout, child);
1104 child->layoutIfNeeded();
1106 updateAutoMarginsInMainAxis(*child, autoMarginOffset);
1109 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMarginsInCrossAxis(*child)) {
1110 LayoutUnit ascent = marginBoxAscentForChild(*child);
1111 LayoutUnit descent = (crossAxisMarginExtentForChild(*child) + crossAxisExtentForChild(*child)) - ascent;
1118 childCrossAxisMarginBoxExtent = crossAxisIntrinsicExtentForChild(*child) + crossAxisMarginExtentForChild(*child) + crossAxisScrollbarExtentForChild(*child);
1124 mainAxisOffset += flowAwareMarginStartForChild(*child);
1126 LayoutUnit childMainExtent = mainAxisExtentForChild(*child);
1130 crossAxisOffset + flowAwareMarginBeforeForChild(*child));
1133 setFlowAwareLocationForChild(*child, childLocation);
1134 mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(*child);
1169 RenderBox* child = children[i];
1171 if (child->isOutOfFlowPositioned()) {
1172 child->layer()->setStaticBlockPosition(mainAxisOffset);
1175 mainAxisOffset -= mainAxisExtentForChild(*child) + flowAwareMarginEndForChild(*child);
1177 setFlowAwareLocationForChild(*child, LayoutPoint(mainAxisOffset, crossAxisOffset + flowAwareMarginBeforeForChild(*child)));
1179 mainAxisOffset -= flowAwareMarginStartForChild(*child);
1232 RenderBox* child = m_orderIterator.first();
1236 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = m_orderIterator.next())
1237 adjustAlignmentForChild(*child, lineOffset);
1246 void RenderFlexibleBox::adjustAlignmentForChild(RenderBox& child, LayoutUnit delta)
1248 if (child.isOutOfFlowPositioned()) {
1249 LayoutUnit staticInlinePosition = child.layer()->staticInlinePosition();
1250 LayoutUnit staticBlockPosition = child.layer()->staticBlockPosition();
1254 prepareChildForPositionedLayout(child, mainAxis, crossAxis, NoFlipForRowReverse);
1258 setFlowAwareLocationForChild(child, flowAwareLocationForChild(child) + LayoutSize(0, delta));
1266 RenderBox* child = m_orderIterator.first();
1272 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = m_orderIterator.next()) {
1273 ASSERT(child);
1274 if (child->isOutOfFlowPositioned()) {
1276 adjustAlignmentForChild(*child, lineCrossAxisExtent);
1280 if (updateAutoMarginsInCrossAxis(*child, std::max(LayoutUnit(0), availableAlignmentSpaceForChild(lineCrossAxisExtent, *child))))
1283 switch (alignmentForChild(*child)) {
1288 applyStretchAlignmentToChild(*child, lineCrossAxisExtent);
1291 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild(lineCrossAxisExtent, *child));
1297 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild(lineCrossAxisExtent, *child));
1300 adjustAlignmentForChild(*child, availableAlignmentSpaceForChild(lineCrossAxisExtent, *child) / 2);
1305 LayoutUnit ascent = marginBoxAscentForChild(*child);
1307 adjustAlignmentForChild(*child, startOffset);
1310 minMarginAfterBaseline = std::min(minMarginAfterBaseline, availableAlignmentSpaceForChild(lineCrossAxisExtent, *child) - startOffset);
1334 child = m_orderIterator.first();
1337 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = m_orderIterator.next()) {
1338 ASSERT(child);
1339 if (alignmentForChild(*child) == ItemPositionBaseline && !hasAutoMarginsInCrossAxis(*child) && minMarginAfterBaseline)
1340 adjustAlignmentForChild(*child, minMarginAfterBaseline);
1345 void RenderFlexibleBox::applyStretchAlignmentToChild(RenderBox& child, LayoutUnit lineCrossAxisExtent)
1347 if (!isColumnFlow() && child.style()->logicalHeight().isAuto()) {
1348 // FIXME: If the child has orthogonal flow, then it already has an override height set, so use it.
1349 if (!hasOrthogonalFlow(child)) {
1350 LayoutUnit heightBeforeStretching = needToStretchChildLogicalHeight(child) ? constrainedChildIntrinsicContentLogicalHeight(child) : child.logicalHeight();
1351 LayoutUnit stretchedLogicalHeight = heightBeforeStretching + availableAlignmentSpaceForChildBeforeStretching(lineCrossAxisExtent, child);
1352 ASSERT(!child.needsLayout());
1353 LayoutUnit desiredLogicalHeight = child.constrainLogicalHeightByMinMax(stretchedLogicalHeight, heightBeforeStretching - child.borderAndPaddingLogicalHeight());
1356 if (desiredLogicalHeight != child.logicalHeight()) {
1357 child.setOverrideLogicalContentHeight(desiredLogicalHeight - child.borderAndPaddingLogicalHeight());
1358 child.setLogicalHeight(0);
1359 // We cache the child's intrinsic content logical height to avoid it being reset to the stretched height.
1362 LayoutUnit childIntrinsicContentLogicalHeight = child.intrinsicContentLogicalHeight();
1363 child.forceChildLayout();
1364 child.updateIntrinsicContentLogicalHeight(childIntrinsicContentLogicalHeight);
1367 } else if (isColumnFlow() && child.style()->logicalWidth().isAuto()) {
1368 // FIXME: If the child doesn't have orthogonal flow, then it already has an override width set, so use it.
1369 if (hasOrthogonalFlow(child)) {
1370 LayoutUnit childWidth = std::max<LayoutUnit>(0, lineCrossAxisExtent - crossAxisMarginExtentForChild(child));
1371 childWidth = child.constrainLogicalWidthByMinMax(childWidth, childWidth, this);
1373 if (childWidth != child.logicalWidth()) {
1374 child.setOverrideLogicalContentWidth(childWidth - child.borderAndPaddingLogicalWidth());
1375 child.forceChildLayout();
1387 for (RenderBox* child = m_orderIterator.first(); child; child = m_orderIterator.next()) {
1388 if (child->isOutOfFlowPositioned())
1390 LayoutPoint location = flowAwareLocationForChild(*child);
1393 location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y());
1394 setFlowAwareLocationForChild(*child, location);
1401 RenderBox* child = m_orderIterator.first();
1403 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numberOfChildren; ++childNumber, child = m_orderIterator.next()) {
1404 ASSERT(child);
1408 adjustAlignmentForChild(*child, newOffset - originalOffset);