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

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: Created 4 years, 10 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 255
256 // Force inline display (except for floating first-letters). 256 // Force inline display (except for floating first-letters).
257 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 257 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
258 258
259 // CSS2 says first-letter can't be positioned. 259 // CSS2 says first-letter can't be positioned.
260 style.setPosition(StaticPosition); 260 style.setPosition(StaticPosition);
261 } 261 }
262 262
263 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle) 263 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
264 { 264 {
265 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 265 // If the inherited value of justify-items includes the 'legacy' keyword, 'a uto'
266 bool absolutePositioned = style.position() == AbsolutePosition;
267
268 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
269 // computes to the the inherited value. 266 // computes to the the inherited value.
270 // Otherwise, auto computes to: 267 // Otherwise, 'auto' computes to 'normal'.
271 // - 'stretch' for flex containers and grid containers.
272 // - 'start' for everything else.
273 if (style.justifyItemsPosition() == ItemPositionAuto) { 268 if (style.justifyItemsPosition() == ItemPositionAuto) {
274 if (parentStyle.justifyItemsPositionType() == LegacyPosition) 269 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
275 style.setJustifyItems(parentStyle.justifyItems()); 270 style.setJustifyItems(parentStyle.justifyItems());
276 else if (isFlexOrGrid)
277 style.setJustifyItemsPosition(ItemPositionStretch);
278 }
279
280 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
281 // and to the computed value of justify-items on the parent (minus
282 // any legacy keywords) on all other boxes.
283 if (style.justifySelfPosition() == ItemPositionAuto) {
284 if (absolutePositioned)
285 style.setJustifySelfPosition(ItemPositionStretch);
286 else 271 else
287 style.setJustifySelf(parentStyle.justifyItems()); 272 style.setJustifyItemsPosition(ItemPositionNormal);
288 }
289
290 // The 'auto' keyword computes to:
291 // - 'stretch' for flex containers and grid containers,
292 // - 'start' for everything else.
293 if (style.alignItemsPosition() == ItemPositionAuto) {
294 if (isFlexOrGrid)
295 style.setAlignItemsPosition(ItemPositionStretch);
296 } 273 }
297 } 274 }
298 275
299 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) 276 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
300 { 277 {
301 // <div> and <span> are the most common elements on the web, we skip all the work for them. 278 // <div> and <span> are the most common elements on the web, we skip all the work for them.
302 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 279 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
303 return; 280 return;
304 281
305 if (isHTMLTableCellElement(element)) { 282 if (isHTMLTableCellElement(element)) {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // We want to count vertical percentage paddings/margins on flex items b ecause our current 413 // We want to count vertical percentage paddings/margins on flex items b ecause our current
437 // behavior is different from the spec and we want to gather compatibili ty data. 414 // behavior is different from the spec and we want to gather compatibili ty data.
438 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t()) 415 if (style.paddingBefore().hasPercent() || style.paddingAfter().hasPercen t())
439 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical); 416 UseCounter::count(document, UseCounter::FlexboxPercentagePaddingVert ical);
440 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( )) 417 if (style.marginBefore().hasPercent() || style.marginAfter().hasPercent( ))
441 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal); 418 UseCounter::count(document, UseCounter::FlexboxPercentageMarginVerti cal);
442 } 419 }
443 } 420 }
444 421
445 } // namespace blink 422 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698