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

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

Issue 1405953005: Avoid multiple recursions through the tree when calculating percent height (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@322039-2
Patch Set: Updated Created 5 years, 1 month 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 | « no previous file | 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
585 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { 585 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) {
586 LayoutUnit maxH = computeLogicalHeightUsing(MaxSize, styleToUse.logicalM axHeight(), intrinsicContentHeight); 586 LayoutUnit maxH = computeLogicalHeightUsing(MaxSize, styleToUse.logicalM axHeight(), intrinsicContentHeight);
587 if (maxH != -1) 587 if (maxH != -1)
588 logicalHeight = std::min(logicalHeight, maxH); 588 logicalHeight = std::min(logicalHeight, maxH);
589 } 589 }
590 return std::max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse .logicalMinHeight(), intrinsicContentHeight)); 590 return std::max(logicalHeight, computeLogicalHeightUsing(MinSize, styleToUse .logicalMinHeight(), intrinsicContentHeight));
591 } 591 }
592 592
593 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const 593 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const
594 { 594 {
595 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height
596 // to avoid recursing up through our containing blocks again to determine it .
595 const ComputedStyle& styleToUse = styleRef(); 597 const ComputedStyle& styleToUse = styleRef();
596 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { 598 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) {
597 LayoutUnit maxH = computeContentLogicalHeight(MaxSize, styleToUse.logica lMaxHeight(), intrinsicContentHeight); 599 if (styleToUse.logicalMaxHeight().hasPercent() && styleToUse.logicalHeig ht().hasPercent()) {
598 if (maxH != -1) 600 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logic alHeight().value() * 100;
599 logicalHeight = std::min(logicalHeight, maxH); 601 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight));
602 } else {
603 LayoutUnit maxHeight = computeContentLogicalHeight(MaxSize, styleToU se.logicalMaxHeight(), -1);
604 if (maxHeight != -1)
605 logicalHeight = std::min(logicalHeight, maxHeight);
606 }
600 } 607 }
601 return std::max(logicalHeight, computeContentLogicalHeight(MinSize, styleToU se.logicalMinHeight(), intrinsicContentHeight)); 608
609 if (styleToUse.logicalMinHeight().hasPercent() && styleToUse.logicalHeight() .hasPercent()) {
610 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logicalHe ight().value() * 100;
611 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight));
612 } else {
613 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight));
614 }
615
616 return logicalHeight;
602 } 617 }
603 618
604 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint& location) 619 void LayoutBox::setLocationAndUpdateOverflowControlsIfNeeded(const LayoutPoint& location)
605 { 620 {
606 if (hasOverflowClip()) { 621 if (hasOverflowClip()) {
607 IntSize oldPixelSnappedBorderRectSize = pixelSnappedBorderBoxRect().size (); 622 IntSize oldPixelSnappedBorderRectSize = pixelSnappedBorderBoxRect().size ();
608 setLocation(location); 623 setLocation(location);
609 if (pixelSnappedBorderBoxRect().size() != oldPixelSnappedBorderRectSize) 624 if (pixelSnappedBorderBoxRect().size() != oldPixelSnappedBorderRectSize)
610 scrollableArea()->updateAfterLayout(); 625 scrollableArea()->updateAfterLayout();
611 return; 626 return;
(...skipping 4228 matching lines...) Expand 10 before | Expand all | Expand 10 after
4840 StyleImage* borderImage = style()->borderImage().image(); 4855 StyleImage* borderImage = style()->borderImage().image();
4841 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded(); 4856 return borderImage && borderImage->canRender(*this, style()->effectiveZoom() ) && borderImage->isLoaded();
4842 } 4857 }
4843 4858
4844 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const 4859 ShapeOutsideInfo* LayoutBox::shapeOutsideInfo() const
4845 { 4860 {
4846 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr; 4861 return ShapeOutsideInfo::isEnabledFor(*this) ? ShapeOutsideInfo::info(*this) : nullptr;
4847 } 4862 }
4848 4863
4849 } // namespace blink 4864 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698