Changeset 106632 in webkit


Ignore:
Timestamp:
Feb 2, 2012 11:30:20 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Use content-language from http-equiv to set document locale and font
https://bugs.webkit.org/show_bug.cgi?id=76701

Patch by Matt Falkenhagen <falken@chromium.org> on 2012-02-02
Reviewed by Darin Adler.

Source/WebCore:

So far, only content-language set through http-equiv is used; the HTTP Content-Language
header is not yet supported.

Tests: fast/text/content-language-case-insensitivity.html

fast/text/content-language-mapped-to-webkit-locale.html
fast/text/international/content-language-font-selection-expected.html
fast/text/international/content-language-font-selection.html
fast/text/international/content-language-with-subtags-expected.html
fast/text/international/content-language-with-subtags.html

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::styleForDocument): Use content language when selecting initial font.

  • dom/Document.cpp:

(WebCore::Document::setContentLanguage): Recalculate style so language is taken into account.
(WebCore):

  • dom/Document.h:

(Document):

LayoutTests:

Add tests that content-language from http-equiv sets document locale and is used in font selection.

  • fast/text/content-language-case-insensitivity-expected.txt: Added.
  • fast/text/content-language-case-insensitivity.html: Added.
  • fast/text/content-language-mapped-to-webkit-locale-expected.txt: Added.
  • fast/text/content-language-mapped-to-webkit-locale.html: Added.
  • fast/text/international/content-language-font-selection-expected.html: Added.
  • fast/text/international/content-language-font-selection.html: Added.
  • fast/text/international/content-language-with-subtags-expected.html: Added.
  • fast/text/international/content-language-with-subtags.html: Added.
  • fast/text/lang-mapped-to-webkit-locale-expected.txt:
  • fast/text/lang-mapped-to-webkit-locale.xhtml: Fix some style issues.
  • fast/text/xml-lang-ignored-in-html-expected.txt:
  • fast/text/xml-lang-ignored-in-html.html: Fix some style issues.
  • platform/efl/Skipped: Skip tests using overridePreference("WebKit*FontMap"...) on non-Chromium ports.
  • platform/gtk-wk2/Skipped: Ditto.
  • platform/gtk/Skipped: Ditto.
  • platform/mac/Skipped: Ditto.
  • platform/qt/Skipped: Ditto.
  • platform/win/Skipped: Ditto.
  • platform/wincairo/Skipped: Ditto.
  • platform/wk2/Skipped: Ditto.
