Chromium Code Reviews| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 int LayoutFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const | 234 int LayoutFlexibleBox::inlineBlockBaseline(LineDirectionMode direction) const |
| 235 { | 235 { |
| 236 int baseline = firstLineBoxBaseline(); | 236 int baseline = firstLineBoxBaseline(); |
| 237 if (baseline != -1) | 237 if (baseline != -1) |
| 238 return baseline; | 238 return baseline; |
| 239 | 239 |
| 240 int marginAscent = direction == HorizontalLine ? marginTop() : marginRight() ; | 240 int marginAscent = direction == HorizontalLine ? marginTop() : marginRight() ; |
| 241 return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; | 241 return synthesizedBaselineFromContentBox(*this, direction) + marginAscent; |
| 242 } | 242 } |
| 243 | 243 |
| 244 IntSize LayoutFlexibleBox::originAdjustmentForScrollbars() const | |
| 245 { | |
| 246 IntSize size; | |
| 247 int adjustmentWidth = verticalScrollbarWidth(); | |
| 248 int adjustmentHeight = horizontalScrollbarHeight(); | |
| 249 if (!adjustmentWidth && !adjustmentHeight) | |
| 250 return size; | |
| 251 | |
| 252 EFlexDirection flexDirection = style()->flexDirection(); | |
| 253 TextDirection textDirection = style()->direction(); | |
| 254 WritingMode writingMode = style()->getWritingMode(); | |
| 255 | |
| 256 if (flexDirection == FlowRow) { | |
|
leviw_travelin_and_unemployed
2016/05/10 17:52:42
This is super easy to follow now, but I can totall
| |
| 257 if (textDirection == RTL) { | |
| 258 if (writingMode == TopToBottomWritingMode) | |
| 259 size.expand(adjustmentWidth, 0); | |
| 260 else | |
| 261 size.expand(0, adjustmentHeight); | |
| 262 } | |
| 263 if (writingMode == RightToLeftWritingMode) | |
| 264 size.expand(adjustmentWidth, 0); | |
| 265 } else if (flexDirection == FlowRowReverse) { | |
| 266 if (textDirection == LTR) { | |
| 267 if (writingMode == TopToBottomWritingMode) | |
| 268 size.expand(adjustmentWidth, 0); | |
| 269 else | |
| 270 size.expand(0, adjustmentHeight); | |
| 271 } | |
| 272 if (writingMode == RightToLeftWritingMode) | |
| 273 size.expand(adjustmentWidth, 0); | |
| 274 } else if (flexDirection == FlowColumn) { | |
| 275 if (writingMode == RightToLeftWritingMode) | |
| 276 size.expand(adjustmentWidth, 0); | |
| 277 } else { | |
| 278 if (writingMode == TopToBottomWritingMode) | |
| 279 size.expand(0, adjustmentHeight); | |
| 280 else if (writingMode == LeftToRightWritingMode) | |
| 281 size.expand(adjustmentWidth, 0); | |
| 282 } | |
| 283 return size; | |
| 284 } | |
| 285 | |
| 286 bool LayoutFlexibleBox::hasTopOverflow() const | |
| 287 { | |
| 288 EFlexDirection flexDirection = style()->flexDirection(); | |
| 289 if (isHorizontalWritingMode()) | |
| 290 return flexDirection == FlowColumnReverse; | |
| 291 return flexDirection == (style()->isLeftToRightDirection() ? FlowRowReverse : FlowRow); | |
| 292 } | |
| 293 | |
| 294 bool LayoutFlexibleBox::hasLeftOverflow() const | |
| 295 { | |
| 296 EFlexDirection flexDirection = style()->flexDirection(); | |
| 297 if (isHorizontalWritingMode()) | |
| 298 return flexDirection == (style()->isLeftToRightDirection() ? FlowRowReve rse : FlowRow); | |
| 299 return flexDirection == FlowColumnReverse; | |
| 300 } | |
| 301 | |
| 244 void LayoutFlexibleBox::removeChild(LayoutObject* child) | 302 void LayoutFlexibleBox::removeChild(LayoutObject* child) |
| 245 { | 303 { |
| 246 LayoutBlock::removeChild(child); | 304 LayoutBlock::removeChild(child); |
| 247 m_intrinsicSizeAlongMainAxis.remove(child); | 305 m_intrinsicSizeAlongMainAxis.remove(child); |
| 248 } | 306 } |
| 249 | 307 |
| 250 void LayoutFlexibleBox::styleDidChange(StyleDifference diff, const ComputedStyle * oldStyle) | 308 void LayoutFlexibleBox::styleDidChange(StyleDifference diff, const ComputedStyle * oldStyle) |
| 251 { | 309 { |
| 252 LayoutBlock::styleDidChange(diff, oldStyle); | 310 LayoutBlock::styleDidChange(diff, oldStyle); |
| 253 | 311 |
| (...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1525 { | 1583 { |
| 1526 ASSERT(childSizes.size() == children.size()); | 1584 ASSERT(childSizes.size() == children.size()); |
| 1527 | 1585 |
| 1528 ContentPosition position = styleRef().resolvedJustifyContentPosition(normalV alueBehavior()); | 1586 ContentPosition position = styleRef().resolvedJustifyContentPosition(normalV alueBehavior()); |
| 1529 ContentDistributionType distribution = styleRef().resolvedJustifyContentDist ribution(normalValueBehavior()); | 1587 ContentDistributionType distribution = styleRef().resolvedJustifyContentDist ribution(normalValueBehavior()); |
| 1530 | 1588 |
| 1531 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children); | 1589 size_t numberOfChildrenForJustifyContent = numberOfInFlowPositionedChildren( children); |
| 1532 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available FreeSpace); | 1590 LayoutUnit autoMarginOffset = autoMarginOffsetInMainAxis(children, available FreeSpace); |
| 1533 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart() ; | 1591 LayoutUnit mainAxisOffset = flowAwareBorderStart() + flowAwarePaddingStart() ; |
| 1534 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, position, distribution, numberOfChildrenForJustifyContent); | 1592 mainAxisOffset += initialJustifyContentOffset(availableFreeSpace, position, distribution, numberOfChildrenForJustifyContent); |
| 1535 if (style()->flexDirection() == FlowRowReverse) | 1593 if (style()->flexDirection() == FlowRowReverse && shouldPlaceBlockDirectionS crollbarOnLogicalLeft()) |
| 1536 mainAxisOffset += isHorizontalFlow() ? verticalScrollbarWidth() : horizo ntalScrollbarHeight(); | 1594 mainAxisOffset += isHorizontalFlow() ? verticalScrollbarWidth() : horizo ntalScrollbarHeight(); |
| 1537 | 1595 |
| 1538 LayoutUnit totalMainExtent = mainAxisExtent(); | 1596 LayoutUnit totalMainExtent = mainAxisExtent(); |
| 1597 if (!shouldPlaceBlockDirectionScrollbarOnLogicalLeft()) | |
| 1598 totalMainExtent -= isHorizontalFlow() ? verticalScrollbarWidth() : horiz ontalScrollbarHeight(); | |
| 1539 LayoutUnit maxAscent, maxDescent; // Used when align-items: baseline. | 1599 LayoutUnit maxAscent, maxDescent; // Used when align-items: baseline. |
| 1540 LayoutUnit maxChildCrossAxisExtent; | 1600 LayoutUnit maxChildCrossAxisExtent; |
| 1541 size_t seenInFlowPositionedChildren = 0; | 1601 size_t seenInFlowPositionedChildren = 0; |
| 1542 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); | 1602 bool shouldFlipMainAxis = !isColumnFlow() && !isLeftToRightFlow(); |
| 1543 for (size_t i = 0; i < children.size(); ++i) { | 1603 for (size_t i = 0; i < children.size(); ++i) { |
| 1544 LayoutBox* child = children[i]; | 1604 LayoutBox* child = children[i]; |
| 1545 | 1605 |
| 1546 if (child->isOutOfFlowPositioned()) { | 1606 if (child->isOutOfFlowPositioned()) { |
| 1547 prepareChildForPositionedLayout(*child); | 1607 prepareChildForPositionedLayout(*child); |
| 1548 continue; | 1608 continue; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1592 setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros sAxisScrollbarExtent())); | 1652 setLogicalHeight(std::max(logicalHeight(), crossAxisOffset + flowAwa reBorderAfter() + flowAwarePaddingAfter() + childCrossAxisMarginBoxExtent + cros sAxisScrollbarExtent())); |
| 1593 maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx isMarginBoxExtent); | 1653 maxChildCrossAxisExtent = std::max(maxChildCrossAxisExtent, childCrossAx isMarginBoxExtent); |
| 1594 | 1654 |
| 1595 mainAxisOffset += flowAwareMarginStartForChild(*child); | 1655 mainAxisOffset += flowAwareMarginStartForChild(*child); |
| 1596 | 1656 |
| 1597 LayoutUnit childMainExtent = mainAxisExtentForChild(*child); | 1657 LayoutUnit childMainExtent = mainAxisExtentForChild(*child); |
| 1598 // In an RTL column situation, this will apply the margin-right/margin-e nd on the left. | 1658 // In an RTL column situation, this will apply the margin-right/margin-e nd on the left. |
| 1599 // This will be fixed later in flipForRightToLeftColumn. | 1659 // This will be fixed later in flipForRightToLeftColumn. |
| 1600 LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi sOffset - childMainExtent : mainAxisOffset, | 1660 LayoutPoint childLocation(shouldFlipMainAxis ? totalMainExtent - mainAxi sOffset - childMainExtent : mainAxisOffset, |
| 1601 crossAxisOffset + flowAwareMarginBeforeForChild(*child)); | 1661 crossAxisOffset + flowAwareMarginBeforeForChild(*child)); |
| 1602 | |
| 1603 setFlowAwareLocationForChild(*child, childLocation); | 1662 setFlowAwareLocationForChild(*child, childLocation); |
| 1604 mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(*child); | 1663 mainAxisOffset += childMainExtent + flowAwareMarginEndForChild(*child); |
| 1605 | 1664 |
| 1606 ++seenInFlowPositionedChildren; | 1665 ++seenInFlowPositionedChildren; |
| 1607 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) | 1666 if (seenInFlowPositionedChildren < numberOfChildrenForJustifyContent) |
| 1608 mainAxisOffset += justifyContentSpaceBetweenChildren(availableFreeSp ace, distribution, numberOfChildrenForJustifyContent); | 1667 mainAxisOffset += justifyContentSpaceBetweenChildren(availableFreeSp ace, distribution, numberOfChildrenForJustifyContent); |
| 1609 } | 1668 } |
| 1610 | 1669 |
| 1611 if (isColumnFlow()) | 1670 if (isColumnFlow()) |
| 1612 setLogicalHeight(std::max(logicalHeight(), mainAxisOffset + flowAwareBor derEnd() + flowAwarePaddingEnd() + scrollbarLogicalHeight())); | 1671 setLogicalHeight(std::max(logicalHeight(), mainAxisOffset + flowAwareBor derEnd() + flowAwarePaddingEnd() + scrollbarLogicalHeight())); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1820 return; | 1879 return; |
| 1821 | 1880 |
| 1822 LayoutUnit crossExtent = crossAxisExtent(); | 1881 LayoutUnit crossExtent = crossAxisExtent(); |
| 1823 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { | 1882 for (LayoutBox* child = m_orderIterator.first(); child; child = m_orderItera tor.next()) { |
| 1824 if (child->isOutOfFlowPositioned()) | 1883 if (child->isOutOfFlowPositioned()) |
| 1825 continue; | 1884 continue; |
| 1826 LayoutPoint location = flowAwareLocationForChild(*child); | 1885 LayoutPoint location = flowAwareLocationForChild(*child); |
| 1827 // For vertical flows, setFlowAwareLocationForChild will transpose x and y, | 1886 // For vertical flows, setFlowAwareLocationForChild will transpose x and y, |
| 1828 // so using the y axis for a column cross axis extent is correct. | 1887 // so using the y axis for a column cross axis extent is correct. |
| 1829 location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y ()); | 1888 location.setY(crossExtent - crossAxisExtentForChild(*child) - location.y ()); |
| 1889 if (!isHorizontalWritingMode()) | |
| 1890 location.move(LayoutSize(0, -horizontalScrollbarHeight())); | |
| 1830 setFlowAwareLocationForChild(*child, location); | 1891 setFlowAwareLocationForChild(*child, location); |
| 1831 } | 1892 } |
| 1832 } | 1893 } |
| 1833 | 1894 |
| 1834 void LayoutFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex ts, LayoutUnit crossAxisStartEdge) | 1895 void LayoutFlexibleBox::flipForWrapReverse(const Vector<LineContext>& lineContex ts, LayoutUnit crossAxisStartEdge) |
| 1835 { | 1896 { |
| 1836 LayoutUnit contentExtent = crossAxisContentExtent(); | 1897 LayoutUnit contentExtent = crossAxisContentExtent(); |
| 1837 LayoutBox* child = m_orderIterator.first(); | 1898 LayoutBox* child = m_orderIterator.first(); |
| 1838 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) { | 1899 for (size_t lineNumber = 0; lineNumber < lineContexts.size(); ++lineNumber) { |
| 1839 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb erOfChildren; ++childNumber, child = m_orderIterator.next()) { | 1900 for (size_t childNumber = 0; childNumber < lineContexts[lineNumber].numb erOfChildren; ++childNumber, child = m_orderIterator.next()) { |
| 1840 ASSERT(child); | 1901 ASSERT(child); |
| 1841 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; | 1902 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; |
| 1842 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; | 1903 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; |
| 1843 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; | 1904 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; |
| 1844 adjustAlignmentForChild(*child, newOffset - originalOffset); | 1905 adjustAlignmentForChild(*child, newOffset - originalOffset); |
| 1845 } | 1906 } |
| 1846 } | 1907 } |
| 1847 } | 1908 } |
| 1848 | 1909 |
| 1849 } // namespace blink | 1910 } // namespace blink |
| OLD | NEW |