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

Side by Side Diff: Source/core/css/CSSComputedStyleDeclaration.cpp

Issue 82083002: Move viewport unit resolution to style recalc time (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: rebased Created 7 years 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 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 #include "core/css/Rect.h" 56 #include "core/css/Rect.h"
57 #include "core/css/RuntimeCSSEnabled.h" 57 #include "core/css/RuntimeCSSEnabled.h"
58 #include "core/css/StylePropertySet.h" 58 #include "core/css/StylePropertySet.h"
59 #include "core/css/resolver/StyleResolver.h" 59 #include "core/css/resolver/StyleResolver.h"
60 #include "core/dom/Document.h" 60 #include "core/dom/Document.h"
61 #include "core/dom/ExceptionCode.h" 61 #include "core/dom/ExceptionCode.h"
62 #include "core/dom/PseudoElement.h" 62 #include "core/dom/PseudoElement.h"
63 #include "core/frame/animation/AnimationController.h" 63 #include "core/frame/animation/AnimationController.h"
64 #include "core/rendering/RenderBox.h" 64 #include "core/rendering/RenderBox.h"
65 #include "core/rendering/RenderGrid.h" 65 #include "core/rendering/RenderGrid.h"
66 #include "core/rendering/RenderView.h"
67 #include "core/rendering/style/ContentData.h" 66 #include "core/rendering/style/ContentData.h"
68 #include "core/rendering/style/CounterContent.h" 67 #include "core/rendering/style/CounterContent.h"
69 #include "core/rendering/style/CursorList.h" 68 #include "core/rendering/style/CursorList.h"
70 #include "core/rendering/style/RenderStyle.h" 69 #include "core/rendering/style/RenderStyle.h"
71 #include "core/rendering/style/ShadowList.h" 70 #include "core/rendering/style/ShadowList.h"
72 #include "core/rendering/style/ShapeValue.h" 71 #include "core/rendering/style/ShapeValue.h"
73 #include "core/rendering/style/StyleCustomFilterProgram.h" 72 #include "core/rendering/style/StyleCustomFilterProgram.h"
74 #include "platform/fonts/FontFeatureSettings.h" 73 #include "platform/fonts/FontFeatureSettings.h"
75 #include "platform/graphics/filters/custom/CustomFilterArrayParameter.h" 74 #include "platform/graphics/filters/custom/CustomFilterArrayParameter.h"
76 #include "platform/graphics/filters/custom/CustomFilterNumberParameter.h" 75 #include "platform/graphics/filters/custom/CustomFilterNumberParameter.h"
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 } 607 }
609 positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), sty le)); 608 positionList->append(zoomAdjustedPixelValueForLength(layer->xPosition(), sty le));
610 if (layer->isBackgroundYOriginSet()) { 609 if (layer->isBackgroundYOriginSet()) {
611 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSP ropertyWebkitMaskPosition); 610 ASSERT(propertyID == CSSPropertyBackgroundPosition || propertyID == CSSP ropertyWebkitMaskPosition);
612 positionList->append(cssValuePool().createValue(layer->backgroundYOrigin ())); 611 positionList->append(cssValuePool().createValue(layer->backgroundYOrigin ()));
613 } 612 }
614 positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), sty le)); 613 positionList->append(zoomAdjustedPixelValueForLength(layer->yPosition(), sty le));
615 return positionList.release(); 614 return positionList.release();
616 } 615 }
617 616
618 static PassRefPtr<CSSValue> valueForPositionOffset(RenderStyle& style, CSSProper tyID propertyID, const RenderObject* renderer, RenderView* renderView) 617 static PassRefPtr<CSSValue> valueForPositionOffset(RenderStyle& style, CSSProper tyID propertyID, const RenderObject* renderer)
619 { 618 {
620 Length l; 619 Length l;
621 switch (propertyID) { 620 switch (propertyID) {
622 case CSSPropertyLeft: 621 case CSSPropertyLeft:
623 l = style.left(); 622 l = style.left();
624 break; 623 break;
625 case CSSPropertyRight: 624 case CSSPropertyRight:
626 l = style.right(); 625 l = style.right();
627 break; 626 break;
628 case CSSPropertyTop: 627 case CSSPropertyTop:
629 l = style.top(); 628 l = style.top();
630 break; 629 break;
631 case CSSPropertyBottom: 630 case CSSPropertyBottom:
632 l = style.bottom(); 631 l = style.bottom();
633 break; 632 break;
634 default: 633 default:
635 return 0; 634 return 0;
636 } 635 }
637 636
638 if (l.isPercent() && renderer && renderer->isBox()) { 637 if (l.isPercent() && renderer && renderer->isBox()) {
639 LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || prope rtyID == CSSPropertyRight) ? 638 LayoutUnit containingBlockSize = (propertyID == CSSPropertyLeft || prope rtyID == CSSPropertyRight) ?
640 toRenderBox(renderer)->containingBlockLogicalWidthForContent() : 639 toRenderBox(renderer)->containingBlockLogicalWidthForContent() :
641 toRenderBox(renderer)->containingBlockLogicalHeightForContent(Exclud eMarginBorderPadding); 640 toRenderBox(renderer)->containingBlockLogicalHeightForContent(Exclud eMarginBorderPadding);
642 return zoomAdjustedPixelValue(valueForLength(l, containingBlockSize, 0), style); 641 return zoomAdjustedPixelValue(valueForLength(l, containingBlockSize), st yle);
643 } 642 }
644 if (l.isViewportPercentage())
645 return zoomAdjustedPixelValue(valueForLength(l, 0, renderView), style);
646 if (l.isAuto()) { 643 if (l.isAuto()) {
647 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. 644 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined.
648 // In other words if left is auto and right is not auto, then left's com puted value is negative right(). 645 // In other words if left is auto and right is not auto, then left's com puted value is negative right().
649 // So we should get the opposite length unit and see if it is auto. 646 // So we should get the opposite length unit and see if it is auto.
650 return cssValuePool().createValue(l); 647 return cssValuePool().createValue(l);
651 } 648 }
652 649
653 return zoomAdjustedPixelValueForLength(l, style); 650 return zoomAdjustedPixelValueForLength(l, style);
654 } 651 }
655 652
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 default: 961 default:
965 filterValue = CSSFilterValue::create(CSSFilterValue::UnknownFilterOp eration); 962 filterValue = CSSFilterValue::create(CSSFilterValue::UnknownFilterOp eration);
966 break; 963 break;
967 } 964 }
968 list->append(filterValue.release()); 965 list->append(filterValue.release());
969 } 966 }
970 967
971 return list.release(); 968 return list.release();
972 } 969 }
973 970
974 static PassRefPtr<CSSValue> specifiedValueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle& style, RenderView* renderView) 971 static PassRefPtr<CSSValue> specifiedValueForGridTrackBreadth(const GridLength& trackBreadth, const RenderStyle& style)
975 { 972 {
976 if (!trackBreadth.isLength()) 973 if (!trackBreadth.isLength())
977 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR); 974 return cssValuePool().createValue(trackBreadth.flex(), CSSPrimitiveValue ::CSS_FR);
978 975
979 const Length& trackBreadthLength = trackBreadth.length(); 976 const Length& trackBreadthLength = trackBreadth.length();
980 if (trackBreadthLength.isAuto()) 977 if (trackBreadthLength.isAuto())
981 return cssValuePool().createIdentifierValue(CSSValueAuto); 978 return cssValuePool().createIdentifierValue(CSSValueAuto);
982 if (trackBreadthLength.isViewportPercentage())
983 return zoomAdjustedPixelValue(valueForLength(trackBreadthLength, 0, rend erView), style);
984 return zoomAdjustedPixelValueForLength(trackBreadthLength, style); 979 return zoomAdjustedPixelValueForLength(trackBreadthLength, style);
985 } 980 }
986 981
987 static PassRefPtr<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle& style, RenderView* renderView) 982 static PassRefPtr<CSSValue> specifiedValueForGridTrackSize(const GridTrackSize& trackSize, const RenderStyle& style)
988 { 983 {
989 switch (trackSize.type()) { 984 switch (trackSize.type()) {
990 case LengthTrackSizing: 985 case LengthTrackSizing:
991 return specifiedValueForGridTrackBreadth(trackSize.length(), style, rend erView); 986 return specifiedValueForGridTrackBreadth(trackSize.length(), style);
992 case MinMaxTrackSizing: 987 case MinMaxTrackSizing:
993 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated(); 988 RefPtr<CSSValueList> minMaxTrackBreadths = CSSValueList::createCommaSepa rated();
994 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize. minTrackBreadth(), style, renderView)); 989 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize. minTrackBreadth(), style));
995 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize. maxTrackBreadth(), style, renderView)); 990 minMaxTrackBreadths->append(specifiedValueForGridTrackBreadth(trackSize. maxTrackBreadth(), style));
996 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths); 991 return CSSFunctionValue::create("minmax(", minMaxTrackBreadths);
997 } 992 }
998 ASSERT_NOT_REACHED(); 993 ASSERT_NOT_REACHED();
999 return 0; 994 return 0;
1000 } 995 }
1001 996
1002 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list) 997 static void addValuesForNamedGridLinesAtIndex(const OrderedNamedGridLines& order edNamedGridLines, size_t i, CSSValueList& list)
1003 { 998 {
1004 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i); 999 const Vector<String>& namedGridLines = orderedNamedGridLines.get(i);
1005 if (namedGridLines.isEmpty()) 1000 if (namedGridLines.isEmpty())
1006 return; 1001 return;
1007 1002
1008 RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create(); 1003 RefPtr<CSSGridLineNamesValue> lineNames = CSSGridLineNamesValue::create();
1009 for (size_t j = 0; j < namedGridLines.size(); ++j) 1004 for (size_t j = 0; j < namedGridLines.size(); ++j)
1010 lineNames->append(cssValuePool().createValue(namedGridLines[j], CSSPrimi tiveValue::CSS_STRING)); 1005 lineNames->append(cssValuePool().createValue(namedGridLines[j], CSSPrimi tiveValue::CSS_STRING));
1011 list.append(lineNames.release()); 1006 list.append(lineNames.release());
1012 } 1007 }
1013 1008
1014 static PassRefPtr<CSSValue> valueForGridTrackList(GridTrackSizingDirection direc tion, RenderObject* renderer, const RenderStyle& style, RenderView* renderView) 1009 static PassRefPtr<CSSValue> valueForGridTrackList(GridTrackSizingDirection direc tion, RenderObject* renderer, const RenderStyle& style)
1015 { 1010 {
1016 const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style.gr idDefinitionColumns() : style.gridDefinitionRows(); 1011 const Vector<GridTrackSize>& trackSizes = direction == ForColumns ? style.gr idDefinitionColumns() : style.gridDefinitionRows();
1017 const OrderedNamedGridLines& orderedNamedGridLines = direction == ForColumns ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines(); 1012 const OrderedNamedGridLines& orderedNamedGridLines = direction == ForColumns ? style.orderedNamedGridColumnLines() : style.orderedNamedGridRowLines();
1018 1013
1019 // Handle the 'none' case here. 1014 // Handle the 'none' case here.
1020 if (!trackSizes.size()) { 1015 if (!trackSizes.size()) {
1021 ASSERT(orderedNamedGridLines.isEmpty()); 1016 ASSERT(orderedNamedGridLines.isEmpty());
1022 return cssValuePool().createIdentifierValue(CSSValueNone); 1017 return cssValuePool().createIdentifierValue(CSSValueNone);
1023 } 1018 }
1024 1019
1025 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 1020 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
1026 if (renderer && renderer->isRenderGrid()) { 1021 if (renderer && renderer->isRenderGrid()) {
1027 const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toR enderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions(); 1022 const Vector<LayoutUnit>& trackPositions = direction == ForColumns ? toR enderGrid(renderer)->columnPositions() : toRenderGrid(renderer)->rowPositions();
1028 // There are at least #tracks + 1 grid lines (trackPositions). Apart fro m that, the grid container can generate implicit grid tracks, 1023 // There are at least #tracks + 1 grid lines (trackPositions). Apart fro m that, the grid container can generate implicit grid tracks,
1029 // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid. 1024 // so we'll have more trackPositions than trackSizes as the latter only contain the explicit grid.
1030 ASSERT(trackPositions.size() - 1 >= trackSizes.size()); 1025 ASSERT(trackPositions.size() - 1 >= trackSizes.size());
1031 1026
1032 for (size_t i = 0; i < trackSizes.size(); ++i) { 1027 for (size_t i = 0; i < trackSizes.size(); ++i) {
1033 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list); 1028 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
1034 list->append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPos itions[i], style)); 1029 list->append(zoomAdjustedPixelValue(trackPositions[i + 1] - trackPos itions[i], style));
1035 } 1030 }
1036 } else { 1031 } else {
1037 for (size_t i = 0; i < trackSizes.size(); ++i) { 1032 for (size_t i = 0; i < trackSizes.size(); ++i) {
1038 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list); 1033 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, i, *list);
1039 list->append(specifiedValueForGridTrackSize(trackSizes[i], style, re nderView)); 1034 list->append(specifiedValueForGridTrackSize(trackSizes[i], style));
1040 } 1035 }
1041 } 1036 }
1042 // Those are the trailing <string>* allowed in the syntax. 1037 // Those are the trailing <string>* allowed in the syntax.
1043 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list); 1038 addValuesForNamedGridLinesAtIndex(orderedNamedGridLines, trackSizes.size(), *list);
1044 return list.release(); 1039 return list.release();
1045 } 1040 }
1046 1041
1047 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position) 1042 static PassRefPtr<CSSValue> valueForGridPosition(const GridPosition& position)
1048 { 1043 {
1049 if (position.isAuto()) 1044 if (position.isAuto())
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 1480
1486 static PassRefPtr<CSSValueList> valueForFontFamily(RenderStyle& style) 1481 static PassRefPtr<CSSValueList> valueForFontFamily(RenderStyle& style)
1487 { 1482 {
1488 const FontFamily& firstFamily = style.fontDescription().family(); 1483 const FontFamily& firstFamily = style.fontDescription().family();
1489 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); 1484 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
1490 for (const FontFamily* family = &firstFamily; family; family = family->next( )) 1485 for (const FontFamily* family = &firstFamily; family; family = family->next( ))
1491 list->append(valueForFamily(family->family())); 1486 list->append(valueForFamily(family->family()));
1492 return list.release(); 1487 return list.release();
1493 } 1488 }
1494 1489
1495 static PassRefPtr<CSSPrimitiveValue> valueForLineHeight(RenderStyle& style, Rend erView* renderView) 1490 static PassRefPtr<CSSPrimitiveValue> valueForLineHeight(RenderStyle& style)
1496 { 1491 {
1497 Length length = style.lineHeight(); 1492 Length length = style.lineHeight();
1498 if (length.isNegative()) 1493 if (length.isNegative())
1499 return cssValuePool().createIdentifierValue(CSSValueNormal); 1494 return cssValuePool().createIdentifierValue(CSSValueNormal);
1500 1495
1501 return zoomAdjustedPixelValue(floatValueForLength(length, style.fontDescript ion().specifiedSize(), renderView), style); 1496 return zoomAdjustedPixelValue(floatValueForLength(length, style.fontDescript ion().specifiedSize()), style);
1502 } 1497 }
1503 1498
1504 static PassRefPtr<CSSPrimitiveValue> valueForFontSize(RenderStyle& style) 1499 static PassRefPtr<CSSPrimitiveValue> valueForFontSize(RenderStyle& style)
1505 { 1500 {
1506 return zoomAdjustedPixelValue(style.fontDescription().computedPixelSize(), s tyle); 1501 return zoomAdjustedPixelValue(style.fontDescription().computedPixelSize(), s tyle);
1507 } 1502 }
1508 1503
1509 static PassRefPtr<CSSPrimitiveValue> valueForFontStyle(RenderStyle& style) 1504 static PassRefPtr<CSSPrimitiveValue> valueForFontStyle(RenderStyle& style)
1510 { 1505 {
1511 if (style.fontDescription().italic()) 1506 if (style.fontDescription().italic())
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
1848 return cssValuePool().createValue(style->borderLeftStyle()); 1843 return cssValuePool().createValue(style->borderLeftStyle());
1849 case CSSPropertyBorderTopWidth: 1844 case CSSPropertyBorderTopWidth:
1850 return zoomAdjustedPixelValue(style->borderTopWidth(), *style); 1845 return zoomAdjustedPixelValue(style->borderTopWidth(), *style);
1851 case CSSPropertyBorderRightWidth: 1846 case CSSPropertyBorderRightWidth:
1852 return zoomAdjustedPixelValue(style->borderRightWidth(), *style); 1847 return zoomAdjustedPixelValue(style->borderRightWidth(), *style);
1853 case CSSPropertyBorderBottomWidth: 1848 case CSSPropertyBorderBottomWidth:
1854 return zoomAdjustedPixelValue(style->borderBottomWidth(), *style); 1849 return zoomAdjustedPixelValue(style->borderBottomWidth(), *style);
1855 case CSSPropertyBorderLeftWidth: 1850 case CSSPropertyBorderLeftWidth:
1856 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style); 1851 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style);
1857 case CSSPropertyBottom: 1852 case CSSPropertyBottom:
1858 return valueForPositionOffset(*style, CSSPropertyBottom, renderer, m _node->document().renderView()); 1853 return valueForPositionOffset(*style, CSSPropertyBottom, renderer);
1859 case CSSPropertyWebkitBoxAlign: 1854 case CSSPropertyWebkitBoxAlign:
1860 return cssValuePool().createValue(style->boxAlign()); 1855 return cssValuePool().createValue(style->boxAlign());
1861 case CSSPropertyWebkitBoxDecorationBreak: 1856 case CSSPropertyWebkitBoxDecorationBreak:
1862 if (style->boxDecorationBreak() == DSLICE) 1857 if (style->boxDecorationBreak() == DSLICE)
1863 return cssValuePool().createIdentifierValue(CSSValueSlice); 1858 return cssValuePool().createIdentifierValue(CSSValueSlice);
1864 return cssValuePool().createIdentifierValue(CSSValueClone); 1859 return cssValuePool().createIdentifierValue(CSSValueClone);
1865 case CSSPropertyWebkitBoxDirection: 1860 case CSSPropertyWebkitBoxDirection:
1866 return cssValuePool().createValue(style->boxDirection()); 1861 return cssValuePool().createValue(style->boxDirection());
1867 case CSSPropertyWebkitBoxFlex: 1862 case CSSPropertyWebkitBoxFlex:
1868 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValu e::CSS_NUMBER); 1863 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValu e::CSS_NUMBER);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1986 case CSSPropertyFloat: 1981 case CSSPropertyFloat:
1987 if (style->display() != NONE && style->hasOutOfFlowPosition()) 1982 if (style->display() != NONE && style->hasOutOfFlowPosition())
1988 return cssValuePool().createIdentifierValue(CSSValueNone); 1983 return cssValuePool().createIdentifierValue(CSSValueNone);
1989 return cssValuePool().createValue(style->floating()); 1984 return cssValuePool().createValue(style->floating());
1990 case CSSPropertyFont: { 1985 case CSSPropertyFont: {
1991 RefPtr<CSSFontValue> computedFont = CSSFontValue::create(); 1986 RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
1992 computedFont->style = valueForFontStyle(*style); 1987 computedFont->style = valueForFontStyle(*style);
1993 computedFont->variant = valueForFontVariant(*style); 1988 computedFont->variant = valueForFontVariant(*style);
1994 computedFont->weight = valueForFontWeight(*style); 1989 computedFont->weight = valueForFontWeight(*style);
1995 computedFont->size = valueForFontSize(*style); 1990 computedFont->size = valueForFontSize(*style);
1996 computedFont->lineHeight = valueForLineHeight(*style, m_node->docume nt().renderView()); 1991 computedFont->lineHeight = valueForLineHeight(*style);
1997 computedFont->family = valueForFontFamily(*style); 1992 computedFont->family = valueForFontFamily(*style);
1998 return computedFont.release(); 1993 return computedFont.release();
1999 } 1994 }
2000 case CSSPropertyFontFamily: { 1995 case CSSPropertyFontFamily: {
2001 RefPtr<CSSValueList> fontFamilyList = valueForFontFamily(*style); 1996 RefPtr<CSSValueList> fontFamilyList = valueForFontFamily(*style);
2002 // If there's only a single family, return that as a CSSPrimitiveVal ue. 1997 // If there's only a single family, return that as a CSSPrimitiveVal ue.
2003 // NOTE: Gecko always returns this as a comma-separated CSSPrimitive Value string. 1998 // NOTE: Gecko always returns this as a comma-separated CSSPrimitive Value string.
2004 if (fontFamilyList->length() == 1) 1999 if (fontFamilyList->length() == 1)
2005 return fontFamilyList->item(0); 2000 return fontFamilyList->item(0);
2006 return fontFamilyList.release(); 2001 return fontFamilyList.release();
(...skipping 20 matching lines...) Expand all
2027 } 2022 }
2028 case CSSPropertyGridAutoFlow: 2023 case CSSPropertyGridAutoFlow:
2029 return cssValuePool().createValue(style->gridAutoFlow()); 2024 return cssValuePool().createValue(style->gridAutoFlow());
2030 2025
2031 // Specs mention that getComputedStyle() should return the used value of the property instead of the computed 2026 // Specs mention that getComputedStyle() should return the used value of the property instead of the computed
2032 // one for grid-definition-{rows|columns} but not for the grid-auto-{row s|columns} as things like 2027 // one for grid-definition-{rows|columns} but not for the grid-auto-{row s|columns} as things like
2033 // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as th e '2fr' means very different things 2028 // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as th e '2fr' means very different things
2034 // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See 2029 // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See
2035 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html 2030 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html
2036 case CSSPropertyGridAutoColumns: 2031 case CSSPropertyGridAutoColumns:
2037 return specifiedValueForGridTrackSize(style->gridAutoColumns(), *sty le, m_node->document().renderView()); 2032 return specifiedValueForGridTrackSize(style->gridAutoColumns(), *sty le);
2038 case CSSPropertyGridAutoRows: 2033 case CSSPropertyGridAutoRows:
2039 return specifiedValueForGridTrackSize(style->gridAutoRows(), *style, m_node->document().renderView()); 2034 return specifiedValueForGridTrackSize(style->gridAutoRows(), *style) ;
2040 2035
2041 case CSSPropertyGridDefinitionColumns: 2036 case CSSPropertyGridDefinitionColumns:
2042 return valueForGridTrackList(ForColumns, renderer, *style, m_node->d ocument().renderView()); 2037 return valueForGridTrackList(ForColumns, renderer, *style);
2043 case CSSPropertyGridDefinitionRows: 2038 case CSSPropertyGridDefinitionRows:
2044 return valueForGridTrackList(ForRows, renderer, *style, m_node->docu ment().renderView()); 2039 return valueForGridTrackList(ForRows, renderer, *style);
2045 2040
2046 case CSSPropertyGridColumnStart: 2041 case CSSPropertyGridColumnStart:
2047 return valueForGridPosition(style->gridColumnStart()); 2042 return valueForGridPosition(style->gridColumnStart());
2048 case CSSPropertyGridColumnEnd: 2043 case CSSPropertyGridColumnEnd:
2049 return valueForGridPosition(style->gridColumnEnd()); 2044 return valueForGridPosition(style->gridColumnEnd());
2050 case CSSPropertyGridRowStart: 2045 case CSSPropertyGridRowStart:
2051 return valueForGridPosition(style->gridRowStart()); 2046 return valueForGridPosition(style->gridRowStart());
2052 case CSSPropertyGridRowEnd: 2047 case CSSPropertyGridRowEnd:
2053 return valueForGridPosition(style->gridRowEnd()); 2048 return valueForGridPosition(style->gridRowEnd());
2054 case CSSPropertyGridColumn: 2049 case CSSPropertyGridColumn:
(...skipping 30 matching lines...) Expand all
2085 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); 2080 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING);
2086 case CSSPropertyWebkitBorderFit: 2081 case CSSPropertyWebkitBorderFit:
2087 if (style->borderFit() == BorderFitBorder) 2082 if (style->borderFit() == BorderFitBorder)
2088 return cssValuePool().createIdentifierValue(CSSValueBorder); 2083 return cssValuePool().createIdentifierValue(CSSValueBorder);
2089 return cssValuePool().createIdentifierValue(CSSValueLines); 2084 return cssValuePool().createIdentifierValue(CSSValueLines);
2090 case CSSPropertyImageRendering: 2085 case CSSPropertyImageRendering:
2091 return CSSPrimitiveValue::create(style->imageRendering()); 2086 return CSSPrimitiveValue::create(style->imageRendering());
2092 case CSSPropertyIsolation: 2087 case CSSPropertyIsolation:
2093 return cssValuePool().createValue(style->isolation()); 2088 return cssValuePool().createValue(style->isolation());
2094 case CSSPropertyLeft: 2089 case CSSPropertyLeft:
2095 return valueForPositionOffset(*style, CSSPropertyLeft, renderer, m_n ode->document().renderView()); 2090 return valueForPositionOffset(*style, CSSPropertyLeft, renderer);
2096 case CSSPropertyLetterSpacing: 2091 case CSSPropertyLetterSpacing:
2097 if (!style->letterSpacing()) 2092 if (!style->letterSpacing())
2098 return cssValuePool().createIdentifierValue(CSSValueNormal); 2093 return cssValuePool().createIdentifierValue(CSSValueNormal);
2099 return zoomAdjustedPixelValue(style->letterSpacing(), *style); 2094 return zoomAdjustedPixelValue(style->letterSpacing(), *style);
2100 case CSSPropertyWebkitLineClamp: 2095 case CSSPropertyWebkitLineClamp:
2101 if (style->lineClamp().isNone()) 2096 if (style->lineClamp().isNone())
2102 return cssValuePool().createIdentifierValue(CSSValueNone); 2097 return cssValuePool().createIdentifierValue(CSSValueNone);
2103 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); 2098 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER);
2104 case CSSPropertyLineHeight: 2099 case CSSPropertyLineHeight:
2105 return valueForLineHeight(*style, m_node->document().renderView()); 2100 return valueForLineHeight(*style);
2106 case CSSPropertyListStyleImage: 2101 case CSSPropertyListStyleImage:
2107 if (style->listStyleImage()) 2102 if (style->listStyleImage())
2108 return style->listStyleImage()->cssValue(); 2103 return style->listStyleImage()->cssValue();
2109 return cssValuePool().createIdentifierValue(CSSValueNone); 2104 return cssValuePool().createIdentifierValue(CSSValueNone);
2110 case CSSPropertyListStylePosition: 2105 case CSSPropertyListStylePosition:
2111 return cssValuePool().createValue(style->listStylePosition()); 2106 return cssValuePool().createValue(style->listStylePosition());
2112 case CSSPropertyListStyleType: 2107 case CSSPropertyListStyleType:
2113 return cssValuePool().createValue(style->listStyleType()); 2108 return cssValuePool().createValue(style->listStyleType());
2114 case CSSPropertyWebkitLocale: 2109 case CSSPropertyWebkitLocale:
2115 if (style->locale().isNull()) 2110 if (style->locale().isNull())
2116 return cssValuePool().createIdentifierValue(CSSValueAuto); 2111 return cssValuePool().createIdentifierValue(CSSValueAuto);
2117 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue ::CSS_STRING); 2112 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue ::CSS_STRING);
2118 case CSSPropertyMarginTop: { 2113 case CSSPropertyMarginTop: {
2119 Length marginTop = style->marginTop(); 2114 Length marginTop = style->marginTop();
2120 if (marginTop.isFixed() || !renderer || !renderer->isBox()) 2115 if (marginTop.isFixed() || !renderer || !renderer->isBox())
2121 return zoomAdjustedPixelValueForLength(marginTop, *style); 2116 return zoomAdjustedPixelValueForLength(marginTop, *style);
2122 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), *s tyle); 2117 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), *s tyle);
2123 } 2118 }
2124 case CSSPropertyMarginRight: { 2119 case CSSPropertyMarginRight: {
2125 Length marginRight = style->marginRight(); 2120 Length marginRight = style->marginRight();
2126 if (marginRight.isFixed() || !renderer || !renderer->isBox()) 2121 if (marginRight.isFixed() || !renderer || !renderer->isBox())
2127 return zoomAdjustedPixelValueForLength(marginRight, *style); 2122 return zoomAdjustedPixelValueForLength(marginRight, *style);
2128 float value; 2123 float value;
2129 if (marginRight.isPercent() || marginRight.isViewportPercentage()) { 2124 if (marginRight.isPercent()) {
2130 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box 2125 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2131 // and the right-edge of the containing box, when display == BLO CK. Let's calculate the absolute 2126 // and the right-edge of the containing box, when display == BLO CK. Let's calculate the absolute
2132 // value of the specified margin-right % instead of relying on R enderBox's marginRight() value. 2127 // value of the specified margin-right % instead of relying on R enderBox's marginRight() value.
2133 value = minimumValueForLength(marginRight, toRenderBox(renderer) ->containingBlockLogicalWidthForContent(), m_node->document().renderView()); 2128 value = minimumValueForLength(marginRight, toRenderBox(renderer) ->containingBlockLogicalWidthForContent());
2134 } else { 2129 } else {
2135 value = toRenderBox(renderer)->marginRight(); 2130 value = toRenderBox(renderer)->marginRight();
2136 } 2131 }
2137 return zoomAdjustedPixelValue(value, *style); 2132 return zoomAdjustedPixelValue(value, *style);
2138 } 2133 }
2139 case CSSPropertyMarginBottom: { 2134 case CSSPropertyMarginBottom: {
2140 Length marginBottom = style->marginBottom(); 2135 Length marginBottom = style->marginBottom();
2141 if (marginBottom.isFixed() || !renderer || !renderer->isBox()) 2136 if (marginBottom.isFixed() || !renderer || !renderer->isBox())
2142 return zoomAdjustedPixelValueForLength(marginBottom, *style); 2137 return zoomAdjustedPixelValueForLength(marginBottom, *style);
2143 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), *style); 2138 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), *style);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2235 case CSSPropertyPageBreakInside: { 2230 case CSSPropertyPageBreakInside: {
2236 EPageBreak pageBreak = style->pageBreakInside(); 2231 EPageBreak pageBreak = style->pageBreakInside();
2237 ASSERT(pageBreak != PBALWAYS); 2232 ASSERT(pageBreak != PBALWAYS);
2238 if (pageBreak == PBALWAYS) 2233 if (pageBreak == PBALWAYS)
2239 return 0; 2234 return 0;
2240 return cssValuePool().createValue(style->pageBreakInside()); 2235 return cssValuePool().createValue(style->pageBreakInside());
2241 } 2236 }
2242 case CSSPropertyPosition: 2237 case CSSPropertyPosition:
2243 return cssValuePool().createValue(style->position()); 2238 return cssValuePool().createValue(style->position());
2244 case CSSPropertyRight: 2239 case CSSPropertyRight:
2245 return valueForPositionOffset(*style, CSSPropertyRight, renderer, m_ node->document().renderView()); 2240 return valueForPositionOffset(*style, CSSPropertyRight, renderer);
2246 case CSSPropertyWebkitRubyPosition: 2241 case CSSPropertyWebkitRubyPosition:
2247 return cssValuePool().createValue(style->rubyPosition()); 2242 return cssValuePool().createValue(style->rubyPosition());
2248 case CSSPropertyTableLayout: 2243 case CSSPropertyTableLayout:
2249 return cssValuePool().createValue(style->tableLayout()); 2244 return cssValuePool().createValue(style->tableLayout());
2250 case CSSPropertyTextAlign: 2245 case CSSPropertyTextAlign:
2251 return cssValuePool().createValue(style->textAlign()); 2246 return cssValuePool().createValue(style->textAlign());
2252 case CSSPropertyTextAlignLast: 2247 case CSSPropertyTextAlignLast:
2253 return cssValuePool().createValue(style->textAlignLast()); 2248 return cssValuePool().createValue(style->textAlignLast());
2254 case CSSPropertyTextDecoration: 2249 case CSSPropertyTextDecoration:
2255 return valuesForShorthandProperty(textDecorationShorthand()); 2250 return valuesForShorthandProperty(textDecorationShorthand());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 return cssValuePool().createIdentifierValue(CSSValueClip); 2306 return cssValuePool().createIdentifierValue(CSSValueClip);
2312 case CSSPropertyWebkitTextSecurity: 2307 case CSSPropertyWebkitTextSecurity:
2313 return cssValuePool().createValue(style->textSecurity()); 2308 return cssValuePool().createValue(style->textSecurity());
2314 case CSSPropertyWebkitTextStrokeColor: 2309 case CSSPropertyWebkitTextStrokeColor:
2315 return currentColorOrValidColor(*style, style->textStrokeColor()); 2310 return currentColorOrValidColor(*style, style->textStrokeColor());
2316 case CSSPropertyWebkitTextStrokeWidth: 2311 case CSSPropertyWebkitTextStrokeWidth:
2317 return zoomAdjustedPixelValue(style->textStrokeWidth(), *style); 2312 return zoomAdjustedPixelValue(style->textStrokeWidth(), *style);
2318 case CSSPropertyTextTransform: 2313 case CSSPropertyTextTransform:
2319 return cssValuePool().createValue(style->textTransform()); 2314 return cssValuePool().createValue(style->textTransform());
2320 case CSSPropertyTop: 2315 case CSSPropertyTop:
2321 return valueForPositionOffset(*style, CSSPropertyTop, renderer, m_no de->document().renderView()); 2316 return valueForPositionOffset(*style, CSSPropertyTop, renderer);
2322 case CSSPropertyTouchAction: 2317 case CSSPropertyTouchAction:
2323 return cssValuePool().createValue(style->touchAction()); 2318 return cssValuePool().createValue(style->touchAction());
2324 case CSSPropertyTouchActionDelay: 2319 case CSSPropertyTouchActionDelay:
2325 return cssValuePool().createValue(style->touchActionDelay()); 2320 return cssValuePool().createValue(style->touchActionDelay());
2326 case CSSPropertyUnicodeBidi: 2321 case CSSPropertyUnicodeBidi:
2327 return cssValuePool().createValue(style->unicodeBidi()); 2322 return cssValuePool().createValue(style->unicodeBidi());
2328 case CSSPropertyVerticalAlign: 2323 case CSSPropertyVerticalAlign:
2329 switch (style->verticalAlign()) { 2324 switch (style->verticalAlign()) {
2330 case BASELINE: 2325 case BASELINE:
2331 return cssValuePool().createIdentifierValue(CSSValueBaseline ); 2326 return cssValuePool().createIdentifierValue(CSSValueBaseline );
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2577 if (!style->hasPerspective()) 2572 if (!style->hasPerspective())
2578 return cssValuePool().createIdentifierValue(CSSValueNone); 2573 return cssValuePool().createIdentifierValue(CSSValueNone);
2579 return zoomAdjustedPixelValue(style->perspective(), *style); 2574 return zoomAdjustedPixelValue(style->perspective(), *style);
2580 case CSSPropertyWebkitPerspectiveOrigin: { 2575 case CSSPropertyWebkitPerspectiveOrigin: {
2581 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 2576 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2582 if (renderer) { 2577 if (renderer) {
2583 LayoutRect box; 2578 LayoutRect box;
2584 if (renderer->isBox()) 2579 if (renderer->isBox())
2585 box = toRenderBox(renderer)->borderBoxRect(); 2580 box = toRenderBox(renderer)->borderBoxRect();
2586 2581
2587 RenderView* renderView = m_node->document().renderView(); 2582 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginX(), box.width()), *style));
2588 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginX(), box.width(), renderView), *style)); 2583 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginY(), box.height()), *style));
2589 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginY(), box.height(), renderView), *style));
2590 } 2584 }
2591 else { 2585 else {
2592 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginX(), *style)); 2586 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginX(), *style));
2593 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginY(), *style)); 2587 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginY(), *style));
2594 2588
2595 } 2589 }
2596 return list.release(); 2590 return list.release();
2597 } 2591 }
2598 case CSSPropertyWebkitRtlOrdering: 2592 case CSSPropertyWebkitRtlOrdering:
2599 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? C SSValueVisual : CSSValueLogical); 2593 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? C SSValueVisual : CSSValueLogical);
(...skipping 25 matching lines...) Expand all
2625 return cssValuePool().createValue(style->speak()); 2619 return cssValuePool().createValue(style->speak());
2626 case CSSPropertyWebkitTransform: 2620 case CSSPropertyWebkitTransform:
2627 return computedTransform(renderer, *style); 2621 return computedTransform(renderer, *style);
2628 case CSSPropertyWebkitTransformOrigin: { 2622 case CSSPropertyWebkitTransformOrigin: {
2629 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 2623 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2630 if (renderer) { 2624 if (renderer) {
2631 LayoutRect box; 2625 LayoutRect box;
2632 if (renderer->isBox()) 2626 if (renderer->isBox())
2633 box = toRenderBox(renderer)->borderBoxRect(); 2627 box = toRenderBox(renderer)->borderBoxRect();
2634 2628
2635 RenderView* renderView = m_node->document().renderView(); 2629 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginX(), box.width()), *style));
2636 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginX(), box.width(), renderView), *style)); 2630 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginY(), box.height()), *style));
2637 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginY(), box.height(), renderView), *style));
2638 if (style->transformOriginZ() != 0) 2631 if (style->transformOriginZ() != 0)
2639 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style)); 2632 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style));
2640 } else { 2633 } else {
2641 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginX(), *style)); 2634 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginX(), *style));
2642 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginY(), *style)); 2635 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginY(), *style));
2643 if (style->transformOriginZ() != 0) 2636 if (style->transformOriginZ() != 0)
2644 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style)); 2637 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style));
2645 } 2638 }
2646 return list.release(); 2639 return list.release();
2647 } 2640 }
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3234 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3227 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3235 CSSPropertyB ackgroundClip }; 3228 CSSPropertyB ackgroundClip };
3236 3229
3237 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3230 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3238 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator)))); 3231 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator))));
3239 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator)))); 3232 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator))));
3240 return list.release(); 3233 return list.release();
3241 } 3234 }
3242 3235
3243 } // namespace WebCore 3236 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698