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

Side by Side Diff: third_party/WebKit/Source/core/css/ComputedStyleCSSValueMapping.cpp

Issue 1583433002: [css-align] New CSS Value 'normal' for Content Alignment (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed layout tests failing. 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) 2004 Zack Rusin <zack@kde.org> 2 * Copyright (C) 2004 Zack Rusin <zack@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> 5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
6 * Copyright (C) 2011 Sencha, Inc. All rights reserved. 6 * Copyright (C) 2011 Sencha, Inc. All rights reserved.
7 * Copyright (C) 2015 Google Inc. All rights reserved. 7 * Copyright (C) 2015 Google Inc. All rights reserved.
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public 10 * modify it under the terms of the GNU Lesser General Public
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS eparated(); 438 RefPtrWillBeRawPtr<CSSValueList> afterSlash = CSSValueList::createSpaceS eparated();
439 afterSlash->append(valueForFillSize(currLayer->size(), style)); 439 afterSlash->append(valueForFillSize(currLayer->size(), style));
440 afterSlash->append(cssValuePool().createValue(currLayer->origin())); 440 afterSlash->append(cssValuePool().createValue(currLayer->origin()));
441 afterSlash->append(cssValuePool().createValue(currLayer->clip())); 441 afterSlash->append(cssValuePool().createValue(currLayer->clip()));
442 list->append(afterSlash); 442 list->append(afterSlash);
443 ret->append(list); 443 ret->append(list);
444 } 444 }
445 return ret.release(); 445 return ret.release();
446 } 446 }
447 447
448 static StyleContentAlignmentData resolveJustifyContentAuto(const ComputedStyle& style)
449 {
450 const StyleContentAlignmentData& data = style.justifyContent();
451 if (data.position() != ContentPositionAuto || data.distribution() != Content DistributionDefault)
452 return data;
453
454 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
455 return {ContentPositionFlexStart, ContentDistributionDefault, OverflowAl ignmentDefault};
456
457 if (style.isDisplayFlexibleBox())
458 return {ContentPositionFlexStart, ContentDistributionDefault, OverflowAl ignmentDefault};
459
460 return {ContentPositionStart, ContentDistributionDefault, OverflowAlignmentD efault};
461 }
462
463 static StyleContentAlignmentData resolveAlignContentAuto(const ComputedStyle& st yle)
464 {
465 const StyleContentAlignmentData& data = style.alignContent();
466 if (data.position() != ContentPositionAuto || data.distribution() != Content DistributionDefault)
467 return data;
468
469 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled())
470 return {ContentPositionAuto, ContentDistributionStretch, OverflowAlignme ntDefault};
471
472 if (style.isDisplayFlexibleBox())
473 return {ContentPositionAuto, ContentDistributionStretch, OverflowAlignme ntDefault};
474
475 return {ContentPositionStart, ContentDistributionDefault, OverflowAlignmentD efault};
476 }
477
478 static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributi onWithOverflowAlignment(const StyleContentAlignmentData& data) 448 static PassRefPtrWillBeRawPtr<CSSValueList> valueForContentPositionAndDistributi onWithOverflowAlignment(const StyleContentAlignmentData& data)
479 { 449 {
480 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated (); 450 RefPtrWillBeRawPtr<CSSValueList> result = CSSValueList::createSpaceSeparated ();
481 if (data.distribution() != ContentDistributionDefault) 451 if (data.distribution() != ContentDistributionDefault)
482 result->append(CSSPrimitiveValue::create(data.distribution())); 452 result->append(CSSPrimitiveValue::create(data.distribution()));
483 if (data.distribution() == ContentDistributionDefault || data.position() != ContentPositionAuto) 453 if (data.distribution() == ContentDistributionDefault || data.position() != ContentPositionNormal)
484 result->append(CSSPrimitiveValue::create(data.position())); 454 result->append(CSSPrimitiveValue::create(data.position()));
485 if ((data.position() >= ContentPositionCenter || data.distribution() != Cont entDistributionDefault) && data.overflow() != OverflowAlignmentDefault) 455 if ((data.position() >= ContentPositionCenter || data.distribution() != Cont entDistributionDefault) && data.overflow() != OverflowAlignmentDefault)
486 result->append(CSSPrimitiveValue::create(data.overflow())); 456 result->append(CSSPrimitiveValue::create(data.overflow()));
487 ASSERT(result->length() > 0); 457 ASSERT(result->length() > 0);
488 ASSERT(result->length() <= 3); 458 ASSERT(result->length() <= 3);
489 return result.release(); 459 return result.release();
490 } 460 }
491 461
492 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForLineHeight(const Comput edStyle& style) 462 static PassRefPtrWillBeRawPtr<CSSPrimitiveValue> valueForLineHeight(const Comput edStyle& style)
493 { 463 {
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 } 1566 }
1597 return value.release(); 1567 return value.release();
1598 } 1568 }
1599 case CSSPropertyDirection: 1569 case CSSPropertyDirection:
1600 return cssValuePool().createValue(style.direction()); 1570 return cssValuePool().createValue(style.direction());
1601 case CSSPropertyDisplay: 1571 case CSSPropertyDisplay:
1602 return cssValuePool().createValue(style.display()); 1572 return cssValuePool().createValue(style.display());
1603 case CSSPropertyEmptyCells: 1573 case CSSPropertyEmptyCells:
1604 return cssValuePool().createValue(style.emptyCells()); 1574 return cssValuePool().createValue(style.emptyCells());
1605 case CSSPropertyAlignContent: 1575 case CSSPropertyAlignContent:
1606 return valueForContentPositionAndDistributionWithOverflowAlignment(resol veAlignContentAuto(style)); 1576 return valueForContentPositionAndDistributionWithOverflowAlignment(style .alignContent());
1607 case CSSPropertyAlignItems: 1577 case CSSPropertyAlignItems:
1608 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition); 1578 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac yPosition);
1609 case CSSPropertyAlignSelf: { 1579 case CSSPropertyAlignSelf: {
1610 ItemPosition position = style.alignSelfPosition(); 1580 ItemPosition position = style.alignSelfPosition();
1611 if (position == ItemPositionAuto) { 1581 if (position == ItemPositionAuto) {
1612 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle) 1582 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par entComputedStyle)
1613 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr; 1583 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled Node->parentNode()->ensureComputedStyle() : nullptr;
1614 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart; 1584 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle)) : ItemPositionStart;
1615 } 1585 }
1616 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition); 1586 return valueForItemPositionWithOverflowAlignment(position, style.alignSe lfOverflowAlignment(), NonLegacyPosition);
1617 } 1587 }
1618 case CSSPropertyFlex: 1588 case CSSPropertyFlex:
1619 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle); 1589 return valuesForShorthandProperty(flexShorthand(), style, layoutObject, styledNode, allowVisitedStyle);
1620 case CSSPropertyFlexBasis: 1590 case CSSPropertyFlexBasis:
1621 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); 1591 return zoomAdjustedPixelValueForLength(style.flexBasis(), style);
1622 case CSSPropertyFlexDirection: 1592 case CSSPropertyFlexDirection:
1623 return cssValuePool().createValue(style.flexDirection()); 1593 return cssValuePool().createValue(style.flexDirection());
1624 case CSSPropertyFlexFlow: 1594 case CSSPropertyFlexFlow:
1625 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle); 1595 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje ct, styledNode, allowVisitedStyle);
1626 case CSSPropertyFlexGrow: 1596 case CSSPropertyFlexGrow:
1627 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number); 1597 return cssValuePool().createValue(style.flexGrow(), CSSPrimitiveValue::U nitType::Number);
1628 case CSSPropertyFlexShrink: 1598 case CSSPropertyFlexShrink:
1629 return cssValuePool().createValue(style.flexShrink(), CSSPrimitiveValue: :UnitType::Number); 1599 return cssValuePool().createValue(style.flexShrink(), CSSPrimitiveValue: :UnitType::Number);
1630 case CSSPropertyFlexWrap: 1600 case CSSPropertyFlexWrap:
1631 return cssValuePool().createValue(style.flexWrap()); 1601 return cssValuePool().createValue(style.flexWrap());
1632 case CSSPropertyJustifyContent: 1602 case CSSPropertyJustifyContent:
1633 return valueForContentPositionAndDistributionWithOverflowAlignment(resol veJustifyContentAuto(style)); 1603 return valueForContentPositionAndDistributionWithOverflowAlignment(style .justifyContent());
1634 case CSSPropertyOrder: 1604 case CSSPropertyOrder:
1635 return cssValuePool().createValue(style.order(), CSSPrimitiveValue::Unit Type::Number); 1605 return cssValuePool().createValue(style.order(), CSSPrimitiveValue::Unit Type::Number);
1636 case CSSPropertyFloat: 1606 case CSSPropertyFloat:
1637 if (style.display() != NONE && style.hasOutOfFlowPosition()) 1607 if (style.display() != NONE && style.hasOutOfFlowPosition())
1638 return cssValuePool().createIdentifierValue(CSSValueNone); 1608 return cssValuePool().createIdentifierValue(CSSValueNone);
1639 return cssValuePool().createValue(style.floating()); 1609 return cssValuePool().createValue(style.floating());
1640 case CSSPropertyFont: 1610 case CSSPropertyFont:
1641 return valueForFont(style); 1611 return valueForFont(style);
1642 case CSSPropertyFontFamily: 1612 case CSSPropertyFontFamily:
1643 return valueForFontFamily(style); 1613 return valueForFontFamily(style);
(...skipping 1090 matching lines...) Expand 10 before | Expand all | Expand 10 after
2734 case CSSPropertyAll: 2704 case CSSPropertyAll:
2735 return nullptr; 2705 return nullptr;
2736 default: 2706 default:
2737 break; 2707 break;
2738 } 2708 }
2739 ASSERT_NOT_REACHED(); 2709 ASSERT_NOT_REACHED();
2740 return nullptr; 2710 return nullptr;
2741 } 2711 }
2742 2712
2743 } // namespace blink 2713 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698