Changeset 66647 in webkit


Ignore:
Timestamp:
Sep 2, 2010 12:52:42 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-09-02 Ilya Sherman <isherman@google.com>

Reviewed by Eric Seidel.

Decompose computing an element's inherited language, expose this
capability to clients (in particular, for Chromium).
https://bugs.webkit.org/show_bug.cgi?id=44803

No new tests -- just refactoring + exposing code.

  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
  • dom/Element.cpp: (WebCore::Element::computeInheritedLang):
  • dom/Element.h:

2010-09-02 Ilya Sherman <isherman@google.com>

Reviewed by Eric Seidel.

Exposing computing an element's inherited language, per the DOM, in the
Chromium API -- primarily for use with autofill i18n.
https://bugs.webkit.org/show_bug.cgi?id=44803

  • public/WebElement.h:
  • src/WebElement.cpp: (WebKit::WebElement::computeInheritedLanguage):
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r66646 r66647  
     12010-09-02  Ilya Sherman  <isherman@google.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Decompose computing an element's inherited language, expose this
     6        capability to clients (in particular, for Chromium).
     7        https://bugs.webkit.org/show_bug.cgi?id=44803
     8
     9        No new tests -- just refactoring + exposing code.
     10
     11        * css/CSSStyleSelector.cpp:
     12        (WebCore::CSSStyleSelector::SelectorChecker::checkOneSelector):
     13        * dom/Element.cpp:
     14        (WebCore::Element::computeInheritedLang):
     15        * dom/Element.h:
     16
    1172010-08-31  Philippe Normand  <pnormand@igalia.com>
    218
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r66615 r66647  
    26022602                break;
    26032603            case CSSSelector::PseudoLang: {
    2604                 Node* n = e;
    2605                 AtomicString value;
    2606                 // The language property is inherited, so we iterate over the parents
    2607                 // to find the first language.
    2608                 while (n && value.isNull()) {
    2609                     if (n->isElementNode()) {
    2610                         // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7
    2611                         value = static_cast<Element*>(n)->fastGetAttribute(XMLNames::langAttr);
    2612                         if (value.isNull())
    2613                             value = static_cast<Element*>(n)->fastGetAttribute(langAttr);
    2614                     } else if (n->isDocumentNode())
    2615                         // checking the MIME content-language
    2616                         value = static_cast<Document*>(n)->contentLanguage();
    2617 
    2618                     n = n->parent();
    2619                 }
     2604                AtomicString value = e->computeInheritedLanguage();
    26202605                const AtomicString& argument = sel->argument();
    26212606                if (value.isEmpty() || !value.startsWith(argument, false))
  • trunk/WebCore/dom/Element.cpp

    r66284 r66647  
    14241424}
    14251425
     1426AtomicString Element::computeInheritedLanguage() const
     1427{
     1428    const Node* n = this;
     1429    AtomicString value;
     1430    // The language property is inherited, so we iterate over the parents to find the first language.
     1431    while (n && value.isNull()) {
     1432        if (n->isElementNode()) {
     1433            // Spec: xml:lang takes precedence -- http://www.w3.org/TR/xhtml1/#C_7
     1434            value = static_cast<const Element*>(n)->fastGetAttribute(XMLNames::langAttr);
     1435            if (value.isNull())
     1436                value = static_cast<const Element*>(n)->fastGetAttribute(HTMLNames::langAttr);
     1437        } else if (n->isDocumentNode()) {
     1438            // checking the MIME content-language
     1439            value = static_cast<const Document*>(n)->contentLanguage();
     1440        }
     1441
     1442        n = n->parent();
     1443    }
     1444
     1445    return value;
     1446}
     1447
    14261448void Element::cancelFocusAppearanceUpdate()
    14271449{
  • trunk/WebCore/dom/Element.h

    r66251 r66647  
    219219    RenderStyle* computedStyle(PseudoId = NOPSEUDO);
    220220
     221    AtomicString computeInheritedLanguage() const;
     222
    221223    void dispatchAttrRemovalEvent(Attribute*);
    222224    void dispatchAttrAdditionEvent(Attribute*);
  • trunk/WebKit/chromium/ChangeLog

    r66637 r66647  
     12010-09-02  Ilya Sherman  <isherman@google.com>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Exposing computing an element's inherited language, per the DOM, in the
     6        Chromium API -- primarily for use with autofill i18n.
     7        https://bugs.webkit.org/show_bug.cgi?id=44803
     8
     9        * public/WebElement.h:
     10        * src/WebElement.cpp:
     11        (WebKit::WebElement::computeInheritedLanguage):
     12
    1132010-09-01  Mikhail Naganov  <mnaganov@chromium.org>
    214
  • trunk/WebKit/chromium/public/WebElement.h

    r64112 r66647  
    5959        WEBKIT_API WebString innerText() const;
    6060
     61        // Returns the language code specified for this element.  This attribute
     62        // is inherited, so the returned value is drawn from the closest parent
     63        // element that has the lang attribute set, or from the HTTP
     64        // "Content-Language" header as a fallback.
     65        WEBKIT_API WebString computeInheritedLanguage() const;
     66
    6167#if WEBKIT_IMPLEMENTATION
    6268        WebElement(const WTF::PassRefPtr<WebCore::Element>&);
  • trunk/WebKit/chromium/src/WebElement.cpp

    r64112 r66647  
    8686}
    8787
     88WebString WebElement::computeInheritedLanguage() const
     89{
     90    return WebString(constUnwrap<Element>()->computeInheritedLanguage());
     91}
     92
    8893WebElement::WebElement(const PassRefPtr<Element>& elem)
    8994    : WebNode(elem)
Note: See TracChangeset for help on using the changeset viewer.