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

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

Powered by Google App Engine
This is Rietveld 408576698