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

Side by Side Diff: Source/core/rendering/RenderBox.cpp

Issue 360613003: Ensure we compute the min and max height of replaced elements to 'none' or 0 when appropriate. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/rendering/RenderBox.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) 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 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after
2732 2732
2733 ASSERT_NOT_REACHED(); 2733 ASSERT_NOT_REACHED();
2734 return 0; 2734 return 0;
2735 } 2735 }
2736 2736
2737 LayoutUnit RenderBox::computeReplacedLogicalHeight() const 2737 LayoutUnit RenderBox::computeReplacedLogicalHeight() const
2738 { 2738 {
2739 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog icalHeightUsing(style()->logicalHeight())); 2739 return computeReplacedLogicalHeightRespectingMinMaxHeight(computeReplacedLog icalHeightUsing(style()->logicalHeight()));
2740 } 2740 }
2741 2741
2742 bool RenderBox::logicalHeightComputesAsNone(SizeType sizeType) const
2743 {
2744 ASSERT(sizeType == MinSize || sizeType == MaxSize);
2745 Length logicalHeight = sizeType == MinSize ? style()->logicalMinHeight() : s tyle()->logicalMaxHeight();
2746 Length initialLogicalHeight = sizeType == MinSize ? RenderStyle::initialMinS ize() : RenderStyle::initialMaxSize();
2747
2748 if (logicalHeight == initialLogicalHeight)
2749 return true;
2750
2751 if (!logicalHeight.isPercent() || isOutOfFlowPositioned())
2752 return false;
2753
2754 // Anonymous block boxes are ignored when resolving percentage values that w ould refer to it:
2755 // the closest non-anonymous ancestor box is used instead.
2756 RenderBlock* containingBlock = this->containingBlock();
2757 while (containingBlock->isAnonymous())
2758 containingBlock = containingBlock->containingBlock();
2759
2760 return containingBlock->hasAutoHeightOrContainingBlockWithAutoHeight();
2761 }
2762
2742 LayoutUnit RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU nit logicalHeight) const 2763 LayoutUnit RenderBox::computeReplacedLogicalHeightRespectingMinMaxHeight(LayoutU nit logicalHeight) const
2743 { 2764 {
2744 LayoutUnit minLogicalHeight = computeReplacedLogicalHeightUsing(style()->log icalMinHeight()); 2765 // If the height of the containing block is not specified explicitly (i.e., it depends on content height), and this element is not absolutely positioned,
2745 LayoutUnit maxLogicalHeight = style()->logicalMaxHeight().isUndefined() ? lo gicalHeight : computeReplacedLogicalHeightUsing(style()->logicalMaxHeight()); 2766 // the percentage value is treated as '0' (for 'min-height') or 'none' (for 'max-height').
2767 LayoutUnit minLogicalHeight;
2768 if (!logicalHeightComputesAsNone(MinSize))
2769 minLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMin Height());
2770 LayoutUnit maxLogicalHeight = logicalHeight;
2771 if (!logicalHeightComputesAsNone(MaxSize))
2772 maxLogicalHeight = computeReplacedLogicalHeightUsing(style()->logicalMa xHeight());
2746 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight)) ; 2773 return std::max(minLogicalHeight, std::min(logicalHeight, maxLogicalHeight)) ;
2747 } 2774 }
2748 2775
2749 LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(const Length& logicalHei ght) const 2776 LayoutUnit RenderBox::computeReplacedLogicalHeightUsing(const Length& logicalHei ght) const
2750 { 2777 {
2751 switch (logicalHeight.type()) { 2778 switch (logicalHeight.type()) {
2752 case Fixed: 2779 case Fixed:
2753 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value ()); 2780 return adjustContentBoxLogicalHeightForBoxSizing(logicalHeight.value ());
2754 case Percent: 2781 case Percent:
2755 case Calculated: 2782 case Calculated:
(...skipping 1869 matching lines...) Expand 10 before | Expand all | Expand 10 after
4625 4652
4626 // We need the old border box size only when the box has background or b ox decorations. 4653 // We need the old border box size only when the box has background or b ox decorations.
4627 if (!style()->hasBackground() && !style()->hasBoxDecorations()) 4654 if (!style()->hasBackground() && !style()->hasBoxDecorations())
4628 return; 4655 return;
4629 } 4656 }
4630 4657
4631 ensureRareData().m_previousBorderBoxSize = size(); 4658 ensureRareData().m_previousBorderBoxSize = size();
4632 } 4659 }
4633 4660
4634 } // namespace WebCore 4661 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/RenderBox.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698