Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(349)

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleBuilderCustom.cpp

Issue 2310823002: Skeleton implementation of CSS Properties and Values API (Closed)
Patch Set: fix stylevardata copy ctor Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "core/css/CSSCursorImageValue.h" 44 #include "core/css/CSSCursorImageValue.h"
45 #include "core/css/CSSCustomPropertyDeclaration.h" 45 #include "core/css/CSSCustomPropertyDeclaration.h"
46 #include "core/css/CSSFunctionValue.h" 46 #include "core/css/CSSFunctionValue.h"
47 #include "core/css/CSSGridTemplateAreasValue.h" 47 #include "core/css/CSSGridTemplateAreasValue.h"
48 #include "core/css/CSSHelper.h" 48 #include "core/css/CSSHelper.h"
49 #include "core/css/CSSImageSetValue.h" 49 #include "core/css/CSSImageSetValue.h"
50 #include "core/css/CSSPendingSubstitutionValue.h" 50 #include "core/css/CSSPendingSubstitutionValue.h"
51 #include "core/css/CSSPrimitiveValueMappings.h" 51 #include "core/css/CSSPrimitiveValueMappings.h"
52 #include "core/css/CSSPropertyMetadata.h" 52 #include "core/css/CSSPropertyMetadata.h"
53 #include "core/css/CSSVariableReferenceValue.h" 53 #include "core/css/CSSVariableReferenceValue.h"
54 #include "core/css/PropertyRegistration.h"
55 #include "core/css/PropertyRegistry.h"
54 #include "core/css/StylePropertySet.h" 56 #include "core/css/StylePropertySet.h"
55 #include "core/css/StyleRule.h" 57 #include "core/css/StyleRule.h"
56 #include "core/css/resolver/CSSVariableResolver.h" 58 #include "core/css/resolver/CSSVariableResolver.h"
57 #include "core/css/resolver/ElementStyleResources.h" 59 #include "core/css/resolver/ElementStyleResources.h"
58 #include "core/css/resolver/FilterOperationResolver.h" 60 #include "core/css/resolver/FilterOperationResolver.h"
59 #include "core/css/resolver/FontBuilder.h" 61 #include "core/css/resolver/FontBuilder.h"
60 #include "core/css/resolver/StyleBuilder.h" 62 #include "core/css/resolver/StyleBuilder.h"
61 #include "core/css/resolver/TransformBuilder.h" 63 #include "core/css/resolver/TransformBuilder.h"
62 #include "core/frame/LocalFrame.h" 64 #include "core/frame/LocalFrame.h"
63 #include "core/frame/Settings.h" 65 #include "core/frame/Settings.h"
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 793 }
792 794
793 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, const CSSValue& value) 795 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextOrientation(StyleReso lverState& state, const CSSValue& value)
794 { 796 {
795 state.setTextOrientation(toCSSPrimitiveValue(value).convertTo<TextOrientatio n>()); 797 state.setTextOrientation(toCSSPrimitiveValue(value).convertTo<TextOrientatio n>());
796 } 798 }
797 799
798 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st ate, const CSSValue& value) 800 void StyleBuilderFunctions::applyValueCSSPropertyVariable(StyleResolverState& st ate, const CSSValue& value)
799 { 801 {
800 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara tion(value); 802 const CSSCustomPropertyDeclaration& declaration = toCSSCustomPropertyDeclara tion(value);
803 const AtomicString& name = declaration.name();
804 const PropertyRegistry::Registration* registration = nullptr;
805 const PropertyRegistry* registry = state.document().propertyRegistry();
806 if (registry)
807 registration = registry->registration(name);
808
801 switch (declaration.id()) { 809 switch (declaration.id()) {
802 case CSSValueInitial: 810 case CSSValueInitial:
803 state.style()->removeVariable(declaration.name()); 811 state.style()->removeVariable(name);
804 break; 812 break;
805 813
806 case CSSValueUnset: 814 case CSSValueUnset:
807 case CSSValueInherit: { 815 case CSSValueInherit: {
808 state.style()->removeVariable(declaration.name()); 816 state.style()->removeVariable(name);
809 StyleVariableData* parentVariables = state.parentStyle()->variables(); 817 StyleVariableData* parentVariables = state.parentStyle()->variables();
810 if (!parentVariables) 818 if (!parentVariables)
811 return; 819 return;
812 CSSVariableData* value = parentVariables->getVariable(declaration.name() ); 820 CSSVariableData* value = parentVariables->getVariable(name);
813 if (!value) 821 if (!value)
814 return; 822 return;
815 state.style()->setVariable(declaration.name(), value); 823 state.style()->setVariable(name, value);
824 if (registration)
825 state.style()->setRegisteredInheritedProperty(name, parentVariables- >registeredInheritedProperty(name));
816 break; 826 break;
817 } 827 }
818 case CSSValueInternalVariableValue: 828 case CSSValueInternalVariableValue:
819 state.style()->setVariable(declaration.name(), declaration.value()); 829 if (registration) {
830 if (declaration.value()->needsVariableResolution()) {
831 state.style()->setVariable(name, declaration.value());
832 return;
833 }
834 const CSSValue* parsedValue = declaration.value()->parseForSyntax(re gistration->syntax());
835 if (!parsedValue) {
836 state.style()->setVariable(name, nullptr);
837 state.style()->setRegisteredInheritedProperty(name, nullptr);
838 return;
839 }
840 parsedValue = &StyleBuilderConverter::convertRegisteredPropertyValue (state, *parsedValue);
841 state.style()->setVariable(name, declaration.value());
842 state.style()->setRegisteredInheritedProperty(name, parsedValue);
843 return;
844 }
845 state.style()->setVariable(name, declaration.value());
820 break; 846 break;
821 default: 847 default:
822 NOTREACHED(); 848 NOTREACHED();
823 } 849 }
824 } 850 }
825 851
826 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state) 852 void StyleBuilderFunctions::applyInheritCSSPropertyBaselineShift(StyleResolverSt ate& state)
827 { 853 {
828 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle(); 854 const SVGComputedStyle& parentSvgStyle = state.parentStyle()->svgStyle();
829 EBaselineShift baselineShift = parentSvgStyle.baselineShift(); 855 EBaselineShift baselineShift = parentSvgStyle.baselineShift();
(...skipping 28 matching lines...) Expand all
858 } 884 }
859 } 885 }
860 886
861 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState& state) 887 void StyleBuilderFunctions::applyInheritCSSPropertyPosition(StyleResolverState& state)
862 { 888 {
863 if (!state.parentNode()->isDocumentNode()) 889 if (!state.parentNode()->isDocumentNode())
864 state.style()->setPosition(state.parentStyle()->position()); 890 state.style()->setPosition(state.parentStyle()->position());
865 } 891 }
866 892
867 } // namespace blink 893 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698