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

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

Issue 2086083002: Fix percentage handling for replaced elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: with test Created 4 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com) 5 * (C) 2005, 2006 Samuel Weinig (sam.weinig@gmail.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed.
7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. 7 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 2892 matching lines...) Expand 10 before | Expand all | Expand 10 after
2903 2903
2904 switch (logicalHeight.type()) { 2904 switch (logicalHeight.type()) {
2905 case Fixed: 2905 case Fixed:
2906 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value()); 2906 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value());
2907 case Percent: 2907 case Percent:
2908 case Calculated: 2908 case Calculated:
2909 { 2909 {
2910 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containingBlo ck(); 2910 LayoutObject* cb = isOutOfFlowPositioned() ? container() : containingBlo ck();
2911 while (cb->isAnonymous()) 2911 while (cb->isAnonymous())
2912 cb = cb->containingBlock(); 2912 cb = cb->containingBlock();
2913 if (cb->isLayoutBlock()) 2913 LayoutUnit stretchedFlexHeight(-1);
2914 toLayoutBlock(cb)->addPercentHeightDescendant(const_cast<LayoutBox*> (this)); 2914 if (cb->isLayoutBlock()) {
2915 LayoutBlock* block = toLayoutBlock(cb);
2916 block->addPercentHeightDescendant(const_cast<LayoutBox*>(this));
2917 if (block->isFlexItem())
2918 stretchedFlexHeight = toLayoutFlexibleBox(block->parent())->chil dLogicalHeightForPercentageResolution(*block);
2919
2920 }
2915 2921
2916 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() && !(c b->style()->top().isAuto() || cb->style()->bottom().isAuto())) { 2922 if (cb->isOutOfFlowPositioned() && cb->style()->height().isAuto() && !(c b->style()->top().isAuto() || cb->style()->bottom().isAuto())) {
2917 ASSERT_WITH_SECURITY_IMPLICATION(cb->isLayoutBlock()); 2923 ASSERT_WITH_SECURITY_IMPLICATION(cb->isLayoutBlock());
2918 LayoutBlock* block = toLayoutBlock(cb); 2924 LayoutBlock* block = toLayoutBlock(cb);
2919 LogicalExtentComputedValues computedValues; 2925 LogicalExtentComputedValues computedValues;
2920 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), co mputedValues); 2926 block->computeLogicalHeight(block->logicalHeight(), LayoutUnit(), co mputedValues);
2921 LayoutUnit newContentHeight = computedValues.m_extent - block->borde rAndPaddingLogicalHeight() - block->scrollbarLogicalHeight(); 2927 LayoutUnit newContentHeight = computedValues.m_extent - block->borde rAndPaddingLogicalHeight() - block->scrollbarLogicalHeight();
2922 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSiz ing(newContentHeight); 2928 LayoutUnit newHeight = block->adjustContentBoxLogicalHeightForBoxSiz ing(newContentHeight);
2923 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi calHeight, newHeight)); 2929 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(logi calHeight, newHeight));
2924 } 2930 }
2925 2931
2926 // FIXME: availableLogicalHeight() is wrong if the replaced element's wr iting-mode is perpendicular to the 2932 // FIXME: availableLogicalHeight() is wrong if the replaced element's wr iting-mode is perpendicular to the
2927 // containing block's writing-mode. 2933 // containing block's writing-mode.
2928 // https://bugs.webkit.org/show_bug.cgi?id=46496 2934 // https://bugs.webkit.org/show_bug.cgi?id=46496
2929 LayoutUnit availableHeight; 2935 LayoutUnit availableHeight;
2930 if (isOutOfFlowPositioned()) { 2936 if (isOutOfFlowPositioned()) {
2931 availableHeight = containingBlockLogicalHeightForPositioned(toLayout BoxModelObject(cb)); 2937 availableHeight = containingBlockLogicalHeightForPositioned(toLayout BoxModelObject(cb));
2938 } else if (stretchedFlexHeight != -1) {
2939 availableHeight = stretchedFlexHeight;
2932 } else { 2940 } else {
2933 availableHeight = containingBlockLogicalHeightForContent(IncludeMarg inBorderPadding); 2941 availableHeight = containingBlockLogicalHeightForContent(IncludeMarg inBorderPadding);
2934 // It is necessary to use the border-box to match WinIE's broken 2942 // It is necessary to use the border-box to match WinIE's broken
2935 // box model. This is essential for sizing inside 2943 // box model. This is essential for sizing inside
2936 // table cells using percentage heights. 2944 // table cells using percentage heights.
2937 // FIXME: This needs to be made writing-mode-aware. If the cell and image are perpendicular writing-modes, this isn't right. 2945 // FIXME: This needs to be made writing-mode-aware. If the cell and image are perpendicular writing-modes, this isn't right.
2938 // https://bugs.webkit.org/show_bug.cgi?id=46997 2946 // https://bugs.webkit.org/show_bug.cgi?id=46997
2939 while (cb && !cb->isLayoutView() && (cb->style()->logicalHeight().is Auto() || cb->style()->logicalHeight().hasPercent())) { 2947 while (cb && !cb->isLayoutView() && (cb->style()->logicalHeight().is Auto() || cb->style()->logicalHeight().hasPercent())) {
2940 if (cb->isTableCell()) { 2948 if (cb->isTableCell()) {
2941 // Don't let table cells squeeze percent-height replaced ele ments 2949 // Don't let table cells squeeze percent-height replaced ele ments
(...skipping 1936 matching lines...) Expand 10 before | Expand all | Expand 10 after
4878 m_rareData->m_snapAreas->remove(&snapArea); 4886 m_rareData->m_snapAreas->remove(&snapArea);
4879 } 4887 }
4880 } 4888 }
4881 4889
4882 SnapAreaSet* LayoutBox::snapAreas() const 4890 SnapAreaSet* LayoutBox::snapAreas() const
4883 { 4891 {
4884 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr; 4892 return m_rareData ? m_rareData->m_snapAreas.get() : nullptr;
4885 } 4893 }
4886 4894
4887 } // namespace blink 4895 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698