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

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: Unskipped some repaint tests and rebaselined. Created 4 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 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 267
268 // Force inline display (except for floating first-letters). 268 // Force inline display (except for floating first-letters).
269 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 269 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
270 270
271 // CSS2 says first-letter can't be positioned. 271 // CSS2 says first-letter can't be positioned.
272 style.setPosition(StaticPosition); 272 style.setPosition(StaticPosition);
273 } 273 }
274 274
275 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle) 275 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
276 { 276 {
277 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 277 // To avoid needing to copy the RareNonInheritedData, we could repurporse th e 'auto'
Timothy Loh 2016/05/23 05:45:39 The word 'could' here suggests we don't actually d
jfernandez 2016/05/25 18:26:49 Done.
278 bool absolutePositioned = style.position() == AbsolutePosition; 278 // flag to not just mean 'auto' prior to running the StyleAdjuster but also mean 'normal'
279 // after running it.
279 280
280 // If the inherited value of justify-items includes the legacy keyword, 'aut o' 281 // If the inherited value of justify-items includes the 'legacy' keyword, 'a uto'
281 // computes to the the inherited value. 282 // computes to the the inherited value.
282 // Otherwise, auto computes to: 283 // Otherwise, 'auto' computes to 'normal'.
283 // - 'stretch' for flex containers and grid containers.
284 // - 'start' for everything else.
285 if (style.justifyItemsPosition() == ItemPositionAuto) { 284 if (style.justifyItemsPosition() == ItemPositionAuto) {
286 if (parentStyle.justifyItemsPositionType() == LegacyPosition) 285 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
287 style.setJustifyItems(parentStyle.justifyItems()); 286 style.setJustifyItems(parentStyle.justifyItems());
288 else if (isFlexOrGrid)
289 style.setJustifyItemsPosition(ItemPositionStretch);
290 } 287 }
291 288
292 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 289 // The 'auto' keyword computes the computed value of justify-items on the pa rent (minus
293 // and to the computed value of justify-items on the parent (minus 290 // any legacy keywords), or 'normal' if the box has no parent.
294 // any legacy keywords) on all other boxes.
295 if (style.justifySelfPosition() == ItemPositionAuto) { 291 if (style.justifySelfPosition() == ItemPositionAuto) {
296 if (absolutePositioned) 292 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
297 style.setJustifySelfPosition(ItemPositionStretch); 293 style.setJustifySelfPosition(parentStyle.justifyItemsPosition());
298 else 294 else if (parentStyle.justifyItemsPosition() != ItemPositionAuto)
299 style.setJustifySelf(parentStyle.justifyItems()); 295 style.setJustifySelf(parentStyle.justifyItems());
300 } 296 }
301 297
302 // The 'auto' keyword computes to: 298 // The 'auto' keyword computes the computed value of align-items on the pare nt
303 // - 'stretch' for flex containers and grid containers, 299 // or 'normal' if the box has no parent.
304 // - 'start' for everything else. 300 if (style.alignSelfPosition() == ItemPositionAuto && parentStyle.alignItemsP osition() != ItemPositionNormal)
305 if (style.alignItemsPosition() == ItemPositionAuto) { 301 style.setAlignSelf(parentStyle.alignItems());
306 if (isFlexOrGrid)
307 style.setAlignItemsPosition(ItemPositionStretch);
308 }
309 } 302 }
310 303
311 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) 304 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
312 { 305 {
313 // <div> and <span> are the most common elements on the web, we skip all the work for them. 306 // <div> and <span> are the most common elements on the web, we skip all the work for them.
314 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 307 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
315 return; 308 return;
316 309
317 if (isHTMLTableCellElement(element)) { 310 if (isHTMLTableCellElement(element)) {
318 if (style.whiteSpace() == KHTML_NOWRAP) { 311 if (style.whiteSpace() == KHTML_NOWRAP) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 // We want to count vertical percentage paddings/margins on flex items b ecause our current 451 // We want to count vertical percentage paddings/margins on flex items b ecause our current
459 // behavior is different from the spec and we want to gather compatibili ty data. 452 // behavior is different from the spec and we want to gather compatibili ty data.
460 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) 453 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t())
461 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); 454 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical);
462 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) 455 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( ))
463 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); 456 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal);
464 } 457 }
465 } 458 }
466 459
467 } // namespace blink 460 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698