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

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

Issue 1709963002: [css-align] New CSS Value 'normal' for Self Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Getting back the FullScreen fix, missed during the rebase. Created 4 years, 4 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 3 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 4 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 5 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 6 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 7 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 9 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
10 * Copyright (C) Research In Motion Limited 2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2011. All rights reserved.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 if (style.styleType() != PseudoIdFirstLetter) 137 if (style.styleType() != PseudoIdFirstLetter)
138 return; 138 return;
139 139
140 // Force inline display (except for floating first-letters). 140 // Force inline display (except for floating first-letters).
141 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 141 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
142 142
143 // CSS2 says first-letter can't be positioned. 143 // CSS2 says first-letter can't be positioned.
144 style.setPosition(StaticPosition); 144 style.setPosition(StaticPosition);
145 } 145 }
146 146
147 static void adjustStyleForAlignment(ComputedStyle& style, const ComputedStyle& p arentStyle) 147 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
148 { 148 {
149 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 149 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto ' flag
150 bool absolutePositioned = style.position() == AbsolutePosition; 150 // to not just mean 'auto' prior to running the StyleAdjuster but also mean 'normal'
151 // after running it.
151 152
152 // If the inherited value of justify-items includes the legacy keyword, 'aut o' 153 // If the inherited value of justify-items includes the 'legacy' keyword, 'a uto'
153 // computes to the the inherited value. 154 // computes to the the inherited value.
154 // Otherwise, auto computes to: 155 // Otherwise, 'auto' computes to 'normal'.
155 // - 'stretch' for flex containers and grid containers.
156 // - 'start' for everything else.
157 if (style.justifyItemsPosition() == ItemPositionAuto) { 156 if (style.justifyItemsPosition() == ItemPositionAuto) {
158 if (parentStyle.justifyItemsPositionType() == LegacyPosition) 157 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
159 style.setJustifyItems(parentStyle.justifyItems()); 158 style.setJustifyItems(parentStyle.justifyItems());
160 else if (isFlexOrGrid)
161 style.setJustifyItemsPosition(ItemPositionStretch);
162 } 159 }
163 160
164 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 161 // The 'auto' keyword computes the computed value of justify-items on the pa rent (minus
165 // and to the computed value of justify-items on the parent (minus 162 // any legacy keywords), or 'normal' if the box has no parent.
166 // any legacy keywords) on all other boxes.
167 if (style.justifySelfPosition() == ItemPositionAuto) { 163 if (style.justifySelfPosition() == ItemPositionAuto) {
168 if (absolutePositioned) 164 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
169 style.setJustifySelfPosition(ItemPositionStretch); 165 style.setJustifySelfPosition(parentStyle.justifyItemsPosition());
170 else 166 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto)
171 style.setJustifySelf(parentStyle.justifyItems()); 167 style.setJustifySelf(parentStyle.justifyItems());
172 } 168 }
173 169
174 // The 'auto' keyword computes to: 170 // The 'auto' keyword computes the computed value of align-items on the pare nt
175 // - 'stretch' for flex containers and grid containers, 171 // or 'normal' if the box has no parent.
176 // - 'start' for everything else. 172 if (style.alignSelfPosition() == ItemPositionAuto && parentStyle.alignItemsP osition() != ItemPositionNormal)
177 if (style.alignItemsPosition() == ItemPositionAuto) { 173 style.setAlignSelf(parentStyle.alignItems());
178 if (isFlexOrGrid)
179 style.setAlignItemsPosition(ItemPositionStretch);
180 }
181 } 174 }
182 175
183 static void adjustStyleForHTMLElement(ComputedStyle& style, const ComputedStyle& parentStyle, HTMLElement& element) 176 static void adjustStyleForHTMLElement(ComputedStyle& style, const ComputedStyle& parentStyle, HTMLElement& element)
184 { 177 {
185 // <div> and <span> are the most common elements on the web, we skip all the work for them. 178 // <div> and <span> are the most common elements on the web, we skip all the work for them.
186 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 179 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
187 return; 180 return;
188 181
189 if (isHTMLTableCellElement(element)) { 182 if (isHTMLTableCellElement(element)) {
190 if (style.whiteSpace() == KHTML_NOWRAP) { 183 if (style.whiteSpace() == KHTML_NOWRAP) {
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 style.setDisplay(BLOCK); 404 style.setDisplay(BLOCK);
412 405
413 // Columns don't apply to svg text elements. 406 // Columns don't apply to svg text elements.
414 if (isSVGTextElement(*element)) 407 if (isSVGTextElement(*element))
415 style.clearMultiCol(); 408 style.clearMultiCol();
416 } 409 }
417 adjustStyleForAlignment(style, parentStyle); 410 adjustStyleForAlignment(style, parentStyle);
418 } 411 }
419 412
420 } // namespace blink 413 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698