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

Side by Side Diff: sky/engine/core/rendering/RenderBox.cpp

Issue 760143002: Make fixed-width elements not center by default. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 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
« no previous file with comments | « no previous file | sky/tests/layout/ellipsis-expected.txt » ('j') | 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 * 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 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, conta inerWidth); 1641 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, conta inerWidth);
1642 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, container Width); 1642 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, container Width);
1643 1643
1644 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa dding-left' + 'width' + 'padding-right' + 'border-right-width' 1644 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa dding-left' + 'width' + 'padding-right' + 'border-right-width'
1645 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg er than the width of the containing block, then any 'auto' 1645 // (plus any of 'margin-left' or 'margin-right' that are not 'auto') is larg er than the width of the containing block, then any 'auto'
1646 // values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero. 1646 // values for 'margin-left' or 'margin-right' are, for the following rules, treated as zero.
1647 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi nStartWidth + marginEndWidth : LayoutUnit()); 1647 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi nStartWidth + marginEndWidth : LayoutUnit());
1648 1648
1649 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element 1649 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used values are equal. This horizontally centers the element
1650 // with respect to the edges of the containing block." 1650 // with respect to the edges of the containing block."
1651 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt h < containerWidth) 1651 if (marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidth < containerWidth) {
1652 || (!marginStartLength.isAuto() && !marginEndLength.isAuto())) {
1653 // Other browsers center the margin box for align=center elements so we match them here. 1652 // Other browsers center the margin box for align=center elements so we match them here.
1654 LayoutUnit centeredMarginBoxStart = std::max<LayoutUnit>(0, (containerWi dth - childWidth - marginStartWidth - marginEndWidth) / 2); 1653 LayoutUnit centeredMarginBoxStart = std::max<LayoutUnit>(0, (containerWi dth - childWidth - marginStartWidth - marginEndWidth) / 2);
1655 marginStart = centeredMarginBoxStart + marginStartWidth; 1654 marginStart = centeredMarginBoxStart + marginStartWidth;
1656 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; 1655 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth;
1657 return; 1656 return;
1658 } 1657 }
1659 1658
1660 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality." 1659 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality."
1661 if (marginEndLength.isAuto() && marginBoxWidth < containerWidth) { 1660 if (marginEndLength.isAuto() && marginBoxWidth < containerWidth) {
1662 marginStart = marginStartWidth; 1661 marginStart = marginStartWidth;
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3511 3510
3512 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) 3511 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style)
3513 { 3512 {
3514 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); 3513 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor);
3515 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); 3514 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage();
3516 ASSERT(hasBackground == style.hasBackground()); 3515 ASSERT(hasBackground == style.hasBackground());
3517 hasBorder = style.hasBorder(); 3516 hasBorder = style.hasBorder();
3518 } 3517 }
3519 3518
3520 } // namespace blink 3519 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | sky/tests/layout/ellipsis-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698