| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above | |
| 9 * copyright notice, this list of conditions and the following | |
| 10 * disclaimer. | |
| 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. | |
| 15 * | |
| 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. | |
| 28 */ | |
| 29 | |
| 30 #include "config.h" | |
| 31 #include "core/page/RuntimeCSSEnabled.h" | |
| 32 #include "RuntimeEnabledFeatures.h" | |
| 33 | |
| 34 namespace WebCore { | |
| 35 | |
| 36 // FIXME: We should use a real BitVector class instead! | |
| 37 typedef Vector<bool> BoolVector; | |
| 38 | |
| 39 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bo
ol featureFlag) | |
| 40 { | |
| 41 for (size_t i = 0; i < length; i++) | |
| 42 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag); | |
| 43 } | |
| 44 | |
| 45 static void setPropertySwitchesFromRuntimeFeatures() | |
| 46 { | |
| 47 CSSPropertyID regionProperites[] = { | |
| 48 CSSPropertyWebkitFlowInto, | |
| 49 CSSPropertyWebkitFlowFrom, | |
| 50 CSSPropertyWebkitRegionFragment, | |
| 51 CSSPropertyWebkitRegionBreakAfter, | |
| 52 CSSPropertyWebkitRegionBreakBefore, | |
| 53 CSSPropertyWebkitRegionBreakInside | |
| 54 }; | |
| 55 setCSSPropertiesEnabled(regionProperites, WTF_ARRAY_LENGTH(regionProperites)
, RuntimeEnabledFeatures::cssRegionsEnabled()); | |
| 56 CSSPropertyID exclusionProperties[] = { | |
| 57 CSSPropertyWebkitWrapFlow, | |
| 58 CSSPropertyWebkitWrapThrough, | |
| 59 }; | |
| 60 setCSSPropertiesEnabled(exclusionProperties, WTF_ARRAY_LENGTH(exclusionPrope
rties), RuntimeEnabledFeatures::cssExclusionsEnabled()); | |
| 61 CSSPropertyID shapeProperties[] = { | |
| 62 CSSPropertyShapeMargin, | |
| 63 CSSPropertyShapePadding, | |
| 64 CSSPropertyShapeImageThreshold, | |
| 65 CSSPropertyShapeInside, | |
| 66 CSSPropertyShapeOutside, | |
| 67 }; | |
| 68 setCSSPropertiesEnabled(shapeProperties, WTF_ARRAY_LENGTH(shapeProperties),
RuntimeEnabledFeatures::cssShapesEnabled()); | |
| 69 CSSPropertyID css3TextDecorationProperties[] = { | |
| 70 CSSPropertyTextDecorationColor, | |
| 71 CSSPropertyTextDecorationLine, | |
| 72 CSSPropertyTextDecorationStyle, | |
| 73 CSSPropertyTextUnderlinePosition, | |
| 74 }; | |
| 75 setCSSPropertiesEnabled(css3TextDecorationProperties, WTF_ARRAY_LENGTH(css3T
extDecorationProperties), RuntimeEnabledFeatures::css3TextDecorationsEnabled()); | |
| 76 CSSPropertyID css3TextProperties[] = { | |
| 77 CSSPropertyTextAlignLast, | |
| 78 CSSPropertyTextJustify, | |
| 79 }; | |
| 80 setCSSPropertiesEnabled(css3TextProperties, WTF_ARRAY_LENGTH(css3TextPropert
ies), RuntimeEnabledFeatures::css3TextEnabled()); | |
| 81 CSSPropertyID cssGridLayoutProperties[] = { | |
| 82 CSSPropertyGridAutoColumns, | |
| 83 CSSPropertyGridAutoRows, | |
| 84 CSSPropertyGridDefinitionColumns, | |
| 85 CSSPropertyGridDefinitionRows, | |
| 86 CSSPropertyGridColumnStart, | |
| 87 CSSPropertyGridColumnEnd, | |
| 88 CSSPropertyGridRowStart, | |
| 89 CSSPropertyGridRowEnd, | |
| 90 CSSPropertyGridColumn, | |
| 91 CSSPropertyGridRow, | |
| 92 CSSPropertyGridArea, | |
| 93 CSSPropertyGridAutoFlow, | |
| 94 CSSPropertyGridTemplate | |
| 95 }; | |
| 96 setCSSPropertiesEnabled(cssGridLayoutProperties, WTF_ARRAY_LENGTH(cssGridLay
outProperties), RuntimeEnabledFeatures::cssGridLayoutEnabled()); | |
| 97 CSSPropertyID cssObjectFitPositionProperties[] = { | |
| 98 CSSPropertyObjectFit, | |
| 99 CSSPropertyObjectPosition | |
| 100 }; | |
| 101 setCSSPropertiesEnabled(cssObjectFitPositionProperties, WTF_ARRAY_LENGTH(css
ObjectFitPositionProperties), RuntimeEnabledFeatures::objectFitPositionEnabled()
); | |
| 102 | |
| 103 CSSPropertyID animationProperties[] = { | |
| 104 CSSPropertyAnimation, | |
| 105 CSSPropertyAnimationName, | |
| 106 CSSPropertyAnimationDuration, | |
| 107 CSSPropertyAnimationTimingFunction, | |
| 108 CSSPropertyAnimationDelay, | |
| 109 CSSPropertyAnimationIterationCount, | |
| 110 CSSPropertyAnimationDirection, | |
| 111 CSSPropertyAnimationFillMode, | |
| 112 CSSPropertyAnimationPlayState | |
| 113 }; | |
| 114 setCSSPropertiesEnabled(animationProperties, WTF_ARRAY_LENGTH(animationPrope
rties), RuntimeEnabledFeatures::cssAnimationUnprefixedEnabled()); | |
| 115 | |
| 116 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyBackgroundBlendMode, Run
timeEnabledFeatures::cssCompositingEnabled()); | |
| 117 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMixBlendMode, RuntimeEna
bledFeatures::cssCompositingEnabled()); | |
| 118 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyIsolation, RuntimeEnable
dFeatures::cssCompositingEnabled()); | |
| 119 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyTouchAction, RuntimeEnab
ledFeatures::cssTouchActionEnabled()); | |
| 120 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabl
edFeatures::svgPaintOrderEnabled()); | |
| 121 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyVariable, RuntimeEnabled
Features::cssVariablesEnabled()); | |
| 122 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeE
nabledFeatures::cssMaskSourceTypeEnabled()); | |
| 123 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabl
edFeatures::regionBasedColumnsEnabled()); | |
| 124 | |
| 125 // InternalCallback is an implementation detail, rather than an experimental
feature, and should never be exposed to the web. | |
| 126 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false)
; | |
| 127 } | |
| 128 | |
| 129 static BoolVector& propertySwitches() | |
| 130 { | |
| 131 static BoolVector* switches = 0; | |
| 132 if (!switches) { | |
| 133 switches = new BoolVector; | |
| 134 // Accomodate CSSPropertyIDs that fall outside the firstCSSProperty, las
tCSSProperty range (eg. CSSPropertyVariable). | |
| 135 switches->fill(true, lastCSSProperty + 1); | |
| 136 setPropertySwitchesFromRuntimeFeatures(); | |
| 137 } | |
| 138 return *switches; | |
| 139 } | |
| 140 | |
| 141 size_t indexForProperty(CSSPropertyID propertyId) | |
| 142 { | |
| 143 RELEASE_ASSERT(propertyId >= 0 && propertyId <= lastCSSProperty); | |
| 144 ASSERT(propertyId != CSSPropertyInvalid); | |
| 145 return static_cast<size_t>(propertyId); | |
| 146 } | |
| 147 | |
| 148 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId) | |
| 149 { | |
| 150 // Internal properties shouldn't be exposed to the web | |
| 151 // so they are considered to be always disabled. | |
| 152 if (isInternalProperty(propertyId)) | |
| 153 return false; | |
| 154 | |
| 155 return propertySwitches()[indexForProperty(propertyId)]; | |
| 156 } | |
| 157 | |
| 158 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool ena
ble) | |
| 159 { | |
| 160 propertySwitches()[indexForProperty(propertyId)] = enable; | |
| 161 } | |
| 162 | |
| 163 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID
* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) | |
| 164 { | |
| 165 for (unsigned i = 0; i < propertyCount; i++) { | |
| 166 CSSPropertyID property = properties[i]; | |
| 167 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property)) | |
| 168 outVector.append(property); | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 } // namespace WebCore | |
| OLD | NEW |