Changeset 107883 in webkit


Ignore:
Timestamp:
Feb 15, 2012 9:42:02 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Add support for the translate attribute in html elements.
https://bugs.webkit.org/show_bug.cgi?id=78751

Patch by Pablo Flouret <pablof@motorola.com> on 2012-02-15
Reviewed by Adam Barth.

The translate attribute is used to specify whether an element's
attribute values and the values of its Text node children are to be
translated when the page is localized, or whether to leave them
unchanged.

Details at http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-translate

Source/WebCore:

Test: fast/dom/HTMLElement/translate.html

  • html/HTMLAttributeNames.in:
  • html/HTMLElement.cpp:

(WebCore::HTMLElement::translateAttributeMode):
(WebCore):
(WebCore::HTMLElement::translate):
(WebCore::HTMLElement::setTranslate):

  • html/HTMLElement.h:

(HTMLElement):

  • html/HTMLElement.idl:

LayoutTests:

  • fast/dom/HTMLElement/translate-expected.txt: Added.
  • fast/dom/HTMLElement/translate.html: Added.
Location:
trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r107882 r107883  
     12012-02-15  Pablo Flouret  <pablof@motorola.com>
     2
     3        Add support for the translate attribute in html elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=78751
     5
     6        Reviewed by Adam Barth.
     7
     8        The translate attribute is used to specify whether an element's
     9        attribute values and the values of its Text node children are to be
     10        translated when the page is localized, or whether to leave them
     11        unchanged.
     12
     13        Details at http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-translate
     14
     15        * fast/dom/HTMLElement/translate-expected.txt: Added.
     16        * fast/dom/HTMLElement/translate.html: Added.
     17
    1182012-02-15  Noel Gordon  <noel.gordon@gmail.com>
    219
  • trunk/Source/WebCore/ChangeLog

    r107881 r107883  
     12012-02-15  Pablo Flouret  <pablof@motorola.com>
     2
     3        Add support for the translate attribute in html elements.
     4        https://bugs.webkit.org/show_bug.cgi?id=78751
     5
     6        Reviewed by Adam Barth.
     7
     8        The translate attribute is used to specify whether an element's
     9        attribute values and the values of its Text node children are to be
     10        translated when the page is localized, or whether to leave them
     11        unchanged.
     12
     13        Details at http://www.whatwg.org/specs/web-apps/current-work/multipage/elements.html#attr-translate
     14
     15        Test: fast/dom/HTMLElement/translate.html
     16
     17        * html/HTMLAttributeNames.in:
     18        * html/HTMLElement.cpp:
     19        (WebCore::HTMLElement::translateAttributeMode):
     20        (WebCore):
     21        (WebCore::HTMLElement::translate):
     22        (WebCore::HTMLElement::setTranslate):
     23        * html/HTMLElement.h:
     24        (HTMLElement):
     25        * html/HTMLElement.idl:
     26
    1272012-02-15  Sami Kyostila  <skyostil@google.com>
    228
  • trunk/Source/WebCore/html/HTMLAttributeNames.in

    r104919 r107883  
    305305top
    306306topmargin
     307translate
    307308truespeed
    308309type
  • trunk/Source/WebCore/html/HTMLElement.cpp

    r107554 r107883  
    801801}
    802802
     803TranslateAttributeMode HTMLElement::translateAttributeMode() const
     804{
     805    const AtomicString& value = getAttribute(translateAttr);
     806
     807    if (value == nullAtom)
     808        return TranslateAttributeInherit;
     809    if (equalIgnoringCase(value, "yes") || equalIgnoringCase(value, ""))
     810        return TranslateAttributeYes;
     811    if (equalIgnoringCase(value, "no"))
     812        return TranslateAttributeNo;
     813
     814    return TranslateAttributeInherit;
     815}
     816
     817bool HTMLElement::translate() const
     818{
     819    for (const Node* n = this; n; n = n->parentNode()) {
     820        if (n->isHTMLElement()) {
     821            TranslateAttributeMode mode = static_cast<const HTMLElement*>(n)->translateAttributeMode();
     822            if (mode != TranslateAttributeInherit) {
     823                ASSERT(mode == TranslateAttributeYes || mode == TranslateAttributeNo);
     824                return mode == TranslateAttributeYes;
     825            }
     826        }
     827    }
     828
     829    // Default on the root element is translate=yes.
     830    return true;
     831}
     832
     833void HTMLElement::setTranslate(bool enable)
     834{
     835    setAttribute(translateAttr, enable ? "yes" : "no");
     836}
     837
     838
    803839HTMLCollection* HTMLElement::children()
    804840{
  • trunk/Source/WebCore/html/HTMLElement.h

    r107554 r107883  
    3636#endif
    3737
     38enum TranslateAttributeMode {
     39    TranslateAttributeYes,
     40    TranslateAttributeNo,
     41    TranslateAttributeInherit
     42};
     43
    3844class HTMLElement : public StyledElement {
    3945public:
     
    6874    bool spellcheck() const;
    6975    void setSpellcheck(bool);
     76
     77    bool translate() const;
     78    void setTranslate(bool);
    7079
    7180    void click();
     
    122131    TextDirection directionality(Node** strongDirectionalityTextNode= 0) const;
    123132
     133    TranslateAttributeMode translateAttributeMode() const;
     134
    124135#if ENABLE(MICRODATA)
    125136    virtual String itemValueText() const;
  • trunk/Source/WebCore/html/HTMLElement.idl

    r107530 r107883  
    3131                 attribute [Reflect] DOMString title;
    3232                 attribute [Reflect] DOMString lang;
     33                 attribute boolean             translate;
    3334                 attribute [Reflect] DOMString dir;
    3435                 attribute [Reflect=class] DOMString className;
Note: See TracChangeset for help on using the changeset viewer.