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

Unified Diff: Source/core/rendering/RenderBox.cpp

Issue 790943004: An align attribute should not be applied for wider children (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.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 side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index 7c0317be2904508c2c8bb47f8f9942dddf60f2b2..6f6266bfd33367ee13b25bcf49b23b4ee8769f61 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2144,26 +2144,22 @@ void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const
}
// CSS 2.1: "If there is exactly one value specified as 'auto', its used value follows from the equality."
- if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) {
- marginStart = marginStartWidth;
- marginEnd = availableWidth - childWidth - marginStart;
- return;
- }
-
- bool adjustFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
- || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
- bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection() != style()->isLeftToRightDirection();
-
- if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || (adjustFromTextAlign && !hasInvertedDirection)) {
- marginEnd = marginEndWidth;
- marginStart = availableWidth - childWidth - marginEnd;
- return;
- }
+ 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.
+ bool adjustFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
+ || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
+ bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection() != style()->isLeftToRightDirection();
+
+ if (marginEndLength.isAuto() || (adjustFromTextAlign && hasInvertedDirection && !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
+ marginStart = marginStartWidth;
+ marginEnd = availableWidth - childWidth - marginStart;
+ return;
+ }
- if (adjustFromTextAlign && hasInvertedDirection) {
- marginStart = marginStartWidth;
- marginEnd = availableWidth - childWidth - marginStart;
- return;
+ if (marginStartLength.isAuto() || adjustFromTextAlign) {
+ marginEnd = marginEndWidth;
+ marginStart = availableWidth - childWidth - marginEnd;
+ return;
+ }
}
// Either no auto margins, or our margin box width is >= the container width, auto margins will just turn into 0.

Powered by Google App Engine
This is Rietveld 408576698