Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(980)

Unified Diff: Source/core/html/HTMLElement.cpp

Issue 706503002: Add UseCounters for lang and xml:lang content attributes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Count <input type=submit> with/without value= Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/html/forms/BaseButtonInputType.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLElement.cpp
diff --git a/Source/core/html/HTMLElement.cpp b/Source/core/html/HTMLElement.cpp
index 42d27a47a5b5ea39d6f55b467ebc5b1888525e90..59e0cba45f063250b31e2a2163e13c282a11bf59 100644
--- a/Source/core/html/HTMLElement.cpp
+++ b/Source/core/html/HTMLElement.cpp
@@ -45,6 +45,7 @@
#include "core/events/EventListener.h"
#include "core/events/KeyboardEvent.h"
#include "core/frame/Settings.h"
+#include "core/frame/UseCounter.h"
#include "core/html/HTMLBRElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLInputElement.h"
@@ -53,6 +54,7 @@
#include "core/html/HTMLTextFormControlElement.h"
#include "core/html/parser/HTMLParserIdioms.h"
#include "core/rendering/RenderObject.h"
+#include "platform/Language.h"
#include "platform/text/BidiResolver.h"
#include "platform/text/BidiTextRun.h"
#include "platform/text/TextRunIterator.h"
@@ -140,6 +142,27 @@ void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, Mutabl
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);
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/html/forms/BaseButtonInputType.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698