bool DOMCSSNamespace::supports(const String& property, const String& value) { CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace()); if (propertyID == CSSPropertyInvalid) return false; // CSSParser::parseValue() won't work correctly if !important is present, // so just get rid of it. It doesn't matter to supports() if it's actually // there or not, provided how it's specified in the value is correct. String normalizedValue = value.stripWhiteSpace().simplifyWhiteSpace(); normalizedValue = valueWithoutImportant(normalizedValue); if (normalizedValue.isEmpty()) return false; auto dummyStyle = MutableStyleProperties::create(); return CSSParser::parseValue(dummyStyle, propertyID, normalizedValue, false, CSSStrictMode, nullptr) != CSSParser::ParseResult::Error; }
bool DOMWindowCSS::supports(const String& property, const String& value) const { CSSPropertyID propertyID = cssPropertyID(property.stripWhiteSpace()); if (propertyID == CSSPropertyInvalid) return false; ASSERT(CSSPropertyMetadata::isEnabledProperty(propertyID)); // CSSParser::parseValue() won't work correctly if !important is present, // so just get rid of it. It doesn't matter to supports() if it's actually // there or not, provided how it's specified in the value is correct. String normalizedValue = value.stripWhiteSpace().simplifyWhiteSpace(); normalizedValue = valueWithoutImportant(normalizedValue); if (normalizedValue.isEmpty()) return false; RefPtrWillBeRawPtr<MutableStylePropertySet> dummyStyle = MutableStylePropertySet::create(); return CSSParser::parseValue(dummyStyle.get(), propertyID, normalizedValue, false, HTMLStandardMode, 0); }