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

Unified Diff: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp

Issue 2913093002: Revert of [css-align] Don't resolve 'auto' values for computed style. (Closed)
Patch Set: Created 3 years, 7 months 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: third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
index a6a68a4cf8e6ecfe467a4c78549682454c30d1fc..5ebd8582c05c20f4b8786e7ddb2d5071c36b63a3 100644
--- a/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp
@@ -159,6 +159,38 @@
style.SetPosition(EPosition::kStatic);
}
+void StyleAdjuster::AdjustStyleForAlignment(
+ ComputedStyle& style,
+ const ComputedStyle& layout_parent_style) {
+ // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto'
+ // flag to not just mean 'auto' prior to running the StyleAdjuster but also
+ // mean 'normal' after running it.
+
+ // If the inherited value of justify-items includes the 'legacy' keyword,
+ // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to
+ // 'normal'.
+ if (style.JustifyItemsPosition() == kItemPositionAuto) {
+ if (layout_parent_style.JustifyItemsPositionType() == kLegacyPosition)
+ style.SetJustifyItems(layout_parent_style.JustifyItems());
+ }
+
+ // The 'auto' keyword computes the computed value of justify-items on the
+ // parent (minus any legacy keywords), or 'normal' if the box has no parent.
+ if (style.JustifySelfPosition() == kItemPositionAuto) {
+ if (layout_parent_style.JustifyItemsPositionType() == kLegacyPosition)
+ style.SetJustifySelfPosition(layout_parent_style.JustifyItemsPosition());
+ else if (layout_parent_style.JustifyItemsPosition() != kItemPositionAuto)
+ style.SetJustifySelf(layout_parent_style.JustifyItems());
+ }
+
+ // The 'auto' keyword computes the computed value of align-items on the parent
+ // or 'normal' if the box has no parent.
+ if (style.AlignSelfPosition() == kItemPositionAuto &&
+ layout_parent_style.AlignItemsPosition() !=
+ ComputedStyle::InitialDefaultAlignment().GetPosition())
+ style.SetAlignSelf(layout_parent_style.AlignItems());
+}
+
static void AdjustStyleForHTMLElement(ComputedStyle& style,
HTMLElement& element) {
// <div> and <span> are the most common elements on the web, we skip all the
@@ -479,6 +511,7 @@
if (isSVGTextElement(*element))
style.ClearMultiCol();
}
+ AdjustStyleForAlignment(style, layout_parent_style);
// If this node is sticky it marks the creation of a sticky subtree, which we
// must track to properly handle document lifecycle in some cases.
@@ -488,14 +521,6 @@
// inheritance from the ancestor and there is no harm to setting it again.
if (style.GetPosition() == EPosition::kSticky)
style.SetSubtreeIsSticky(true);
-
- // If the inherited value of justify-items includes the 'legacy' keyword,
- // 'auto' computes to the the inherited value. Otherwise, 'auto' computes to
- // 'normal'.
- if (style.JustifyItemsPosition() == kItemPositionAuto) {
- if (parent_style.JustifyItemsPositionType() == kLegacyPosition)
- style.SetJustifyItems(parent_style.JustifyItems());
- }
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698