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

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

Issue 1070143002: [Alignment] Single class for holding the alignment data. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased and got back previous setter names. Created 5 years, 8 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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle) 261 void StyleAdjuster::adjustStyleForAlignment(ComputedStyle& style, const Computed Style& parentStyle)
262 { 262 {
263 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 263 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox();
264 bool absolutePositioned = style.position() == AbsolutePosition; 264 bool absolutePositioned = style.position() == AbsolutePosition;
265 265
266 // If the inherited value of justify-items includes the legacy keyword, 'aut o' 266 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
267 // computes to the the inherited value. 267 // computes to the the inherited value.
268 // Otherwise, auto computes to: 268 // Otherwise, auto computes to:
269 // - 'stretch' for flex containers and grid containers. 269 // - 'stretch' for flex containers and grid containers.
270 // - 'start' for everything else. 270 // - 'start' for everything else.
271 if (style.justifyItems() == ItemPositionAuto) { 271 if (style.justifyItemsPosition() == ItemPositionAuto) {
272 if (parentStyle.justifyItemsPositionType() == LegacyPosition) { 272 if (parentStyle.justifyItemsPositionType() == LegacyPosition)
273 style.setJustifyItems(parentStyle.justifyItems()); 273 style.setJustifyItems(parentStyle.justifyItems());
274 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionTy pe()); 274 else if (isFlexOrGrid)
275 } else if (isFlexOrGrid) { 275 style.setJustifyItemsPosition(ItemPositionStretch);
276 style.setJustifyItems(ItemPositionStretch);
277 }
278 } 276 }
279 277
280 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 278 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
281 // and to the computed value of justify-items on the parent (minus 279 // and to the computed value of justify-items on the parent (minus
282 // any legacy keywords) on all other boxes. 280 // any legacy keywords) on all other boxes.
283 if (style.justifySelf() == ItemPositionAuto) { 281 if (style.justifySelfPosition() == ItemPositionAuto) {
284 if (absolutePositioned) { 282 if (absolutePositioned)
285 style.setJustifySelf(ItemPositionStretch); 283 style.setJustifySelfPosition(ItemPositionStretch);
286 } else { 284 else
287 style.setJustifySelf(parentStyle.justifyItems()); 285 style.setJustifySelf(parentStyle.justifyItems());
288 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverfl owAlignment());
289 }
290 } 286 }
291 287
292 // The 'auto' keyword computes to: 288 // The 'auto' keyword computes to:
293 // - 'stretch' for flex containers and grid containers, 289 // - 'stretch' for flex containers and grid containers,
294 // - 'start' for everything else. 290 // - 'start' for everything else.
295 if (style.alignItems() == ItemPositionAuto) { 291 if (style.alignItemsPosition() == ItemPositionAuto) {
296 if (isFlexOrGrid) 292 if (isFlexOrGrid)
297 style.setAlignItems(ItemPositionStretch); 293 style.setAlignItemsPosition(ItemPositionStretch);
298 } 294 }
299 295
300 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 296 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
301 // and to the computed value of align-items on the parent (minus 297 // and to the computed value of align-items on the parent (minus
302 // any 'legacy' keywords) on all other boxes. 298 // any 'legacy' keywords) on all other boxes.
303 if (style.alignSelf() == ItemPositionAuto) { 299 if (style.alignSelfPosition() == ItemPositionAuto) {
304 if (absolutePositioned) { 300 if (absolutePositioned)
305 style.setAlignSelf(ItemPositionStretch); 301 style.setAlignSelfPosition(ItemPositionStretch);
306 } else { 302 else
307 style.setAlignSelf(parentStyle.alignItems()); 303 style.setAlignSelf(parentStyle.alignItems());
308 style.setAlignSelfOverflowAlignment(parentStyle.alignItemsOverflowAl ignment());
309 }
310 } 304 }
311 305
312 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed 306 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
313 // value of 'vertical-align', otherwise behaves as 'start'. 307 // value of 'vertical-align', otherwise behaves as 'start'.
314 // Flex Containers: 'auto' computes to 'flex-start'. 308 // Flex Containers: 'auto' computes to 'flex-start'.
315 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'. 309 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
316 if ((style.justifyContent() == ContentPositionAuto) && (style.justifyContent Distribution() == ContentDistributionDefault)) { 310 if ((style.justifyContentPosition() == ContentPositionAuto) && (style.justif yContentDistribution() == ContentDistributionDefault)) {
317 if (style.isDisplayFlexibleOrGridBox()) { 311 if (style.isDisplayFlexibleOrGridBox()) {
318 if (style.isDisplayFlexibleBox()) 312 if (style.isDisplayFlexibleBox())
319 style.setJustifyContent(ContentPositionFlexStart); 313 style.setJustifyContentPosition(ContentPositionFlexStart);
320 else 314 else
321 style.setJustifyContent(ContentPositionStart); 315 style.setJustifyContentPosition(ContentPositionStart);
322 } 316 }
323 } 317 }
324 318
325 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed 319 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
326 // value of 'vertical-align', otherwise behaves as 'start'. 320 // value of 'vertical-align', otherwise behaves as 'start'.
327 // Flex Containers: 'auto' computes to 'stretch'. 321 // Flex Containers: 'auto' computes to 'stretch'.
328 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'. 322 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
329 if (style.alignContent() == ContentPositionAuto && style.alignContentDistrib ution() == ContentDistributionDefault) { 323 if (style.alignContentPosition() == ContentPositionAuto && style.alignConten tDistribution() == ContentDistributionDefault) {
330 if (style.isDisplayFlexibleOrGridBox()) { 324 if (style.isDisplayFlexibleOrGridBox()) {
331 if (style.isDisplayFlexibleBox()) 325 if (style.isDisplayFlexibleBox())
332 style.setAlignContentDistribution(ContentDistributionStretch); 326 style.setAlignContentDistribution(ContentDistributionStretch);
333 else 327 else
334 style.setAlignContent(ContentPositionStart); 328 style.setAlignContentPosition(ContentPositionStart);
335 } 329 }
336 } 330 }
337 } 331 }
338 332
339 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) 333 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
340 { 334 {
341 // <div> and <span> are the most common elements on the web, we skip all the work for them. 335 // <div> and <span> are the most common elements on the web, we skip all the work for them.
342 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 336 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
343 return; 337 return;
344 338
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX)) 482 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX))
489 style.setWritingMode(TopToBottomWritingMode); 483 style.setWritingMode(TopToBottomWritingMode);
490 484
491 if (parentStyle.isDisplayFlexibleOrGridBox()) { 485 if (parentStyle.isDisplayFlexibleOrGridBox()) {
492 style.setFloating(NoFloat); 486 style.setFloating(NoFloat);
493 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles)); 487 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles));
494 } 488 }
495 } 489 }
496 490
497 } 491 }
OLDNEW
« no previous file with comments | « Source/core/css/ComputedStyleCSSValueMapping.cpp ('k') | Source/core/css/resolver/StyleBuilderConverter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698