Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutFlexibleBox.cpp

Issue 2342663002: [css-flexbox] Fix size comparison when scrollbars are present (Closed)
Patch Set: add test Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 LayoutUnit LayoutFlexibleBox::crossAxisIntrinsicExtentForChild(const LayoutBox& child) const 514 LayoutUnit LayoutFlexibleBox::crossAxisIntrinsicExtentForChild(const LayoutBox& child) const
515 { 515 {
516 return hasOrthogonalFlow(child) ? childIntrinsicLogicalWidth(child) : childI ntrinsicLogicalHeight(child); 516 return hasOrthogonalFlow(child) ? childIntrinsicLogicalWidth(child) : childI ntrinsicLogicalHeight(child);
517 } 517 }
518 518
519 LayoutUnit LayoutFlexibleBox::mainAxisExtentForChild(const LayoutBox& child) con st 519 LayoutUnit LayoutFlexibleBox::mainAxisExtentForChild(const LayoutBox& child) con st
520 { 520 {
521 return isHorizontalFlow() ? child.size().width() : child.size().height(); 521 return isHorizontalFlow() ? child.size().width() : child.size().height();
522 } 522 }
523 523
524 LayoutUnit LayoutFlexibleBox::mainAxisContentExtentForChild(const LayoutBox& chi ld) const 524 LayoutUnit LayoutFlexibleBox::mainAxisContentExtentForChildIncludingScrollbar(co nst LayoutBox& child) const
525 { 525 {
526 return isHorizontalFlow() ? child.contentWidth() : child.contentHeight(); 526 return isHorizontalFlow() ? child.contentWidth() + child.verticalScrollbarWi dth() : child.contentHeight() + child.horizontalScrollbarHeight();
527 } 527 }
528 528
529 LayoutUnit LayoutFlexibleBox::crossAxisExtent() const 529 LayoutUnit LayoutFlexibleBox::crossAxisExtent() const
530 { 530 {
531 return isHorizontalFlow() ? size().height() : size().width(); 531 return isHorizontalFlow() ? size().height() : size().width();
532 } 532 }
533 533
534 LayoutUnit LayoutFlexibleBox::mainAxisExtent() const 534 LayoutUnit LayoutFlexibleBox::mainAxisExtent() const
535 { 535 {
536 return isHorizontalFlow() ? size().width() : size().height(); 536 return isHorizontalFlow() ? size().width() : size().height();
(...skipping 1118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 LayoutBox* child = flexItem.box; 1655 LayoutBox* child = flexItem.box;
1656 1656
1657 if (child->isOutOfFlowPositioned()) { 1657 if (child->isOutOfFlowPositioned()) {
1658 prepareChildForPositionedLayout(*child); 1658 prepareChildForPositionedLayout(*child);
1659 continue; 1659 continue;
1660 } 1660 }
1661 1661
1662 child->setMayNeedPaintInvalidation(); 1662 child->setMayNeedPaintInvalidation();
1663 1663
1664 setOverrideMainAxisContentSizeForChild(*child, flexItem.flexedContentSiz e); 1664 setOverrideMainAxisContentSizeForChild(*child, flexItem.flexedContentSiz e);
1665 if (flexItem.flexedContentSize != mainAxisContentExtentForChild(*child)) { 1665 // The flexed content size and the override size include the scrollbar
1666 // width, so we need to compare to the size including the scrollbar.
1667 // TODO(cbiesinger): Should it include the scrollbar?
1668 if (flexItem.flexedContentSize != mainAxisContentExtentForChildIncluding Scrollbar(*child)) {
1666 child->setChildNeedsLayout(MarkOnlyThis); 1669 child->setChildNeedsLayout(MarkOnlyThis);
1667 } else { 1670 } else {
1668 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here. 1671 // To avoid double applying margin changes in updateAutoMarginsInCro ssAxis, we reset the margins here.
1669 resetAutoMarginsAndLogicalTopInCrossAxis(*child); 1672 resetAutoMarginsAndLogicalTopInCrossAxis(*child);
1670 } 1673 }
1671 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild. 1674 // We may have already forced relayout for orthogonal flowing children i n computeInnerFlexBaseSizeForChild.
1672 bool forceChildRelayout = relayoutChildren && !m_relaidOutChildren.conta ins(child); 1675 bool forceChildRelayout = relayoutChildren && !m_relaidOutChildren.conta ins(child);
1673 if (child->isLayoutBlock() && toLayoutBlock(*child).hasPercentHeightDesc endants()) { 1676 if (child->isLayoutBlock() && toLayoutBlock(*child).hasPercentHeightDesc endants()) {
1674 // Have to force another relayout even though the child is sized cor rectly, because 1677 // Have to force another relayout even though the child is sized cor rectly, because
1675 // its descendants are not sized correctly yet. Our previous layout of the child was 1678 // its descendants are not sized correctly yet. Our previous layout of the child was
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
1953 DCHECK(child); 1956 DCHECK(child);
1954 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent; 1957 LayoutUnit lineCrossAxisExtent = lineContexts[lineNumber].crossAxisE xtent;
1955 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge; 1958 LayoutUnit originalOffset = lineContexts[lineNumber].crossAxisOffset - crossAxisStartEdge;
1956 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent; 1959 LayoutUnit newOffset = contentExtent - originalOffset - lineCrossAxi sExtent;
1957 adjustAlignmentForChild(*child, newOffset - originalOffset); 1960 adjustAlignmentForChild(*child, newOffset - originalOffset);
1958 } 1961 }
1959 } 1962 }
1960 } 1963 }
1961 1964
1962 } // namespace blink 1965 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutFlexibleBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698