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

Side by Side Diff: Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

Issue 11017062: Merge 130549 - Deprecated flexboxes subtract scrollbar width/height twice (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1271/
Patch Set: Created 8 years, 2 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 | « Source/WebCore/rendering/RenderBox.cpp ('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 * This file is part of the render object implementation for KHTML. 2 * This file is part of the render object implementation for KHTML.
3 * 3 *
4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 4 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
5 * (C) 1999 Antti Koivisto (koivisto@kde.org) 5 * (C) 1999 Antti Koivisto (koivisto@kde.org)
6 * Copyright (C) 2003 Apple Computer, Inc. 6 * Copyright (C) 2003 Apple Computer, Inc.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 margin += marginRight.value(); 144 margin += marginRight.value();
145 return margin; 145 return margin;
146 } 146 }
147 147
148 static bool childDoesNotAffectWidthOrFlexing(RenderObject* child) 148 static bool childDoesNotAffectWidthOrFlexing(RenderObject* child)
149 { 149 {
150 // Positioned children and collapsed children don't affect the min/max width . 150 // Positioned children and collapsed children don't affect the min/max width .
151 return child->isOutOfFlowPositioned() || child->style()->visibility() == COL LAPSE; 151 return child->isOutOfFlowPositioned() || child->style()->visibility() == COL LAPSE;
152 } 152 }
153 153
154 static LayoutUnit contentWidthForChild(RenderBox* child)
155 {
156 if (child->hasOverrideWidth())
157 return child->overrideLogicalContentWidth();
158 return child->logicalWidth() - child->borderAndPaddingLogicalWidth();
159 }
160
161 static LayoutUnit contentHeightForChild(RenderBox* child)
162 {
163 if (child->hasOverrideHeight())
164 return child->overrideLogicalContentHeight();
165 return child->logicalHeight() - child->borderAndPaddingLogicalHeight();
166 }
167
154 void RenderDeprecatedFlexibleBox::styleWillChange(StyleDifference diff, const Re nderStyle* newStyle) 168 void RenderDeprecatedFlexibleBox::styleWillChange(StyleDifference diff, const Re nderStyle* newStyle)
155 { 169 {
156 RenderStyle* oldStyle = style(); 170 RenderStyle* oldStyle = style();
157 if (oldStyle && !oldStyle->lineClamp().isNone() && newStyle->lineClamp().isN one()) 171 if (oldStyle && !oldStyle->lineClamp().isNone() && newStyle->lineClamp().isN one())
158 clearLineClamp(); 172 clearLineClamp();
159 173
160 RenderBlock::styleWillChange(diff, newStyle); 174 RenderBlock::styleWillChange(diff, newStyle);
161 } 175 }
162 176
163 void RenderDeprecatedFlexibleBox::calcHorizontalPrefWidths() 177 void RenderDeprecatedFlexibleBox::calcHorizontalPrefWidths()
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 } 545 }
532 546
533 // Now distribute the space to objects. 547 // Now distribute the space to objects.
534 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) { 548 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) {
535 if (child->style()->visibility() == COLLAPSE) 549 if (child->style()->visibility() == COLLAPSE)
536 continue; 550 continue;
537 551
538 if (allowedChildFlex(child, expanding, i)) { 552 if (allowedChildFlex(child, expanding, i)) {
539 LayoutUnit spaceAdd = LayoutUnit(spaceAvailableThisP ass * (child->style()->boxFlex() / totalFlex)); 553 LayoutUnit spaceAdd = LayoutUnit(spaceAvailableThisP ass * (child->style()->boxFlex() / totalFlex));
540 if (spaceAdd) { 554 if (spaceAdd) {
541 child->setOverrideLogicalContentWidth(child->ove rrideLogicalContentWidth() + spaceAdd); 555 child->setOverrideLogicalContentWidth(contentWid thForChild(child) + spaceAdd);
542 flexingChildren = true; 556 flexingChildren = true;
543 relayoutChildren = true; 557 relayoutChildren = true;
544 } 558 }
545 559
546 spaceAvailableThisPass -= spaceAdd; 560 spaceAvailableThisPass -= spaceAdd;
547 remainingSpace -= spaceAdd; 561 remainingSpace -= spaceAdd;
548 groupRemainingSpace -= spaceAdd; 562 groupRemainingSpace -= spaceAdd;
549 563
550 totalFlex -= child->style()->boxFlex(); 564 totalFlex -= child->style()->boxFlex();
551 } 565 }
552 } 566 }
553 if (groupRemainingSpace == groupRemainingSpaceAtBeginning) { 567 if (groupRemainingSpace == groupRemainingSpaceAtBeginning) {
554 // This is not advancing, avoid getting stuck by distrib uting the remaining pixels. 568 // This is not advancing, avoid getting stuck by distrib uting the remaining pixels.
555 LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1; 569 LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1;
556 for (RenderBox* child = iterator.first(); child && group RemainingSpace; child = iterator.next()) { 570 for (RenderBox* child = iterator.first(); child && group RemainingSpace; child = iterator.next()) {
557 if (allowedChildFlex(child, expanding, i)) { 571 if (allowedChildFlex(child, expanding, i)) {
558 child->setOverrideLogicalContentWidth(child->ove rrideLogicalContentWidth() + spaceAdd); 572 child->setOverrideLogicalContentWidth(contentWid thForChild(child) + spaceAdd);
559 flexingChildren = true; 573 flexingChildren = true;
560 relayoutChildren = true; 574 relayoutChildren = true;
561 remainingSpace -= spaceAdd; 575 remainingSpace -= spaceAdd;
562 groupRemainingSpace -= spaceAdd; 576 groupRemainingSpace -= spaceAdd;
563 } 577 }
564 } 578 }
565 } 579 }
566 } while (absoluteValue(groupRemainingSpace) >= 1); 580 } while (absoluteValue(groupRemainingSpace) >= 1);
567 } 581 }
568 582
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 // If we just couldn't grow/shrink any more, then it's t ime to transition to the next flex group. 796 // If we just couldn't grow/shrink any more, then it's t ime to transition to the next flex group.
783 groupRemainingSpace = 0; 797 groupRemainingSpace = 0;
784 continue; 798 continue;
785 } 799 }
786 800
787 // Now distribute the space to objects. 801 // Now distribute the space to objects.
788 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) { 802 for (RenderBox* child = iterator.first(); child && spaceAvai lableThisPass && totalFlex; child = iterator.next()) {
789 if (allowedChildFlex(child, expanding, i)) { 803 if (allowedChildFlex(child, expanding, i)) {
790 LayoutUnit spaceAdd = static_cast<LayoutUnit>(spaceA vailableThisPass * (child->style()->boxFlex() / totalFlex)); 804 LayoutUnit spaceAdd = static_cast<LayoutUnit>(spaceA vailableThisPass * (child->style()->boxFlex() / totalFlex));
791 if (spaceAdd) { 805 if (spaceAdd) {
792 child->setOverrideLogicalContentHeight(child->ov errideLogicalContentHeight() + spaceAdd); 806 child->setOverrideLogicalContentHeight(contentHe ightForChild(child) + spaceAdd);
793 flexingChildren = true; 807 flexingChildren = true;
794 relayoutChildren = true; 808 relayoutChildren = true;
795 } 809 }
796 810
797 spaceAvailableThisPass -= spaceAdd; 811 spaceAvailableThisPass -= spaceAdd;
798 remainingSpace -= spaceAdd; 812 remainingSpace -= spaceAdd;
799 groupRemainingSpace -= spaceAdd; 813 groupRemainingSpace -= spaceAdd;
800 814
801 totalFlex -= child->style()->boxFlex(); 815 totalFlex -= child->style()->boxFlex();
802 } 816 }
803 } 817 }
804 if (groupRemainingSpace == groupRemainingSpaceAtBeginning) { 818 if (groupRemainingSpace == groupRemainingSpaceAtBeginning) {
805 // This is not advancing, avoid getting stuck by distrib uting the remaining pixels. 819 // This is not advancing, avoid getting stuck by distrib uting the remaining pixels.
806 LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1; 820 LayoutUnit spaceAdd = groupRemainingSpace > 0 ? 1 : -1;
807 for (RenderBox* child = iterator.first(); child && group RemainingSpace; child = iterator.next()) { 821 for (RenderBox* child = iterator.first(); child && group RemainingSpace; child = iterator.next()) {
808 if (allowedChildFlex(child, expanding, i)) { 822 if (allowedChildFlex(child, expanding, i)) {
809 child->setOverrideLogicalContentHeight(child->ov errideLogicalContentHeight() + spaceAdd); 823 child->setOverrideLogicalContentHeight(contentHe ightForChild(child) + spaceAdd);
810 flexingChildren = true; 824 flexingChildren = true;
811 relayoutChildren = true; 825 relayoutChildren = true;
812 remainingSpace -= spaceAdd; 826 remainingSpace -= spaceAdd;
813 groupRemainingSpace -= spaceAdd; 827 groupRemainingSpace -= spaceAdd;
814 } 828 }
815 } 829 }
816 } 830 }
817 } while (absoluteValue(groupRemainingSpace) >= 1); 831 } while (absoluteValue(groupRemainingSpace) >= 1);
818 } 832 }
819 833
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1012 1026
1013 LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool expanding, unsigned int group) 1027 LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool expanding, unsigned int group)
1014 { 1028 {
1015 if (childDoesNotAffectWidthOrFlexing(child) || child->style()->boxFlex() == 0.0f || child->style()->boxFlexGroup() != group) 1029 if (childDoesNotAffectWidthOrFlexing(child) || child->style()->boxFlex() == 0.0f || child->style()->boxFlexGroup() != group)
1016 return 0; 1030 return 0;
1017 1031
1018 if (expanding) { 1032 if (expanding) {
1019 if (isHorizontal()) { 1033 if (isHorizontal()) {
1020 // FIXME: For now just handle fixed values. 1034 // FIXME: For now just handle fixed values.
1021 LayoutUnit maxWidth = MAX_LAYOUT_UNIT; 1035 LayoutUnit maxWidth = MAX_LAYOUT_UNIT;
1022 LayoutUnit width = child->overrideLogicalContentWidth(); 1036 LayoutUnit width = contentWidthForChild(child);
1023 if (!child->style()->maxWidth().isUndefined() && child->style()->max Width().isFixed()) 1037 if (!child->style()->maxWidth().isUndefined() && child->style()->max Width().isFixed())
1024 maxWidth = child->style()->maxWidth().value(); 1038 maxWidth = child->style()->maxWidth().value();
1025 else if (child->style()->maxWidth().type() == Intrinsic) 1039 else if (child->style()->maxWidth().type() == Intrinsic)
1026 maxWidth = child->maxPreferredLogicalWidth(); 1040 maxWidth = child->maxPreferredLogicalWidth();
1027 else if (child->style()->maxWidth().type() == MinIntrinsic) 1041 else if (child->style()->maxWidth().type() == MinIntrinsic)
1028 maxWidth = child->minPreferredLogicalWidth(); 1042 maxWidth = child->minPreferredLogicalWidth();
1029 if (maxWidth == MAX_LAYOUT_UNIT) 1043 if (maxWidth == MAX_LAYOUT_UNIT)
1030 return maxWidth; 1044 return maxWidth;
1031 return max<LayoutUnit>(0, maxWidth - width); 1045 return max<LayoutUnit>(0, maxWidth - width);
1032 } else { 1046 } else {
1033 // FIXME: For now just handle fixed values. 1047 // FIXME: For now just handle fixed values.
1034 LayoutUnit maxHeight = MAX_LAYOUT_UNIT; 1048 LayoutUnit maxHeight = MAX_LAYOUT_UNIT;
1035 LayoutUnit height = child->overrideLogicalContentHeight(); 1049 LayoutUnit height = contentHeightForChild(child);
1036 if (!child->style()->maxHeight().isUndefined() && child->style()->ma xHeight().isFixed()) 1050 if (!child->style()->maxHeight().isUndefined() && child->style()->ma xHeight().isFixed())
1037 maxHeight = child->style()->maxHeight().value(); 1051 maxHeight = child->style()->maxHeight().value();
1038 if (maxHeight == MAX_LAYOUT_UNIT) 1052 if (maxHeight == MAX_LAYOUT_UNIT)
1039 return maxHeight; 1053 return maxHeight;
1040 return max<LayoutUnit>(0, maxHeight - height); 1054 return max<LayoutUnit>(0, maxHeight - height);
1041 } 1055 }
1042 } 1056 }
1043 1057
1044 // FIXME: For now just handle fixed values. 1058 // FIXME: For now just handle fixed values.
1045 if (isHorizontal()) { 1059 if (isHorizontal()) {
1046 LayoutUnit minWidth = child->minPreferredLogicalWidth(); 1060 LayoutUnit minWidth = child->minPreferredLogicalWidth();
1047 LayoutUnit width = child->overrideLogicalContentWidth(); 1061 LayoutUnit width = contentWidthForChild(child);
1048 if (child->style()->minWidth().isFixed()) 1062 if (child->style()->minWidth().isFixed())
1049 minWidth = child->style()->minWidth().value(); 1063 minWidth = child->style()->minWidth().value();
1050 else if (child->style()->minWidth().type() == Intrinsic) 1064 else if (child->style()->minWidth().type() == Intrinsic)
1051 minWidth = child->maxPreferredLogicalWidth(); 1065 minWidth = child->maxPreferredLogicalWidth();
1052 else if (child->style()->minWidth().type() == MinIntrinsic) 1066 else if (child->style()->minWidth().type() == MinIntrinsic)
1053 minWidth = child->minPreferredLogicalWidth(); 1067 minWidth = child->minPreferredLogicalWidth();
1054 else if (child->style()->minWidth().type() == Auto) 1068 else if (child->style()->minWidth().type() == Auto)
1055 minWidth = 0; 1069 minWidth = 0;
1056 1070
1057 LayoutUnit allowedShrinkage = min<LayoutUnit>(0, minWidth - width); 1071 LayoutUnit allowedShrinkage = min<LayoutUnit>(0, minWidth - width);
1058 return allowedShrinkage; 1072 return allowedShrinkage;
1059 } else { 1073 } else {
1060 Length minHeight = child->style()->minHeight(); 1074 Length minHeight = child->style()->minHeight();
1061 if (minHeight.isFixed() || minHeight.isAuto()) { 1075 if (minHeight.isFixed() || minHeight.isAuto()) {
1062 LayoutUnit minHeight = child->style()->minHeight().value(); 1076 LayoutUnit minHeight = child->style()->minHeight().value();
1063 LayoutUnit height = child->overrideLogicalContentHeight(); 1077 LayoutUnit height = contentHeightForChild(child);
1064 LayoutUnit allowedShrinkage = min<LayoutUnit>(0, minHeight - height) ; 1078 LayoutUnit allowedShrinkage = min<LayoutUnit>(0, minHeight - height) ;
1065 return allowedShrinkage; 1079 return allowedShrinkage;
1066 } 1080 }
1067 } 1081 }
1068 1082
1069 return 0; 1083 return 0;
1070 } 1084 }
1071 1085
1072 const char *RenderDeprecatedFlexibleBox::renderName() const 1086 const char *RenderDeprecatedFlexibleBox::renderName() const
1073 { 1087 {
1074 if (isFloating()) 1088 if (isFloating())
1075 return "RenderDeprecatedFlexibleBox (floating)"; 1089 return "RenderDeprecatedFlexibleBox (floating)";
1076 if (isOutOfFlowPositioned()) 1090 if (isOutOfFlowPositioned())
1077 return "RenderDeprecatedFlexibleBox (positioned)"; 1091 return "RenderDeprecatedFlexibleBox (positioned)";
1078 if (isAnonymous()) 1092 if (isAnonymous())
1079 return "RenderDeprecatedFlexibleBox (generated)"; 1093 return "RenderDeprecatedFlexibleBox (generated)";
1080 if (isRelPositioned()) 1094 if (isRelPositioned())
1081 return "RenderDeprecatedFlexibleBox (relative positioned)"; 1095 return "RenderDeprecatedFlexibleBox (relative positioned)";
1082 return "RenderDeprecatedFlexibleBox"; 1096 return "RenderDeprecatedFlexibleBox";
1083 } 1097 }
1084 1098
1085 } // namespace WebCore 1099 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/WebCore/rendering/RenderBox.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698