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

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

Issue 1192983003: CSS Custom Properties (Variables) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: with missing files Created 5 years, 6 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #include "core/css/BasicShapeFunctions.h" 45 #include "core/css/BasicShapeFunctions.h"
46 #include "core/css/CSSCursorImageValue.h" 46 #include "core/css/CSSCursorImageValue.h"
47 #include "core/css/CSSGradientValue.h" 47 #include "core/css/CSSGradientValue.h"
48 #include "core/css/CSSGridTemplateAreasValue.h" 48 #include "core/css/CSSGridTemplateAreasValue.h"
49 #include "core/css/CSSHelper.h" 49 #include "core/css/CSSHelper.h"
50 #include "core/css/CSSImageSetValue.h" 50 #include "core/css/CSSImageSetValue.h"
51 #include "core/css/CSSLineBoxContainValue.h" 51 #include "core/css/CSSLineBoxContainValue.h"
52 #include "core/css/CSSPathValue.h" 52 #include "core/css/CSSPathValue.h"
53 #include "core/css/CSSPrimitiveValueMappings.h" 53 #include "core/css/CSSPrimitiveValueMappings.h"
54 #include "core/css/CSSPropertyMetadata.h" 54 #include "core/css/CSSPropertyMetadata.h"
55 #include "core/css/CSSReflectValue.h"
56 #include "core/css/CSSVariableValue.h"
55 #include "core/css/Counter.h" 57 #include "core/css/Counter.h"
56 #include "core/css/Pair.h" 58 #include "core/css/Pair.h"
57 #include "core/css/StylePropertySet.h" 59 #include "core/css/StylePropertySet.h"
58 #include "core/css/StyleRule.h" 60 #include "core/css/StyleRule.h"
61 #include "core/css/parser/CSSParser.h"
62 #include "core/css/parser/CSSParserTokenRange.h"
63 #include "core/css/parser/CSSPropertyParser.h"
64 #include "core/css/resolver/CSSVariableResolver.h"
59 #include "core/css/resolver/ElementStyleResources.h" 65 #include "core/css/resolver/ElementStyleResources.h"
60 #include "core/css/resolver/FilterOperationResolver.h" 66 #include "core/css/resolver/FilterOperationResolver.h"
61 #include "core/css/resolver/FontBuilder.h" 67 #include "core/css/resolver/FontBuilder.h"
62 #include "core/css/resolver/StyleBuilder.h" 68 #include "core/css/resolver/StyleBuilder.h"
63 #include "core/css/resolver/TransformBuilder.h" 69 #include "core/css/resolver/TransformBuilder.h"
64 #include "core/frame/LocalFrame.h" 70 #include "core/frame/LocalFrame.h"
65 #include "core/frame/Settings.h" 71 #include "core/frame/Settings.h"
66 #include "core/style/CounterContent.h" 72 #include "core/style/CounterContent.h"
67 #include "core/style/ComputedStyle.h" 73 #include "core/style/ComputedStyle.h"
68 #include "core/style/ComputedStyleConstants.h" 74 #include "core/style/ComputedStyleConstants.h"
(...skipping 28 matching lines...) Expand all
97 case CSSPropertyWebkitTextFillColor: 103 case CSSPropertyWebkitTextFillColor:
98 case CSSPropertyWebkitTextStrokeColor: 104 case CSSPropertyWebkitTextStrokeColor:
99 return true; 105 return true;
100 default: 106 default:
101 return false; 107 return false;
102 } 108 }
103 } 109 }
104 110
105 } // namespace 111 } // namespace
106 112
113 static bool hasVariableReference(CSSValue* value)
114 {
115 return value->isPrimitiveValue() && toCSSPrimitiveValue(value)->primitiveTyp e() == CSSPrimitiveValue::CSS_VARIABLE_REFERENCE;
116 }
117
107 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value) 118 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value)
108 { 119 {
120 if (RuntimeEnabledFeatures::cssVariablesEnabled() /*&& state.documentUsesCSS Variables()*/ && id != CSSPropertyVariable && hasVariableReference(value)) {
121 CSSVariableResolver::resolveAndApplyVariableReferences(state, id, toCSSP rimitiveValue(value));
122 return;
123 }
124
109 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa sn't expanded at parsing time", id); 125 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa sn't expanded at parsing time", id);
110 126
111 bool isInherit = state.parentNode() && value->isInheritedValue(); 127 bool isInherit = state.parentNode() && value->isInheritedValue();
112 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); 128 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue());
113 129
114 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit 130 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit
115 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle()) 131 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle())
116 132
117 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { 133 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) {
118 // Limit the properties that can be applied to only the ones honored by :visited. 134 // Limit the properties that can be applied to only the ones honored by :visited.
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value) 807 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value)
792 { 808 {
793 state.setWritingMode(*toCSSPrimitiveValue(value)); 809 state.setWritingMode(*toCSSPrimitiveValue(value));
794 } 810 }
795 811
796 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value) 812 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value)
797 { 813 {
798 state.setTextOrientation(*toCSSPrimitiveValue(value)); 814 state.setTextOrientation(*toCSSPrimitiveValue(value));
799 } 815 }
800 816
817 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st ate, CSSValue* value)
818 {
819 CSSVariableValue* varVal = toCSSVariableValue(value);
820 if (state.style()->variables()) {
821 switch (varVal->id()) {
822 case CSSValueInitial:
823 state.style()->variables()->removeVariable(varVal->name());
824 break;
825 case CSSValueInherit: {
826 StyleVariableData* parentVariables = state.parentStyle()->variables( );
827 if (!parentVariables)
828 return;
829 CSSVariableData* value = parentVariables->getVariable(varVal->name() );
830 if (!value)
831 return;
832 state.style()->variables()->setVariable(varVal->name(), value);
833 break;
834 }
835 case CSSValueInternalVariableValue:
836 state.style()->variables()->setVariable(varVal->name(), varVal->valu e());
837 break;
838 default:
839 ASSERT_NOT_REACHED();
840 }
841 } else if (varVal->id() == CSSValueInternalVariableValue) {
842 RefPtr<StyleVariableData> variableData = state.parentStyle()->variables( ) ? state.parentStyle()->variables()->copy() : StyleVariableData::create();
843 variableData->setVariable(varVal->name(), varVal->value());
844 state.style()->setVariables(variableData.release());
845 }
846 }
847
848 void StyleBuilderFunctions::applyInheritCSSPropertyVariable(StyleResolverState& state)
849 {
850 ASSERT_NOT_REACHED();
851 }
852
853 void StyleBuilderFunctions::applyInitialCSSPropertyVariable(StyleResolverState& state)
854 {
855 ASSERT_NOT_REACHED();
856 }
alancutter (OOO until 2018) 2015/06/26 06:56:08 Can we use the regular StyleBuilder machinery for
857
801 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state) 858 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state)
802 { 859 {
803 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); 860 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle();
804 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); 861 EBaselineShift baselineShift = parentSvgStyle.baselineShift();
805 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); 862 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle();
806 svgStyle.setBaselineShift(baselineShift); 863 svgStyle.setBaselineShift(baselineShift);
807 if (baselineShift == BS_LENGTH) 864 if (baselineShift == BS_LENGTH)
808 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); 865 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue());
809 } 866 }
810 867
(...skipping 16 matching lines...) Expand all
827 return; 884 return;
828 case CSSValueSuper: 885 case CSSValueSuper:
829 svgStyle.setBaselineShift(BS_SUPER); 886 svgStyle.setBaselineShift(BS_SUPER);
830 return; 887 return;
831 default: 888 default:
832 ASSERT_NOT_REACHED(); 889 ASSERT_NOT_REACHED();
833 } 890 }
834 } 891 }
835 892
836 } // namespace blink 893 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698