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

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: consider auto margins & add test cases for them 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 d08b3e586e7a1029c8b6f54e29794111935075af..c7b81bda82fd98fd1d4e20790a27ebbe9764fa49 100644
--- a/Source/core/rendering/RenderBox.cpp
+++ b/Source/core/rendering/RenderBox.cpp
@@ -2100,15 +2100,19 @@ void RenderBox::computeMarginsForDirection(MarginDirection flowDirection, const
return;
}
+
+
mstensho (USE GERRIT) 2014/12/09 09:54:41 Couple of extraneous blank lines.
Kyungtae Kim 2014/12/09 11:36:32 Done.
+ bool hasInvertedDirection = containingBlockStyle->isLeftToRightDirection() != style()->isLeftToRightDirection();
+ bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
+ || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
+
// CSS 2.1: "If there is exactly one value specified as 'auto', its used value follows from the equality."
- if (marginEndLength.isAuto() && marginBoxWidth < availableWidth) {
+ if ((marginEndLength.isAuto() && marginBoxWidth < availableWidth) || (pushToEndFromTextAlign && hasInvertedDirection)) {
marginStart = marginStartWidth;
marginEnd = availableWidth - childWidth - marginStart;
return;
}
- bool pushToEndFromTextAlign = !marginEndLength.isAuto() && ((!containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_LEFT)
- || (containingBlockStyle->isLeftToRightDirection() && containingBlockStyle->textAlign() == WEBKIT_RIGHT));
if ((marginStartLength.isAuto() && marginBoxWidth < availableWidth) || pushToEndFromTextAlign) {
marginEnd = marginEndWidth;
marginStart = availableWidth - childWidth - marginEnd;

Powered by Google App Engine
This is Rietveld 408576698