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

Side by Side Diff: third_party/WebKit/Source/core/layout/LayoutBox.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) 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 2046 matching lines...) Expand 10 before | Expand all | Expand 10 after
2057 itemMarker->layout(); 2057 itemMarker->layout();
2058 maxWidth = std::max<float>(maxWidth, toLayoutListMarker(itemMarker)- >logicalWidth().toFloat()); 2058 maxWidth = std::max<float>(maxWidth, toLayoutListMarker(itemMarker)- >logicalWidth().toFloat());
2059 break; 2059 break;
2060 } 2060 }
2061 } 2061 }
2062 return maxWidth; 2062 return maxWidth;
2063 } 2063 }
2064 2064
2065 void LayoutBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues) const 2065 void LayoutBox::computeLogicalWidth(LogicalExtentComputedValues& computedValues) const
2066 { 2066 {
2067 computedValues.m_extent = logicalWidth(); 2067 computedValues.m_extent = style()->containsLayout() ? borderAndPaddingLogica lWidth() : logicalWidth();
2068 computedValues.m_position = logicalLeft(); 2068 computedValues.m_position = logicalLeft();
2069 computedValues.m_margins.m_start = marginStart(); 2069 computedValues.m_margins.m_start = marginStart();
2070 computedValues.m_margins.m_end = marginEnd(); 2070 computedValues.m_margins.m_end = marginEnd();
2071 2071
2072 if (isOutOfFlowPositioned()) { 2072 if (isOutOfFlowPositioned()) {
2073 computePositionedLogicalWidth(computedValues); 2073 computePositionedLogicalWidth(computedValues);
2074 return; 2074 return;
2075 } 2075 }
2076 2076
2077 // The parent box is flexing us, so it has increased or decreased our 2077 // The parent box is flexing us, so it has increased or decreased our
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0. 2372 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0.
2373 marginStart = marginStartWidth; 2373 marginStart = marginStartWidth;
2374 marginEnd = marginEndWidth; 2374 marginEnd = marginEndWidth;
2375 } 2375 }
2376 2376
2377 void LayoutBox::updateLogicalHeight() 2377 void LayoutBox::updateLogicalHeight()
2378 { 2378 {
2379 m_intrinsicContentLogicalHeight = contentLogicalHeight(); 2379 m_intrinsicContentLogicalHeight = contentLogicalHeight();
2380 2380
2381 LogicalExtentComputedValues computedValues; 2381 LogicalExtentComputedValues computedValues;
2382 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues); 2382 if (style()->containsLayout())
ojan 2015/12/18 18:21:14 Nit: I might have written this as: LayoutUnit heig
2383 computeLogicalHeight(borderAndPaddingLogicalHeight(), logicalTop(), comp utedValues);
2384 else
2385 computeLogicalHeight(logicalHeight(), logicalTop(), computedValues);
2383 2386
2384 setLogicalHeight(computedValues.m_extent); 2387 setLogicalHeight(computedValues.m_extent);
2385 setLogicalTop(computedValues.m_position); 2388 setLogicalTop(computedValues.m_position);
2386 setMarginBefore(computedValues.m_margins.m_before); 2389 setMarginBefore(computedValues.m_margins.m_before);
2387 setMarginAfter(computedValues.m_margins.m_after); 2390 setMarginAfter(computedValues.m_margins.m_after);
2388 } 2391 }
2389 2392
2390 void LayoutBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica lTop, LogicalExtentComputedValues& computedValues) const 2393 void LayoutBox::computeLogicalHeight(LayoutUnit logicalHeight, LayoutUnit logica lTop, LogicalExtentComputedValues& computedValues) const
2391 { 2394 {
2392 computedValues.m_extent = logicalHeight; 2395 computedValues.m_extent = logicalHeight;
(...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after
4051 } 4054 }
4052 4055
4053 static bool shouldBeConsideredAsReplaced(Node* node) 4056 static bool shouldBeConsideredAsReplaced(Node* node)
4054 { 4057 {
4055 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have their own layoutObject in which to override avoidFloats(). 4058 // Checkboxes and radioboxes are not isAtomicInlineLevel() nor do they have their own layoutObject in which to override avoidFloats().
4056 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node))); 4059 return node && node->isElementNode() && (toElement(node)->isFormControlEleme nt() || isHTMLImageElement(toElement(node)));
4057 } 4060 }
4058 4061
4059 bool LayoutBox::avoidsFloats() const 4062 bool LayoutBox::avoidsFloats() const
4060 { 4063 {
4061 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint(); 4064 return isAtomicInlineLevel() || shouldBeConsideredAsReplaced(node()) || hasO verflowClip() || isHR() || isLegend() || isWritingModeRoot() || isFlexItemInclud ingDeprecated() || style()->containsPaint() || style()->containsLayout();
4062 } 4065 }
4063 4066
4064 bool LayoutBox::hasNonCompositedScrollbars() const 4067 bool LayoutBox::hasNonCompositedScrollbars() const
4065 { 4068 {
4066 if (PaintLayer* layer = this->layer()) { 4069 if (PaintLayer* layer = this->layer()) {
4067 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { 4070 if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
4068 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay erForHorizontalScrollbar()) 4071 if (scrollableArea->hasHorizontalScrollbar() && !scrollableArea->lay erForHorizontalScrollbar())
4069 return true; 4072 return true;
4070 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer ForVerticalScrollbar()) 4073 if (scrollableArea->hasVerticalScrollbar() && !scrollableArea->layer ForVerticalScrollbar())
4071 return true; 4074 return true;
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
4913 } 4916 }
4914 4917
4915 void LayoutBox::clearPreviousPaintInvalidationRects() 4918 void LayoutBox::clearPreviousPaintInvalidationRects()
4916 { 4919 {
4917 LayoutBoxModelObject::clearPreviousPaintInvalidationRects(); 4920 LayoutBoxModelObject::clearPreviousPaintInvalidationRects();
4918 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea()) 4921 if (PaintLayerScrollableArea* scrollableArea = this->scrollableArea())
4919 scrollableArea->clearPreviousPaintInvalidationRects(); 4922 scrollableArea->clearPreviousPaintInvalidationRects();
4920 } 4923 }
4921 4924
4922 } // namespace blink 4925 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698