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

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: Switch to Ahem. Created 4 years, 9 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 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 1027
1028 IntRect inflatedRect = pixelSnappedBorderBoxRect(); 1028 IntRect inflatedRect = pixelSnappedBorderBoxRect();
1029 LayoutTheme::theme().addVisualOverflow(*this, inflatedRect); 1029 LayoutTheme::theme().addVisualOverflow(*this, inflatedRect);
1030 addVisualOverflow(LayoutRect(inflatedRect)); 1030 addVisualOverflow(LayoutRect(inflatedRect));
1031 } 1031 }
1032 1032
1033 bool LayoutBlock::createsNewFormattingContext() const 1033 bool LayoutBlock::createsNewFormattingContext() const
1034 { 1034 {
1035 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated() 1035 return isInlineBlockOrInlineTable() || isFloatingOrOutOfFlowPositioned() || hasOverflowClip() || isFlexItemIncludingDeprecated()
1036 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot() 1036 || style()->specifiesColumns() || isLayoutFlowThread() || isTableCell() || isTableCaption() || isFieldset() || isWritingModeRoot()
1037 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint(); 1037 || isDocumentElement() || isColumnSpanAll() || isGridItem() || style()-> containsPaint() || style()->containsLayout();
1038 } 1038 }
1039 1039
1040 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child) 1040 void LayoutBlock::updateBlockChildDirtyBitsBeforeLayout(bool relayoutChildren, L ayoutBox& child)
1041 { 1041 {
1042 if (child.isOutOfFlowPositioned()) { 1042 if (child.isOutOfFlowPositioned()) {
1043 // It's rather useless to mark out-of-flow children at this point. We ma y not be their 1043 // It's rather useless to mark out-of-flow children at this point. We ma y not be their
1044 // containing block (and if we are, it's just pure luck), so this would be the wrong place 1044 // containing block (and if we are, it's just pure luck), so this would be the wrong place
1045 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column 1045 // for it. Furthermore, it would cause trouble for out-of-flow descendan ts of column
1046 // spanners, if the containing block is outside the spanner but inside t he multicol container. 1046 // spanners, if the containing block is outside the spanner but inside t he multicol container.
1047 return; 1047 return;
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 1941
1942 int LayoutBlock::columnGap() const 1942 int LayoutBlock::columnGap() const
1943 { 1943 {
1944 if (style()->hasNormalColumnGap()) 1944 if (style()->hasNormalColumnGap())
1945 return style()->fontDescription().computedPixelSize(); // "1em" is recom mended as the normal gap setting. Matches <p> margins. 1945 return style()->fontDescription().computedPixelSize(); // "1em" is recom mended as the normal gap setting. Matches <p> margins.
1946 return static_cast<int>(style()->columnGap()); 1946 return static_cast<int>(style()->columnGap());
1947 } 1947 }
1948 1948
1949 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const 1949 void LayoutBlock::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, Lay outUnit& maxLogicalWidth) const
1950 { 1950 {
1951 // Layout-contained elements don't consider their contents for preferred siz ing.
1952 if (style()->containsLayout())
1953 return;
1954
1951 if (childrenInline()) { 1955 if (childrenInline()) {
1952 // FIXME: Remove this const_cast. 1956 // FIXME: Remove this const_cast.
1953 toLayoutBlockFlow(const_cast<LayoutBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth); 1957 toLayoutBlockFlow(const_cast<LayoutBlock*>(this))->computeInlinePreferre dLogicalWidths(minLogicalWidth, maxLogicalWidth);
1954 } else { 1958 } else {
1955 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth); 1959 computeBlockPreferredLogicalWidths(minLogicalWidth, maxLogicalWidth);
1956 } 1960 }
1957 1961
1958 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth); 1962 maxLogicalWidth = std::max(minLogicalWidth, maxLogicalWidth);
1959 1963
1960 if (isHTMLMarqueeElement(node()) && toHTMLMarqueeElement(node())->isHorizont al()) 1964 if (isHTMLMarqueeElement(node()) && toHTMLMarqueeElement(node())->isHorizont al())
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 return -1; 2232 return -1;
2229 } 2233 }
2230 2234
2231 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const 2235 int LayoutBlock::inlineBlockBaseline(LineDirectionMode lineDirection) const
2232 { 2236 {
2233 // CSS2.1 states that the baseline of an 'inline-block' is: 2237 // CSS2.1 states that the baseline of an 'inline-block' is:
2234 // the baseline of the last line box in the normal flow, unless it has 2238 // the baseline of the last line box in the normal flow, unless it has
2235 // either no in-flow line boxes or if its 'overflow' property has a computed 2239 // either no in-flow line boxes or if its 'overflow' property has a computed
2236 // value other than 'visible', in which case the baseline is the bottom 2240 // value other than 'visible', in which case the baseline is the bottom
2237 // margin edge. 2241 // margin edge.
2242 // We likewise avoid using the last line box in the case of layout containme nt,
2243 // where the block's contents shouldn't be considered when laying out its
2244 // ancestors or siblings.
2238 2245
2239 if (!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInlineB lockBaseline()) { 2246 if ((!style()->isOverflowVisible() && !shouldIgnoreOverflowPropertyForInline BlockBaseline()) || style()->containsLayout()) {
2240 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us. 2247 // We are not calling LayoutBox::baselinePosition here because the calle r should add the margin-top/margin-right, not us.
2241 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft(); 2248 return lineDirection == HorizontalLine ? size().height() + marginBottom( ) : size().width() + marginLeft();
2242 } 2249 }
2243 2250
2244 if (isWritingModeRoot() && !isRubyRun()) 2251 if (isWritingModeRoot() && !isRubyRun())
2245 return -1; 2252 return -1;
2246 2253
2247 if (childrenInline()) { 2254 if (childrenInline()) {
2248 if (!firstLineBox() && hasLineIfEmpty()) { 2255 if (!firstLineBox() && hasLineIfEmpty()) {
2249 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics(); 2256 const FontMetrics& fontMetrics = firstLineStyle()->fontMetrics();
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const 2897 void LayoutBlock::showLineTreeAndMark(const InlineBox* markedBox1, const char* m arkedLabel1, const InlineBox* markedBox2, const char* markedLabel2, const Layout Object* obj) const
2891 { 2898 {
2892 showLayoutObject(); 2899 showLayoutObject();
2893 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box()) 2900 for (const RootInlineBox* root = firstRootBox(); root; root = root->nextRoot Box())
2894 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1); 2901 root->showLineTreeAndMark(markedBox1, markedLabel1, markedBox2, markedLa bel2, obj, 1);
2895 } 2902 }
2896 2903
2897 #endif 2904 #endif
2898 2905
2899 } // namespace blink 2906 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698