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

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

Issue 1530303003: Implement Layout Containment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add additional test case and descriptions Created 5 years 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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 1000
1001 IntRect inflatedRect = pixelSnappedBorderBoxRect(); 1001 IntRect inflatedRect = pixelSnappedBorderBoxRect();
1002 LayoutTheme::theme().addVisualOverflow(*this, inflatedRect); 1002 LayoutTheme::theme().addVisualOverflow(*this, inflatedRect);
1003 addVisualOverflow(LayoutRect(inflatedRect)); 1003 addVisualOverflow(LayoutRect(inflatedRect));
1004 } 1004 }
1005 1005
1006 bool LayoutBlock::createsNewFormattingContext() const 1006 bool LayoutBlock::createsNewFormattingContext() const
1007 { 1007 {
1008 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() 1008 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated()
1009 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() 1009 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot()
1010 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint(); 1010 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint() || style()->containsLayout();
1011 } 1011 }
1012 1012
1013 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child) 1013 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child)
1014 { 1014 {
1015 if (child.isOutOfFlowPositioned()) { 1015 if (child.isOutOfFlowPositioned()) {
1016 // It's rather useless to mark out-of-flow children at this point. We ma y not be their 1016 // It's rather useless to mark out-of-flow children at this point. We ma y not be their
1017 // containing block (and if we are, it's just pure luck), so this would be the wrong place 1017 // containing block (and if we are, it's just pure luck), so this would be the wrong place
1018 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column 1018 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column
1019 // spanners, if the containing block is outside the spanner but inside t he multicol container. 1019 // spanners, if the containing block is outside the spanner but inside t he multicol container.
1020 return; 1020 return;
(...skipping 929 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 1950
1951 int LayoutBlock::columnGap() const 1951 int LayoutBlock::columnGap() const
1952 { 1952 {
1953 if (style()->hasNormalColumnGap()) 1953 if (style()->hasNormalColumnGap())
1954 return style()->fontDescription().computedPixelSize(); // "1em" is recom mended as the normal gap setting. Matches <p> margins. 1954 return style()->fontDescription().computedPixelSize(); // "1em" is recom mended as the normal gap setting. Matches <p> margins.
1955 return static_cast<int>(style()->columnGap()); 1955 return static_cast<int>(style()->columnGap());
1956 } 1956 }
1957 1957
1958 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const 1958 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const
1959 { 1959 {
1960 // Layout-contained elements don't consider their contents for preferred siz ing.
1961 if (style()->containsLayout())
1962 return;
1963
1960 if (childrenInline()) { 1964 if (childrenInline()) {
1961 // FIXME: Remove this const_cast. 1965 // FIXME: Remove this const_cast.
1962 toLayoutBlockFlow(const_cast<LayoutBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); 1966 toLayoutBlockFlow(const_cast<LayoutBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth);
1963 } else { 1967 } else {
1964 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); 1968 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
1965 } 1969 }
1966 1970
1967 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 1971 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
1968 1972
1969 if (isHTMLMarqueeElement(node()) && toHTMLMarqueeElement(node())->isHorizont al()) 1973 if (isHTMLMarqueeElement(node()) && toHTMLMarqueeElement(node())->isHorizont al())
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
2230 return -1; 2234 return -1;
2231 } 2235 }
2232 2236
2233 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const 2237 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const
2234 { 2238 {
2235 // CSS2.1 states that the baseline of an 'inline-block' is: 2239 // CSS2.1 states that the baseline of an 'inline-block' is:
2236 // the baseline of the last line box in the normal flow, unless it has 2240 // the baseline of the last line box in the normal flow, unless it has
2237 // either no in-flow line boxes or if its 'overflow' property has a computed 2241 // either no in-flow line boxes or if its 'overflow' property has a computed
2238 // value other than 'visible', in which case the baseline is the bottom 2242 // value other than 'visible', in which case the baseline is the bottom
2239 // margin edge. 2243 // margin edge.
2244 // We likewise avoid using the last line box in the case of layout containme nt,
2245 // where the block's contents shouldn't be considered when laying out its
2246 // ancestors or siblings.
2240 2247
2241 if (!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInlineB lockBaseline()) { 2248 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsLayout()) {
ojan 2015/12/18 18:21:14 I think this is the right behavior, although I'm n
leviw_travelin_and_unemployed 2016/01/12 19:36:31 I did add some info to the above comment to try an
2242 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. 2249 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us.
2243 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft(); 2250 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft();
2244 } 2251 }
2245 2252
2246 if (isWritingModeRoot() && !isRubyRun()) 2253 if (isWritingModeRoot() && !isRubyRun())
2247 return -1; 2254 return -1;
2248 2255
2249 if (childrenInline()) { 2256 if (childrenInline()) {
2250 if (!firstLineBox() && hasLineIfEmpty()) { 2257 if (!firstLineBox() && hasLineIfEmpty()) {
2251 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 2258 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics();
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2892 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2899 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2893 { 2900 {
2894 showLayoutObject(); 2901 showLayoutObject();
2895 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2902 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2896 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2903 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2897 } 2904 }
2898 2905
2899 #endif 2906 #endif
2900 2907
2901 } // namespace blink 2908 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698