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

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

Issue 766223004: Blocks should be aligned by style of parents (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
« no previous file with comments | « LayoutTests/fast/dom/margin-left-margin-right-auto-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderBox.cpp
diff --git a/Source/core/rendering/RenderBox.cpp b/Source/core/rendering/RenderBox.cpp
index d08b3e586e7a1029c8b6f54e29794111935075af..5cc2f0f8d93141e1654c227eb53538e58786c97b 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2107,14 +2107,22 @@ void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const
return;
}
- bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
+ bool adjustFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
|| (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
- if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushToEndFromTextAlign) {
+ bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection() != style()->isLeftToRightDirection();
+
+ if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || (adjustFromTextAlign && !hasInvertedDirection)) {
marginEnd = marginEndWidth;
marginStart = availableWidth - childWidth - marginEnd;
return;
}
+ if (adjustFromTextAlign && hasInvertedDirection) {
+ marginStart = marginStartWidth;
+ marginEnd = availableWidth - childWidth - marginStart;
+ return;
+ }
+
// Either no auto margins, or our margin box width is >= the container width, auto margins will just turn into 0.
marginStart = marginStartWidth;
marginEnd = marginEndWidth;
« no previous file with comments | « LayoutTests/fast/dom/margin-left-margin-right-auto-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698