OLD | NEW |
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 27 matching lines...) Expand all Loading... |
38 | 38 |
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/CSSCounterValue.h" | 46 #include "core/css/CSSCounterValue.h" |
47 #include "core/css/CSSCursorImageValue.h" | 47 #include "core/css/CSSCursorImageValue.h" |
| 48 #include "core/css/CSSCustomPropertyDeclaration.h" |
48 #include "core/css/CSSFunctionValue.h" | 49 #include "core/css/CSSFunctionValue.h" |
49 #include "core/css/CSSGradientValue.h" | 50 #include "core/css/CSSGradientValue.h" |
50 #include "core/css/CSSGridTemplateAreasValue.h" | 51 #include "core/css/CSSGridTemplateAreasValue.h" |
51 #include "core/css/CSSHelper.h" | 52 #include "core/css/CSSHelper.h" |
52 #include "core/css/CSSImageSetValue.h" | 53 #include "core/css/CSSImageSetValue.h" |
53 #include "core/css/CSSPathValue.h" | 54 #include "core/css/CSSPathValue.h" |
54 #include "core/css/CSSPrimitiveValueMappings.h" | 55 #include "core/css/CSSPrimitiveValueMappings.h" |
55 #include "core/css/CSSPropertyMetadata.h" | 56 #include "core/css/CSSPropertyMetadata.h" |
56 #include "core/css/CSSValuePair.h" | 57 #include "core/css/CSSValuePair.h" |
57 #include "core/css/StylePropertySet.h" | 58 #include "core/css/StylePropertySet.h" |
58 #include "core/css/StyleRule.h" | 59 #include "core/css/StyleRule.h" |
| 60 #include "core/css/resolver/CSSVariableResolver.h" |
59 #include "core/css/resolver/ElementStyleResources.h" | 61 #include "core/css/resolver/ElementStyleResources.h" |
60 #include "core/css/resolver/FilterOperationResolver.h" | 62 #include "core/css/resolver/FilterOperationResolver.h" |
61 #include "core/css/resolver/FontBuilder.h" | 63 #include "core/css/resolver/FontBuilder.h" |
62 #include "core/css/resolver/StyleBuilder.h" | 64 #include "core/css/resolver/StyleBuilder.h" |
63 #include "core/css/resolver/TransformBuilder.h" | 65 #include "core/css/resolver/TransformBuilder.h" |
64 #include "core/frame/LocalFrame.h" | 66 #include "core/frame/LocalFrame.h" |
65 #include "core/frame/Settings.h" | 67 #include "core/frame/Settings.h" |
66 #include "core/style/CounterContent.h" | 68 #include "core/style/CounterContent.h" |
67 #include "core/style/ComputedStyle.h" | 69 #include "core/style/ComputedStyle.h" |
68 #include "core/style/ComputedStyleConstants.h" | 70 #include "core/style/ComputedStyleConstants.h" |
(...skipping 30 matching lines...) Expand all Loading... |
99 return true; | 101 return true; |
100 default: | 102 default: |
101 return false; | 103 return false; |
102 } | 104 } |
103 } | 105 } |
104 | 106 |
105 } // namespace | 107 } // namespace |
106 | 108 |
107 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
SValue* value) | 109 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
SValue* value) |
108 { | 110 { |
| 111 if (RuntimeEnabledFeatures::cssVariablesEnabled() && id != CSSPropertyVariab
le && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isVariableReferen
ce()) { |
| 112 CSSVariableResolver::resolveAndApplyVariableReferences(state, id, *toCSS
PrimitiveValue(value)); |
| 113 return; |
| 114 } |
| 115 |
109 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa
sn't expanded at parsing time", id); | 116 ASSERT_WITH_MESSAGE(!isShorthandProperty(id), "Shorthand property id = %d wa
sn't expanded at parsing time", id); |
110 | 117 |
111 bool isInherit = state.parentNode() && value->isInheritedValue(); | 118 bool isInherit = state.parentNode() && value->isInheritedValue(); |
112 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i
sInheritedValue()); | 119 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i
sInheritedValue()); |
113 | 120 |
114 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial ->
!isInherit | 121 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial ->
!isInherit |
115 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe
rit -> (state.parentNode() && state.parentStyle()) | 122 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe
rit -> (state.parentNode() && state.parentStyle()) |
116 | 123 |
117 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi
nkStyle() || !isValidVisitedLinkProperty(id))) { | 124 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi
nkStyle() || !isValidVisitedLinkProperty(id))) { |
118 // Limit the properties that can be applied to only the ones honored by
:visited. | 125 // Limit the properties that can be applied to only the ones honored by
:visited. |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver
State& state, CSSValue* value) | 815 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver
State& state, CSSValue* value) |
809 { | 816 { |
810 state.setWritingMode(*toCSSPrimitiveValue(value)); | 817 state.setWritingMode(*toCSSPrimitiveValue(value)); |
811 } | 818 } |
812 | 819 |
813 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) | 820 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) |
814 { | 821 { |
815 state.setTextOrientation(*toCSSPrimitiveValue(value)); | 822 state.setTextOrientation(*toCSSPrimitiveValue(value)); |
816 } | 823 } |
817 | 824 |
| 825 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, CSSValue* value) |
| 826 { |
| 827 CSSCustomPropertyDeclaration* varVal = toCSSCustomPropertyDeclaration(value)
; |
| 828 switch (varVal->id()) { |
| 829 case CSSValueInitial: |
| 830 state.style()->removeVariable(varVal->name()); |
| 831 break; |
| 832 |
| 833 case CSSValueUnset: |
| 834 case CSSValueInherit: { |
| 835 state.style()->removeVariable(varVal->name()); |
| 836 StyleVariableData* parentVariables = state.parentStyle()->variables(); |
| 837 if (!parentVariables) |
| 838 return; |
| 839 CSSVariableData* value = parentVariables->getVariable(varVal->name()); |
| 840 if (!value) |
| 841 return; |
| 842 state.style()->setVariable(varVal->name(), value); |
| 843 break; |
| 844 } |
| 845 case CSSValueInternalVariableValue: |
| 846 state.style()->setVariable(varVal->name(), varVal->value()); |
| 847 break; |
| 848 default: |
| 849 ASSERT_NOT_REACHED(); |
| 850 } |
| 851 } |
| 852 |
818 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) | 853 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) |
819 { | 854 { |
820 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); | 855 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |
821 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); | 856 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); |
822 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); | 857 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); |
823 svgStyle.setBaselineShift(baselineShift); | 858 svgStyle.setBaselineShift(baselineShift); |
824 if (baselineShift == BS_LENGTH) | 859 if (baselineShift == BS_LENGTH) |
825 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); | 860 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); |
826 } | 861 } |
827 | 862 |
(...skipping 16 matching lines...) Expand all Loading... |
844 return; | 879 return; |
845 case CSSValueSuper: | 880 case CSSValueSuper: |
846 svgStyle.setBaselineShift(BS_SUPER); | 881 svgStyle.setBaselineShift(BS_SUPER); |
847 return; | 882 return; |
848 default: | 883 default: |
849 ASSERT_NOT_REACHED(); | 884 ASSERT_NOT_REACHED(); |
850 } | 885 } |
851 } | 886 } |
852 | 887 |
853 } // namespace blink | 888 } // namespace blink |
OLD | NEW |