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

Side by Side Diff: Source/WebCore/rendering/RenderBox.cpp

Issue 10668050: Merge 120934 - Non-fixed length margins don't work with align=center (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/1180/
Patch Set: Created 8 years, 5 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
« no previous file with comments | « LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 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 1815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1826 // Inline blocks/tables and floats don't have their margins increased. 1826 // Inline blocks/tables and floats don't have their margins increased.
1827 containingBlock->setMarginStartForChild(this, minimumValueForLength(marg inStartLength, containerWidth, renderView)); 1827 containingBlock->setMarginStartForChild(this, minimumValueForLength(marg inStartLength, containerWidth, renderView));
1828 containingBlock->setMarginEndForChild(this, minimumValueForLength(margin EndLength, containerWidth, renderView)); 1828 containingBlock->setMarginEndForChild(this, minimumValueForLength(margin EndLength, containerWidth, renderView));
1829 return; 1829 return;
1830 } 1830 }
1831 1831
1832 // Case One: The object is being centered in the containing block's availabl e logical width. 1832 // Case One: The object is being centered in the containing block's availabl e logical width.
1833 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth) 1833 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && childWidth < containerWidth)
1834 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlock->style()->textAlign() == WEBKIT_CENTER)) { 1834 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlock->style()->textAlign() == WEBKIT_CENTER)) {
1835 // Other browsers center the margin box for align=center elements so we match them here. 1835 // Other browsers center the margin box for align=center elements so we match them here.
1836 LayoutUnit marginStartWidth = marginStartLength.value(); 1836 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, c ontainerWidth, renderView);
1837 LayoutUnit marginEndWidth = marginEndLength.value(); 1837 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, conta inerWidth, renderView);
1838 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2); 1838 LayoutUnit centeredMarginBoxStart = max<LayoutUnit>(0, (containerWidth - childWidth - marginStartWidth - marginEndWidth) / 2);
1839 containingBlock->setMarginStartForChild(this, centeredMarginBoxStart + m arginStartWidth); 1839 containingBlock->setMarginStartForChild(this, centeredMarginBoxStart + m arginStartWidth);
1840 containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this) + marginEndWidth); 1840 containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this) + marginEndWidth);
1841 return; 1841 return;
1842 } 1842 }
1843 1843
1844 // Case Two: The object is being pushed to the start of the containing block 's available logical width. 1844 // Case Two: The object is being pushed to the start of the containing block 's available logical width.
1845 if (marginEndLength.isAuto() && childWidth < containerWidth) { 1845 if (marginEndLength.isAuto() && childWidth < containerWidth) {
1846 containingBlock->setMarginStartForChild(this, valueForLength(marginStart Length, containerWidth, renderView)); 1846 containingBlock->setMarginStartForChild(this, valueForLength(marginStart Length, containerWidth, renderView));
1847 containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this)); 1847 containingBlock->setMarginEndForChild(this, containerWidth - childWidth - containingBlock->marginStartForChild(this));
(...skipping 2136 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 } 3984 }
3985 3985
3986 if (didSplitParentAnonymousBoxes) 3986 if (didSplitParentAnonymousBoxes)
3987 markBoxForRelayoutAfterSplit(this); 3987 markBoxForRelayoutAfterSplit(this);
3988 3988
3989 ASSERT(beforeChild->parent() == this); 3989 ASSERT(beforeChild->parent() == this);
3990 return beforeChild; 3990 return beforeChild;
3991 } 3991 }
3992 3992
3993 } // namespace WebCore 3993 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/block/positive-margin-block-child-align-center-calc-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698