Changeset 35931 in webkit


Ignore:
Timestamp:
Aug 26, 2008 3:27:33 AM (16 years ago)
Author:
jchaffraix@webkit.org
Message:

WebCore:

2008-08-25 Julien Chaffraix <jchaffraix@webkit.org>

Reviewed by Darin.

Bug 20247: setAttributeNode() does not work when attribute name has a capital letter in it
https://bugs.webkit.org/show_bug.cgi?id=20247

<rdar://problem/6118218>

Add a boolean parameter to getAttributeItem to choose between case sensitive and case insensitive
check. This keeps the behaviour for setAttribute / hasAttribute (case sensitive) and getAttribute
(case insensitive for HTML elements).

Test: fast/dom/Element/getAttribute-check-case-sensitivity.html

  • dom/Element.cpp: (WebCore::Element::getAttribute):
  • dom/NamedAttrMap.cpp: (WebCore::NamedAttrMap::getNamedItem): (WebCore::NamedAttrMap::getAttributeItem):
  • dom/NamedAttrMap.h:

LayoutTests:

2008-08-25 Julien Chaffraix <jchaffraix@webkit.org>

Reviewed by Darin.

Test case for Bug 20247: setAttributeNode() does not work when attribute name
has a capital letter in it
https://bugs.webkit.org/show_bug.cgi?id=20247

<rdar://problem/6118218>

Most of this test case was done by Eric Roman <minatoar@gmail.com>, the rest by ap and was
tweaked by me.

  • fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt: Added.
  • fast/dom/Element/getAttribute-check-case-sensitivity.html: Added.
  • fast/dom/Element/resources/getAttribute-check-case-sensitivity.js: Added.
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r35928 r35931  
     12008-08-25  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        Test case for Bug 20247: setAttributeNode() does not work when attribute name
     6        has a capital letter in it
     7        https://bugs.webkit.org/show_bug.cgi?id=20247
     8
     9        <rdar://problem/6118218>
     10
     11        Most of this test case was done by Eric Roman <minatoar@gmail.com>, the rest by ap and was
     12        tweaked by me.
     13
     14        * fast/dom/Element/getAttribute-check-case-sensitivity-expected.txt: Added.
     15        * fast/dom/Element/getAttribute-check-case-sensitivity.html: Added.
     16        * fast/dom/Element/resources/getAttribute-check-case-sensitivity.js: Added.
     17
    1182008-08-25  Sam Weinig  <sam@webkit.org>
    219
  • trunk/WebCore/ChangeLog

    r35928 r35931  
     12008-08-25  Julien Chaffraix  <jchaffraix@webkit.org>
     2
     3        Reviewed by Darin.
     4
     5        Bug 20247: setAttributeNode() does not work when attribute name has a capital letter in it
     6        https://bugs.webkit.org/show_bug.cgi?id=20247
     7
     8        <rdar://problem/6118218>
     9
     10        Add a boolean parameter to getAttributeItem to choose between case sensitive and case insensitive
     11        check. This keeps the behaviour for setAttribute / hasAttribute (case sensitive) and getAttribute
     12        (case insensitive for HTML elements).
     13
     14        Test: fast/dom/Element/getAttribute-check-case-sensitivity.html
     15
     16        * dom/Element.cpp:
     17        (WebCore::Element::getAttribute):
     18        * dom/NamedAttrMap.cpp:
     19        (WebCore::NamedAttrMap::getNamedItem):
     20        (WebCore::NamedAttrMap::getAttributeItem):
     21        * dom/NamedAttrMap.h:
     22
    1232008-08-25  Sam Weinig  <sam@webkit.org>
    224
  • trunk/WebCore/dom/Element.cpp

    r35648 r35931  
    491491
    492492    if (namedAttrMap)
    493         if (Attribute* a = namedAttrMap->getAttributeItem(localName))
     493        if (Attribute* a = namedAttrMap->getAttributeItem(name, shouldIgnoreAttributeCase(this)))
    494494            return a->value();
    495495   
     
    512512
    513513    // allocate attributemap if necessary
    514     Attribute* old = attributes(false)->getAttributeItem(localName);
     514    Attribute* old = attributes(false)->getAttributeItem(localName, false);
    515515
    516516    document()->incDOMTreeVersion();
     
    11211121    if (!attrs)
    11221122        return false;
     1123
     1124    // This call to String::lower() seems to be required but
     1125    // there may be a way to remove it.
    11231126    String localName = shouldIgnoreAttributeCase(this) ? name.lower() : name;
    1124     return attrs->getAttributeItem(localName);
     1127    return attrs->getAttributeItem(localName, false);
    11251128}
    11261129
  • trunk/WebCore/dom/NamedAttrMap.cpp

    r34138 r35931  
    5252PassRefPtr<Node> NamedAttrMap::getNamedItem(const String& name) const
    5353{
    54     String localName = shouldIgnoreAttributeCase(m_element) ? name.lower() : name;
    55     Attribute* a = getAttributeItem(localName);
     54    Attribute* a = getAttributeItem(name, shouldIgnoreAttributeCase(m_element));
    5655    if (!a)
    5756        return 0;
     
    6766PassRefPtr<Node> NamedAttrMap::removeNamedItem(const String& name, ExceptionCode& ec)
    6867{
    69     String localName = shouldIgnoreAttributeCase(m_element) ? name.lower() : name;
    70     Attribute* a = getAttributeItem(localName);
     68    Attribute* a = getAttributeItem(name, shouldIgnoreAttributeCase(m_element));
    7169    if (!a) {
    7270        ec = NOT_FOUND_ERR;
     
    165163}
    166164
    167 Attribute* NamedAttrMap::getAttributeItem(const String& name) const
     165// We use a boolean parameter instead of calling shouldIgnoreAttributeCase so that the caller
     166// can tune the behaviour (hasAttribute is case sensitive whereas getAttribute is not).
     167Attribute* NamedAttrMap::getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const
    168168{
    169169    unsigned len = length();
     
    172172            m_attributes[i]->name().localName() == name)
    173173                return m_attributes[i].get();
    174        
    175         if (m_attributes[i]->name().toString() == name)
     174
     175        if (shouldIgnoreAttributeCase ? equalIgnoringCase(m_attributes[i]->name().toString(), name) : name == m_attributes[i]->name().toString())
    176176            return m_attributes[i].get();
    177177    }
  • trunk/WebCore/dom/NamedAttrMap.h

    r35035 r35931  
    6969    Attribute* attributeItem(unsigned index) const { return m_attributes[index].get(); }
    7070    Attribute* getAttributeItem(const QualifiedName& name) const;
    71     Attribute* getAttributeItem(const String& name) const;
     71    Attribute* getAttributeItem(const String& name, bool shouldIgnoreAttributeCase) const;
    7272   
    7373    void shrinkToLength() { m_attributes.shrinkCapacity(length()); }
  • trunk/WebCore/dom/NamedMappedAttrMap.h

    r31435 r35931  
    5858        { return static_cast<MappedAttribute*>(NamedAttrMap::getAttributeItem(name)); }
    5959    MappedAttribute* getAttributeItem(const String& name) const
    60         { return static_cast<MappedAttribute*>(NamedAttrMap::getAttributeItem(name)); }
     60        { return static_cast<MappedAttribute*>(NamedAttrMap::getAttributeItem(name, false)); }
    6161
    6262private:
Note: See TracChangeset for help on using the changeset viewer.