| OLD | NEW |
| 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 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1854 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, conta
inerWidth); | 1854 LayoutUnit marginStartWidth = minimumValueForLength(marginStartLength, conta
inerWidth); |
| 1855 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, container
Width); | 1855 LayoutUnit marginEndWidth = minimumValueForLength(marginEndLength, container
Width); |
| 1856 | 1856 |
| 1857 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' | 1857 // CSS 2.1 (10.3.3): "If 'width' is not 'auto' and 'border-left-width' + 'pa
dding-left' + 'width' + 'padding-right' + 'border-right-width' |
| 1858 // (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' | 1858 // (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' |
| 1859 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. | 1859 // values for 'margin-left' or 'margin-right' are, for the following rules,
treated as zero. |
| 1860 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); | 1860 LayoutUnit marginBoxWidth = childWidth + (!style()->width().isAuto() ? margi
nStartWidth + marginEndWidth : LayoutUnit()); |
| 1861 | 1861 |
| 1862 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used
values are equal. This horizontally centers the element | 1862 // CSS 2.1: "If both 'margin-left' and 'margin-right' are 'auto', their used
values are equal. This horizontally centers the element |
| 1863 // with respect to the edges of the containing block." | 1863 // with respect to the edges of the containing block." |
| 1864 const RenderStyle* containingBlockStyle = containingBlock->style(); | |
| 1865 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt
h < containerWidth) | 1864 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt
h < containerWidth) |
| 1866 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi
ngBlockStyle->textAlign() == WEBKIT_CENTER)) { | 1865 || (!marginStartLength.isAuto() && !marginEndLength.isAuto())) { |
| 1867 // Other browsers center the margin box for align=center elements so we
match them here. | 1866 // Other browsers center the margin box for align=center elements so we
match them here. |
| 1868 LayoutUnit centeredMarginBoxStart = std::max<LayoutUnit>(0, (containerWi
dth - childWidth - marginStartWidth - marginEndWidth) / 2); | 1867 LayoutUnit centeredMarginBoxStart = std::max<LayoutUnit>(0, (containerWi
dth - childWidth - marginStartWidth - marginEndWidth) / 2); |
| 1869 marginStart = centeredMarginBoxStart + marginStartWidth; | 1868 marginStart = centeredMarginBoxStart + marginStartWidth; |
| 1870 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; | 1869 marginEnd = containerWidth - childWidth - marginStart + marginEndWidth; |
| 1871 return; | 1870 return; |
| 1872 } | 1871 } |
| 1873 | 1872 |
| 1874 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val
ue follows from the equality." | 1873 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val
ue follows from the equality." |
| 1875 if (marginEndLength.isAuto() && marginBoxWidth < containerWidth) { | 1874 if (marginEndLength.isAuto() && marginBoxWidth < containerWidth) { |
| 1876 marginStart = marginStartWidth; | 1875 marginStart = marginStartWidth; |
| 1877 marginEnd = containerWidth - childWidth - marginStart; | 1876 marginEnd = containerWidth - childWidth - marginStart; |
| 1878 return; | 1877 return; |
| 1879 } | 1878 } |
| 1880 | 1879 |
| 1881 bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBloc
kStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_
LEFT) | 1880 if (marginStartLength.isAuto() && marginBoxWidth < containerWidth) { |
| 1882 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty
le->textAlign() == WEBKIT_RIGHT)); | |
| 1883 if ((marginStartLength.isAuto() && marginBoxWidth < containerWidth) || pushT
oEndFromTextAlign) { | |
| 1884 marginEnd = marginEndWidth; | 1881 marginEnd = marginEndWidth; |
| 1885 marginStart = containerWidth - childWidth - marginEnd; | 1882 marginStart = containerWidth - childWidth - marginEnd; |
| 1886 return; | 1883 return; |
| 1887 } | 1884 } |
| 1888 | 1885 |
| 1889 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. | 1886 // Either no auto margins, or our margin box width is >= the container width
, auto margins will just turn into 0. |
| 1890 marginStart = marginStartWidth; | 1887 marginStart = marginStartWidth; |
| 1891 marginEnd = marginEndWidth; | 1888 marginEnd = marginEndWidth; |
| 1892 } | 1889 } |
| 1893 | 1890 |
| (...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3848 | 3845 |
| 3849 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) | 3846 RenderBox::BoxDecorationData::BoxDecorationData(const RenderStyle& style) |
| 3850 { | 3847 { |
| 3851 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); | 3848 backgroundColor = style.colorIncludingFallback(CSSPropertyBackgroundColor); |
| 3852 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); | 3849 hasBackground = backgroundColor.alpha() || style.hasBackgroundImage(); |
| 3853 ASSERT(hasBackground == style.hasBackground()); | 3850 ASSERT(hasBackground == style.hasBackground()); |
| 3854 hasBorder = style.hasBorder(); | 3851 hasBorder = style.hasBorder(); |
| 3855 } | 3852 } |
| 3856 | 3853 |
| 3857 } // namespace blink | 3854 } // namespace blink |
| OLD | NEW |