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

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

Issue 879483002: [New Multicolumn] Intrinsic/preferred logical width calculation for spanners. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: final code review Created 5 years, 11 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) 2007 David Smith (catfish.man@gmail.com) 4 * (C) 2007 David Smith (catfish.man@gmail.com)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 * Copyright (C) Research In Motion Limited 2010. All rights reserved. 6 * Copyright (C) Research In Motion Limited 2010. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 2938 matching lines...) Expand 10 before | Expand all | Expand 10 after
2949 { 2949 {
2950 if (childrenInline()) { 2950 if (childrenInline()) {
2951 // FIXME: Remove this const_cast. 2951 // FIXME: Remove this const_cast.
2952 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); 2952 toRenderBlockFlow(const_cast<RenderBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth);
2953 } else { 2953 } else {
2954 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); 2954 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
2955 } 2955 }
2956 2956
2957 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 2957 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
2958 2958
2959 adjustIntrinsicLogicalWidthsForColumns(minLogicalWidth, maxLogicalWidth); 2959 // The flow thread based multicol implementation will do this adjustment on the flow thread, and
2960 // not here on the multicol container, so that spanners won't incorrectly be treated as column
2961 // content (and have spanners' preferred widths multiplied by the number of columns, etc.).
2962 if (style()->specifiesColumns() && !document().regionBasedColumnsEnabled())
2963 adjustIntrinsicLogicalWidthsForColumns(minLogicalWidth, maxLogicalWidth) ;
2960 2964
2961 if (isTableCell()) { 2965 if (isTableCell()) {
2962 Length tableCellWidth = toLayoutTableCell(this)->styleOrColLogicalWidth( ); 2966 Length tableCellWidth = toLayoutTableCell(this)->styleOrColLogicalWidth( );
2963 if (tableCellWidth.isFixed() && tableCellWidth.value() > 0) 2967 if (tableCellWidth.isFixed() && tableCellWidth.value() > 0)
2964 maxLogicalWidth = std::max(minLogicalWidth, adjustContentBoxLogicalW idthForBoxSizing(tableCellWidth.value())); 2968 maxLogicalWidth = std::max(minLogicalWidth, adjustContentBoxLogicalW idthForBoxSizing(tableCellWidth.value()));
2965 } 2969 }
2966 2970
2967 int scrollbarWidth = intrinsicScrollbarLogicalWidth(); 2971 int scrollbarWidth = intrinsicScrollbarLogicalWidth();
2968 maxLogicalWidth += scrollbarWidth; 2972 maxLogicalWidth += scrollbarWidth;
2969 minLogicalWidth += scrollbarWidth; 2973 minLogicalWidth += scrollbarWidth;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3003 3007
3004 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth(); 3008 LayoutUnit borderAndPadding = borderAndPaddingLogicalWidth();
3005 m_minPreferredLogicalWidth += borderAndPadding; 3009 m_minPreferredLogicalWidth += borderAndPadding;
3006 m_maxPreferredLogicalWidth += borderAndPadding; 3010 m_maxPreferredLogicalWidth += borderAndPadding;
3007 3011
3008 clearPreferredLogicalWidthsDirty(); 3012 clearPreferredLogicalWidthsDirty();
3009 } 3013 }
3010 3014
3011 void RenderBlock::adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalW idth, LayoutUnit& maxLogicalWidth) const 3015 void RenderBlock::adjustIntrinsicLogicalWidthsForColumns(LayoutUnit& minLogicalW idth, LayoutUnit& maxLogicalWidth) const
3012 { 3016 {
3017 ASSERT(!document().regionBasedColumnsEnabled());
3013 if (!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth()) { 3018 if (!style()->hasAutoColumnCount() || !style()->hasAutoColumnWidth()) {
3014 // The min/max intrinsic widths calculated really tell how much space el ements need when 3019 // The min/max intrinsic widths calculated really tell how much space el ements need when
3015 // laid out inside the columns. In order to eventually end up with the d esired column width, 3020 // laid out inside the columns. In order to eventually end up with the d esired column width,
3016 // we need to convert them to values pertaining to the multicol containe r. 3021 // we need to convert them to values pertaining to the multicol containe r.
3017 int columnCount = style()->hasAutoColumnCount() ? 1 : style()->columnCou nt(); 3022 int columnCount = style()->hasAutoColumnCount() ? 1 : style()->columnCou nt();
3018 LayoutUnit columnWidth; 3023 LayoutUnit columnWidth;
3019 LayoutUnit gapExtra = (columnCount - 1) * columnGap(); 3024 LayoutUnit gapExtra = (columnCount - 1) * columnGap();
3020 if (style()->hasAutoColumnWidth()) { 3025 if (style()->hasAutoColumnWidth()) {
3021 minLogicalWidth = minLogicalWidth * columnCount + gapExtra; 3026 minLogicalWidth = minLogicalWidth * columnCount + gapExtra;
3022 } else { 3027 } else {
(...skipping 11 matching lines...) Expand all
3034 3039
3035 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth , LayoutUnit& maxLogicalWidth) const 3040 void RenderBlock::computeBlockPreferredLogicalWidths(LayoutUnit& minLogicalWidth , LayoutUnit& maxLogicalWidth) const
3036 { 3041 {
3037 RenderStyle* styleToUse = style(); 3042 RenderStyle* styleToUse = style();
3038 bool nowrap = styleToUse->whiteSpace() == NOWRAP; 3043 bool nowrap = styleToUse->whiteSpace() == NOWRAP;
3039 3044
3040 RenderObject* child = firstChild(); 3045 RenderObject* child = firstChild();
3041 RenderBlock* containingBlock = this->containingBlock(); 3046 RenderBlock* containingBlock = this->containingBlock();
3042 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0; 3047 LayoutUnit floatLeftWidth = 0, floatRightWidth = 0;
3043 while (child) { 3048 while (child) {
3044 // Positioned children don't affect the min/max width 3049 // Positioned children don't affect the min/max width. Spanners only aff ect the min/max
3045 if (child->isOutOfFlowPositioned()) { 3050 // width of the multicol container, not the flow thread.
3051 if (child->isOutOfFlowPositioned() || child->isColumnSpanAll()) {
3046 child = child->nextSibling(); 3052 child = child->nextSibling();
3047 continue; 3053 continue;
3048 } 3054 }
3049 3055
3050 RefPtr<RenderStyle> childStyle = child->style(); 3056 RefPtr<RenderStyle> childStyle = child->style();
3051 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids Floats())) { 3057 if (child->isFloating() || (child->isBox() && toRenderBox(child)->avoids Floats())) {
3052 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth; 3058 LayoutUnit floatTotalWidth = floatLeftWidth + floatRightWidth;
3053 if (childStyle->clear() & CLEFT) { 3059 if (childStyle->clear() & CLEFT) {
3054 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth); 3060 maxLogicalWidth = std::max(floatTotalWidth, maxLogicalWidth);
3055 floatLeftWidth = 0; 3061 floatLeftWidth = 0;
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const 3947 void RenderBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Render Object* obj) const
3942 { 3948 {
3943 showRenderObject(); 3949 showRenderObject();
3944 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 3950 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
3945 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 3951 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
3946 } 3952 }
3947 3953
3948 #endif 3954 #endif
3949 3955
3950 } // namespace blink 3956 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698