Changeset 103608 in webkit


Ignore:
Timestamp:
Dec 22, 2011 11:29:32 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

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 <jshin@chromium.org>

Patch by Matt Falkenhagen <falken@chromium.org> on 2011-12-22
Reviewed by Darin Adler.

Source/WebCore:

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:

LayoutTests:

  • 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.
Location:
trunk
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r103607 r103608  
     12011-12-22  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Map 'lang' and xml:lang attributes to '-webkit-locale' CSS property for use with font fallback and text-transform
     4        https://bugs.webkit.org/show_bug.cgi?id=67586
     5
     6        Original patch by Jungshik Shin <jshin@chromium.org>
     7
     8        Reviewed by Darin Adler.
     9
     10        * fast/text/lang-mapped-to-webkit-locale-expected.txt: Added.
     11        * fast/text/lang-mapped-to-webkit-locale.xhtml: Added.
     12        * fast/text/xml-lang-ignored-in-html-expected.txt: Added.
     13        * fast/text/xml-lang-ignored-in-html.html: Added.
     14
    1152011-12-22  Ilya Tikhonovsky  <loislo@chromium.org>
    216
  • trunk/Source/WebCore/ChangeLog

    r103605 r103608  
     12011-12-22  Matt Falkenhagen  <falken@chromium.org>
     2
     3        Map 'lang' and xml:lang attributes to '-webkit-locale' CSS property for use with font fallback and text-transform
     4        https://bugs.webkit.org/show_bug.cgi?id=67586
     5
     6        Original patch by Jungshik Shin <jshin@chromium.org>
     7
     8        Reviewed by Darin Adler.
     9
     10        Tests: fast/text/lang-mapped-to-webkit-locale.xhtml
     11               fast/text/xml-lang-ignored-in-html.html
     12
     13        * html/HTMLElement.cpp:
     14        (WebCore::HTMLElement::mapLanguageAttributeToLocale):
     15        (WebCore::HTMLElement::parseMappedAttribute): Map 'lang' and 'xml:lang' to -webkit-locale.
     16        * html/HTMLElement.h:
     17
    1182011-12-22  Ryosuke Niwa  <rniwa@webkit.org>
    219
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r103373 r103608  
    2727
    2828#include "Attribute.h"
     29#include "CSSParser.h"
    2930#include "CSSPropertyNames.h"
    3031#include "CSSValueKeywords.h"
     
    4950#include "Text.h"
    5051#include "TextIterator.h"
     52#include "XMLNames.h"
    5153#include "markup.h"
    5254#include <wtf/StdLibExtras.h>
     
    169171}
    170172
     173void HTMLElement::mapLanguageAttributeToLocale(Attribute* attribute)
     174{
     175    ASSERT(attribute && (attribute->name() == langAttr || attribute->name().matches(XMLNames::langAttr)));
     176    const AtomicString& value = attribute->value();
     177    if (!value.isEmpty()) {
     178        // Have to quote so the locale id is treated as a string instead of as a CSS keyword.
     179        addCSSProperty(attribute, CSSPropertyWebkitLocale, quoteCSSString(value));
     180    } else {
     181        // The empty string means the language is explicitly unknown.
     182        addCSSProperty(attribute, CSSPropertyWebkitLocale, CSSValueAuto);
     183    }
     184    setNeedsStyleRecalc();
     185}
     186
    171187void HTMLElement::parseMappedAttribute(Attribute* attr)
    172188{
     
    193209            setTabIndexExplicitly(max(static_cast<int>(std::numeric_limits<short>::min()), min(tabindex, static_cast<int>(std::numeric_limits<short>::max()))));
    194210        }
     211    } else if (attr->name().matches(XMLNames::langAttr)) {
     212        mapLanguageAttributeToLocale(attr);
    195213    } else if (attr->name() == langAttr) {
    196         // FIXME: Implement
     214        // xml:lang has a higher priority than lang.
     215        if (!fastHasAttribute(XMLNames::langAttr))
     216            mapLanguageAttributeToLocale(attr);
    197217    } else if (attr->name() == dirAttr) {
    198218        bool dirIsAuto = equalIgnoringCase(attr->value(), "auto");
  • trunk/Source/WebCore/html/HTMLElement.h

    r101144 r103608  
    108108    virtual String nodeName() const;
    109109
     110    void mapLanguageAttributeToLocale(Attribute*);
     111
    110112    void setContentEditable(Attribute*);
    111113
Note: See TracChangeset for help on using the changeset viewer.