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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 | 798 |
799 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, const CSSValue& value) | 799 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st
ate, const CSSValue& value) |
800 { | 800 { |
801 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara
tion(value); | 801 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara
tion(value); |
802 const AtomicString& name = declaration.name(); | 802 const AtomicString& name = declaration.name(); |
803 const PropertyRegistry::Registration* registration = nullptr; | 803 const PropertyRegistry::Registration* registration = nullptr; |
804 const PropertyRegistry* registry = state.document().propertyRegistry(); | 804 const PropertyRegistry* registry = state.document().propertyRegistry(); |
805 if (registry) | 805 if (registry) |
806 registration = registry->registration(name); | 806 registration = registry->registration(name); |
807 | 807 |
808 bool initial = declaration.id() == CSSValueInitial | 808 bool isInheritedProperty = !registration || registration->inherits(); |
809 || (declaration.id() == CSSValueUnset && registration && !registration->
inherits()); | 809 bool initial = declaration.isInitial(isInheritedProperty); |
810 bool inherit = declaration.id() == CSSValueInherit | 810 bool inherit = declaration.isInherit(isInheritedProperty); |
811 || (declaration.id() == CSSValueUnset && (!registration || registration-
>inherits())); | |
812 DCHECK(!(initial && inherit)); | 811 DCHECK(!(initial && inherit)); |
813 | 812 |
814 if (declaration.id() == CSSValueInternalVariableValue) { | 813 if (!initial && !inherit) { |
815 if (declaration.value()->needsVariableResolution()) { | 814 if (declaration.value()->needsVariableResolution()) { |
816 if (!registration || registration->inherits()) | 815 if (isInheritedProperty) |
817 state.style()->setUnresolvedInheritedVariable(name, declaration.
value()); | 816 state.style()->setUnresolvedInheritedVariable(name, declaration.
value()); |
818 else | 817 else |
819 state.style()->setUnresolvedNonInheritedVariable(name, declarati
on.value()); | 818 state.style()->setUnresolvedNonInheritedVariable(name, declarati
on.value()); |
820 return; | 819 return; |
821 } | 820 } |
822 | 821 |
823 if (!registration) { | 822 if (!registration) { |
824 state.style()->setResolvedUnregisteredVariable(name, declaration.val
ue()); | 823 state.style()->setResolvedUnregisteredVariable(name, declaration.val
ue()); |
825 return; | 824 return; |
826 } | 825 } |
827 | 826 |
828 const CSSValue* parsedValue = declaration.value()->parseForSyntax(regist
ration->syntax()); | 827 const CSSValue* parsedValue = declaration.value()->parseForSyntax(regist
ration->syntax()); |
829 if (parsedValue) { | 828 if (parsedValue) { |
830 parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue
(state, *parsedValue); | 829 parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue
(state, *parsedValue); |
831 DCHECK(parsedValue); | 830 DCHECK(parsedValue); |
832 if (registration->inherits()) | 831 if (isInheritedProperty) |
833 state.style()->setResolvedInheritedVariable(name, declaration.va
lue(), parsedValue); | 832 state.style()->setResolvedInheritedVariable(name, declaration.va
lue(), parsedValue); |
834 else | 833 else |
835 state.style()->setResolvedNonInheritedVariable(name, declaration
.value(), parsedValue); | 834 state.style()->setResolvedNonInheritedVariable(name, declaration
.value(), parsedValue); |
836 return; | 835 return; |
837 } | 836 } |
838 if (registration->inherits()) | 837 if (isInheritedProperty) |
839 inherit = true; | 838 inherit = true; |
840 else | 839 else |
841 initial = true; | 840 initial = true; |
842 } | 841 } |
843 | 842 |
844 DCHECK(initial ^ inherit); | 843 DCHECK(initial ^ inherit); |
845 | 844 |
846 if (initial) { | 845 if (initial) { |
847 if (!registration || registration->inherits()) | 846 if (isInheritedProperty) |
848 state.style()->removeInheritedVariable(name); | 847 state.style()->removeInheritedVariable(name); |
849 else | 848 else |
850 state.style()->removeNonInheritedVariable(name); | 849 state.style()->removeNonInheritedVariable(name); |
851 return; | 850 return; |
852 } | 851 } |
853 | 852 |
854 if (!registration || registration->inherits()) { | 853 if (isInheritedProperty) { |
855 state.style()->removeInheritedVariable(name); | 854 state.style()->removeInheritedVariable(name); |
856 StyleInheritedVariables* parentVariables = state.parentStyle()->inherite
dVariables(); | 855 StyleInheritedVariables* parentVariables = state.parentStyle()->inherite
dVariables(); |
857 if (!parentVariables) | 856 if (!parentVariables) |
858 return; | 857 return; |
859 CSSVariableData* parentValue = parentVariables->getVariable(name); | 858 CSSVariableData* parentValue = parentVariables->getVariable(name); |
860 if (parentValue) { | 859 if (parentValue) { |
861 if (!registration) | 860 if (!registration) |
862 state.style()->setResolvedUnregisteredVariable(name, parentValue
); | 861 state.style()->setResolvedUnregisteredVariable(name, parentValue
); |
863 else | 862 else |
864 state.style()->setResolvedInheritedVariable(name, parentValue, p
arentVariables->registeredVariable(name)); | 863 state.style()->setResolvedInheritedVariable(name, parentValue, p
arentVariables->registeredVariable(name)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 } | 909 } |
911 } | 910 } |
912 | 911 |
913 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState&
state) | 912 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState&
state) |
914 { | 913 { |
915 if (!state.parentNode()->isDocumentNode()) | 914 if (!state.parentNode()->isDocumentNode()) |
916 state.style()->setPosition(state.parentStyle()->position()); | 915 state.style()->setPosition(state.parentStyle()->position()); |
917 } | 916 } |
918 | 917 |
919 } // namespace blink | 918 } // namespace blink |
OLD | NEW |