OLD | NEW |
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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 direction = CSSPrimitiveValue::createIdentifier(CSSValueLeft); | 427 direction = CSSPrimitiveValue::createIdentifier(CSSValueLeft); |
428 break; | 428 break; |
429 case ReflectionRight: | 429 case ReflectionRight: |
430 direction = CSSPrimitiveValue::createIdentifier(CSSValueRight); | 430 direction = CSSPrimitiveValue::createIdentifier(CSSValueRight); |
431 break; | 431 break; |
432 } | 432 } |
433 | 433 |
434 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref
lection->mask(), style)); | 434 return CSSReflectValue::create(direction, offset, valueForNinePieceImage(ref
lection->mask(), style)); |
435 } | 435 } |
436 | 436 |
437 static ItemPosition resolveAlignmentAuto(ItemPosition position, const ComputedSt
yle* style) | 437 static CSSValueList* valueForItemPositionWithOverflowAlignment(const StyleSelfAl
ignmentData& data) |
438 { | |
439 if (position != ItemPositionAuto) | |
440 return position; | |
441 | |
442 if (!RuntimeEnabledFeatures::cssGridLayoutEnabled()) | |
443 return ItemPositionStretch; | |
444 | |
445 return isFlexOrGrid(style) ? ItemPositionStretch : ItemPositionStart; | |
446 } | |
447 | |
448 static CSSValueList* valueForItemPositionWithOverflowAlignment(ItemPosition item
Position, OverflowAlignment overflowAlignment, ItemPositionType positionType) | |
449 { | 438 { |
450 CSSValueList* result = CSSValueList::createSpaceSeparated(); | 439 CSSValueList* result = CSSValueList::createSpaceSeparated(); |
451 if (positionType == LegacyPosition) | 440 if (data.positionType() == LegacyPosition) |
452 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); | 441 result->append(*CSSPrimitiveValue::createIdentifier(CSSValueLegacy)); |
453 result->append(*CSSPrimitiveValue::create(itemPosition)); | 442 // To avoid needing to copy the RareNonInheritedData, we repurpose the 'auto
' flag to not just mean 'auto' prior to running the StyleAdjuster but also mean
'normal' after running it. |
454 if (itemPosition >= ItemPositionCenter && overflowAlignment != OverflowAlign
mentDefault) | 443 result->append(*CSSPrimitiveValue::create(data.position() == ItemPositionAut
o ? ItemPositionNormal : data.position())); |
455 result->append(*CSSPrimitiveValue::create(overflowAlignment)); | 444 if (data.position() >= ItemPositionCenter && data.overflow() != OverflowAlig
nmentDefault) |
| 445 result->append(*CSSPrimitiveValue::create(data.overflow())); |
456 ASSERT(result->length() <= 2); | 446 ASSERT(result->length() <= 2); |
457 return result; | 447 return result; |
458 } | 448 } |
459 | 449 |
460 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth
and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN
ode, bool allowVisitedStyle) | 450 static CSSValueList* valuesForGridShorthand(const StylePropertyShorthand& shorth
and, const ComputedStyle& style, const LayoutObject* layoutObject, Node* styledN
ode, bool allowVisitedStyle) |
461 { | 451 { |
462 CSSValueList* list = CSSValueList::createSlashSeparated(); | 452 CSSValueList* list = CSSValueList::createSlashSeparated(); |
463 for (size_t i = 0; i < shorthand.length(); ++i) { | 453 for (size_t i = 0; i < shorthand.length(); ++i) { |
464 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop
erties()[i], style, layoutObject, styledNode, allowVisitedStyle); | 454 const CSSValue* value = ComputedStyleCSSValueMapping::get(shorthand.prop
erties()[i], style, layoutObject, styledNode, allowVisitedStyle); |
465 ASSERT(value); | 455 ASSERT(value); |
(...skipping 1399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 } | 1855 } |
1866 case CSSPropertyDirection: | 1856 case CSSPropertyDirection: |
1867 return CSSPrimitiveValue::create(style.direction()); | 1857 return CSSPrimitiveValue::create(style.direction()); |
1868 case CSSPropertyDisplay: | 1858 case CSSPropertyDisplay: |
1869 return CSSPrimitiveValue::create(style.display()); | 1859 return CSSPrimitiveValue::create(style.display()); |
1870 case CSSPropertyEmptyCells: | 1860 case CSSPropertyEmptyCells: |
1871 return CSSPrimitiveValue::create(style.emptyCells()); | 1861 return CSSPrimitiveValue::create(style.emptyCells()); |
1872 case CSSPropertyAlignContent: | 1862 case CSSPropertyAlignContent: |
1873 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); | 1863 return valueForContentPositionAndDistributionWithOverflowAlignment(style
.alignContent()); |
1874 case CSSPropertyAlignItems: | 1864 case CSSPropertyAlignItems: |
1875 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.alignItemsPosition(), &style), style.alignItemsOverflowAlignment(), NonLegac
yPosition); | 1865 return valueForItemPositionWithOverflowAlignment(style.alignItems()); |
1876 case CSSPropertyAlignSelf: { | 1866 case CSSPropertyAlignSelf: |
1877 ItemPosition position = style.alignSelfPosition(); | 1867 return valueForItemPositionWithOverflowAlignment(style.alignSelf()); |
1878 if (position == ItemPositionAuto) { | |
1879 // TODO(lajava): This code doesn't work for ShadowDOM (see Node::par
entComputedStyle) | |
1880 const ComputedStyle* parentStyle = styledNode->parentNode() ? styled
Node->parentNode()->ensureComputedStyle() : nullptr; | |
1881 position = parentStyle ? ComputedStyle::resolveAlignment(*parentStyl
e, style, resolveAlignmentAuto(parentStyle->alignItemsPosition(), parentStyle))
: ItemPositionStart; | |
1882 } | |
1883 return valueForItemPositionWithOverflowAlignment(position, style.alignSe
lfOverflowAlignment(), NonLegacyPosition); | |
1884 } | |
1885 case CSSPropertyFlex: | 1868 case CSSPropertyFlex: |
1886 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); | 1869 return valuesForShorthandProperty(flexShorthand(), style, layoutObject,
styledNode, allowVisitedStyle); |
1887 case CSSPropertyFlexBasis: | 1870 case CSSPropertyFlexBasis: |
1888 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); | 1871 return zoomAdjustedPixelValueForLength(style.flexBasis(), style); |
1889 case CSSPropertyFlexDirection: | 1872 case CSSPropertyFlexDirection: |
1890 return CSSPrimitiveValue::create(style.flexDirection()); | 1873 return CSSPrimitiveValue::create(style.flexDirection()); |
1891 case CSSPropertyFlexFlow: | 1874 case CSSPropertyFlexFlow: |
1892 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); | 1875 return valuesForShorthandProperty(flexFlowShorthand(), style, layoutObje
ct, styledNode, allowVisitedStyle); |
1893 case CSSPropertyFlexGrow: | 1876 case CSSPropertyFlexGrow: |
1894 return CSSPrimitiveValue::create(style.flexGrow(), CSSPrimitiveValue::Un
itType::Number); | 1877 return CSSPrimitiveValue::create(style.flexGrow(), CSSPrimitiveValue::Un
itType::Number); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 return CSSStringValue::create(style.hyphenationString()); | 2012 return CSSStringValue::create(style.hyphenationString()); |
2030 case CSSPropertyImageRendering: | 2013 case CSSPropertyImageRendering: |
2031 return CSSPrimitiveValue::create(style.imageRendering()); | 2014 return CSSPrimitiveValue::create(style.imageRendering()); |
2032 case CSSPropertyImageOrientation: | 2015 case CSSPropertyImageOrientation: |
2033 if (style.respectImageOrientation() == RespectImageOrientation) | 2016 if (style.respectImageOrientation() == RespectImageOrientation) |
2034 return CSSPrimitiveValue::createIdentifier(CSSValueFromImage); | 2017 return CSSPrimitiveValue::createIdentifier(CSSValueFromImage); |
2035 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Degrees
); | 2018 return CSSPrimitiveValue::create(0, CSSPrimitiveValue::UnitType::Degrees
); |
2036 case CSSPropertyIsolation: | 2019 case CSSPropertyIsolation: |
2037 return CSSPrimitiveValue::create(style.isolation()); | 2020 return CSSPrimitiveValue::create(style.isolation()); |
2038 case CSSPropertyJustifyItems: | 2021 case CSSPropertyJustifyItems: |
2039 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifyItemsPosition(), &style), style.justifyItemsOverflowAlignment(), styl
e.justifyItemsPositionType()); | 2022 return valueForItemPositionWithOverflowAlignment(style.justifyItems()); |
2040 case CSSPropertyJustifySelf: { | 2023 case CSSPropertyJustifySelf: |
2041 Node* parent = styledNode->parentNode(); | 2024 return valueForItemPositionWithOverflowAlignment(style.justifySelf()); |
2042 return valueForItemPositionWithOverflowAlignment(resolveAlignmentAuto(st
yle.justifySelfPosition(), parent ? parent->ensureComputedStyle() : nullptr), st
yle.justifySelfOverflowAlignment(), NonLegacyPosition); | |
2043 } | |
2044 case CSSPropertyLeft: | 2025 case CSSPropertyLeft: |
2045 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); | 2026 return valueForPositionOffset(style, CSSPropertyLeft, layoutObject); |
2046 case CSSPropertyLetterSpacing: | 2027 case CSSPropertyLetterSpacing: |
2047 if (!style.letterSpacing()) | 2028 if (!style.letterSpacing()) |
2048 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); | 2029 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
2049 return zoomAdjustedPixelValue(style.letterSpacing(), style); | 2030 return zoomAdjustedPixelValue(style.letterSpacing(), style); |
2050 case CSSPropertyWebkitLineClamp: | 2031 case CSSPropertyWebkitLineClamp: |
2051 if (style.lineClamp().isNone()) | 2032 if (style.lineClamp().isNone()) |
2052 return CSSPrimitiveValue::createIdentifier(CSSValueNone); | 2033 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
2053 return CSSPrimitiveValue::create(style.lineClamp().value(), style.lineCl
amp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVal
ue::UnitType::Number); | 2034 return CSSPrimitiveValue::create(style.lineClamp().value(), style.lineCl
amp().isPercentage() ? CSSPrimitiveValue::UnitType::Percentage : CSSPrimitiveVal
ue::UnitType::Number); |
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3003 case CSSPropertyAll: | 2984 case CSSPropertyAll: |
3004 return nullptr; | 2985 return nullptr; |
3005 default: | 2986 default: |
3006 break; | 2987 break; |
3007 } | 2988 } |
3008 ASSERT_NOT_REACHED(); | 2989 ASSERT_NOT_REACHED(); |
3009 return nullptr; | 2990 return nullptr; |
3010 } | 2991 } |
3011 | 2992 |
3012 } // namespace blink | 2993 } // namespace blink |
OLD | NEW |