Commit eb1a2f56 authored by Vladimir Levin's avatar Vladimir Levin Committed by Commit Bot

IntrinsicSizing: Small clean-up to LayoutReplaced and comments.

This patch is a small clean-up to LayoutReplaced logic which is
overly complicated in light of the fact that intrinsic sizing override
can only take place under size containment.

Also removes an obsolete comment.

R=cbiesinger@chromium.org, ikilpatrick@chromium.org

Bug: 1124771
Change-Id: I22c07b01146ee11e8e7adc8c877d90b161a107f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392741
Commit-Queue: vmpstr <vmpstr@chromium.org>
Reviewed-by: default avatarChris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804371}
parent b7d8b543
...@@ -3967,9 +3967,6 @@ static inline const Length& HeightForDocumentElement(const Document& document) { ...@@ -3967,9 +3967,6 @@ static inline const Length& HeightForDocumentElement(const Document& document) {
void LayoutBox::ComputeLogicalHeight( void LayoutBox::ComputeLogicalHeight(
LogicalExtentComputedValues& computed_values) const { LogicalExtentComputedValues& computed_values) const {
LayoutUnit height; LayoutUnit height;
// TODO(962979): Implement grid layout with display locking. We need to figure
// out what happens here if IsLayoutGrid() is true and size containment is
// specified while the box is locked.
if (HasOverrideIntrinsicContentLogicalHeight()) { if (HasOverrideIntrinsicContentLogicalHeight()) {
height = OverrideIntrinsicContentLogicalHeight() + height = OverrideIntrinsicContentLogicalHeight() +
BorderAndPaddingLogicalHeight() + ScrollbarLogicalHeight(); BorderAndPaddingLogicalHeight() + ScrollbarLogicalHeight();
......
...@@ -163,21 +163,13 @@ void LayoutReplaced::RecalcVisualOverflow() { ...@@ -163,21 +163,13 @@ void LayoutReplaced::RecalcVisualOverflow() {
void LayoutReplaced::ComputeIntrinsicSizingInfoForReplacedContent( void LayoutReplaced::ComputeIntrinsicSizingInfoForReplacedContent(
IntrinsicSizingInfo& intrinsic_sizing_info) const { IntrinsicSizingInfo& intrinsic_sizing_info) const {
// In cases where both size dimensions are overridden, or we apply size // In cases where we apply size containment we don't need to compute sizing
// containment we don't need to compute sizing information, since the final // information, since the final result does not depend on it.
// result does not depend on it. if (ShouldApplySizeContainment()) {
// TODO(vmpstr): The only difference between this and calling
// ComputeIntrinsicSizingInfo below is that the latter may use an aspect ratio
// from width and height. See if the two code paths can be unified.
if ((HasOverrideIntrinsicContentLogicalWidth() &&
HasOverrideIntrinsicContentLogicalHeight()) ||
ShouldApplySizeContainment()) {
// Reset the size in case it was already populated. // Reset the size in case it was already populated.
intrinsic_sizing_info.size = FloatSize(); intrinsic_sizing_info.size = FloatSize();
// If any of the dimensions are overriden, set those sizes. Note that we // If any of the dimensions are overridden, set those sizes.
// have to check individual dimensions because we might reach here because
// of size-containment.
if (HasOverrideIntrinsicContentLogicalWidth()) { if (HasOverrideIntrinsicContentLogicalWidth()) {
intrinsic_sizing_info.size.SetWidth( intrinsic_sizing_info.size.SetWidth(
OverrideIntrinsicContentLogicalWidth().ToFloat()); OverrideIntrinsicContentLogicalWidth().ToFloat());
...@@ -189,16 +181,12 @@ void LayoutReplaced::ComputeIntrinsicSizingInfoForReplacedContent( ...@@ -189,16 +181,12 @@ void LayoutReplaced::ComputeIntrinsicSizingInfoForReplacedContent(
return; return;
} }
ComputeIntrinsicSizingInfo(intrinsic_sizing_info); // Size overrides only apply if there is size-containment, which is checked
// above.
DCHECK(!HasOverrideIntrinsicContentLogicalWidth());
DCHECK(!HasOverrideIntrinsicContentLogicalHeight());
// The above call to ComputeIntrinsicSizingInfo should have used the override ComputeIntrinsicSizingInfo(intrinsic_sizing_info);
// if it was set.
DCHECK(!HasOverrideIntrinsicContentLogicalWidth() ||
OverrideIntrinsicContentLogicalWidth() ==
intrinsic_sizing_info.size.Width());
DCHECK(!HasOverrideIntrinsicContentLogicalHeight() ||
OverrideIntrinsicContentLogicalHeight() ==
intrinsic_sizing_info.size.Height());
// Update our intrinsic size to match what was computed, so that // Update our intrinsic size to match what was computed, so that
// when we constrain the size, the correct intrinsic size will be // when we constrain the size, the correct intrinsic size will be
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment