2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
19 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20 * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
21 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 * OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "core/css/RuntimeCSSEnabled.h"
33 #include "RuntimeEnabledFeatures.h"
37 // FIXME: We should use a real BitVector class instead!
38 typedef Vector<bool> BoolVector;
40 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bool featureFlag)
42 for (size_t i = 0; i < length; i++)
43 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag);
46 static void setPropertySwitchesFromRuntimeFeatures()
48 CSSPropertyID exclusionProperties[] = {
49 CSSPropertyWebkitWrapFlow,
50 CSSPropertyWebkitWrapThrough,
52 setCSSPropertiesEnabled(exclusionProperties, WTF_ARRAY_LENGTH(exclusionProperties), RuntimeEnabledFeatures::cssExclusionsEnabled());
53 CSSPropertyID shapeProperties[] = {
54 CSSPropertyShapeMargin,
55 CSSPropertyShapePadding,
56 CSSPropertyShapeImageThreshold,
57 CSSPropertyShapeInside,
58 CSSPropertyShapeOutside,
60 setCSSPropertiesEnabled(shapeProperties, WTF_ARRAY_LENGTH(shapeProperties), RuntimeEnabledFeatures::cssShapesEnabled());
61 CSSPropertyID css3TextDecorationProperties[] = {
62 CSSPropertyTextDecorationColor,
63 CSSPropertyTextDecorationLine,
64 CSSPropertyTextDecorationStyle,
65 CSSPropertyTextUnderlinePosition,
67 setCSSPropertiesEnabled(css3TextDecorationProperties, WTF_ARRAY_LENGTH(css3TextDecorationProperties), RuntimeEnabledFeatures::css3TextDecorationsEnabled());
68 CSSPropertyID css3TextProperties[] = {
69 CSSPropertyTextAlignLast,
70 CSSPropertyTextJustify,
72 setCSSPropertiesEnabled(css3TextProperties, WTF_ARRAY_LENGTH(css3TextProperties), RuntimeEnabledFeatures::css3TextEnabled());
73 CSSPropertyID cssGridLayoutProperties[] = {
74 CSSPropertyGridAutoColumns,
75 CSSPropertyGridAutoRows,
76 CSSPropertyGridTemplateColumns,
77 CSSPropertyGridTemplateRows,
78 CSSPropertyGridColumnStart,
79 CSSPropertyGridColumnEnd,
80 CSSPropertyGridRowStart,
81 CSSPropertyGridRowEnd,
82 CSSPropertyGridColumn,
85 CSSPropertyGridAutoFlow,
86 CSSPropertyGridTemplateAreas,
87 CSSPropertyJustifySelf
89 setCSSPropertiesEnabled(cssGridLayoutProperties, WTF_ARRAY_LENGTH(cssGridLayoutProperties), RuntimeEnabledFeatures::cssGridLayoutEnabled());
90 CSSPropertyID cssObjectFitPositionProperties[] = {
92 CSSPropertyObjectPosition
94 setCSSPropertiesEnabled(cssObjectFitPositionProperties, WTF_ARRAY_LENGTH(cssObjectFitPositionProperties), RuntimeEnabledFeatures::objectFitPositionEnabled());
96 CSSPropertyID animationProperties[] = {
98 CSSPropertyAnimationName,
99 CSSPropertyAnimationDuration,
100 CSSPropertyAnimationTimingFunction,
101 CSSPropertyAnimationDelay,
102 CSSPropertyAnimationIterationCount,
103 CSSPropertyAnimationDirection,
104 CSSPropertyAnimationFillMode,
105 CSSPropertyAnimationPlayState
107 setCSSPropertiesEnabled(animationProperties, WTF_ARRAY_LENGTH(animationProperties), RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled());
109 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyBackgroundBlendMode, RuntimeEnabledFeatures::cssCompositingEnabled());
110 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMixBlendMode, RuntimeEnabledFeatures::cssCompositingEnabled());
111 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyIsolation, RuntimeEnabledFeatures::cssCompositingEnabled());
112 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyTouchAction, RuntimeEnabledFeatures::cssTouchActionEnabled());
113 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyTouchActionDelay, RuntimeEnabledFeatures::cssTouchActionDelayEnabled());
114 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabledFeatures::svgPaintOrderEnabled());
115 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeEnabledFeatures::cssMaskSourceTypeEnabled());
116 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabledFeatures::regionBasedColumnsEnabled());
117 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyScrollBehavior, RuntimeEnabledFeatures::cssomSmoothScrollEnabled());
119 // InternalCallback is an implementation detail, rather than an experimental feature, and should never be exposed to the web.
120 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false);
123 static BoolVector& propertySwitches()
125 static BoolVector* switches = 0;
127 switches = new BoolVector;
128 switches->fill(true, numCSSProperties);
129 setPropertySwitchesFromRuntimeFeatures();
134 size_t indexForProperty(CSSPropertyID propertyId)
136 RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProperty);
137 // Values all start at 0. Vector RELEASE_ASSERTS will catch if we're ever wrong.
138 return static_cast<size_t>(propertyId - firstCSSProperty);
141 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId)
143 // Internal properties shouldn't be exposed to the web
144 // so they are considered to be always disabled.
145 if (isInternalProperty(propertyId))
148 return propertySwitches()[indexForProperty(propertyId)];
151 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool enable)
153 propertySwitches()[indexForProperty(propertyId)] = enable;
156 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector)
158 for (unsigned i = 0; i < propertyCount; i++) {
159 CSSPropertyID property = properties[i];
160 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property))
161 outVector.append(property);
165 } // namespace WebCore