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

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

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Whoops, the forward declaration just needed to be moved. Created 5 years, 2 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com)
5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com)
6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org>
8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org>
9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved.
(...skipping 28 matching lines...) Expand all
39 #include "config.h" 39 #include "config.h"
40 40
41 #include "core/CSSPropertyNames.h" 41 #include "core/CSSPropertyNames.h"
42 #include "core/CSSValueKeywords.h" 42 #include "core/CSSValueKeywords.h"
43 #include "core/StyleBuilderFunctions.h" 43 #include "core/StyleBuilderFunctions.h"
44 #include "core/StylePropertyShorthand.h" 44 #include "core/StylePropertyShorthand.h"
45 #include "core/css/BasicShapeFunctions.h" 45 #include "core/css/BasicShapeFunctions.h"
46 #include "core/css/CSSBasicShapeValues.h" 46 #include "core/css/CSSBasicShapeValues.h"
47 #include "core/css/CSSCounterValue.h" 47 #include "core/css/CSSCounterValue.h"
48 #include "core/css/CSSCursorImageValue.h" 48 #include "core/css/CSSCursorImageValue.h"
49 #include "core/css/CSSCustomPropertyDeclaration.h"
49 #include "core/css/CSSFunctionValue.h" 50 #include "core/css/CSSFunctionValue.h"
50 #include "core/css/CSSGradientValue.h" 51 #include "core/css/CSSGradientValue.h"
51 #include "core/css/CSSGridTemplateAreasValue.h" 52 #include "core/css/CSSGridTemplateAreasValue.h"
52 #include "core/css/CSSHelper.h" 53 #include "core/css/CSSHelper.h"
53 #include "core/css/CSSImageSetValue.h" 54 #include "core/css/CSSImageSetValue.h"
54 #include "core/css/CSSPathValue.h" 55 #include "core/css/CSSPathValue.h"
55 #include "core/css/CSSPrimitiveValueMappings.h" 56 #include "core/css/CSSPrimitiveValueMappings.h"
56 #include "core/css/CSSPropertyMetadata.h" 57 #include "core/css/CSSPropertyMetadata.h"
57 #include "core/css/CSSURIValue.h" 58 #include "core/css/CSSURIValue.h"
58 #include "core/css/CSSValuePair.h" 59 #include "core/css/CSSValuePair.h"
60 #include "core/css/CSSVariableReferenceValue.h"
59 #include "core/css/StylePropertySet.h" 61 #include "core/css/StylePropertySet.h"
60 #include "core/css/StyleRule.h" 62 #include "core/css/StyleRule.h"
63 #include "core/css/resolver/CSSVariableResolver.h"
61 #include "core/css/resolver/ElementStyleResources.h" 64 #include "core/css/resolver/ElementStyleResources.h"
62 #include "core/css/resolver/FilterOperationResolver.h" 65 #include "core/css/resolver/FilterOperationResolver.h"
63 #include "core/css/resolver/FontBuilder.h" 66 #include "core/css/resolver/FontBuilder.h"
64 #include "core/css/resolver/StyleBuilder.h" 67 #include "core/css/resolver/StyleBuilder.h"
65 #include "core/css/resolver/TransformBuilder.h" 68 #include "core/css/resolver/TransformBuilder.h"
66 #include "core/frame/LocalFrame.h" 69 #include "core/frame/LocalFrame.h"
67 #include "core/frame/Settings.h" 70 #include "core/frame/Settings.h"
68 #include "core/style/CounterContent.h" 71 #include "core/style/CounterContent.h"
69 #include "core/style/ComputedStyle.h" 72 #include "core/style/ComputedStyle.h"
70 #include "core/style/ComputedStyleConstants.h" 73 #include "core/style/ComputedStyleConstants.h"
(...skipping 30 matching lines...) Expand all
101 return true; 104 return true;
102 default: 105 default:
103 return false; 106 return false;
104 } 107 }
105 } 108 }
106 109
107 } // namespace 110 } // namespace
108 111
109 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value) 112 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value)
110 { 113 {
114 if (RuntimeEnabledFeatures::cssVariablesEnabled() && id != CSSPropertyVariab le && value->isVariableReferenceValue()) {
115 CSSVariableResolver::resolveAndApplyVariableReferences(state, id, *toCSS VariableReferenceValue(value));
116 return;
117 }
118
111 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa sn't expanded at parsing time", id); 119 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa sn't expanded at parsing time", id);
112 120
113 bool isInherit = state.parentNode() && value->isInheritedValue(); 121 bool isInherit = state.parentNode() && value->isInheritedValue();
114 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); 122 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue());
115 123
116 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit 124 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
117 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle()) 125 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle())
118 126
119 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { 127 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) {
120 // Limit the properties that can be applied to only the ones honored by :visited. 128 // Limit the properties that can be applied to only the ones honored by :visited.
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation(StyleResolverSt ate& state, CSSValue* value) 819 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation(StyleResolverSt ate& state, CSSValue* value)
812 { 820 {
813 state.setTextOrientation(*toCSSPrimitiveValue(value)); 821 state.setTextOrientation(*toCSSPrimitiveValue(value));
814 } 822 }
815 823
816 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value) 824 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value)
817 { 825 {
818 state.setTextOrientation(*toCSSPrimitiveValue(value)); 826 state.setTextOrientation(*toCSSPrimitiveValue(value));
819 } 827 }
820 828
829 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st ate, CSSValue* value)
830 {
831 CSSCustomPropertyDeclaration* varVal = toCSSCustomPropertyDeclaration(value) ;
Timothy Loh 2015/10/15 03:43:48 varVal -> declaration?
832 switch (varVal->id()) {
833 case CSSValueInitial:
834 state.style()->removeVariable(varVal->name());
835 break;
836
837 case CSSValueUnset:
838 case CSSValueInherit: {
839 state.style()->removeVariable(varVal->name());
840 StyleVariableData* parentVariables = state.parentStyle()->variables();
841 if (!parentVariables)
842 return;
843 CSSVariableData* value = parentVariables->getVariable(varVal->name());
844 if (!value)
845 return;
846 state.style()->setVariable(varVal->name(), value);
847 break;
848 }
849 case CSSValueInternalVariableValue:
850 state.style()->setVariable(varVal->name(), varVal->value());
851 break;
852 default:
853 ASSERT_NOT_REACHED();
854 }
855 }
856
821 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state) 857 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state)
822 { 858 {
823 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); 859 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle();
824 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); 860 EBaselineShift baselineShift = parentSvgStyle.baselineShift();
825 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); 861 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle();
826 svgStyle.setBaselineShift(baselineShift); 862 svgStyle.setBaselineShift(baselineShift);
827 if (baselineShift == BS_LENGTH) 863 if (baselineShift == BS_LENGTH)
828 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); 864 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue());
829 } 865 }
830 866
(...skipping 16 matching lines...) Expand all
847 return; 883 return;
848 case CSSValueSuper: 884 case CSSValueSuper:
849 svgStyle.setBaselineShift(BS_SUPER); 885 svgStyle.setBaselineShift(BS_SUPER);
850 return; 886 return;
851 default: 887 default:
852 ASSERT_NOT_REACHED(); 888 ASSERT_NOT_REACHED();
853 } 889 }
854 } 890 }
855 891
856 } // namespace blink 892 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698