Chromium Code Reviews| 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 26 matching lines...) Expand all Loading... | |
| 37 */ | 37 */ |
| 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/CSSCursorImageValue.h" | 46 #include "core/css/CSSCursorImageValue.h" |
| 47 #include "core/css/CSSCustomVariableValue.h" | |
| 47 #include "core/css/CSSGradientValue.h" | 48 #include "core/css/CSSGradientValue.h" |
| 48 #include "core/css/CSSGridTemplateAreasValue.h" | 49 #include "core/css/CSSGridTemplateAreasValue.h" |
| 49 #include "core/css/CSSHelper.h" | 50 #include "core/css/CSSHelper.h" |
| 50 #include "core/css/CSSImageSetValue.h" | 51 #include "core/css/CSSImageSetValue.h" |
| 51 #include "core/css/CSSLineBoxContainValue.h" | 52 #include "core/css/CSSLineBoxContainValue.h" |
| 52 #include "core/css/CSSPathValue.h" | 53 #include "core/css/CSSPathValue.h" |
| 53 #include "core/css/CSSPrimitiveValueMappings.h" | 54 #include "core/css/CSSPrimitiveValueMappings.h" |
| 54 #include "core/css/CSSPropertyMetadata.h" | 55 #include "core/css/CSSPropertyMetadata.h" |
| 55 #include "core/css/Counter.h" | 56 #include "core/css/Counter.h" |
| 56 #include "core/css/Pair.h" | 57 #include "core/css/Pair.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/parser/CSSParser.h" | |
|
Timothy Loh
2015/08/25 09:21:11
parser includes not needed here?
| |
| 61 #include "core/css/parser/CSSParserTokenRange.h" | |
| 62 #include "core/css/parser/CSSPropertyParser.h" | |
| 63 #include "core/css/resolver/CSSVariableResolver.h" | |
| 59 #include "core/css/resolver/ElementStyleResources.h" | 64 #include "core/css/resolver/ElementStyleResources.h" |
| 60 #include "core/css/resolver/FilterOperationResolver.h" | 65 #include "core/css/resolver/FilterOperationResolver.h" |
| 61 #include "core/css/resolver/FontBuilder.h" | 66 #include "core/css/resolver/FontBuilder.h" |
| 62 #include "core/css/resolver/StyleBuilder.h" | 67 #include "core/css/resolver/StyleBuilder.h" |
| 63 #include "core/css/resolver/TransformBuilder.h" | 68 #include "core/css/resolver/TransformBuilder.h" |
| 64 #include "core/frame/LocalFrame.h" | 69 #include "core/frame/LocalFrame.h" |
| 65 #include "core/frame/Settings.h" | 70 #include "core/frame/Settings.h" |
| 66 #include "core/style/CounterContent.h" | 71 #include "core/style/CounterContent.h" |
| 67 #include "core/style/ComputedStyle.h" | 72 #include "core/style/ComputedStyle.h" |
| 68 #include "core/style/ComputedStyleConstants.h" | 73 #include "core/style/ComputedStyleConstants.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 99 return true; | 104 return true; |
| 100 default: | 105 default: |
| 101 return false; | 106 return false; |
| 102 } | 107 } |
| 103 } | 108 } |
| 104 | 109 |
| 105 } // namespace | 110 } // namespace |
| 106 | 111 |
| 107 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value) | 112 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value) |
| 108 { | 113 { |
| 114 if (RuntimeEnabledFeatures::cssVariablesEnabled() && id != CSSPropertyVariab le && value->isPrimitiveValue() && toCSSPrimitiveValue(value)->isVariableReferen ce()) { | |
| 115 CSSVariableResolver::resolveAndApplyVariableReferences(state, id, toCSSP rimitiveValue(value)); | |
| 116 return; | |
| 117 } | |
| 118 | |
| 109 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); |
| 110 | 120 |
| 111 bool isInherit = state.parentNode() && value->isInheritedValue(); | 121 bool isInherit = state.parentNode() && value->isInheritedValue(); |
| 112 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); | 122 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); |
| 113 | 123 |
| 114 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit | 124 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit |
| 115 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()) |
| 116 | 126 |
| 117 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { | 127 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { |
| 118 // 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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 792 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value) | 802 void StyleBuilderFunctions::applyValueCSSPropertyWebkitWritingMode(StyleResolver State& state, CSSValue* value) |
| 793 { | 803 { |
| 794 state.setWritingMode(*toCSSPrimitiveValue(value)); | 804 state.setWritingMode(*toCSSPrimitiveValue(value)); |
| 795 } | 805 } |
| 796 | 806 |
| 797 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value) | 807 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, CSSValue* value) |
| 798 { | 808 { |
| 799 state.setTextOrientation(*toCSSPrimitiveValue(value)); | 809 state.setTextOrientation(*toCSSPrimitiveValue(value)); |
| 800 } | 810 } |
| 801 | 811 |
| 812 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st ate, CSSValue* value) | |
| 813 { | |
| 814 CSSCustomVariableValue* varVal = toCSSCustomVariableValue(value); | |
| 815 switch (varVal->id()) { | |
| 816 case CSSValueInitial: | |
| 817 state.style()->removeVariable(varVal->name()); | |
| 818 break; | |
| 819 | |
| 820 case CSSValueUnset: | |
|
Timothy Loh
2015/08/25 09:21:11
Shouldn't unset and inherit do the same thing?
| |
| 821 state.style()->removeVariable(varVal->name()); | |
| 822 // Intentional fallthrough. | |
| 823 case CSSValueInherit: { | |
| 824 StyleVariableData* parentVariables = state.parentStyle()->variables(); | |
| 825 if (!parentVariables) | |
| 826 return; | |
| 827 CSSVariableData* value = parentVariables->getVariable(varVal->name()); | |
| 828 if (!value) | |
| 829 return; | |
| 830 state.style()->setVariable(varVal->name(), value); | |
| 831 break; | |
| 832 } | |
| 833 case CSSValueInternalVariableValue: | |
| 834 state.style()->setVariable(varVal->name(), varVal->value()); | |
| 835 break; | |
| 836 default: | |
| 837 ASSERT_NOT_REACHED(); | |
| 838 } | |
| 839 } | |
| 840 | |
| 802 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state) | 841 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state) |
| 803 { | 842 { |
| 804 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); | 843 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |
| 805 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); | 844 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); |
| 806 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); | 845 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); |
| 807 svgStyle.setBaselineShift(baselineShift); | 846 svgStyle.setBaselineShift(baselineShift); |
| 808 if (baselineShift == BS_LENGTH) | 847 if (baselineShift == BS_LENGTH) |
| 809 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); | 848 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); |
| 810 } | 849 } |
| 811 | 850 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 828 return; | 867 return; |
| 829 case CSSValueSuper: | 868 case CSSValueSuper: |
| 830 svgStyle.setBaselineShift(BS_SUPER); | 869 svgStyle.setBaselineShift(BS_SUPER); |
| 831 return; | 870 return; |
| 832 default: | 871 default: |
| 833 ASSERT_NOT_REACHED(); | 872 ASSERT_NOT_REACHED(); |
| 834 } | 873 } |
| 835 } | 874 } |
| 836 | 875 |
| 837 } // namespace blink | 876 } // namespace blink |
| OLD | NEW |