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

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: Using the StyleConverter. 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 { 260 {
261 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox(); 261 bool isFlexOrGrid = style.isDisplayFlexibleOrGridBox();
262 bool absolutePositioned = style.position() == AbsolutePosition; 262 bool absolutePositioned = style.position() == AbsolutePosition;
263 263
264 // If the inherited value of justify-items includes the legacy keyword, 'aut o' 264 // If the inherited value of justify-items includes the legacy keyword, 'aut o'
265 // computes to the the inherited value. 265 // computes to the the inherited value.
266 // Otherwise, auto computes to: 266 // Otherwise, auto computes to:
267 // - 'stretch' for flex containers and grid containers. 267 // - 'stretch' for flex containers and grid containers.
268 // - 'start' for everything else. 268 // - 'start' for everything else.
269 if (style.justifyItems() == ItemPositionAuto) { 269 if (style.justifyItems() == ItemPositionAuto) {
270 if (parentStyle.justifyItemsPositionType() == LegacyPosition) { 270 if (parentStyle.justifyItems() == LegacyPosition)
271 style.setJustifyItems(parentStyle.justifyItems()); 271 style.setJustifyItems(parentStyle.justifyItems());
272 style.setJustifyItemsPositionType(parentStyle.justifyItemsPositionTy pe()); 272 else if (isFlexOrGrid)
273 } else if (isFlexOrGrid) {
274 style.setJustifyItems(ItemPositionStretch); 273 style.setJustifyItems(ItemPositionStretch);
275 }
276 } 274 }
277 275
278 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 276 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
279 // and to the computed value of justify-items on the parent (minus 277 // and to the computed value of justify-items on the parent (minus
280 // any legacy keywords) on all other boxes. 278 // any legacy keywords) on all other boxes.
281 if (style.justifySelf() == ItemPositionAuto) { 279 if (style.justifySelf() == ItemPositionAuto) {
282 if (absolutePositioned) { 280 if (absolutePositioned)
283 style.setJustifySelf(ItemPositionStretch); 281 style.setJustifySelf(ItemPositionStretch);
284 } else { 282 else
285 style.setJustifySelf(parentStyle.justifyItems()); 283 style.setJustifySelf(parentStyle.justifyItems());
286 style.setJustifySelfOverflowAlignment(parentStyle.justifyItemsOverfl owAlignment());
287 }
288 } 284 }
289 285
290 // The 'auto' keyword computes to: 286 // The 'auto' keyword computes to:
291 // - 'stretch' for flex containers and grid containers, 287 // - 'stretch' for flex containers and grid containers,
292 // - 'start' for everything else. 288 // - 'start' for everything else.
293 if (style.alignItems() == ItemPositionAuto) { 289 if (style.alignItems() == ItemPositionAuto) {
294 if (isFlexOrGrid) 290 if (isFlexOrGrid)
295 style.setAlignItems(ItemPositionStretch); 291 style.setAlignItems(ItemPositionStretch);
296 } 292 }
297 293
298 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s, 294 // The 'auto' keyword computes to 'stretch' on absolutely-positioned element s,
299 // and to the computed value of align-items on the parent (minus 295 // and to the computed value of align-items on the parent (minus
300 // any 'legacy' keywords) on all other boxes. 296 // any 'legacy' keywords) on all other boxes.
301 if (style.alignSelf() == ItemPositionAuto) { 297 if (style.alignSelf() == ItemPositionAuto) {
302 if (absolutePositioned) { 298 if (absolutePositioned)
303 style.setAlignSelf(ItemPositionStretch); 299 style.setAlignSelf(ItemPositionStretch);
304 } else { 300 else
305 style.setAlignSelf(parentStyle.alignItems()); 301 style.setAlignSelf(parentStyle.alignItems());
306 style.setAlignSelfOverflowAlignment(parentStyle.alignItemsOverflowAl ignment());
307 }
308 } 302 }
309 303
310 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed 304 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
311 // value of 'vertical-align', otherwise behaves as 'start'. 305 // value of 'vertical-align', otherwise behaves as 'start'.
312 // Flex Containers: 'auto' computes to 'flex-start'. 306 // Flex Containers: 'auto' computes to 'flex-start'.
313 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'. 307 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
314 if ((style.justifyContent() == ContentPositionAuto) && (style.justifyContent Distribution() == ContentDistributionDefault)) { 308 if ((style.justifyContent() == ContentPositionAuto) && (style.justifyContent () == ContentDistributionDefault)) {
315 if (style.isDisplayFlexibleOrGridBox()) { 309 if (style.isDisplayFlexibleOrGridBox()) {
316 if (style.isDisplayFlexibleBox()) 310 if (style.isDisplayFlexibleBox())
317 style.setJustifyContent(ContentPositionFlexStart); 311 style.setJustifyContent(ContentPositionFlexStart);
318 else 312 else
319 style.setJustifyContent(ContentPositionStart); 313 style.setJustifyContent(ContentPositionStart);
320 } 314 }
321 } 315 }
322 316
323 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed 317 // Block Containers: For table cells, the behavior of the 'auto' depends on the computed
324 // value of 'vertical-align', otherwise behaves as 'start'. 318 // value of 'vertical-align', otherwise behaves as 'start'.
325 // Flex Containers: 'auto' computes to 'stretch'. 319 // Flex Containers: 'auto' computes to 'stretch'.
326 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'. 320 // Grid Containers: 'auto' computes to 'start', and 'stretch' behaves like ' start'.
327 if (style.alignContent() == ContentPositionAuto && style.alignContentDistrib ution() == ContentDistributionDefault) { 321 if (style.alignContent() == ContentPositionAuto && style.alignContent() == C ontentDistributionDefault) {
328 if (style.isDisplayFlexibleOrGridBox()) { 322 if (style.isDisplayFlexibleOrGridBox()) {
329 if (style.isDisplayFlexibleBox()) 323 if (style.isDisplayFlexibleBox())
330 style.setAlignContentDistribution(ContentDistributionStretch); 324 style.setAlignContent(ContentDistributionStretch);
331 else 325 else
332 style.setAlignContent(ContentPositionStart); 326 style.setAlignContent(ContentPositionStart);
333 } 327 }
334 } 328 }
335 } 329 }
336 330
337 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element) 331 void StyleAdjuster::adjustStyleForHTMLElement(ComputedStyle& style, const Comput edStyle& parentStyle, HTMLElement& element)
338 { 332 {
339 // <div> and <span> are the most common elements on the web, we skip all the work for them. 333 // <div> and <span> are the most common elements on the web, we skip all the work for them.
340 if (isHTMLDivElement(element) || isHTMLSpanElement(element)) 334 if (isHTMLDivElement(element) || isHTMLSpanElement(element))
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX)) 480 if (style.writingMode() != TopToBottomWritingMode && (style.display() == BOX || style.display() == INLINE_BOX))
487 style.setWritingMode(TopToBottomWritingMode); 481 style.setWritingMode(TopToBottomWritingMode);
488 482
489 if (parentStyle.isDisplayFlexibleOrGridBox()) { 483 if (parentStyle.isDisplayFlexibleOrGridBox()) {
490 style.setFloating(NoFloat); 484 style.setFloating(NoFloat);
491 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles)); 485 style.setDisplay(equivalentBlockDisplay(style.display(), style.isFloatin g(), !m_useQuirksModeStyles));
492 } 486 }
493 } 487 }
494 488
495 } 489 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698