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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/frame/UseCounter.h ('k') | Source/core/html/forms/BaseButtonInputType.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved. 4 * Copyright (C) 2004-2008, 2013, 2014 Apple Inc. All rights reserved.
5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 5 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
6 * Copyright (C) 2011 Motorola Mobility. All rights reserved. 6 * Copyright (C) 2011 Motorola Mobility. All rights reserved.
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 27 matching lines...) Expand all
38 #include "core/dom/ElementTraversal.h" 38 #include "core/dom/ElementTraversal.h"
39 #include "core/dom/ExceptionCode.h" 39 #include "core/dom/ExceptionCode.h"
40 #include "core/dom/NodeTraversal.h" 40 #include "core/dom/NodeTraversal.h"
41 #include "core/dom/Text.h" 41 #include "core/dom/Text.h"
42 #include "core/dom/shadow/ElementShadow.h" 42 #include "core/dom/shadow/ElementShadow.h"
43 #include "core/dom/shadow/ShadowRoot.h" 43 #include "core/dom/shadow/ShadowRoot.h"
44 #include "core/editing/markup.h" 44 #include "core/editing/markup.h"
45 #include "core/events/EventListener.h" 45 #include "core/events/EventListener.h"
46 #include "core/events/KeyboardEvent.h" 46 #include "core/events/KeyboardEvent.h"
47 #include "core/frame/Settings.h" 47 #include "core/frame/Settings.h"
48 #include "core/frame/UseCounter.h"
48 #include "core/html/HTMLBRElement.h" 49 #include "core/html/HTMLBRElement.h"
49 #include "core/html/HTMLFormElement.h" 50 #include "core/html/HTMLFormElement.h"
50 #include "core/html/HTMLInputElement.h" 51 #include "core/html/HTMLInputElement.h"
51 #include "core/html/HTMLMenuElement.h" 52 #include "core/html/HTMLMenuElement.h"
52 #include "core/html/HTMLTemplateElement.h" 53 #include "core/html/HTMLTemplateElement.h"
53 #include "core/html/HTMLTextFormControlElement.h" 54 #include "core/html/HTMLTextFormControlElement.h"
54 #include "core/html/parser/HTMLParserIdioms.h" 55 #include "core/html/parser/HTMLParserIdioms.h"
55 #include "core/rendering/RenderObject.h" 56 #include "core/rendering/RenderObject.h"
57 #include "platform/Language.h"
56 #include "platform/text/BidiResolver.h" 58 #include "platform/text/BidiResolver.h"
57 #include "platform/text/BidiTextRun.h" 59 #include "platform/text/BidiTextRun.h"
58 #include "platform/text/TextRunIterator.h" 60 #include "platform/text/TextRunIterator.h"
59 #include "wtf/StdLibExtras.h" 61 #include "wtf/StdLibExtras.h"
60 #include "wtf/text/CString.h" 62 #include "wtf/text/CString.h"
61 63
62 namespace blink { 64 namespace blink {
63 65
64 using namespace HTMLNames; 66 using namespace HTMLNames;
65 using namespace WTF; 67 using namespace WTF;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 { 135 {
134 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parse BorderWidthAttribute(value), CSSPrimitiveValue::CSS_PX); 136 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderWidth, parse BorderWidthAttribute(value), CSSPrimitiveValue::CSS_PX);
135 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, CSSVa lueSolid); 137 addPropertyToPresentationAttributeStyle(style, CSSPropertyBorderStyle, CSSVa lueSolid);
136 } 138 }
137 139
138 void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, Mutabl eStylePropertySet* style) 140 void HTMLElement::mapLanguageAttributeToLocale(const AtomicString& value, Mutabl eStylePropertySet* style)
139 { 141 {
140 if (!value.isEmpty()) { 142 if (!value.isEmpty()) {
141 // Have to quote so the locale id is treated as a string instead of as a CSS keyword. 143 // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
142 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(value)); 144 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, quoteCSSString(value));
145
146 // FIXME: Remove the following UseCounter code when we collect enough
147 // data.
148 UseCounter::count(document(), UseCounter::LangAttribute);
149 if (isHTMLHtmlElement(*this))
150 UseCounter::count(document(), UseCounter::LangAttributeOnHTML);
151 else if (isHTMLBodyElement(*this))
152 UseCounter::count(document(), UseCounter::LangAttributeOnBody);
153 String htmlLanguage = value.string();
154 size_t firstSeparator = htmlLanguage.find('-');
155 if (firstSeparator != kNotFound)
156 htmlLanguage = htmlLanguage.left(firstSeparator);
157 String uiLanguage = defaultLanguage();
158 firstSeparator = uiLanguage.find('-');
159 if (firstSeparator != kNotFound)
160 uiLanguage = uiLanguage.left(firstSeparator);
161 firstSeparator = uiLanguage.find('_');
162 if (firstSeparator != kNotFound)
163 uiLanguage = uiLanguage.left(firstSeparator);
164 if (!equalIgnoringCase(htmlLanguage, uiLanguage))
165 UseCounter::count(document(), UseCounter::LangAttributeDoesNotMatchT oUILocale);
143 } else { 166 } else {
144 // The empty string means the language is explicitly unknown. 167 // The empty string means the language is explicitly unknown.
145 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto); 168 addPropertyToPresentationAttributeStyle(style, CSSPropertyWebkitLocale, CSSValueAuto);
146 } 169 }
147 } 170 }
148 171
149 bool HTMLElement::isPresentationAttribute(const QualifiedName& name) const 172 bool HTMLElement::isPresentationAttribute(const QualifiedName& name) const
150 { 173 {
151 if (name == alignAttr || name == contenteditableAttr || name == hiddenAttr | | name == langAttr || name.matches(XMLNames::langAttr) || name == draggableAttr || name == dirAttr) 174 if (name == alignAttr || name == contenteditableAttr || name == hiddenAttr | | name == langAttr || name.matches(XMLNames::langAttr) || name == draggableAttr || name == dirAttr)
152 return true; 175 return true;
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 #ifndef NDEBUG 1026 #ifndef NDEBUG
1004 1027
1005 // For use in the debugger 1028 // For use in the debugger
1006 void dumpInnerHTML(blink::HTMLElement*); 1029 void dumpInnerHTML(blink::HTMLElement*);
1007 1030
1008 void dumpInnerHTML(blink::HTMLElement* element) 1031 void dumpInnerHTML(blink::HTMLElement* element)
1009 { 1032 {
1010 printf("%s\n", element->innerHTML().ascii().data()); 1033 printf("%s\n", element->innerHTML().ascii().data());
1011 } 1034 }
1012 #endif 1035 #endif
OLDNEW
« 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