Diff
Modified: trunk/LayoutTests/ChangeLog (103607 => 103608)
--- trunk/LayoutTests/ChangeLog 2011-12-23 06:30:59 UTC (rev 103607)
+++ trunk/LayoutTests/ChangeLog 2011-12-23 07:29:32 UTC (rev 103608)
@@ -1,3 +1,17 @@
+2011-12-22 Matt Falkenhagen <[email protected]>
+
+ Map 'lang' and xml:lang attributes to '-webkit-locale' CSS property for use with font fallback and text-transform
+ https://bugs.webkit.org/show_bug.cgi?id=67586
+
+ Original patch by Jungshik Shin <[email protected]>
+
+ Reviewed by Darin Adler.
+
+ * fast/text/lang-mapped-to-webkit-locale-expected.txt: Added.
+ * fast/text/lang-mapped-to-webkit-locale.xhtml: Added.
+ * fast/text/xml-lang-ignored-in-html-expected.txt: Added.
+ * fast/text/xml-lang-ignored-in-html.html: Added.
+
2011-12-22 Ilya Tikhonovsky <[email protected]>
Unreviewed. Update chromium test expectations.
Added: trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale-expected.txt (0 => 103608)
--- trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale-expected.txt 2011-12-23 07:29:32 UTC (rev 103608)
@@ -0,0 +1,29 @@
+This is a test for bug 67586. HTML attributes lang and xml:lang are mapped to '-webkit-locale' to use their value in font fallback.
+
+PASS getLangOfNode('x1') is "ja"
+PASS getLangOfNode('x2') is "ja"
+PASS getLangOfNode('x3') is "ja"
+PASS getLangOfNode('l1') is "zh"
+PASS getLangOfNode('l2') is "zh"
+PASS getLangOfNode('l3') is "zh"
+PASS getLangOfNode('m1') is "ko"
+PASS getLangOfNode('m2') is "fr"
+PASS getLangOfNode('m3') is "fr"
+PASS getLangOfNode('n1') is "fr"
+PASS getLangOfNode('n2') is "fr"
+PASS getLangOfNode('n3') is "sv"
+PASS getLangOfNode('p1') is "ja"
+PASS getLangOfNode('p2') is "auto"
+PASS getLangOfNode('q1') is "ja"
+PASS getLangOfNode('q2') is "auto"
+PASS getLangOfNode('q3') is "auto"
+PASS getLangOfNode('q4') is "ar"
+PASS getLangOfNode('q5') is "auto"
+PASS getLangOfNode('q6') is "' '"
+PASS getLangOfNode('q7') is "auto"
+PASS getLangOfNode('q8') is "xyzzy"
+PASS getLangOfNode('q9') is "'][;][['"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale.xhtml (0 => 103608)
--- trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale.xhtml (rev 0)
+++ trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale.xhtml 2011-12-23 07:29:32 UTC (rev 103608)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>mapping lang to -webkit-locale</title>
+<link rel="stylesheet" href="" />
+<script src=""
+</head>
+<body>
+<p>This is a test for <a href="" 67586</a>. HTML attributes lang and xml:lang are mapped to '-webkit-locale' to use their value in font fallback.</p>
+<div id="console"></div>
+<div xml:lang="ja" lang="en" id="x1"><div id="x2"><div id="x3"></div></div></div>
+<div lang="zh" id="l1"><div id="l2"><div id="l3"></div></div></div>
+<div lang="ko" id="m1"><div lang="fr" xml:lang="fr" id="m2"><div id="m3"></div></div></div>
+<div xml:lang="fr" id="n1"><div id="n2"><div lang="sv" id="n3"></div></div></div>
+<div xml:lang="ja" id="p1"><div lang="" id="p2"></div></div>
+<div lang="ja" id="q1">
+ <div lang="" id="q2"></div>
+ <div xml:lang="" id="q3"></div>
+ <div xml:lang="ar" id="q4"><div xml:lang="" id="q5"></div></div>
+ <div lang=" " id="q6"></div>
+ <div lang="auto" id="q7"></div>
+ <div lang="xyzzy" id="q8"></div>
+ <div lang="][;][[" id="q9"></div>
+</div>
+<script>
+function getLangOfNode(n) {
+ e = document.getElementById(n);
+ return window.getComputedStyle(e).webkitLocale;
+}
+shouldBeEqualToString("getLangOfNode('x1')", "ja");
+shouldBeEqualToString("getLangOfNode('x2')", "ja");
+shouldBeEqualToString("getLangOfNode('x3')", "ja");
+shouldBeEqualToString("getLangOfNode('l1')", "zh");
+shouldBeEqualToString("getLangOfNode('l2')", "zh");
+shouldBeEqualToString("getLangOfNode('l3')", "zh");
+shouldBeEqualToString("getLangOfNode('m1')", "ko");
+shouldBeEqualToString("getLangOfNode('m2')", "fr");
+shouldBeEqualToString("getLangOfNode('m3')", "fr");
+shouldBeEqualToString("getLangOfNode('n1')", "fr");
+shouldBeEqualToString("getLangOfNode('n2')", "fr");
+shouldBeEqualToString("getLangOfNode('n3')", "sv");
+shouldBeEqualToString("getLangOfNode('p1')", "ja");
+shouldBeEqualToString("getLangOfNode('p2')", "auto");
+shouldBeEqualToString("getLangOfNode('q1')", "ja");
+shouldBeEqualToString("getLangOfNode('q2')", "auto");
+shouldBeEqualToString("getLangOfNode('q3')", "auto");
+shouldBeEqualToString("getLangOfNode('q4')", "ar");
+shouldBeEqualToString("getLangOfNode('q5')", "auto");
+shouldBeEqualToString("getLangOfNode('q6')", "' '");
+shouldBeEqualToString("getLangOfNode('q7')", "auto");
+shouldBeEqualToString("getLangOfNode('q8')", "xyzzy");
+shouldBeEqualToString("getLangOfNode('q9')", "'][;][['");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
+
Added: trunk/LayoutTests/fast/text/xml-lang-ignored-in-html-expected.txt (0 => 103608)
--- trunk/LayoutTests/fast/text/xml-lang-ignored-in-html-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/xml-lang-ignored-in-html-expected.txt 2011-12-23 07:29:32 UTC (rev 103608)
@@ -0,0 +1,10 @@
+This tests that the attribute in no namespace with no prefix and with the literal localname "xml:lang" is ignored in HTML. See bug 67586.
+
+PASS getLangOfNode('m1') is "auto"
+PASS getLangOfNode('n1') is "ko"
+PASS getLangOfNode('o1') is "ar"
+PASS getLangOfNode('o2') is "ar"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/xml-lang-ignored-in-html.html (0 => 103608)
--- trunk/LayoutTests/fast/text/xml-lang-ignored-in-html.html (rev 0)
+++ trunk/LayoutTests/fast/text/xml-lang-ignored-in-html.html 2011-12-23 07:29:32 UTC (rev 103608)
@@ -0,0 +1,28 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<link rel="stylesheet" href="" />
+<script src=""
+</head>
+<body>
+<p>This tests that the attribute in no namespace with no prefix and with the literal localname "xml:lang" is ignored in HTML. See
+<a href="" 67586</a>.</p>
+<div id="console"></div>
+<div xml:lang="ar" id="m1"></div></div>
+<div lang="ko"><div xml:lang="ar" id="n1"></div></div>
+<div lang="ar" id="o1"><div xml:lang="" id="o2"></div></div>
+<script>
+function getLangOfNode(n) {
+ e = document.getElementById(n);
+ return window.getComputedStyle(e).webkitLocale;
+}
+shouldBeEqualToString("getLangOfNode('m1')", "auto");
+shouldBeEqualToString("getLangOfNode('n1')", "ko");
+shouldBeEqualToString("getLangOfNode('o1')", "ar");
+shouldBeEqualToString("getLangOfNode('o2')", "ar");
+
+var successfullyParsed = true;
+</script>
+<script src=""
+</body>
+</html>
+
Modified: trunk/Source/WebCore/ChangeLog (103607 => 103608)
--- trunk/Source/WebCore/ChangeLog 2011-12-23 06:30:59 UTC (rev 103607)
+++ trunk/Source/WebCore/ChangeLog 2011-12-23 07:29:32 UTC (rev 103608)
@@ -1,3 +1,20 @@
+2011-12-22 Matt Falkenhagen <[email protected]>
+
+ Map 'lang' and xml:lang attributes to '-webkit-locale' CSS property for use with font fallback and text-transform
+ https://bugs.webkit.org/show_bug.cgi?id=67586
+
+ Original patch by Jungshik Shin <[email protected]>
+
+ Reviewed by Darin Adler.
+
+ Tests: fast/text/lang-mapped-to-webkit-locale.xhtml
+ fast/text/xml-lang-ignored-in-html.html
+
+ * html/HTMLElement.cpp:
+ (WebCore::HTMLElement::mapLanguageAttributeToLocale):
+ (WebCore::HTMLElement::parseMappedAttribute): Map 'lang' and 'xml:lang' to -webkit-locale.
+ * html/HTMLElement.h:
+
2011-12-22 Ryosuke Niwa <[email protected]>
WinCE build fix after r103539.
Modified: trunk/Source/WebCore/html/HTMLElement.cpp (103607 => 103608)
--- trunk/Source/WebCore/html/HTMLElement.cpp 2011-12-23 06:30:59 UTC (rev 103607)
+++ trunk/Source/WebCore/html/HTMLElement.cpp 2011-12-23 07:29:32 UTC (rev 103608)
@@ -26,6 +26,7 @@
#include "HTMLElement.h"
#include "Attribute.h"
+#include "CSSParser.h"
#include "CSSPropertyNames.h"
#include "CSSValueKeywords.h"
#include "ChildListMutationScope.h"
@@ -48,6 +49,7 @@
#include "Settings.h"
#include "Text.h"
#include "TextIterator.h"
+#include "XMLNames.h"
#include "markup.h"
#include <wtf/StdLibExtras.h>
#include <wtf/text/CString.h>
@@ -168,6 +170,20 @@
addCSSProperty(attr, CSSPropertyBorderLeftStyle, CSSValueSolid);
}
+void HTMLElement::mapLanguageAttributeToLocale(Attribute* attribute)
+{
+ ASSERT(attribute && (attribute->name() == langAttr || attribute->name().matches(XMLNames::langAttr)));
+ const AtomicString& value = attribute->value();
+ if (!value.isEmpty()) {
+ // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
+ addCSSProperty(attribute, CSSPropertyWebkitLocale, quoteCSSString(value));
+ } else {
+ // The empty string means the language is explicitly unknown.
+ addCSSProperty(attribute, CSSPropertyWebkitLocale, CSSValueAuto);
+ }
+ setNeedsStyleRecalc();
+}
+
void HTMLElement::parseMappedAttribute(Attribute* attr)
{
if (isIdAttributeName(attr->name()) || attr->name() == classAttr || attr->name() == styleAttr)
@@ -192,8 +208,12 @@
// Clamp tabindex to the range of 'short' to match Firefox's behavior.
setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
}
+ } else if (attr->name().matches(XMLNames::langAttr)) {
+ mapLanguageAttributeToLocale(attr);
} else if (attr->name() == langAttr) {
- // FIXME: Implement
+ // xml:lang has a higher priority than lang.
+ if (!fastHasAttribute(XMLNames::langAttr))
+ mapLanguageAttributeToLocale(attr);
} else if (attr->name() == dirAttr) {
bool dirIsAuto = equalIgnoringCase(attr->value(), "auto");
if (!dirIsAuto)
Modified: trunk/Source/WebCore/html/HTMLElement.h (103607 => 103608)
--- trunk/Source/WebCore/html/HTMLElement.h 2011-12-23 06:30:59 UTC (rev 103607)
+++ trunk/Source/WebCore/html/HTMLElement.h 2011-12-23 07:29:32 UTC (rev 103608)
@@ -107,6 +107,8 @@
private:
virtual String nodeName() const;
+ void mapLanguageAttributeToLocale(Attribute*);
+
void setContentEditable(Attribute*);
virtual HTMLFormElement* virtualForm() const;