Chromium Code Reviews| 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 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2137 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt h < availableWidth) | 2137 if ((marginStartLength.isAuto() && marginEndLength.isAuto() && marginBoxWidt h < availableWidth) |
| 2138 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlockStyle->textAlign() == WEBKIT_CENTER)) { | 2138 || (!marginStartLength.isAuto() && !marginEndLength.isAuto() && containi ngBlockStyle->textAlign() == WEBKIT_CENTER)) { |
| 2139 // Other browsers center the margin box for align=center elements so we match them here. | 2139 // Other browsers center the margin box for align=center elements so we match them here. |
| 2140 LayoutUnit centeredMarginBoxStart = std::max(LayoutUnit(), (availableWid th - childWidth - marginStartWidth - marginEndWidth) / 2); | 2140 LayoutUnit centeredMarginBoxStart = std::max(LayoutUnit(), (availableWid th - childWidth - marginStartWidth - marginEndWidth) / 2); |
| 2141 marginStart = centeredMarginBoxStart + marginStartWidth; | 2141 marginStart = centeredMarginBoxStart + marginStartWidth; |
| 2142 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; | 2142 marginEnd = availableWidth - childWidth - marginStart + marginEndWidth; |
| 2143 return; | 2143 return; |
| 2144 } | 2144 } |
| 2145 | 2145 |
| 2146 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality." | 2146 // CSS 2.1: "If there is exactly one value specified as 'auto', its used val ue follows from the equality." |
| 2147 if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) { | 2147 if (marginBoxWidth < availableWidth) { |
|
mstensho (USE GERRIT)
2014/12/10 10:45:05
Should move this check to include center alignment
Kyungtae Kim
2014/12/10 11:50:38
Done.
| |
| 2148 marginStart = marginStartWidth; | 2148 bool adjustFromTextAlign = !marginEndLength.isAuto() && ((!containingBlo ckStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT _LEFT) |
| 2149 marginEnd = availableWidth - childWidth - marginStart; | 2149 || (containingBlockStyle->isLeftToRightDirection() && containingBloc kStyle->textAlign() == WEBKIT_RIGHT)); |
| 2150 return; | 2150 bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection () != style()->isLeftToRightDirection(); |
| 2151 } | |
| 2152 | 2151 |
| 2153 bool adjustFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockSt yle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEF T) | 2152 if (marginEndLength.isAuto() || (adjustFromTextAlign && hasInvertedDirec tion && !marginStartLength.isAuto())) { |
|
mstensho (USE GERRIT)
2014/12/10 10:45:05
Now is a good time to get rid of adjustFromTextAli
Kyungtae Kim
2014/12/10 11:50:38
I think it could be confusing.
Because auto margin
mstensho (USE GERRIT)
2014/12/10 23:27:00
The code for WEBKIT_CENTER needs to remain special
| |
| 2154 || (containingBlockStyle->isLeftToRightDirection() && containingBlockSty le->textAlign() == WEBKIT_RIGHT)); | 2153 marginStart = marginStartWidth; |
| 2155 bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection() ! = style()->isLeftToRightDirection(); | 2154 marginEnd = availableWidth - childWidth - marginStart; |
| 2155 return; | |
| 2156 } | |
| 2156 | 2157 |
| 2157 if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || (adju stFromTextAlign && !hasInvertedDirection)) { | 2158 if (marginStartLength.isAuto() || adjustFromTextAlign) { |
| 2158 marginEnd = marginEndWidth; | 2159 marginEnd = marginEndWidth; |
| 2159 marginStart = availableWidth - childWidth - marginEnd; | 2160 marginStart = availableWidth - childWidth - marginEnd; |
| 2160 return; | 2161 return; |
| 2161 } | 2162 } |
| 2162 | |
| 2163 if (adjustFromTextAlign && hasInvertedDirection) { | |
| 2164 marginStart = marginStartWidth; | |
| 2165 marginEnd = availableWidth - childWidth - marginStart; | |
| 2166 return; | |
| 2167 } | 2163 } |
| 2168 | 2164 |
| 2169 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0. | 2165 // Either no auto margins, or our margin box width is >= the container width , auto margins will just turn into 0. |
| 2170 marginStart = marginStartWidth; | 2166 marginStart = marginStartWidth; |
| 2171 marginEnd = marginEndWidth; | 2167 marginEnd = marginEndWidth; |
| 2172 } | 2168 } |
| 2173 | 2169 |
| 2174 void RenderBox::updateLogicalHeight() | 2170 void RenderBox::updateLogicalHeight() |
| 2175 { | 2171 { |
| 2176 m_intrinsicContentLogicalHeight = contentLogicalHeight(); | 2172 m_intrinsicContentLogicalHeight = contentLogicalHeight(); |
| (...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4492 computedValues.m_margins.m_end = marginEnd(); | 4488 computedValues.m_margins.m_end = marginEnd(); |
| 4493 | 4489 |
| 4494 setLogicalTop(oldLogicalTop); | 4490 setLogicalTop(oldLogicalTop); |
| 4495 setLogicalWidth(oldLogicalWidth); | 4491 setLogicalWidth(oldLogicalWidth); |
| 4496 setLogicalLeft(oldLogicalLeft); | 4492 setLogicalLeft(oldLogicalLeft); |
| 4497 setMarginLeft(oldMarginLeft); | 4493 setMarginLeft(oldMarginLeft); |
| 4498 setMarginRight(oldMarginRight); | 4494 setMarginRight(oldMarginRight); |
| 4499 } | 4495 } |
| 4500 | 4496 |
| 4501 } // namespace blink | 4497 } // namespace blink |
| OLD | NEW |