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 28 matching lines...) Expand all Loading... |
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 Loading... |
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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation(StyleResolverSt
ate& state, CSSValue* value) | 814 void StyleBuilderFunctions::applyValueCSSPropertyTextOrientation(StyleResolverSt
ate& state, CSSValue* value) |
807 { | 815 { |
808 state.setTextOrientation(toCSSPrimitiveValue(value)->convertTo<TextOrientati
on>()); | 816 state.setTextOrientation(toCSSPrimitiveValue(value)->convertTo<TextOrientati
on>()); |
809 } | 817 } |
810 | 818 |
811 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) | 819 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso
lverState& state, CSSValue* value) |
812 { | 820 { |
813 state.setTextOrientation(toCSSPrimitiveValue(value)->convertTo<TextOrientati
on>()); | 821 state.setTextOrientation(toCSSPrimitiveValue(value)->convertTo<TextOrientati
on>()); |
814 } | 822 } |
815 | 823 |
| 824 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, CSSValue* value) |
| 825 { |
| 826 CSSCustomPropertyDeclaration* declaration = toCSSCustomPropertyDeclaration(v
alue); |
| 827 switch (declaration->id()) { |
| 828 case CSSValueInitial: |
| 829 state.style()->removeVariable(declaration->name()); |
| 830 break; |
| 831 |
| 832 case CSSValueUnset: |
| 833 case CSSValueInherit: { |
| 834 state.style()->removeVariable(declaration->name()); |
| 835 StyleVariableData* parentVariables = state.parentStyle()->variables(); |
| 836 if (!parentVariables) |
| 837 return; |
| 838 CSSVariableData* value = parentVariables->getVariable(declaration->name(
)); |
| 839 if (!value) |
| 840 return; |
| 841 state.style()->setVariable(declaration->name(), value); |
| 842 break; |
| 843 } |
| 844 case CSSValueInternalVariableValue: |
| 845 state.style()->setVariable(declaration->name(), declaration->value()); |
| 846 break; |
| 847 default: |
| 848 ASSERT_NOT_REACHED(); |
| 849 } |
| 850 } |
| 851 |
816 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) | 852 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) |
817 { | 853 { |
818 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); | 854 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |
819 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); | 855 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); |
820 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); | 856 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); |
821 svgStyle.setBaselineShift(baselineShift); | 857 svgStyle.setBaselineShift(baselineShift); |
822 if (baselineShift == BS_LENGTH) | 858 if (baselineShift == BS_LENGTH) |
823 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); | 859 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); |
824 } | 860 } |
825 | 861 |
(...skipping 16 matching lines...) Expand all Loading... |
842 return; | 878 return; |
843 case CSSValueSuper: | 879 case CSSValueSuper: |
844 svgStyle.setBaselineShift(BS_SUPER); | 880 svgStyle.setBaselineShift(BS_SUPER); |
845 return; | 881 return; |
846 default: | 882 default: |
847 ASSERT_NOT_REACHED(); | 883 ASSERT_NOT_REACHED(); |
848 } | 884 } |
849 } | 885 } |
850 | 886 |
851 } // namespace blink | 887 } // namespace blink |
OLD | NEW |