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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutMultiColumnFlowThread.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) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 LayoutUnit LayoutMultiColumnFlowThread::remainingLogicalHeightAt(LayoutUnit bloc kOffset) 473 LayoutUnit LayoutMultiColumnFlowThread::remainingLogicalHeightAt(LayoutUnit bloc kOffset)
474 { 474 {
475 return pageRemainingLogicalHeightForOffset(blockOffset, AssociateWithLatterP age); 475 return pageRemainingLogicalHeightForOffset(blockOffset, AssociateWithLatterP age);
476 } 476 }
477 477
478 void LayoutMultiColumnFlowThread::calculateColumnCountAndWidth(LayoutUnit& width , unsigned& count) const 478 void LayoutMultiColumnFlowThread::calculateColumnCountAndWidth(LayoutUnit& width , unsigned& count) const
479 { 479 {
480 LayoutBlock* columnBlock = multiColumnBlockFlow(); 480 LayoutBlock* columnBlock = multiColumnBlockFlow();
481 const ComputedStyle* columnStyle = columnBlock->style(); 481 const ComputedStyle* columnStyle = columnBlock->style();
482 LayoutUnit availableWidth = columnBlock->contentLogicalWidth(); 482 LayoutUnit availableWidth = columnBlock->contentLogicalWidth();
483 LayoutUnit columnGap = columnBlock->columnGap(); 483 LayoutUnit columnGap = LayoutUnit(columnBlock->columnGap());
484 LayoutUnit computedColumnWidth = max(LayoutUnit(1), LayoutUnit(columnStyle-> columnWidth())); 484 LayoutUnit computedColumnWidth = max(LayoutUnit(1), LayoutUnit(columnStyle-> columnWidth()));
485 unsigned computedColumnCount = max<int>(1, columnStyle->columnCount()); 485 unsigned computedColumnCount = max<int>(1, columnStyle->columnCount());
486 486
487 ASSERT(!columnStyle->hasAutoColumnCount() || !columnStyle->hasAutoColumnWidt h()); 487 ASSERT(!columnStyle->hasAutoColumnCount() || !columnStyle->hasAutoColumnWidt h());
488 if (columnStyle->hasAutoColumnWidth() && !columnStyle->hasAutoColumnCount()) { 488 if (columnStyle->hasAutoColumnWidth() && !columnStyle->hasAutoColumnCount()) {
489 count = computedColumnCount; 489 count = computedColumnCount;
490 width = ((availableWidth - ((count - 1) * columnGap)) / count).clampNega tiveToZero(); 490 width = ((availableWidth - ((count - 1) * columnGap)) / count).clampNega tiveToZero();
491 } else if (!columnStyle->hasAutoColumnWidth() && columnStyle->hasAutoColumnC ount()) { 491 } else if (!columnStyle->hasAutoColumnWidth() && columnStyle->hasAutoColumnC ount()) {
492 count = std::max(LayoutUnit(1), (availableWidth + columnGap) / (computed ColumnWidth + columnGap)); 492 count = std::max(LayoutUnit(1), (availableWidth + columnGap) / (computed ColumnWidth + columnGap));
493 width = ((availableWidth + columnGap) / count) - columnGap; 493 width = ((availableWidth + columnGap) / count) - columnGap;
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 { 851 {
852 LayoutFlowThread::computePreferredLogicalWidths(); 852 LayoutFlowThread::computePreferredLogicalWidths();
853 853
854 // The min/max intrinsic widths calculated really tell how much space elemen ts need when 854 // The min/max intrinsic widths calculated really tell how much space elemen ts need when
855 // laid out inside the columns. In order to eventually end up with the desir ed column width, 855 // laid out inside the columns. In order to eventually end up with the desir ed column width,
856 // we need to convert them to values pertaining to the multicol container. 856 // we need to convert them to values pertaining to the multicol container.
857 const LayoutBlockFlow* multicolContainer = multiColumnBlockFlow(); 857 const LayoutBlockFlow* multicolContainer = multiColumnBlockFlow();
858 const ComputedStyle* multicolStyle = multicolContainer->style(); 858 const ComputedStyle* multicolStyle = multicolContainer->style();
859 int columnCount = multicolStyle->hasAutoColumnCount() ? 1 : multicolStyle->c olumnCount(); 859 int columnCount = multicolStyle->hasAutoColumnCount() ? 1 : multicolStyle->c olumnCount();
860 LayoutUnit columnWidth; 860 LayoutUnit columnWidth;
861 LayoutUnit gapExtra = (columnCount - 1) * multicolContainer->columnGap(); 861 LayoutUnit gapExtra = LayoutUnit((columnCount - 1) * multicolContainer->colu mnGap());
862 if (multicolStyle->hasAutoColumnWidth()) { 862 if (multicolStyle->hasAutoColumnWidth()) {
863 m_minPreferredLogicalWidth = m_minPreferredLogicalWidth * columnCount + gapExtra; 863 m_minPreferredLogicalWidth = m_minPreferredLogicalWidth * columnCount + gapExtra;
864 } else { 864 } else {
865 columnWidth = multicolStyle->columnWidth(); 865 columnWidth = multicolStyle->columnWidth();
866 m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, column Width); 866 m_minPreferredLogicalWidth = std::min(m_minPreferredLogicalWidth, column Width);
867 } 867 }
868 // Note that if column-count is auto here, we should resolve it to calculate the maximum 868 // Note that if column-count is auto here, we should resolve it to calculate the maximum
869 // intrinsic width, instead of pretending that it's 1. The only way to do th at is by performing 869 // intrinsic width, instead of pretending that it's 1. The only way to do th at is by performing
870 // a layout pass, but this is not an appropriate time or place for layout. T he good news is that 870 // a layout pass, but this is not an appropriate time or place for layout. T he good news is that
871 // if height is unconstrained and there are no explicit breaks, the resolved column-count really 871 // if height is unconstrained and there are no explicit breaks, the resolved column-count really
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 // the "mayBe"), if we're in an out-of-flow subtree and have an outer multic ol container that 925 // the "mayBe"), if we're in an out-of-flow subtree and have an outer multic ol container that
926 // doesn't affect us, but that's okay. We'll discover that further down the road when trying to 926 // doesn't affect us, but that's okay. We'll discover that further down the road when trying to
927 // locate our enclosing flow thread for real. 927 // locate our enclosing flow thread for real.
928 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread() || view()->f ragmentationContext(); 928 bool mayBeNested = multiColumnBlockFlow()->isInsideFlowThread() || view()->f ragmentationContext();
929 if (!mayBeNested) 929 if (!mayBeNested)
930 return; 930 return;
931 appendNewFragmentainerGroupIfNeeded(logicalBottomInFlowThreadAfterPagination ); 931 appendNewFragmentainerGroupIfNeeded(logicalBottomInFlowThreadAfterPagination );
932 } 932 }
933 933
934 } // namespace blink 934 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutListBox.cpp ('k') | third_party/WebKit/Source/core/layout/LayoutObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698