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

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: rename browser zoom to page zoom Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/core/css/CSSCalculationValueTest.cpp ('k') | Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1866 return cssValuePool().createValue(style->borderLeftStyle()); 1861 return cssValuePool().createValue(style->borderLeftStyle());
1867 case CSSPropertyBorderTopWidth: 1862 case CSSPropertyBorderTopWidth:
1868 return zoomAdjustedPixelValue(style->borderTopWidth(), *style); 1863 return zoomAdjustedPixelValue(style->borderTopWidth(), *style);
1869 case CSSPropertyBorderRightWidth: 1864 case CSSPropertyBorderRightWidth:
1870 return zoomAdjustedPixelValue(style->borderRightWidth(), *style); 1865 return zoomAdjustedPixelValue(style->borderRightWidth(), *style);
1871 case CSSPropertyBorderBottomWidth: 1866 case CSSPropertyBorderBottomWidth:
1872 return zoomAdjustedPixelValue(style->borderBottomWidth(), *style); 1867 return zoomAdjustedPixelValue(style->borderBottomWidth(), *style);
1873 case CSSPropertyBorderLeftWidth: 1868 case CSSPropertyBorderLeftWidth:
1874 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style); 1869 return zoomAdjustedPixelValue(style->borderLeftWidth(), *style);
1875 case CSSPropertyBottom: 1870 case CSSPropertyBottom:
1876 return valueForPositionOffset(*style, CSSPropertyBottom, renderer, m _node->document().renderView()); 1871 return valueForPositionOffset(*style, CSSPropertyBottom, renderer);
1877 case CSSPropertyWebkitBoxAlign: 1872 case CSSPropertyWebkitBoxAlign:
1878 return cssValuePool().createValue(style->boxAlign()); 1873 return cssValuePool().createValue(style->boxAlign());
1879 case CSSPropertyWebkitBoxDecorationBreak: 1874 case CSSPropertyWebkitBoxDecorationBreak:
1880 if (style->boxDecorationBreak() == DSLICE) 1875 if (style->boxDecorationBreak() == DSLICE)
1881 return cssValuePool().createIdentifierValue(CSSValueSlice); 1876 return cssValuePool().createIdentifierValue(CSSValueSlice);
1882 return cssValuePool().createIdentifierValue(CSSValueClone); 1877 return cssValuePool().createIdentifierValue(CSSValueClone);
1883 case CSSPropertyWebkitBoxDirection: 1878 case CSSPropertyWebkitBoxDirection:
1884 return cssValuePool().createValue(style->boxDirection()); 1879 return cssValuePool().createValue(style->boxDirection());
1885 case CSSPropertyWebkitBoxFlex: 1880 case CSSPropertyWebkitBoxFlex:
1886 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValu e::CSS_NUMBER); 1881 return cssValuePool().createValue(style->boxFlex(), CSSPrimitiveValu e::CSS_NUMBER);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 case CSSPropertyFloat: 1999 case CSSPropertyFloat:
2005 if (style->display() != NONE && style->hasOutOfFlowPosition()) 2000 if (style->display() != NONE && style->hasOutOfFlowPosition())
2006 return cssValuePool().createIdentifierValue(CSSValueNone); 2001 return cssValuePool().createIdentifierValue(CSSValueNone);
2007 return cssValuePool().createValue(style->floating()); 2002 return cssValuePool().createValue(style->floating());
2008 case CSSPropertyFont: { 2003 case CSSPropertyFont: {
2009 RefPtr<CSSFontValue> computedFont = CSSFontValue::create(); 2004 RefPtr<CSSFontValue> computedFont = CSSFontValue::create();
2010 computedFont->style = valueForFontStyle(*style); 2005 computedFont->style = valueForFontStyle(*style);
2011 computedFont->variant = valueForFontVariant(*style); 2006 computedFont->variant = valueForFontVariant(*style);
2012 computedFont->weight = valueForFontWeight(*style); 2007 computedFont->weight = valueForFontWeight(*style);
2013 computedFont->size = valueForFontSize(*style); 2008 computedFont->size = valueForFontSize(*style);
2014 computedFont->lineHeight = valueForLineHeight(*style, m_node->docume nt().renderView()); 2009 computedFont->lineHeight = valueForLineHeight(*style);
2015 computedFont->family = valueForFontFamily(*style); 2010 computedFont->family = valueForFontFamily(*style);
2016 return computedFont.release(); 2011 return computedFont.release();
2017 } 2012 }
2018 case CSSPropertyFontFamily: { 2013 case CSSPropertyFontFamily: {
2019 RefPtr<CSSValueList> fontFamilyList = valueForFontFamily(*style); 2014 RefPtr<CSSValueList> fontFamilyList = valueForFontFamily(*style);
2020 // If there's only a single family, return that as a CSSPrimitiveVal ue. 2015 // If there's only a single family, return that as a CSSPrimitiveVal ue.
2021 // NOTE: Gecko always returns this as a comma-separated CSSPrimitive Value string. 2016 // NOTE: Gecko always returns this as a comma-separated CSSPrimitive Value string.
2022 if (fontFamilyList->length() == 1) 2017 if (fontFamilyList->length() == 1)
2023 return fontFamilyList->item(0); 2018 return fontFamilyList->item(0);
2024 return fontFamilyList.release(); 2019 return fontFamilyList.release();
(...skipping 20 matching lines...) Expand all
2045 } 2040 }
2046 case CSSPropertyGridAutoFlow: 2041 case CSSPropertyGridAutoFlow:
2047 return cssValuePool().createValue(style->gridAutoFlow()); 2042 return cssValuePool().createValue(style->gridAutoFlow());
2048 2043
2049 // Specs mention that getComputedStyle() should return the used value of the property instead of the computed 2044 // Specs mention that getComputedStyle() should return the used value of the property instead of the computed
2050 // one for grid-definition-{rows|columns} but not for the grid-auto-{row s|columns} as things like 2045 // one for grid-definition-{rows|columns} but not for the grid-auto-{row s|columns} as things like
2051 // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as th e '2fr' means very different things 2046 // grid-auto-columns: 2fr; cannot be resolved to a value in pixels as th e '2fr' means very different things
2052 // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See 2047 // depending on the size of the explicit grid or the number of implicit tracks added to the grid. See
2053 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html 2048 // http://lists.w3.org/Archives/Public/www-style/2013Nov/0014.html
2054 case CSSPropertyGridAutoColumns: 2049 case CSSPropertyGridAutoColumns:
2055 return specifiedValueForGridTrackSize(style->gridAutoColumns(), *sty le, m_node->document().renderView()); 2050 return specifiedValueForGridTrackSize(style->gridAutoColumns(), *sty le);
2056 case CSSPropertyGridAutoRows: 2051 case CSSPropertyGridAutoRows:
2057 return specifiedValueForGridTrackSize(style->gridAutoRows(), *style, m_node->document().renderView()); 2052 return specifiedValueForGridTrackSize(style->gridAutoRows(), *style) ;
2058 2053
2059 case CSSPropertyGridDefinitionColumns: 2054 case CSSPropertyGridDefinitionColumns:
2060 return valueForGridTrackList(ForColumns, renderer, *style, m_node->d ocument().renderView()); 2055 return valueForGridTrackList(ForColumns, renderer, *style);
2061 case CSSPropertyGridDefinitionRows: 2056 case CSSPropertyGridDefinitionRows:
2062 return valueForGridTrackList(ForRows, renderer, *style, m_node->docu ment().renderView()); 2057 return valueForGridTrackList(ForRows, renderer, *style);
2063 2058
2064 case CSSPropertyGridColumnStart: 2059 case CSSPropertyGridColumnStart:
2065 return valueForGridPosition(style->gridColumnStart()); 2060 return valueForGridPosition(style->gridColumnStart());
2066 case CSSPropertyGridColumnEnd: 2061 case CSSPropertyGridColumnEnd:
2067 return valueForGridPosition(style->gridColumnEnd()); 2062 return valueForGridPosition(style->gridColumnEnd());
2068 case CSSPropertyGridRowStart: 2063 case CSSPropertyGridRowStart:
2069 return valueForGridPosition(style->gridRowStart()); 2064 return valueForGridPosition(style->gridRowStart());
2070 case CSSPropertyGridRowEnd: 2065 case CSSPropertyGridRowEnd:
2071 return valueForGridPosition(style->gridRowEnd()); 2066 return valueForGridPosition(style->gridRowEnd());
2072 case CSSPropertyGridColumn: 2067 case CSSPropertyGridColumn:
(...skipping 30 matching lines...) Expand all
2103 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING); 2098 return cssValuePool().createValue(style->hyphenationString(), CSSPri mitiveValue::CSS_STRING);
2104 case CSSPropertyWebkitBorderFit: 2099 case CSSPropertyWebkitBorderFit:
2105 if (style->borderFit() == BorderFitBorder) 2100 if (style->borderFit() == BorderFitBorder)
2106 return cssValuePool().createIdentifierValue(CSSValueBorder); 2101 return cssValuePool().createIdentifierValue(CSSValueBorder);
2107 return cssValuePool().createIdentifierValue(CSSValueLines); 2102 return cssValuePool().createIdentifierValue(CSSValueLines);
2108 case CSSPropertyImageRendering: 2103 case CSSPropertyImageRendering:
2109 return CSSPrimitiveValue::create(style->imageRendering()); 2104 return CSSPrimitiveValue::create(style->imageRendering());
2110 case CSSPropertyIsolation: 2105 case CSSPropertyIsolation:
2111 return cssValuePool().createValue(style->isolation()); 2106 return cssValuePool().createValue(style->isolation());
2112 case CSSPropertyLeft: 2107 case CSSPropertyLeft:
2113 return valueForPositionOffset(*style, CSSPropertyLeft, renderer, m_n ode->document().renderView()); 2108 return valueForPositionOffset(*style, CSSPropertyLeft, renderer);
2114 case CSSPropertyLetterSpacing: 2109 case CSSPropertyLetterSpacing:
2115 if (!style->letterSpacing()) 2110 if (!style->letterSpacing())
2116 return cssValuePool().createIdentifierValue(CSSValueNormal); 2111 return cssValuePool().createIdentifierValue(CSSValueNormal);
2117 return zoomAdjustedPixelValue(style->letterSpacing(), *style); 2112 return zoomAdjustedPixelValue(style->letterSpacing(), *style);
2118 case CSSPropertyWebkitLineClamp: 2113 case CSSPropertyWebkitLineClamp:
2119 if (style->lineClamp().isNone()) 2114 if (style->lineClamp().isNone())
2120 return cssValuePool().createIdentifierValue(CSSValueNone); 2115 return cssValuePool().createIdentifierValue(CSSValueNone);
2121 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER); 2116 return cssValuePool().createValue(style->lineClamp().value(), style- >lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveVa lue::CSS_NUMBER);
2122 case CSSPropertyLineHeight: 2117 case CSSPropertyLineHeight:
2123 return valueForLineHeight(*style, m_node->document().renderView()); 2118 return valueForLineHeight(*style);
2124 case CSSPropertyListStyleImage: 2119 case CSSPropertyListStyleImage:
2125 if (style->listStyleImage()) 2120 if (style->listStyleImage())
2126 return style->listStyleImage()->cssValue(); 2121 return style->listStyleImage()->cssValue();
2127 return cssValuePool().createIdentifierValue(CSSValueNone); 2122 return cssValuePool().createIdentifierValue(CSSValueNone);
2128 case CSSPropertyListStylePosition: 2123 case CSSPropertyListStylePosition:
2129 return cssValuePool().createValue(style->listStylePosition()); 2124 return cssValuePool().createValue(style->listStylePosition());
2130 case CSSPropertyListStyleType: 2125 case CSSPropertyListStyleType:
2131 return cssValuePool().createValue(style->listStyleType()); 2126 return cssValuePool().createValue(style->listStyleType());
2132 case CSSPropertyWebkitLocale: 2127 case CSSPropertyWebkitLocale:
2133 if (style->locale().isNull()) 2128 if (style->locale().isNull())
2134 return cssValuePool().createIdentifierValue(CSSValueAuto); 2129 return cssValuePool().createIdentifierValue(CSSValueAuto);
2135 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue ::CSS_STRING); 2130 return cssValuePool().createValue(style->locale(), CSSPrimitiveValue ::CSS_STRING);
2136 case CSSPropertyMarginTop: { 2131 case CSSPropertyMarginTop: {
2137 Length marginTop = style->marginTop(); 2132 Length marginTop = style->marginTop();
2138 if (marginTop.isFixed() || !renderer || !renderer->isBox()) 2133 if (marginTop.isFixed() || !renderer || !renderer->isBox())
2139 return zoomAdjustedPixelValueForLength(marginTop, *style); 2134 return zoomAdjustedPixelValueForLength(marginTop, *style);
2140 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), *s tyle); 2135 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginTop(), *s tyle);
2141 } 2136 }
2142 case CSSPropertyMarginRight: { 2137 case CSSPropertyMarginRight: {
2143 Length marginRight = style->marginRight(); 2138 Length marginRight = style->marginRight();
2144 if (marginRight.isFixed() || !renderer || !renderer->isBox()) 2139 if (marginRight.isFixed() || !renderer || !renderer->isBox())
2145 return zoomAdjustedPixelValueForLength(marginRight, *style); 2140 return zoomAdjustedPixelValueForLength(marginRight, *style);
2146 float value; 2141 float value;
2147 if (marginRight.isPercent() || marginRight.isViewportPercentage()) { 2142 if (marginRight.isPercent()) {
2148 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box 2143 // RenderBox gives a marginRight() that is the distance between the right-edge of the child box
2149 // and the right-edge of the containing box, when display == BLO CK. Let's calculate the absolute 2144 // and the right-edge of the containing box, when display == BLO CK. Let's calculate the absolute
2150 // value of the specified margin-right % instead of relying on R enderBox's marginRight() value. 2145 // value of the specified margin-right % instead of relying on R enderBox's marginRight() value.
2151 value = minimumValueForLength(marginRight, toRenderBox(renderer) ->containingBlockLogicalWidthForContent(), m_node->document().renderView()); 2146 value = minimumValueForLength(marginRight, toRenderBox(renderer) ->containingBlockLogicalWidthForContent());
2152 } else { 2147 } else {
2153 value = toRenderBox(renderer)->marginRight(); 2148 value = toRenderBox(renderer)->marginRight();
2154 } 2149 }
2155 return zoomAdjustedPixelValue(value, *style); 2150 return zoomAdjustedPixelValue(value, *style);
2156 } 2151 }
2157 case CSSPropertyMarginBottom: { 2152 case CSSPropertyMarginBottom: {
2158 Length marginBottom = style->marginBottom(); 2153 Length marginBottom = style->marginBottom();
2159 if (marginBottom.isFixed() || !renderer || !renderer->isBox()) 2154 if (marginBottom.isFixed() || !renderer || !renderer->isBox())
2160 return zoomAdjustedPixelValueForLength(marginBottom, *style); 2155 return zoomAdjustedPixelValueForLength(marginBottom, *style);
2161 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), *style); 2156 return zoomAdjustedPixelValue(toRenderBox(renderer)->marginBottom(), *style);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
2253 case CSSPropertyPageBreakInside: { 2248 case CSSPropertyPageBreakInside: {
2254 EPageBreak pageBreak = style->pageBreakInside(); 2249 EPageBreak pageBreak = style->pageBreakInside();
2255 ASSERT(pageBreak != PBALWAYS); 2250 ASSERT(pageBreak != PBALWAYS);
2256 if (pageBreak == PBALWAYS) 2251 if (pageBreak == PBALWAYS)
2257 return 0; 2252 return 0;
2258 return cssValuePool().createValue(style->pageBreakInside()); 2253 return cssValuePool().createValue(style->pageBreakInside());
2259 } 2254 }
2260 case CSSPropertyPosition: 2255 case CSSPropertyPosition:
2261 return cssValuePool().createValue(style->position()); 2256 return cssValuePool().createValue(style->position());
2262 case CSSPropertyRight: 2257 case CSSPropertyRight:
2263 return valueForPositionOffset(*style, CSSPropertyRight, renderer, m_ node->document().renderView()); 2258 return valueForPositionOffset(*style, CSSPropertyRight, renderer);
2264 case CSSPropertyWebkitRubyPosition: 2259 case CSSPropertyWebkitRubyPosition:
2265 return cssValuePool().createValue(style->rubyPosition()); 2260 return cssValuePool().createValue(style->rubyPosition());
2266 case CSSPropertyTableLayout: 2261 case CSSPropertyTableLayout:
2267 return cssValuePool().createValue(style->tableLayout()); 2262 return cssValuePool().createValue(style->tableLayout());
2268 case CSSPropertyTextAlign: 2263 case CSSPropertyTextAlign:
2269 return cssValuePool().createValue(style->textAlign()); 2264 return cssValuePool().createValue(style->textAlign());
2270 case CSSPropertyTextAlignLast: 2265 case CSSPropertyTextAlignLast:
2271 return cssValuePool().createValue(style->textAlignLast()); 2266 return cssValuePool().createValue(style->textAlignLast());
2272 case CSSPropertyTextDecoration: 2267 case CSSPropertyTextDecoration:
2273 return valuesForShorthandProperty(textDecorationShorthand()); 2268 return valuesForShorthandProperty(textDecorationShorthand());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 return cssValuePool().createIdentifierValue(CSSValueClip); 2324 return cssValuePool().createIdentifierValue(CSSValueClip);
2330 case CSSPropertyWebkitTextSecurity: 2325 case CSSPropertyWebkitTextSecurity:
2331 return cssValuePool().createValue(style->textSecurity()); 2326 return cssValuePool().createValue(style->textSecurity());
2332 case CSSPropertyWebkitTextStrokeColor: 2327 case CSSPropertyWebkitTextStrokeColor:
2333 return currentColorOrValidColor(*style, style->textStrokeColor()); 2328 return currentColorOrValidColor(*style, style->textStrokeColor());
2334 case CSSPropertyWebkitTextStrokeWidth: 2329 case CSSPropertyWebkitTextStrokeWidth:
2335 return zoomAdjustedPixelValue(style->textStrokeWidth(), *style); 2330 return zoomAdjustedPixelValue(style->textStrokeWidth(), *style);
2336 case CSSPropertyTextTransform: 2331 case CSSPropertyTextTransform:
2337 return cssValuePool().createValue(style->textTransform()); 2332 return cssValuePool().createValue(style->textTransform());
2338 case CSSPropertyTop: 2333 case CSSPropertyTop:
2339 return valueForPositionOffset(*style, CSSPropertyTop, renderer, m_no de->document().renderView()); 2334 return valueForPositionOffset(*style, CSSPropertyTop, renderer);
2340 case CSSPropertyTouchAction: 2335 case CSSPropertyTouchAction:
2341 return touchActionFlagsToCSSValue(style->touchAction()); 2336 return touchActionFlagsToCSSValue(style->touchAction());
2342 case CSSPropertyTouchActionDelay: 2337 case CSSPropertyTouchActionDelay:
2343 return cssValuePool().createValue(style->touchActionDelay()); 2338 return cssValuePool().createValue(style->touchActionDelay());
2344 case CSSPropertyUnicodeBidi: 2339 case CSSPropertyUnicodeBidi:
2345 return cssValuePool().createValue(style->unicodeBidi()); 2340 return cssValuePool().createValue(style->unicodeBidi());
2346 case CSSPropertyVerticalAlign: 2341 case CSSPropertyVerticalAlign:
2347 switch (style->verticalAlign()) { 2342 switch (style->verticalAlign()) {
2348 case BASELINE: 2343 case BASELINE:
2349 return cssValuePool().createIdentifierValue(CSSValueBaseline ); 2344 return cssValuePool().createIdentifierValue(CSSValueBaseline );
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
2595 if (!style->hasPerspective()) 2590 if (!style->hasPerspective())
2596 return cssValuePool().createIdentifierValue(CSSValueNone); 2591 return cssValuePool().createIdentifierValue(CSSValueNone);
2597 return zoomAdjustedPixelValue(style->perspective(), *style); 2592 return zoomAdjustedPixelValue(style->perspective(), *style);
2598 case CSSPropertyWebkitPerspectiveOrigin: { 2593 case CSSPropertyWebkitPerspectiveOrigin: {
2599 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 2594 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2600 if (renderer) { 2595 if (renderer) {
2601 LayoutRect box; 2596 LayoutRect box;
2602 if (renderer->isBox()) 2597 if (renderer->isBox())
2603 box = toRenderBox(renderer)->borderBoxRect(); 2598 box = toRenderBox(renderer)->borderBoxRect();
2604 2599
2605 RenderView* renderView = m_node->document().renderView(); 2600 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginX(), box.width()), *style));
2606 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginX(), box.width(), renderView), *style)); 2601 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginY(), box.height()), *style));
2607 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >perspectiveOriginY(), box.height(), renderView), *style));
2608 } 2602 }
2609 else { 2603 else {
2610 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginX(), *style)); 2604 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginX(), *style));
2611 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginY(), *style)); 2605 list->append(zoomAdjustedPixelValueForLength(style->perspectiveO riginY(), *style));
2612 2606
2613 } 2607 }
2614 return list.release(); 2608 return list.release();
2615 } 2609 }
2616 case CSSPropertyWebkitRtlOrdering: 2610 case CSSPropertyWebkitRtlOrdering:
2617 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? C SSValueVisual : CSSValueLogical); 2611 return cssValuePool().createIdentifierValue(style->rtlOrdering() ? C SSValueVisual : CSSValueLogical);
(...skipping 25 matching lines...) Expand all
2643 return cssValuePool().createValue(style->speak()); 2637 return cssValuePool().createValue(style->speak());
2644 case CSSPropertyWebkitTransform: 2638 case CSSPropertyWebkitTransform:
2645 return computedTransform(renderer, *style); 2639 return computedTransform(renderer, *style);
2646 case CSSPropertyWebkitTransformOrigin: { 2640 case CSSPropertyWebkitTransformOrigin: {
2647 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 2641 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
2648 if (renderer) { 2642 if (renderer) {
2649 LayoutRect box; 2643 LayoutRect box;
2650 if (renderer->isBox()) 2644 if (renderer->isBox())
2651 box = toRenderBox(renderer)->borderBoxRect(); 2645 box = toRenderBox(renderer)->borderBoxRect();
2652 2646
2653 RenderView* renderView = m_node->document().renderView(); 2647 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginX(), box.width()), *style));
2654 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginX(), box.width(), renderView), *style)); 2648 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginY(), box.height()), *style));
2655 list->append(zoomAdjustedPixelValue(minimumValueForLength(style- >transformOriginY(), box.height(), renderView), *style));
2656 if (style->transformOriginZ() != 0) 2649 if (style->transformOriginZ() != 0)
2657 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style)); 2650 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style));
2658 } else { 2651 } else {
2659 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginX(), *style)); 2652 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginX(), *style));
2660 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginY(), *style)); 2653 list->append(zoomAdjustedPixelValueForLength(style->transformOri ginY(), *style));
2661 if (style->transformOriginZ() != 0) 2654 if (style->transformOriginZ() != 0)
2662 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style)); 2655 list->append(zoomAdjustedPixelValue(style->transformOriginZ( ), *style));
2663 } 2656 }
2664 return list.release(); 2657 return list.release();
2665 } 2658 }
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin, 3245 static const CSSPropertyID propertiesAfterSlashSeperator[3] = { CSSPropertyB ackgroundSize, CSSPropertyBackgroundOrigin,
3253 CSSPropertyB ackgroundClip }; 3246 CSSPropertyB ackgroundClip };
3254 3247
3255 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); 3248 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
3256 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator)))); 3249 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesBeforeSlashSeperator, WTF_ARRAY_LENGTH(propertiesBeforeSlash Seperator))));
3257 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator)))); 3250 list->append(valuesForShorthandProperty(StylePropertyShorthand(CSSPropertyBa ckground, propertiesAfterSlashSeperator, WTF_ARRAY_LENGTH(propertiesAfterSlashSe perator))));
3258 return list.release(); 3251 return list.release();
3259 } 3252 }
3260 3253
3261 } // namespace WebCore 3254 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/CSSCalculationValueTest.cpp ('k') | Source/core/css/CSSGradientValue.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698