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

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

Issue 1651703002: More explicit LayoutUnit conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@evenMoarConstructors
Patch Set: Traits vs Properties vs Pandas Created 4 years, 10 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 597 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const 608 LayoutUnit LayoutBox::constrainContentBoxLogicalHeightByMinMax(LayoutUnit logica lHeight, LayoutUnit intrinsicContentHeight) const
609 { 609 {
610 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height 610 // If the min/max height and logical height are both percentages we take adv antage of already knowing the current resolved percentage height
611 // to avoid recursing up through our containing blocks again to determine it . 611 // to avoid recursing up through our containing blocks again to determine it .
612 const ComputedStyle& styleToUse = styleRef(); 612 const ComputedStyle& styleToUse = styleRef();
613 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) { 613 if (!styleToUse.logicalMaxHeight().isMaxSizeNone()) {
614 if (styleToUse.logicalMaxHeight().hasPercent() && styleToUse.logicalHeig ht().hasPercent()) { 614 if (styleToUse.logicalMaxHeight().hasPercent() && styleToUse.logicalHeig ht().hasPercent()) {
615 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logic alHeight().value() * 100; 615 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logic alHeight().value() * 100;
616 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight)); 616 logicalHeight = std::min(logicalHeight, valueForLength(styleToUse.lo gicalMaxHeight(), availableLogicalHeight));
617 } else { 617 } else {
618 LayoutUnit maxHeight = computeContentLogicalHeight(MaxSize, styleToU se.logicalMaxHeight(), -1); 618 LayoutUnit maxHeight = computeContentLogicalHeight(MaxSize, styleToU se.logicalMaxHeight(), LayoutUnit(-1));
619 if (maxHeight != -1) 619 if (maxHeight != -1)
620 logicalHeight = std::min(logicalHeight, maxHeight); 620 logicalHeight = std::min(logicalHeight, maxHeight);
621 } 621 }
622 } 622 }
623 623
624 if (styleToUse.logicalMinHeight().hasPercent() && styleToUse.logicalHeight() .hasPercent()) { 624 if (styleToUse.logicalMinHeight().hasPercent() && styleToUse.logicalHeight() .hasPercent()) {
625 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logicalHe ight().value() * 100; 625 LayoutUnit availableLogicalHeight = logicalHeight / styleToUse.logicalHe ight().value() * 100;
626 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight)); 626 logicalHeight = std::max(logicalHeight, valueForLength(styleToUse.logica lMinHeight(), availableLogicalHeight));
627 } else { 627 } else {
628 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight)); 628 logicalHeight = std::max(logicalHeight, computeContentLogicalHeight(MinS ize, styleToUse.logicalMinHeight(), intrinsicContentHeight));
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1030 1030
1031 void LayoutBox::setOverrideLogicalContentWidth(LayoutUnit width) 1031 void LayoutBox::setOverrideLogicalContentWidth(LayoutUnit width)
1032 { 1032 {
1033 ASSERT(width >= 0); 1033 ASSERT(width >= 0);
1034 ensureRareData().m_overrideLogicalContentWidth = width; 1034 ensureRareData().m_overrideLogicalContentWidth = width;
1035 } 1035 }
1036 1036
1037 void LayoutBox::clearOverrideLogicalContentHeight() 1037 void LayoutBox::clearOverrideLogicalContentHeight()
1038 { 1038 {
1039 if (m_rareData) 1039 if (m_rareData)
1040 m_rareData->m_overrideLogicalContentHeight = -1; 1040 m_rareData->m_overrideLogicalContentHeight = LayoutUnit(-1);
1041 } 1041 }
1042 1042
1043 void LayoutBox::clearOverrideLogicalContentWidth() 1043 void LayoutBox::clearOverrideLogicalContentWidth()
1044 { 1044 {
1045 if (m_rareData) 1045 if (m_rareData)
1046 m_rareData->m_overrideLogicalContentWidth = -1; 1046 m_rareData->m_overrideLogicalContentWidth = LayoutUnit(-1);
1047 } 1047 }
1048 1048
1049 void LayoutBox::clearOverrideSize() 1049 void LayoutBox::clearOverrideSize()
1050 { 1050 {
1051 clearOverrideLogicalContentHeight(); 1051 clearOverrideLogicalContentHeight();
1052 clearOverrideLogicalContentWidth(); 1052 clearOverrideLogicalContentWidth();
1053 } 1053 }
1054 1054
1055 LayoutUnit LayoutBox::overrideLogicalContentWidth() const 1055 LayoutUnit LayoutBox::overrideLogicalContentWidth() const
1056 { 1056 {
(...skipping 3583 matching lines...) Expand 10 before | Expand all | Expand 10 after
4640 4640
4641 void LayoutBox::clearPercentHeightDescendants() 4641 void LayoutBox::clearPercentHeightDescendants()
4642 { 4642 {
4643 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) { 4643 for (LayoutObject* curr = slowFirstChild(); curr; curr = curr->nextInPreOrde r(this)) {
4644 if (curr->isBox()) 4644 if (curr->isBox())
4645 toLayoutBox(curr)->removeFromPercentHeightContainer(); 4645 toLayoutBox(curr)->removeFromPercentHeightContainer();
4646 } 4646 }
4647 } 4647 }
4648 4648
4649 } // namespace blink 4649 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698