Changeset 273627 in webkit
- Timestamp:
- Feb 27, 2021 11:51:44 AM (17 months ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/fast/dom/CSSStyleDeclaration/css-properties-case-sensitive-expected.txt (modified) (1 diff)
-
LayoutTests/fast/dom/CSSStyleDeclaration/css-properties-case-sensitive.html (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSStyleDeclaration.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r273624 r273627 1 2021-02-27 Sam Weinig <weinig@apple.com> 2 3 Remove support for 'pixel' and 'pos' CSSOM prefixes 4 https://bugs.webkit.org/show_bug.cgi?id=119712 5 6 Reviewed by Simon Fraser. 7 8 * fast/dom/CSSStyleDeclaration/css-properties-case-sensitive-expected.txt: 9 * fast/dom/CSSStyleDeclaration/css-properties-case-sensitive.html: 10 Update test to reflect removal of pos/pixel prefixes. 11 1 12 2021-02-27 Rob Buis <rbuis@igalia.com> 2 13 -
trunk/LayoutTests/fast/dom/CSSStyleDeclaration/css-properties-case-sensitive-expected.txt
r273592 r273627 4 4 5 5 6 normal cases7 8 6 PASS element.style.zIndex is '1' 9 7 PASS element.style.ZIndex is undefined. 10 11 "pixel" prefix12 13 PASS element.style.pixelZIndex is 114 PASS element.style.PixelZIndex is 115 PASS element.style.pixelzIndex is undefined.16 PASS element.style.PixelzIndex is undefined.17 18 "pos" prefix19 20 PASS element.style.posZIndex is 121 PASS element.style.PosZIndex is 122 PASS element.style.poszIndex is undefined.23 PASS element.style.PoszIndex is undefined.24 8 PASS successfullyParsed is true 25 9 -
trunk/LayoutTests/fast/dom/CSSStyleDeclaration/css-properties-case-sensitive.html
r273592 r273627 13 13 element.style.zIndex = 1; 14 14 15 debug('normal cases');16 debug('');17 18 15 shouldBe("element.style.zIndex", "'1'"); 19 16 shouldBeUndefined("element.style.ZIndex"); 20 21 debug('');22 debug('"pixel" prefix');23 debug('');24 25 shouldBe("element.style.pixelZIndex", "1");26 shouldBe("element.style.PixelZIndex", "1");27 shouldBeUndefined("element.style.pixelzIndex");28 shouldBeUndefined("element.style.PixelzIndex");29 30 debug('');31 debug('"pos" prefix');32 debug('');33 34 shouldBe("element.style.posZIndex", "1");35 shouldBe("element.style.PosZIndex", "1");36 shouldBeUndefined("element.style.poszIndex");37 shouldBeUndefined("element.style.PoszIndex");38 17 </script> 39 18 <script src="../../../resources/js-test-post.js"></script> -
trunk/Source/WebCore/ChangeLog
r273626 r273627 1 2021-02-27 Sam Weinig <weinig@apple.com> 2 3 Remove support for 'pixel' and 'pos' CSSOM prefixes 4 https://bugs.webkit.org/show_bug.cgi?id=119712 5 <rdar://problem/70660490> 6 7 Reviewed by Simon Fraser. 8 9 Remove support for pixel/pos prefixed properties of CSSStyleDeclaration which 10 are no longer supported by any other browser. 11 12 * css/CSSStyleDeclaration.cpp: 13 (WebCore::CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName): 14 (WebCore::CSSStyleDeclaration::namedItem): 15 (WebCore::CSSStyleDeclaration::setNamedItem): 16 1 17 2021-02-27 Zalan Bujtas <zalan@apple.com> 2 18 -
trunk/Source/WebCore/css/CSSStyleDeclaration.cpp
r273592 r273627 44 44 namespace { 45 45 46 enum class PropertyNamePrefix { 47 None, 48 Epub, 49 Pixel, 50 Pos, 51 WebKit 52 }; 46 enum class PropertyNamePrefix { None, Epub, WebKit }; 53 47 54 48 template<size_t prefixCStringLength> … … 93 87 if (matchesCSSPropertyNamePrefix(propertyName, "epub")) 94 88 return PropertyNamePrefix::Epub; 95 break;96 case 'p':97 if (matchesCSSPropertyNamePrefix(propertyName, "pos"))98 return PropertyNamePrefix::Pos;99 if (matchesCSSPropertyNamePrefix(propertyName, "pixel"))100 return PropertyNamePrefix::Pixel;101 89 break; 102 90 case 'w': … … 132 120 } 133 121 134 struct CSSPropertyInfo { 135 CSSPropertyID propertyID; 136 bool hadPixelOrPosPrefix; 137 }; 138 139 static CSSPropertyInfo parseJavaScriptCSSPropertyName(const AtomString& propertyName) 140 { 141 using CSSPropertyInfoMap = HashMap<String, CSSPropertyInfo>; 142 static NeverDestroyed<CSSPropertyInfoMap> propertyInfoCache; 143 144 CSSPropertyInfo propertyInfo = { CSSPropertyInvalid, false }; 122 static CSSPropertyID parseJavaScriptCSSPropertyName(const AtomString& propertyName) 123 { 124 using CSSPropertyIDMap = HashMap<String, CSSPropertyID>; 125 static NeverDestroyed<CSSPropertyIDMap> propertyIDCache; 145 126 146 127 auto* propertyNameString = propertyName.impl(); 147 128 if (!propertyNameString) 148 return propertyInfo; 129 return CSSPropertyInvalid; 130 149 131 unsigned length = propertyNameString->length(); 150 132 if (!length) 151 return propertyInfo; 152 153 propertyInfo = propertyInfoCache.get().get(propertyNameString); 154 if (propertyInfo.propertyID) 155 return propertyInfo; 156 157 bool hadPixelOrPosPrefix = false; 133 return CSSPropertyInvalid; 134 135 if (auto id = propertyIDCache.get().get(propertyNameString)) 136 return id; 158 137 159 138 constexpr size_t bufferSize = maxCSSPropertyNameLength + 1; … … 163 142 164 143 unsigned i = 0; 165 // Prefixes Pixel and Pos are ignored.166 // Prefixes Apple, KHTML and Webkit are transposed to "-webkit-".167 // The prefix "Epub" becomes "-epub-".168 144 switch (propertyNamePrefix(*propertyNameString)) { 169 145 case PropertyNamePrefix::None: 170 146 if (isASCIIUpper((*propertyNameString)[0])) 171 return propertyInfo; 172 break; 173 case PropertyNamePrefix::Pixel: 174 i += 5; 175 hadPixelOrPosPrefix = true; 176 break; 177 case PropertyNamePrefix::Pos: 178 i += 3; 179 hadPixelOrPosPrefix = true; 147 return CSSPropertyInvalid; 180 148 break; 181 149 case PropertyNamePrefix::Epub: … … 196 164 size_t propertySizeLeft = length - i; 197 165 if (propertySizeLeft > bufferSizeLeft) 198 return propertyInfo;166 return CSSPropertyInvalid; 199 167 200 168 for (; i < length; ++i) { 201 169 UChar c = (*propertyNameString)[i]; 202 170 if (!c || !isASCII(c)) 203 return propertyInfo; // illegal character171 return CSSPropertyInvalid; // illegal character 204 172 if (isASCIIUpper(c)) { 205 173 size_t bufferSizeLeft = stringEnd - bufferPtr; 206 174 size_t propertySizeLeft = length - i + 1; 207 175 if (propertySizeLeft > bufferSizeLeft) 208 return propertyInfo;176 return CSSPropertyInvalid; 209 177 *bufferPtr++ = '-'; 210 178 *bufferPtr++ = toASCIILowerUnchecked(c); … … 221 189 #endif 222 190 223 auto* hashTableEntry = findProperty(name, outputLength); 224 if (auto propertyID = hashTableEntry ? hashTableEntry->id : 0) { 225 auto id = static_cast<CSSPropertyID>(propertyID); 226 propertyInfo.hadPixelOrPosPrefix = hadPixelOrPosPrefix; 227 propertyInfo.propertyID = id; 228 propertyInfoCache.get().add(propertyNameString, propertyInfo); 229 } 230 return propertyInfo; 231 } 232 233 static CSSPropertyInfo propertyInfoFromJavaScriptCSSPropertyName(const AtomString& propertyName, const Settings* settings) 234 { 235 auto propertyInfo = parseJavaScriptCSSPropertyName(propertyName); 236 auto id = propertyInfo.propertyID; 191 auto hashTableEntry = findProperty(name, outputLength); 192 if (!hashTableEntry) 193 return CSSPropertyInvalid; 194 195 auto id = static_cast<CSSPropertyID>(hashTableEntry->id); 196 if (!id) 197 return CSSPropertyInvalid; 198 199 propertyIDCache.get().add(propertyNameString, id); 200 return id; 201 } 202 203 static CSSPropertyID propertyIDFromJavaScriptCSSPropertyName(const AtomString& propertyName, const Settings* settings) 204 { 205 auto id = parseJavaScriptCSSPropertyName(propertyName); 237 206 if (!isEnabledCSSProperty(id) || !isCSSPropertyEnabledBySettings(id, settings)) 238 return { CSSPropertyInvalid, false };239 return propertyInfo;207 return CSSPropertyInvalid; 208 return id; 240 209 } 241 210 … … 244 213 CSSPropertyID CSSStyleDeclaration::getCSSPropertyIDFromJavaScriptPropertyName(const AtomString& propertyName) 245 214 { 246 return propertyInfoFromJavaScriptCSSPropertyName(propertyName, nullptr).propertyID; 215 // FIXME: This is going to return incorrect results for css properties disabled by Settings. 216 return propertyIDFromJavaScriptCSSPropertyName(propertyName, nullptr); 247 217 } 248 218 … … 254 224 Optional<Variant<String, double>> CSSStyleDeclaration::namedItem(const AtomString& propertyName) 255 225 { 256 auto propertyInfo = propertyInfoFromJavaScriptCSSPropertyName(propertyName, settings()); 257 if (!propertyInfo.propertyID) 226 // FIXME: This is going to return incorrect results for css properties disabled by Settings if settings() returns nullptr. 227 auto propertyID = propertyIDFromJavaScriptCSSPropertyName(propertyName, settings()); 228 if (!propertyID) 258 229 return WTF::nullopt; 259 230 260 auto value = getPropertyCSSValueInternal(propertyInfo.propertyID); 261 if (!value) { 262 // If the property is a shorthand property (such as "padding"), it can only be accessed using getPropertyValue. 263 return Variant<String, double> { getPropertyValueInternal(propertyInfo.propertyID) }; 264 } 265 266 if (propertyInfo.hadPixelOrPosPrefix && is<CSSPrimitiveValue>(*value)) { 267 // Call this version of the getter so that, e.g., pixelTop returns top as a number 268 // in pixel units and posTop should does the same _if_ this is a positioned element. 269 // FIXME: If not a positioned element, MSIE documentation says posTop should return 0; this rule is not implemented. 270 return Variant<String, double> { downcast<CSSPrimitiveValue>(*value).floatValue(CSSUnitType::CSS_PX) }; 271 } 272 273 return Variant<String, double> { value->cssText() }; 231 if (auto value = getPropertyCSSValueInternal(propertyID)) 232 return Variant<String, double> { value->cssText() }; 233 234 // If the property is a shorthand property (such as "padding"), it can only be accessed using getPropertyValue. 235 return Variant<String, double> { getPropertyValueInternal(propertyID) }; 274 236 } 275 237 276 238 ExceptionOr<void> CSSStyleDeclaration::setNamedItem(const AtomString& propertyName, String value, bool& propertySupported) 277 239 { 278 auto propertyInfo = propertyInfoFromJavaScriptCSSPropertyName(propertyName, settings()); 279 if (!propertyInfo.propertyID) { 240 // FIXME: This is going to return incorrect results for css properties disabled by Settings if settings() returns nullptr. 241 auto propertyID = propertyIDFromJavaScriptCSSPropertyName(propertyName, settings()); 242 if (!propertyID) { 280 243 propertySupported = false; 281 244 return { }; … … 283 246 284 247 propertySupported = true; 285 286 if (propertyInfo.hadPixelOrPosPrefix)287 value.append("px");288 248 289 249 bool important = false; … … 296 256 } 297 257 298 auto setPropertyInternalResult = setPropertyInternal(propertyI nfo.propertyID, value, important);258 auto setPropertyInternalResult = setPropertyInternal(propertyID, value, important); 299 259 if (setPropertyInternalResult.hasException()) 300 260 return setPropertyInternalResult.releaseException();
Note: See TracChangeset
for help on using the changeset viewer.