OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |