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

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.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: New test for alignment and anonymous boxes. Created 4 years, 6 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 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 { 186 {
187 if ((!oldStyle && newStyle) || (oldStyle && !newStyle)) 187 if ((!oldStyle && newStyle) || (oldStyle && !newStyle))
188 return Reattach; 188 return Reattach;
189 189
190 if (!oldStyle && !newStyle) 190 if (!oldStyle && !newStyle)
191 return NoChange; 191 return NoChange;
192 192
193 if (oldStyle->display() != newStyle->display() 193 if (oldStyle->display() != newStyle->display()
194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter) 194 || oldStyle->hasPseudoStyle(PseudoIdFirstLetter) != newStyle->hasPseudoS tyle(PseudoIdFirstLetter)
195 || !oldStyle->contentDataEquivalent(newStyle) 195 || !oldStyle->contentDataEquivalent(newStyle)
196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine() 196 || oldStyle->hasTextCombine() != newStyle->hasTextCombine())
197 || oldStyle->justifyItems() != newStyle->justifyItems()) // TODO (lajava ): We must avoid this Reattach.
198 return Reattach; 197 return Reattach;
199 198
200 if (oldStyle->inheritedNotEqual(*newStyle)) 199 if (oldStyle->inheritedNotEqual(*newStyle)
200 || oldStyle->alignItems() != newStyle->alignItems()
201 || oldStyle->justifyItems() != newStyle->justifyItems())
201 return Inherit; 202 return Inherit;
202 203
203 if (*oldStyle == *newStyle) 204 if (*oldStyle == *newStyle)
204 return diffPseudoStyles(*oldStyle, *newStyle); 205 return diffPseudoStyles(*oldStyle, *newStyle);
205 206
206 if (oldStyle->hasExplicitlyInheritedProperties()) 207 if (oldStyle->hasExplicitlyInheritedProperties())
207 return Inherit; 208 return Inherit;
208 209
209 return NoInherit; 210 return NoInherit;
210 } 211 }
211 212
212 ItemPosition ComputedStyle::resolveAlignment(const ComputedStyle& parentStyle, c onst ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutObject ) 213 StyleSelfAlignmentData resolvedSelfAlignment(const StyleSelfAlignmentData& value , ItemPosition normalValueBehavior)
213 { 214 {
214 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto". 215 // 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.
215 if (childStyle.alignSelfPosition() == ItemPositionAuto) 216 if (value.position() == ItemPositionNormal || value.position() == ItemPositi onAuto)
216 return (parentStyle.alignItemsPosition() == ItemPositionAuto) ? resolved AutoPositionForLayoutObject : parentStyle.alignItemsPosition(); 217 return {normalValueBehavior, OverflowAlignmentDefault};
217 return childStyle.alignSelfPosition(); 218 return value;
218 } 219 }
219 220
220 const StyleSelfAlignmentData ComputedStyle::resolvedAlignment(const ComputedStyl e& parentStyle, ItemPosition resolvedAutoPositionForLayoutObject) const 221 StyleSelfAlignmentData ComputedStyle::resolvedAlignItems(ItemPosition normalValu eBehaviour) const
221 { 222 {
222 // The auto keyword computes to the parent's align-items computed value, or to "stretch", if not set or "auto". 223 // We will return the behaviour of 'normal' value if needed, which is specif ic of each layout model.
223 if (alignSelfPosition() == ItemPositionAuto) { 224 return resolvedSelfAlignment(alignItems(), normalValueBehaviour);
224 if (parentStyle.alignItemsPosition() == ItemPositionAuto)
225 return {resolvedAutoPositionForLayoutObject, OverflowAlignmentDefaul t};
226 return parentStyle.alignItems();
227 }
228 return alignSelf();
229 } 225 }
230 226
231 ItemPosition ComputedStyle::resolveJustification(const ComputedStyle& parentStyl e, const ComputedStyle& childStyle, ItemPosition resolvedAutoPositionForLayoutOb ject) 227 StyleSelfAlignmentData ComputedStyle::resolvedAlignSelf(ItemPosition normalValue Behaviour, const ComputedStyle* parentStyle) const
232 { 228 {
233 if (childStyle.justifySelfPosition() == ItemPositionAuto) 229 // We will return the behaviour of 'normal' value if needed, which is specif ic of each layout model.
234 return (parentStyle.justifyItemsPosition() == ItemPositionAuto) ? resolv edAutoPositionForLayoutObject : parentStyle.justifyItemsPosition(); 230 if (!parentStyle || alignSelfPosition() != ItemPositionAuto)
235 return childStyle.justifySelfPosition(); 231 return resolvedSelfAlignment(alignSelf(), normalValueBehaviour);
232
233 // We shouldn't need to resolve any 'auto' value in post-adjusment ComputedS tyle, but some layout models
234 // can generate anonymous boxes that may need 'auto' value resolution during layout.
235 // The 'auto' keyword computes to the parent's align-items computed value.
236 return parentStyle->resolvedAlignItems(normalValueBehaviour);
237 }
238
239 StyleSelfAlignmentData ComputedStyle::resolvedJustifyItems(ItemPosition normalVa lueBehaviour) const
240 {
241 // We will return the behaviour of 'normal' value if needed, which is specif ic of each layout model.
242 return resolvedSelfAlignment(justifyItems(), normalValueBehaviour);
243 }
244
245 StyleSelfAlignmentData ComputedStyle::resolvedJustifySelf(ItemPosition normalVal ueBehaviour, const ComputedStyle* parentStyle) const
246 {
247 // We will return the behaviour of 'normal' value if needed, which is specif ic of each layout model.
248 if (!parentStyle || justifySelfPosition() != ItemPositionAuto)
249 return resolvedSelfAlignment(justifySelf(), normalValueBehaviour);
250
251 // We shouldn't need to resolve any 'auto' value in post-adjusment ComputedS tyle, but some layout models
252 // can generate anonymous boxes that may need 'auto' value resolution during layout.
253 // The auto keyword computes to the parent's justify-items computed value.
254 return parentStyle->resolvedJustifyItems(normalValueBehaviour);
236 } 255 }
237 256
238 static inline ContentPosition resolvedContentAlignmentPosition(const StyleConten tAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior) 257 static inline ContentPosition resolvedContentAlignmentPosition(const StyleConten tAlignmentData& value, const StyleContentAlignmentData& normalValueBehavior)
239 { 258 {
240 return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior.position() : value.position() ; 259 return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior.position() : value.position() ;
241 } 260 }
242 261
243 static inline ContentDistributionType resolvedContentAlignmentDistribution(const StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueB ehavior) 262 static inline ContentDistributionType resolvedContentAlignmentDistribution(const StyleContentAlignmentData& value, const StyleContentAlignmentData& normalValueB ehavior)
244 { 263 {
245 return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior.distribution() : value.distri bution(); 264 return (value.position() == ContentPositionNormal && value.distribution() == ContentDistributionDefault) ? normalValueBehavior.distribution() : value.distri bution();
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 if (value < 0) 1892 if (value < 0)
1874 fvalue -= 0.5f; 1893 fvalue -= 0.5f;
1875 else 1894 else
1876 fvalue += 0.5f; 1895 fvalue += 0.5f;
1877 } 1896 }
1878 1897
1879 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 1898 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
1880 } 1899 }
1881 1900
1882 } // namespace blink 1901 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698