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

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

Issue 363133003: [CSS Grid Layout] Adapting align-self, align-items and justify-self to the last CSS 3 spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style->is DisplayInlineType()) 247 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style->is DisplayInlineType())
248 style->setDisplay(BLOCK); 248 style->setDisplay(BLOCK);
249 } 249 }
250 250
251 if (e && e->renderStyle() && e->renderStyle()->textAutosizingMultiplier() != 1) { 251 if (e && e->renderStyle() && e->renderStyle()->textAutosizingMultiplier() != 1) {
252 // Preserve the text autosizing multiplier on style recalc. 252 // Preserve the text autosizing multiplier on style recalc.
253 // (The autosizer will update it during layout if it needs to be changed .) 253 // (The autosizer will update it during layout if it needs to be changed .)
254 style->setTextAutosizingMultiplier(e->renderStyle()->textAutosizingMulti plier()); 254 style->setTextAutosizingMultiplier(e->renderStyle()->textAutosizingMulti plier());
255 style->setUnique(); 255 style->setUnique();
256 } 256 }
257
258 adjustStyleForAlignment(style, parentStyle);
259 }
260
261 void StyleAdjuster::adjustStyleForAlignment(RenderStyle* style, RenderStyle* par entStyle)
esprehn 2014/07/12 00:39:19 These should both be references.
262 {
263 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
264 // computes to the the inherited value.
265 if (style->justifyItems() == ItemPositionAuto) {
266 if (parentStyle->justifyItemsPositionType() == LegacyPosition) {
267 style->setJustifyItems(parentStyle->justifyItems());
268 style->setJustifyItemsPositionType(parentStyle->justifyItemsPosition Type());
269 // Otherwise, auto computes to:
270 } else if (style->isDisplayFlexibleOrGridBox()) {
271 // 'stretch' for flex containers and grid containers.
272 style->setJustifyItems(ItemPositionStretch);
273 } else {
274 // 'start' for everything else.
275 style->setJustifyItems(ItemPositionStart);
276 }
277 }
278
279 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
280 if (style->justifySelf() == ItemPositionAuto) {
281 if (style->position() == AbsolutePosition) {
282 style->setJustifySelf(ItemPositionStretch);
283 } else {
284 // and to the computed value of justify-items on the parent (minus
285 // any legacy keywords) on all other boxes.
286 style->setJustifySelf(parentStyle->justifyItems());
287 style->setJustifySelfOverflowAlignment(parentStyle->justifyItemsOver flowAlignment());
288 }
289 }
290
291 // The 'auto' keyword computes to:
292 if (style->alignItems() == ItemPositionAuto) {
293 if (style->isDisplayFlexibleOrGridBox()) {
294 // 'stretch' for flex containers and grid containers,
295 style->setAlignItems(ItemPositionStretch);
296 } else {
297 // 'start' for everything else
298 style->setAlignItems(ItemPositionStart);
299 }
300 }
301
302 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
303 if (style->alignSelf() == ItemPositionAuto) {
304 if ((style->position() == AbsolutePosition) || (parentStyle->alignItems( ) == ItemPositionAuto)) {
305 style->setAlignSelf(ItemPositionStretch);
306 } else {
307 // and to the computed value of align-items on the parent (minus
308 // any 'legacy' keywords) on all other boxes.
309 style->setAlignSelf(parentStyle->alignItems());
310 style->setAlignSelfOverflowAlignment(parentStyle->alignItemsOverflow Alignment());
311 }
312 }
257 } 313 }
258 314
259 void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* paren tStyle, Element& element) 315 void StyleAdjuster::adjustStyleForTagName(RenderStyle* style, RenderStyle* paren tStyle, Element& element)
260 { 316 {
261 // <div> and <span> are the most common elements on the web, we skip all the work for them. 317 // <div> and <span> are the most common elements on the web, we skip all the work for them.
262 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 318 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
263 return; 319 return;
264 320
265 if (isHTMLTableCellElement(element)) { 321 if (isHTMLTableCellElement(element)) {
266 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property. 322 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B OX || style->display() == INLINE_BOX)) 454 if (style->writingMode() != TopToBottomWritingMode && (style->display() == B OX || style->display() == INLINE_BOX))
399 style->setWritingMode(TopToBottomWritingMode); 455 style->setWritingMode(TopToBottomWritingMode);
400 456
401 if (parentStyle->isDisplayFlexibleOrGridBox()) { 457 if (parentStyle->isDisplayFlexibleOrGridBox()) {
402 style->setFloating(NoFloat); 458 style->setFloating(NoFloat);
403 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa ting(), !m_useQuirksModeStyles)); 459 style->setDisplay(equivalentBlockDisplay(style->display(), style->isFloa ting(), !m_useQuirksModeStyles));
404 } 460 }
405 } 461 }
406 462
407 } 463 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698