Skip to content

Commit 46b0523

Browse files
author
Ahmad Saleem
committed
Change lengths to reference in RenderDeprecatedFlexibleBox.cpp
https://bugs.webkit.org/show_bug.cgi?id=277020 Reviewed by Alan Baradlay. This is just more of code health fixes to change Lengths to references (to avoid copying) and also use local variable to clean-up code as needed. * Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp: (WebCore::marginWidthForChild): (WebCore::RenderDeprecatedFlexibleBox::allowedChildFlex): Canonical link: https://commits.webkit.org/281343@main
1 parent 5d0fe66 commit 46b0523

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

Source/WebCore/rendering/RenderDeprecatedFlexibleBox.cpp

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* Copyright (C) 1999 Lars Knoll ([email protected])
33
* (C) 1999 Antti Koivisto ([email protected])
4-
* Copyright (C) 2003-2023 Apple Inc. All rights reserved.
4+
* Copyright (C) 2003-2024 Apple Inc. All rights reserved.
55
*
66
* This library is free software; you can redistribute it and/or
77
* modify it under the terms of the GNU Library General Public
@@ -143,8 +143,8 @@ static LayoutUnit marginWidthForChild(RenderBox* child)
143143
// A margin basically has three types: fixed, percentage, and auto (variable).
144144
// Auto and percentage margins simply become 0 when computing min/max width.
145145
// Fixed margins can be added in as is.
146-
Length marginLeft = child->style().marginLeft();
147-
Length marginRight = child->style().marginRight();
146+
auto& marginLeft = child->style().marginLeft();
147+
auto& marginRight = child->style().marginRight();
148148
LayoutUnit margin;
149149
if (marginLeft.isFixed())
150150
margin += marginLeft.value();
@@ -1088,11 +1088,12 @@ LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool
10881088
// FIXME: For now just handle fixed values.
10891089
LayoutUnit maxWidth = LayoutUnit::max();
10901090
LayoutUnit width = contentWidthForChild(child);
1091-
if (!child->style().maxWidth().isUndefined() && child->style().maxWidth().isFixed())
1092-
maxWidth = child->style().maxWidth().value();
1093-
else if (child->style().maxWidth().type() == LengthType::Intrinsic)
1091+
auto& maxWidthLength = child->style().maxWidth();
1092+
if (!maxWidthLength.isUndefined() && maxWidthLength.isFixed())
1093+
maxWidth = maxWidthLength.value();
1094+
else if (maxWidthLength.type() == LengthType::Intrinsic)
10941095
maxWidth = child->maxPreferredLogicalWidth();
1095-
else if (child->style().maxWidth().isMinIntrinsic())
1096+
else if (maxWidthLength.isMinIntrinsic())
10961097
maxWidth = child->minPreferredLogicalWidth();
10971098
if (maxWidth == LayoutUnit::max())
10981099
return maxWidth;
@@ -1101,8 +1102,9 @@ LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool
11011102
// FIXME: For now just handle fixed values.
11021103
LayoutUnit maxHeight = LayoutUnit::max();
11031104
LayoutUnit height = contentHeightForChild(child);
1104-
if (!child->style().maxHeight().isUndefined() && child->style().maxHeight().isFixed())
1105-
maxHeight = child->style().maxHeight().value();
1105+
auto& maxHeigthLength = child->style().maxHeight();
1106+
if (!maxHeigthLength.isUndefined() && maxHeigthLength.isFixed())
1107+
maxHeight = maxHeigthLength.value();
11061108
if (maxHeight == LayoutUnit::max())
11071109
return maxHeight;
11081110
return std::max<LayoutUnit>(0, maxHeight - height);
@@ -1113,19 +1115,20 @@ LayoutUnit RenderDeprecatedFlexibleBox::allowedChildFlex(RenderBox* child, bool
11131115
if (isHorizontal()) {
11141116
LayoutUnit minWidth = child->minPreferredLogicalWidth();
11151117
LayoutUnit width = contentWidthForChild(child);
1116-
if (child->style().minWidth().isFixed())
1117-
minWidth = child->style().minWidth().value();
1118-
else if (child->style().minWidth().type() == LengthType::Intrinsic)
1118+
auto& minWidthLength = child->style().minWidth();
1119+
if (minWidthLength.isFixed())
1120+
minWidth = minWidthLength.value();
1121+
else if (minWidthLength.type() == LengthType::Intrinsic)
11191122
minWidth = child->maxPreferredLogicalWidth();
1120-
else if (child->style().minWidth().isMinIntrinsic())
1123+
else if (minWidthLength.isMinIntrinsic())
11211124
minWidth = child->minPreferredLogicalWidth();
1122-
else if (child->style().minWidth().isAuto())
1125+
else if (minWidthLength.isAuto())
11231126
minWidth = 0;
11241127

11251128
LayoutUnit allowedShrinkage = std::min<LayoutUnit>(0, minWidth - width);
11261129
return allowedShrinkage;
11271130
} else {
1128-
Length minHeight = child->style().minHeight();
1131+
auto& minHeight = child->style().minHeight();
11291132
if (minHeight.isFixed() || minHeight.isAuto()) {
11301133
LayoutUnit minHeight { child->style().minHeight().value() };
11311134
LayoutUnit height = contentHeightForChild(child);

0 commit comments

Comments
 (0)