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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 #include "core/css/resolver/TransformBuilder.h" | 63 #include "core/css/resolver/TransformBuilder.h" |
64 #include "core/frame/LocalFrame.h" | 64 #include "core/frame/LocalFrame.h" |
65 #include "core/frame/Settings.h" | 65 #include "core/frame/Settings.h" |
66 #include "core/style/ComputedStyle.h" | 66 #include "core/style/ComputedStyle.h" |
67 #include "core/style/ComputedStyleConstants.h" | 67 #include "core/style/ComputedStyleConstants.h" |
68 #include "core/style/ContentData.h" | 68 #include "core/style/ContentData.h" |
69 #include "core/style/CounterContent.h" | 69 #include "core/style/CounterContent.h" |
70 #include "core/style/QuotesData.h" | 70 #include "core/style/QuotesData.h" |
71 #include "core/style/SVGComputedStyle.h" | 71 #include "core/style/SVGComputedStyle.h" |
72 #include "core/style/StyleGeneratedImage.h" | 72 #include "core/style/StyleGeneratedImage.h" |
73 #include "core/style/StyleVariableData.h" | 73 #include "core/style/StyleInheritedVariables.h" |
| 74 #include "core/style/StyleNonInheritedVariables.h" |
74 #include "platform/fonts/FontDescription.h" | 75 #include "platform/fonts/FontDescription.h" |
75 #include "wtf/MathExtras.h" | 76 #include "wtf/MathExtras.h" |
76 #include "wtf/PtrUtil.h" | 77 #include "wtf/PtrUtil.h" |
77 #include "wtf/StdLibExtras.h" | 78 #include "wtf/StdLibExtras.h" |
78 #include "wtf/Vector.h" | 79 #include "wtf/Vector.h" |
79 #include <memory> | 80 #include <memory> |
80 | 81 |
81 namespace blink { | 82 namespace blink { |
82 | 83 |
83 namespace { | 84 namespace { |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 | 798 |
798 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, const CSSValue& value) | 799 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, const CSSValue& value) |
799 { | 800 { |
800 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara
tion(value); | 801 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara
tion(value); |
801 const AtomicString& name = declaration.name(); | 802 const AtomicString& name = declaration.name(); |
802 const PropertyRegistry::Registration* registration = nullptr; | 803 const PropertyRegistry::Registration* registration = nullptr; |
803 const PropertyRegistry* registry = state.document().propertyRegistry(); | 804 const PropertyRegistry* registry = state.document().propertyRegistry(); |
804 if (registry) | 805 if (registry) |
805 registration = registry->registration(name); | 806 registration = registry->registration(name); |
806 | 807 |
807 switch (declaration.id()) { | 808 bool initial = declaration.id() == CSSValueInitial |
808 case CSSValueInitial: | 809 || (declaration.id() == CSSValueUnset && registration && !registration->
inherits()); |
809 state.style()->removeVariable(name); | 810 bool inherit = declaration.id() == CSSValueInherit |
810 break; | 811 || (declaration.id() == CSSValueUnset && (!registration || registration-
>inherits())); |
| 812 DCHECK(!(initial && inherit)); |
811 | 813 |
812 case CSSValueUnset: | 814 if (declaration.id() == CSSValueInternalVariableValue) { |
813 case CSSValueInherit: { | 815 if (declaration.value()->needsVariableResolution()) { |
814 state.style()->removeVariable(name); | 816 if (!registration || registration->inherits()) |
815 StyleVariableData* parentVariables = state.parentStyle()->variables(); | 817 state.style()->setUnresolvedInheritedVariable(name, declaration.
value()); |
| 818 else |
| 819 state.style()->setUnresolvedNonInheritedVariable(name, declarati
on.value()); |
| 820 return; |
| 821 } |
| 822 |
| 823 if (!registration) { |
| 824 state.style()->setResolvedUnregisteredVariable(name, declaration.val
ue()); |
| 825 return; |
| 826 } |
| 827 |
| 828 const CSSValue* parsedValue = declaration.value()->parseForSyntax(regist
ration->syntax()); |
| 829 if (parsedValue) { |
| 830 parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue
(state, *parsedValue); |
| 831 DCHECK(parsedValue); |
| 832 if (registration->inherits()) |
| 833 state.style()->setResolvedInheritedVariable(name, declaration.va
lue(), parsedValue); |
| 834 else |
| 835 state.style()->setResolvedNonInheritedVariable(name, declaration
.value(), parsedValue); |
| 836 return; |
| 837 } |
| 838 if (registration->inherits()) |
| 839 inherit = true; |
| 840 else |
| 841 initial = true; |
| 842 } |
| 843 |
| 844 DCHECK(initial ^ inherit); |
| 845 |
| 846 if (initial) { |
| 847 if (!registration || registration->inherits()) |
| 848 state.style()->removeInheritedVariable(name); |
| 849 else |
| 850 state.style()->removeNonInheritedVariable(name); |
| 851 return; |
| 852 } |
| 853 |
| 854 if (!registration || registration->inherits()) { |
| 855 state.style()->removeInheritedVariable(name); |
| 856 StyleInheritedVariables* parentVariables = state.parentStyle()->inherite
dVariables(); |
816 if (!parentVariables) | 857 if (!parentVariables) |
817 return; | 858 return; |
818 CSSVariableData* value = parentVariables->getVariable(name); | 859 CSSVariableData* parentValue = parentVariables->getVariable(name); |
819 if (!value) | 860 if (parentValue) { |
820 return; | 861 if (!registration) |
821 state.style()->setVariable(name, value); | 862 state.style()->setResolvedUnregisteredVariable(name, parentValue
); |
822 if (registration) | 863 else |
823 state.style()->setRegisteredInheritedProperty(name, parentVariables-
>registeredInheritedProperty(name)); | 864 state.style()->setResolvedInheritedVariable(name, parentValue, p
arentVariables->registeredVariable(name)); |
824 break; | 865 } |
| 866 return; |
825 } | 867 } |
826 case CSSValueInternalVariableValue: | 868 |
827 if (registration) { | 869 state.style()->removeNonInheritedVariable(name); |
828 if (declaration.value()->needsVariableResolution()) { | 870 StyleNonInheritedVariables* parentVariables = state.parentStyle()->nonInheri
tedVariables(); |
829 state.style()->setVariable(name, declaration.value()); | 871 if (!parentVariables) |
830 return; | 872 return; |
831 } | 873 CSSVariableData* parentValue = parentVariables->getVariable(name); |
832 const CSSValue* parsedValue = declaration.value()->parseForSyntax(re
gistration->syntax()); | 874 if (parentValue) |
833 if (!parsedValue) { | 875 state.style()->setResolvedNonInheritedVariable(name, parentValue, parent
Variables->registeredVariable(name)); |
834 state.style()->setVariable(name, nullptr); | |
835 state.style()->setRegisteredInheritedProperty(name, nullptr); | |
836 return; | |
837 } | |
838 parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue
(state, *parsedValue); | |
839 state.style()->setVariable(name, declaration.value()); | |
840 state.style()->setRegisteredInheritedProperty(name, parsedValue); | |
841 return; | |
842 } | |
843 state.style()->setVariable(name, declaration.value()); | |
844 break; | |
845 default: | |
846 NOTREACHED(); | |
847 } | |
848 } | 876 } |
849 | 877 |
850 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) | 878 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt
ate& state) |
851 { | 879 { |
852 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); | 880 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); |
853 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); | 881 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); |
854 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); | 882 SVGComputedStyle& svgStyle = state.style()->accessSVGStyle(); |
855 svgStyle.setBaselineShift(baselineShift); | 883 svgStyle.setBaselineShift(baselineShift); |
856 if (baselineShift == BS_LENGTH) | 884 if (baselineShift == BS_LENGTH) |
857 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); | 885 svgStyle.setBaselineShiftValue(parentSvgStyle.baselineShiftValue()); |
(...skipping 24 matching lines...) Expand all Loading... |
882 } | 910 } |
883 } | 911 } |
884 | 912 |
885 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState&
state) | 913 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState&
state) |
886 { | 914 { |
887 if (!state.parentNode()->isDocumentNode()) | 915 if (!state.parentNode()->isDocumentNode()) |
888 state.style()->setPosition(state.parentStyle()->position()); | 916 state.style()->setPosition(state.parentStyle()->position()); |
889 } | 917 } |
890 | 918 |
891 } // namespace blink | 919 } // namespace blink |
OLD | NEW |