Location:
trunk
Files:
8 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r106631 r106632  
     12012-02-02  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Use content-language from http-equiv to set document locale and font
     4        https://bugs.webkit.org/show_bug.cgi?id=76701
     5
     6        Reviewed by Darin Adler.
     7
     8        Add tests that content-language from http-equiv sets document locale and is used in font selection.
     9
     10        * fast/text/content-language-case-insensitivity-expected.txt: Added.
     11        * fast/text/content-language-case-insensitivity.html: Added.
     12        * fast/text/content-language-mapped-to-webkit-locale-expected.txt: Added.
     13        * fast/text/content-language-mapped-to-webkit-locale.html: Added.
     14        * fast/text/international/content-language-font-selection-expected.html: Added.
     15        * fast/text/international/content-language-font-selection.html: Added.
     16        * fast/text/international/content-language-with-subtags-expected.html: Added.
     17        * fast/text/international/content-language-with-subtags.html: Added.
     18        * fast/text/lang-mapped-to-webkit-locale-expected.txt:
     19        * fast/text/lang-mapped-to-webkit-locale.xhtml: Fix some style issues.
     20        * fast/text/xml-lang-ignored-in-html-expected.txt:
     21        * fast/text/xml-lang-ignored-in-html.html: Fix some style issues.
     22        * platform/efl/Skipped: Skip tests using overridePreference("WebKit*FontMap"...) on non-Chromium ports.
     23        * platform/gtk-wk2/Skipped: Ditto.
     24        * platform/gtk/Skipped: Ditto.
     25        * platform/mac/Skipped: Ditto.
     26        * platform/qt/Skipped: Ditto.
     27        * platform/win/Skipped: Ditto.
     28        * platform/wincairo/Skipped: Ditto.
     29        * platform/wk2/Skipped: Ditto.
     30
    1312012-02-02  Csaba Osztrogonác  <ossy@webkit.org>
    232
  • trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale-expected.txt

    r103608 r106632  
    11This is a test for bug 67586. HTML attributes lang and xml:lang are mapped to '-webkit-locale' to use their value in font fallback.
    22
    3 PASS getLangOfNode('x1') is "ja"
    4 PASS getLangOfNode('x2') is "ja"
    5 PASS getLangOfNode('x3') is "ja"
    6 PASS getLangOfNode('l1') is "zh"
    7 PASS getLangOfNode('l2') is "zh"
    8 PASS getLangOfNode('l3') is "zh"
    9 PASS getLangOfNode('m1') is "ko"
    10 PASS getLangOfNode('m2') is "fr"
    11 PASS getLangOfNode('m3') is "fr"
    12 PASS getLangOfNode('n1') is "fr"
    13 PASS getLangOfNode('n2') is "fr"
    14 PASS getLangOfNode('n3') is "sv"
    15 PASS getLangOfNode('p1') is "ja"
    16 PASS getLangOfNode('p2') is "auto"
    17 PASS getLangOfNode('q1') is "ja"
    18 PASS getLangOfNode('q2') is "auto"
    19 PASS getLangOfNode('q3') is "auto"
    20 PASS getLangOfNode('q4') is "ar"
    21 PASS getLangOfNode('q5') is "auto"
    22 PASS getLangOfNode('q6') is "'  '"
    23 PASS getLangOfNode('q7') is "auto"
    24 PASS getLangOfNode('q8') is "xyzzy"
    25 PASS getLangOfNode('q9') is "'][;][['"
     3PASS languageOfNode('x1') is "ja"
     4PASS languageOfNode('x2') is "ja"
     5PASS languageOfNode('x3') is "ja"
     6PASS languageOfNode('l1') is "zh"
     7PASS languageOfNode('l2') is "zh"
     8PASS languageOfNode('l3') is "zh"
     9PASS languageOfNode('m1') is "ko"
     10PASS languageOfNode('m2') is "fr"
     11PASS languageOfNode('m3') is "fr"
     12PASS languageOfNode('n1') is "fr"
     13PASS languageOfNode('n2') is "fr"
     14PASS languageOfNode('n3') is "sv"
     15PASS languageOfNode('p1') is "ja"
     16PASS languageOfNode('p2') is "auto"
     17PASS languageOfNode('q1') is "ja"
     18PASS languageOfNode('q2') is "auto"
     19PASS languageOfNode('q3') is "auto"
     20PASS languageOfNode('q4') is "ar"
     21PASS languageOfNode('q5') is "auto"
     22PASS languageOfNode('q6') is "'  '"
     23PASS languageOfNode('q7') is "auto"
     24PASS languageOfNode('q8') is "xyzzy"
     25PASS languageOfNode('q9') is "'][;][['"
    2626PASS successfullyParsed is true
    2727
  • trunk/LayoutTests/fast/text/lang-mapped-to-webkit-locale.xhtml

    r103608 r106632  
    2525</div>
    2626<script>
    27 function getLangOfNode(n) {
    28     e = document.getElementById(n);
    29     return window.getComputedStyle(e).webkitLocale;
     27function languageOfNode(id) {
     28    var element = document.getElementById(id);
     29    return window.getComputedStyle(element).webkitLocale;
    3030}
    31 shouldBeEqualToString("getLangOfNode('x1')", "ja");
    32 shouldBeEqualToString("getLangOfNode('x2')", "ja");
    33 shouldBeEqualToString("getLangOfNode('x3')", "ja");
    34 shouldBeEqualToString("getLangOfNode('l1')", "zh");
    35 shouldBeEqualToString("getLangOfNode('l2')", "zh");
    36 shouldBeEqualToString("getLangOfNode('l3')", "zh");
    37 shouldBeEqualToString("getLangOfNode('m1')", "ko");
    38 shouldBeEqualToString("getLangOfNode('m2')", "fr");
    39 shouldBeEqualToString("getLangOfNode('m3')", "fr");
    40 shouldBeEqualToString("getLangOfNode('n1')", "fr");
    41 shouldBeEqualToString("getLangOfNode('n2')", "fr");
    42 shouldBeEqualToString("getLangOfNode('n3')", "sv");
    43 shouldBeEqualToString("getLangOfNode('p1')", "ja");
    44 shouldBeEqualToString("getLangOfNode('p2')", "auto");
    45 shouldBeEqualToString("getLangOfNode('q1')", "ja");
    46 shouldBeEqualToString("getLangOfNode('q2')", "auto");
    47 shouldBeEqualToString("getLangOfNode('q3')", "auto");
    48 shouldBeEqualToString("getLangOfNode('q4')", "ar");
    49 shouldBeEqualToString("getLangOfNode('q5')", "auto");
    50 shouldBeEqualToString("getLangOfNode('q6')", "'  '");
    51 shouldBeEqualToString("getLangOfNode('q7')", "auto");
    52 shouldBeEqualToString("getLangOfNode('q8')", "xyzzy");
    53 shouldBeEqualToString("getLangOfNode('q9')", "'][;][['");
     31shouldBeEqualToString("languageOfNode('x1')", "ja");
     32shouldBeEqualToString("languageOfNode('x2')", "ja");
     33shouldBeEqualToString("languageOfNode('x3')", "ja");
     34shouldBeEqualToString("languageOfNode('l1')", "zh");
     35shouldBeEqualToString("languageOfNode('l2')", "zh");
     36shouldBeEqualToString("languageOfNode('l3')", "zh");
     37shouldBeEqualToString("languageOfNode('m1')", "ko");
     38shouldBeEqualToString("languageOfNode('m2')", "fr");
     39shouldBeEqualToString("languageOfNode('m3')", "fr");
     40shouldBeEqualToString("languageOfNode('n1')", "fr");
     41shouldBeEqualToString("languageOfNode('n2')", "fr");
     42shouldBeEqualToString("languageOfNode('n3')", "sv");
     43shouldBeEqualToString("languageOfNode('p1')", "ja");
     44shouldBeEqualToString("languageOfNode('p2')", "auto");
     45shouldBeEqualToString("languageOfNode('q1')", "ja");
     46shouldBeEqualToString("languageOfNode('q2')", "auto");
     47shouldBeEqualToString("languageOfNode('q3')", "auto");
     48shouldBeEqualToString("languageOfNode('q4')", "ar");
     49shouldBeEqualToString("languageOfNode('q5')", "auto");
     50shouldBeEqualToString("languageOfNode('q6')", "'  '");
     51shouldBeEqualToString("languageOfNode('q7')", "auto");
     52shouldBeEqualToString("languageOfNode('q8')", "xyzzy");
     53shouldBeEqualToString("languageOfNode('q9')", "'][;][['");
    5454
    5555var successfullyParsed = true;
  • trunk/LayoutTests/fast/text/xml-lang-ignored-in-html-expected.txt

    r103608 r106632  
    11This tests that the attribute in no namespace with no prefix and with the literal localname "xml:lang" is ignored in HTML. See bug 67586.
    22
    3 PASS getLangOfNode('m1') is "auto"
    4 PASS getLangOfNode('n1') is "ko"
    5 PASS getLangOfNode('o1') is "ar"
    6 PASS getLangOfNode('o2') is "ar"
     3PASS languageOfNode('m1') is "auto"
     4PASS languageOfNode('n1') is "ko"
     5PASS languageOfNode('o1') is "ar"
     6PASS languageOfNode('o2') is "ar"
    77PASS successfullyParsed is true
    88
  • trunk/LayoutTests/fast/text/xml-lang-ignored-in-html.html

    r103608 r106632  
    11<html xmlns="http://www.w3.org/1999/xhtml">
    22<head>
    3 <link rel="stylesheet" href="../js/resources/js-test-style.css" />
     3<link rel="stylesheet" href="../js/resources/js-test-style.css">
    44<script src="../js/resources/js-test-pre.js"></script>
    55</head>
     
    88<a href="http://webkit.org/b/67586">bug 67586</a>.</p>
    99<div id="console"></div>
    10 <div xml:lang="ar" id="m1"></div></div>
     10<div xml:lang="ar" id="m1"></div>
    1111<div lang="ko"><div xml:lang="ar" id="n1"></div></div>
    1212<div lang="ar" id="o1"><div xml:lang="" id="o2"></div></div>
    1313<script>
    14 function getLangOfNode(n) {
    15     e = document.getElementById(n);
    16     return window.getComputedStyle(e).webkitLocale;
     14function languageOfNode(id) {
     15    var element = document.getElementById(id);
     16    return window.getComputedStyle(element).webkitLocale;
    1717}
    18 shouldBeEqualToString("getLangOfNode('m1')", "auto");
    19 shouldBeEqualToString("getLangOfNode('n1')", "ko");
    20 shouldBeEqualToString("getLangOfNode('o1')", "ar");
    21 shouldBeEqualToString("getLangOfNode('o2')", "ar");
     18shouldBeEqualToString("languageOfNode('m1')", "auto");
     19shouldBeEqualToString("languageOfNode('n1')", "ko");
     20shouldBeEqualToString("languageOfNode('o1')", "ar");
     21shouldBeEqualToString("languageOfNode('o2')", "ar");
    2222
    2323var successfullyParsed = true;
  • trunk/LayoutTests/platform/efl/Skipped

    r106431 r106632  
    719719fast/repaint/no-caret-repaint-in-non-content-editable-element.html
    720720fast/spatial-navigation
     721fast/text/international/content-language-font-selection.html
     722fast/text/international/content-language-with-subtags.html
    721723fast/text/international/locale-sensitive-fonts.html
    722724fast/text/zero-font-size.html
  • trunk/LayoutTests/platform/gtk-wk2/Skipped

    r102955 r106632  
    209209# WebKit2 needs layoutTestController.overridePreference
    210210# https://bugs.webkit.org/show_bug.cgi?id=42197
     211fast/text/international/content-language-font-selection.html
     212fast/text/international/content-language-with-subtags.html
    211213fast/text/international/locale-sensitive-fonts.html
    212214fast/repaint/no-caret-repaint-in-non-content-editable-element.html
  • trunk/LayoutTests/platform/gtk/Skipped

    r106546 r106632  
    375375# layoutTestController.overridePreference("WebKit*FontMap"...) is not
    376376# supported.
     377fast/text/international/content-language-font-selection.html
     378fast/text/international/content-language-with-subtags.html
    377379fast/text/international/locale-sensitive-fonts.html
    378380
  • trunk/LayoutTests/platform/mac/Skipped

    r106463 r106632  
    494494
    495495# DRT doesn't support overridePreference("WebKit*FontMap"...)
     496fast/text/international/content-language-font-selection.html
     497fast/text/international/content-language-with-subtags.html
    496498fast/text/international/locale-sensitive-fonts.html
    497499
  • trunk/LayoutTests/platform/qt/Skipped

    r106631 r106632  
    995995# Missing DRT ability to override 'standard' preferences.
    996996fast/dom/Window/timer-resume-on-navigation-back.html
     997fast/text/international/content-language-font-selection.html
     998fast/text/international/content-language-with-subtags.html
    997999fast/text/international/locale-sensitive-fonts.html
    9981000loader/go-back-to-different-window-size.html
  • trunk/LayoutTests/platform/win/Skipped

    r106593 r106632  
    15031503
    15041504# DRT doesn't support overridePreference("WebKit*FontMap"...)
     1505fast/text/international/content-language-font-selection.html
     1506fast/text/international/content-language-with-subtags.html
    15051507fast/text/international/locale-sensitive-fonts.html
    15061508
  • trunk/LayoutTests/platform/wincairo/Skipped

    r106337 r106632  
    20272027
    20282028# DRT doesn't support overridePreference("WebKit*FontMap"...)
     2029fast/text/international/content-language-font-selection.html
     2030fast/text/international/content-language-with-subtags.html
    20292031fast/text/international/locale-sensitive-fonts.html
    20302032
  • trunk/LayoutTests/platform/wk2/Skipped

    r106457 r106632  
    291291fast/repaint/no-caret-repaint-in-non-content-editable-element.html
    292292fast/text/zero-font-size.html
     293fast/text/international/content-language-font-selection.html
     294fast/text/international/content-language-with-subtags.html
    293295fast/text/international/locale-sensitive-fonts.html
    294296css3/filters/effect-combined.html
  • trunk/Source/WebCore/ChangeLog

    r106630 r106632  
     12012-02-02  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Use content-language from http-equiv to set document locale and font
     4        https://bugs.webkit.org/show_bug.cgi?id=76701
     5
     6        Reviewed by Darin Adler.
     7
     8        So far, only content-language set through http-equiv is used; the HTTP Content-Language
     9        header is not yet supported.
     10
     11        Tests: fast/text/content-language-case-insensitivity.html
     12               fast/text/content-language-mapped-to-webkit-locale.html
     13               fast/text/international/content-language-font-selection-expected.html
     14               fast/text/international/content-language-font-selection.html
     15               fast/text/international/content-language-with-subtags-expected.html
     16               fast/text/international/content-language-with-subtags.html
     17
     18        * css/CSSStyleSelector.cpp:
     19        (WebCore::CSSStyleSelector::styleForDocument): Use content language when selecting initial font.
     20        * dom/Document.cpp:
     21        (WebCore::Document::setContentLanguage): Recalculate style so language is taken into account.
     22        (WebCore):
     23        * dom/Document.h:
     24        (Document):
     25
    1262012-02-02  Sheriff Bot  <webkit.review.bot@gmail.com>
    227
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r106568 r106632  
    14041404    documentStyle->setPageScaleTransform(frame ? frame->frameScaleFactor() : 1);
    14051405    documentStyle->setUserModify(document->inDesignMode() ? READ_WRITE : READ_ONLY);
     1406    documentStyle->setLocale(document->contentLanguage());
    14061407
    14071408    Element* docElement = document->documentElement();
     
    14341435    FontDescription fontDescription;
    14351436    fontDescription.setUsePrinterFont(document->printing());
     1437    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle->locale()));
    14361438    if (Settings* settings = document->settings()) {
    14371439        fontDescription.setRenderingMode(settings->fontRenderingMode());
    1438         const AtomicString& stdfont = settings->standardFontFamily();
    1439         if (!stdfont.isEmpty()) {
     1440        const AtomicString& standardFont = settings->standardFontFamily(fontDescription.script());
     1441        if (!standardFont.isEmpty()) {
    14401442            fontDescription.setGenericFamily(FontDescription::StandardFamily);
    1441             fontDescription.firstFamily().setFamily(stdfont);
     1443            fontDescription.firstFamily().setFamily(standardFont);
    14421444            fontDescription.firstFamily().appendFamily(0);
    14431445        }
  • trunk/Source/WebCore/dom/Document.cpp

    r106530 r106632  
    11031103}
    11041104
     1105void Document::setContentLanguage(const String& language)
     1106{
     1107    if (m_contentLanguage == language)
     1108        return;
     1109    m_contentLanguage = language;
     1110
     1111    // Recalculate style so language is used when selecting the initial font.
     1112    styleSelectorChanged(DeferRecalcStyle);
     1113}
     1114
    11051115void Document::setXMLVersion(const String& version, ExceptionCode& ec)
    11061116{
  • trunk/Source/WebCore/dom/Document.h

    r106530 r106632  
    388388
    389389    String contentLanguage() const { return m_contentLanguage; }
    390     void setContentLanguage(const String& lang) { m_contentLanguage = lang; }
     390    void setContentLanguage(const String&);
    391391
    392392    String xmlEncoding() const { return m_xmlEncoding; }
Note: See TracChangeset for help on using the changeset viewer.