void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, MutableStylePropertySet* style) { if (!value.isEmpty()) { // Have to quote so the locale id is treated as a string instead of as a CSS keyword. addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(value)); // FIXME: Remove the following UseCounter code when we collect enough // data. UseCounter::count(document(), UseCounter::LangAttribute); if (isHTMLHtmlElement(*this)) UseCounter::count(document(), UseCounter::LangAttributeOnHTML); else if (isHTMLBodyElement(*this)) UseCounter::count(document(), UseCounter::LangAttributeOnBody); String htmlLanguage = value.string(); size_t firstSeparator = htmlLanguage.find('-'); if (firstSeparator != kNotFound) htmlLanguage = htmlLanguage.left(firstSeparator); String uiLanguage = defaultLanguage(); firstSeparator = uiLanguage.find('-'); if (firstSeparator != kNotFound) uiLanguage = uiLanguage.left(firstSeparator); firstSeparator = uiLanguage.find('_'); if (firstSeparator != kNotFound) uiLanguage = uiLanguage.left(firstSeparator); if (!equalIgnoringCase(htmlLanguage, uiLanguage)) UseCounter::count(document(), UseCounter::LangAttributeDoesNotMatchToUILocale); } else { // The empty string means the language is explicitly unknown. addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto); } }
void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, MutableStylePropertySet* style) { if (!value.isEmpty()) { // Have to quote so the locale id is treated as a string instead of as a CSS keyword. addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(value)); } else { // The empty string means the language is explicitly unknown. addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto); } }
String quoteCSSURLIfNeeded(const String& string) { return isCSSTokenizerURL(string) ? string : quoteCSSString(string); }
String quoteCSSStringIfNeeded(const String& string) { return isCSSTokenizerIdentifier(string) ? string : quoteCSSString(string); }