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

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

Issue 1136283006: [CSS Grid Layout] Avoid using StyleAdjuster to resolve 'auto' values. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed some layout tests failures. Created 5 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
« no previous file with comments | « Source/core/css/resolver/StyleAdjuster.h ('k') | Source/core/layout/LayoutBox.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 style.setPosition(ComputedStyle::initialPosition()); 236 style.setPosition(ComputedStyle::initialPosition());
237 237
238 // SVG text layout code expects us to be a block-level style element. 238 // SVG text layout code expects us to be a block-level style element.
239 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style.isD isplayInlineType()) 239 if ((isSVGForeignObjectElement(*e) || isSVGTextElement(*e)) && style.isD isplayInlineType())
240 style.setDisplay(BLOCK); 240 style.setDisplay(BLOCK);
241 241
242 // Columns don't apply to svg text elements. 242 // Columns don't apply to svg text elements.
243 if (isSVGTextElement(*e)) 243 if (isSVGTextElement(*e))
244 style.clearMultiCol(); 244 style.clearMultiCol();
245 } 245 }
246 adjustStyleForAlignment(style, parentStyle); 246
247 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
248 // computes to the the inherited value.
249 if (parentStyle.justifyItemsPositionType() == LegacyPosition && style.justif yItemsPosition() == ItemPositionAuto)
250 style.setJustifyItemsPosition(parentStyle.justifyItemsPosition());
247 } 251 }
248 252
249 void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style) 253 void StyleAdjuster::adjustStyleForFirstLetter(ComputedStyle& style)
250 { 254 {
251 if (style.styleType() != FIRST_LETTER) 255 if (style.styleType() != FIRST_LETTER)
252 return; 256 return;
253 257
254 // Force inline display (except for floating first-letters). 258 // Force inline display (except for floating first-letters).
255 style.setDisplay(style.isFloating() ? BLOCK : INLINE); 259 style.setDisplay(style.isFloating() ? BLOCK : INLINE);
256 260
257 // CSS2 says first-letter can't be positioned. 261 // CSS2 says first-letter can't be positioned.
258 style.setPosition(StaticPosition); 262 style.setPosition(StaticPosition);
259 } 263 }
260 264
261 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
262 {
263 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox();
264 bool absolutePositioned = style.position() == AbsolutePosition;
265
266 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
267 // computes to the the inherited value.
268 // Otherwise, auto computes to:
269 // - 'stretch' for flex containers and grid containers.
270 // - 'start' for everything else.
271 if (style.justifyItemsPosition() == ItemPositionAuto) {
272 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
273 style.setJustifyItems(parentStyle.justifyItems());
274 else if (isFlexOrGrid)
275 style.setJustifyItemsPosition(ItemPositionStretch);
276 }
277
278 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
279 // and to the computed value of justify-items on the parent (minus
280 // any legacy keywords) on all other boxes.
281 if (style.justifySelfPosition() == ItemPositionAuto) {
282 if (absolutePositioned)
283 style.setJustifySelfPosition(ItemPositionStretch);
284 else
285 style.setJustifySelf(parentStyle.justifyItems());
286 }
287
288 // The 'auto' keyword computes to:
289 // - 'stretch' for flex containers and grid containers,
290 // - 'start' for everything else.
291 if (style.alignItemsPosition() == ItemPositionAuto) {
292 if (isFlexOrGrid)
293 style.setAlignItemsPosition(ItemPositionStretch);
294 }
295
296 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
297 // and to the computed value of align-items on the parent (minus
298 // any 'legacy' keywords) on all other boxes.
299 if (style.alignSelfPosition() == ItemPositionAuto) {
300 if (absolutePositioned)
301 style.setAlignSelfPosition(ItemPositionStretch);
302 else
303 style.setAlignSelf(parentStyle.alignItems());
304 }
305
306 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
307 // value of 'vertical-align', otherwise behaves as 'start'.
308 // Flex Containers: 'auto' computes to 'flex-start'.
309 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
310 if ((style.justifyContentPosition() == ContentPositionAuto) && (style.justif yContentDistribution() == ContentDistributionDefault)) {
311 if (style.isDisplayFlexibleOrGridBox()) {
312 if (style.isDisplayFlexibleBox())
313 style.setJustifyContentPosition(ContentPositionFlexStart);
314 else
315 style.setJustifyContentPosition(ContentPositionStart);
316 }
317 }
318
319 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
320 // value of 'vertical-align', otherwise behaves as 'start'.
321 // Flex Containers: 'auto' computes to 'stretch'.
322 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
323 if (style.alignContentPosition() == ContentPositionAuto && style.alignConten tDistribution() == ContentDistributionDefault) {
324 if (style.isDisplayFlexibleOrGridBox()) {
325 if (style.isDisplayFlexibleBox())
326 style.setAlignContentDistribution(ContentDistributionStretch);
327 else
328 style.setAlignContentPosition(ContentPositionStart);
329 }
330 }
331 }
332
333 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) 265 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
334 { 266 {
335 // <div> and <span> are the most common elements on the web, we skip all the work for them. 267 // <div> and <span> are the most common elements on the web, we skip all the work for them.
336 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 268 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
337 return; 269 return;
338 270
339 if (isHTMLTableCellElement(element)) { 271 if (isHTMLTableCellElement(element)) {
340 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property. 272 // If we have a <td> that specifies a float property, in quirks mode we just drop the float property.
341 // FIXME: Why is this only <td> and not <th>? 273 // FIXME: Why is this only <td> and not <th>?
342 if (element.hasTagName(tdTag) && m_useQuirksModeStyles) { 274 if (element.hasTagName(tdTag) && m_useQuirksModeStyles) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX)) 414 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX))
483 style.setWritingMode(TopToBottomWritingMode); 415 style.setWritingMode(TopToBottomWritingMode);
484 416
485 if (parentStyle.isDisplayFlexibleOrGridBox()) { 417 if (parentStyle.isDisplayFlexibleOrGridBox()) {
486 style.setFloating(NoFloat); 418 style.setFloating(NoFloat);
487 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles)); 419 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles));
488 } 420 }
489 } 421 }
490 422
491 } 423 }
OLDNEW
« no previous file with comments | « Source/core/css/resolver/StyleAdjuster.h ('k') | Source/core/layout/LayoutBox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698