Changeset 28722 in webkit


Ignore:
Timestamp:
Dec 14, 2007 1:48:20 PM (16 years ago)
Author:
weinig@apple.com
Message:

WebCore:

Reviewed by Mitz.

This patch also renames AtomicStringList to ClassNames to better reflect its actual use,
and takes advantage of admitting that it's class-specific to encapsulate class attribute
parsing so it can be shared. It also changes the class to use a Vector, rather than a linked
list to store the class names.

Tests: fast/dom/getElementsByClassName/001.html

fast/dom/getElementsByClassName/002.html
fast/dom/getElementsByClassName/003.html
fast/dom/getElementsByClassName/004.html
fast/dom/getElementsByClassName/005.html
fast/dom/getElementsByClassName/006.html
fast/dom/getElementsByClassName/007.html
fast/dom/getElementsByClassName/008.html
fast/dom/getElementsByClassName/009.html
fast/dom/getElementsByClassName/010.xml
fast/dom/getElementsByClassName/011.xml
fast/dom/getElementsByClassName/012.html
fast/dom/getElementsByClassName/013.html
fast/dom/getElementsByClassName/014.html
fast/dom/getElementsByClassName/array/001.html
fast/dom/getElementsByClassName/array/002.html
fast/dom/getElementsByClassName/array/003.html
fast/dom/getElementsByClassName/array/004.html
fast/dom/getElementsByClassName/dumpNodeList.html

  • WebCore.xcodeproj/project.pbxproj:
  • css/CSSStyleSelector.cpp: (WebCore::CSSStyleSelector::matchRules): (WebCore::CSSStyleSelector::checkOneSelector):
  • dom/AtomicStringList.h: Removed.
  • dom/ClassNames.cpp: Added. (WebCore::ClassNames::contains): (WebCore::ClassNames::parseClassAttribute):
  • dom/ClassNames.h: Copied from WebCore/dom/AtomicStringList.h. (WebCore::ClassNames::ClassNames): (WebCore::ClassNames::size): (WebCore::ClassNames::clear): (WebCore::ClassNames::operator[]): (WebCore::isClassWhitespace):
  • dom/ClassNodeList.cpp: Added. (WebCore::ClassNodeList::ClassNodeList): (WebCore::ClassNodeList::length): (WebCore::ClassNodeList::item): (WebCore::ClassNodeList::nodeMatches):
  • dom/ClassNodeList.h: Added.
  • dom/Document.cpp: (WebCore::Document::getElementsByName): (WebCore::Document::getElementsByClassName):
  • dom/Document.h:
  • dom/Document.idl:
  • dom/Element.cpp: (WebCore::Element::getClassNames): (WebCore::Element::getElementsByClassName):
  • dom/Element.h:
  • dom/Element.idl:
  • dom/NameNodeList.cpp: (WebCore::NameNodeList::NameNodeList): (WebCore::NameNodeList::item): (WebCore::NameNodeList::nodeMatches):
  • dom/NameNodeList.h:
  • dom/NamedMappedAttrMap.cpp: (WebCore::NamedMappedAttrMap::clearAttributes): (WebCore::NamedMappedAttrMap::parseClassAttribute):
  • dom/NamedMappedAttrMap.h: (WebCore::NamedMappedAttrMap::getClassNames):
  • dom/StyledElement.cpp: (WebCore::StyledElement::getClassNames):
  • dom/StyledElement.h:

LayoutTests:

Reviewed by Mitz.

Tests added from http://tc.labs.opera.com/apis/getElementsByClassName/

  • fast/dom/Window/window-properties-expected.txt:
  • fast/dom/getElementsByClassName: Added.
  • fast/dom/getElementsByClassName/001-expected.txt: Added.
  • fast/dom/getElementsByClassName/001.html: Added.
  • fast/dom/getElementsByClassName/002-expected.txt: Added.
  • fast/dom/getElementsByClassName/002.html: Added.
  • fast/dom/getElementsByClassName/003-expected.txt: Added.
  • fast/dom/getElementsByClassName/003.html: Added.
  • fast/dom/getElementsByClassName/004-expected.txt: Added.
  • fast/dom/getElementsByClassName/004.html: Added.
  • fast/dom/getElementsByClassName/005-expected.txt: Added.
  • fast/dom/getElementsByClassName/005.html: Added.
  • fast/dom/getElementsByClassName/006-expected.txt: Added.
  • fast/dom/getElementsByClassName/006.html: Added.
  • fast/dom/getElementsByClassName/007-expected.txt: Added.
  • fast/dom/getElementsByClassName/007.html: Added.
  • fast/dom/getElementsByClassName/008-expected.txt: Added.
  • fast/dom/getElementsByClassName/008.html: Added.
  • fast/dom/getElementsByClassName/009-expected.txt: Added.
  • fast/dom/getElementsByClassName/009.html: Added.
  • fast/dom/getElementsByClassName/010-expected.txt: Added.
  • fast/dom/getElementsByClassName/010.xml: Added.
  • fast/dom/getElementsByClassName/011-expected.txt: Added.
  • fast/dom/getElementsByClassName/011.xml: Added.
  • fast/dom/getElementsByClassName/012-expected.txt: Added.
  • fast/dom/getElementsByClassName/012.html: Added.
  • fast/dom/getElementsByClassName/013-expected.txt: Added.
  • fast/dom/getElementsByClassName/013.html: Added.
  • fast/dom/getElementsByClassName/014-expected.txt: Added.
  • fast/dom/getElementsByClassName/014.html: Added.
  • fast/dom/getElementsByClassName/array: Added.
  • fast/dom/getElementsByClassName/array/001-expected.txt: Added.
  • fast/dom/getElementsByClassName/array/001.html: Added.
  • fast/dom/getElementsByClassName/array/002-expected.txt: Added.
  • fast/dom/getElementsByClassName/array/002.html: Added.
  • fast/dom/getElementsByClassName/array/003-expected.txt: Added.
  • fast/dom/getElementsByClassName/array/003.html: Added.
  • fast/dom/getElementsByClassName/array/004-expected.txt: Added.
  • fast/dom/getElementsByClassName/array/004.html: Added.
  • fast/dom/getElementsByClassName/dumpNodeList-expected.txt: Added.
  • fast/dom/getElementsByClassName/dumpNodeList.html: Added.
  • fast/dom/getElementsByClassName/resources: Added.
  • fast/dom/getElementsByClassName/resources/common.js: Added.
Location:
trunk
Files:
45 added
17 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r28717 r28722  
     12007-12-14  David Smith  <catfish.man@gmail.com>
     2
     3        Reviewed by Mitz.
     4
     5        - test for http://bugs.webkit.org/show_bug.cgi?id=14955
     6          Implement getElementsByClassName
     7
     8        Tests added from http://tc.labs.opera.com/apis/getElementsByClassName/
     9
     10        * fast/dom/Window/window-properties-expected.txt:
     11        * fast/dom/getElementsByClassName: Added.
     12        * fast/dom/getElementsByClassName/001-expected.txt: Added.
     13        * fast/dom/getElementsByClassName/001.html: Added.
     14        * fast/dom/getElementsByClassName/002-expected.txt: Added.
     15        * fast/dom/getElementsByClassName/002.html: Added.
     16        * fast/dom/getElementsByClassName/003-expected.txt: Added.
     17        * fast/dom/getElementsByClassName/003.html: Added.
     18        * fast/dom/getElementsByClassName/004-expected.txt: Added.
     19        * fast/dom/getElementsByClassName/004.html: Added.
     20        * fast/dom/getElementsByClassName/005-expected.txt: Added.
     21        * fast/dom/getElementsByClassName/005.html: Added.
     22        * fast/dom/getElementsByClassName/006-expected.txt: Added.
     23        * fast/dom/getElementsByClassName/006.html: Added.
     24        * fast/dom/getElementsByClassName/007-expected.txt: Added.
     25        * fast/dom/getElementsByClassName/007.html: Added.
     26        * fast/dom/getElementsByClassName/008-expected.txt: Added.
     27        * fast/dom/getElementsByClassName/008.html: Added.
     28        * fast/dom/getElementsByClassName/009-expected.txt: Added.
     29        * fast/dom/getElementsByClassName/009.html: Added.
     30        * fast/dom/getElementsByClassName/010-expected.txt: Added.
     31        * fast/dom/getElementsByClassName/010.xml: Added.
     32        * fast/dom/getElementsByClassName/011-expected.txt: Added.
     33        * fast/dom/getElementsByClassName/011.xml: Added.
     34        * fast/dom/getElementsByClassName/012-expected.txt: Added.
     35        * fast/dom/getElementsByClassName/012.html: Added.
     36        * fast/dom/getElementsByClassName/013-expected.txt: Added.
     37        * fast/dom/getElementsByClassName/013.html: Added.
     38        * fast/dom/getElementsByClassName/014-expected.txt: Added.
     39        * fast/dom/getElementsByClassName/014.html: Added.
     40        * fast/dom/getElementsByClassName/array: Added.
     41        * fast/dom/getElementsByClassName/array/001-expected.txt: Added.
     42        * fast/dom/getElementsByClassName/array/001.html: Added.
     43        * fast/dom/getElementsByClassName/array/002-expected.txt: Added.
     44        * fast/dom/getElementsByClassName/array/002.html: Added.
     45        * fast/dom/getElementsByClassName/array/003-expected.txt: Added.
     46        * fast/dom/getElementsByClassName/array/003.html: Added.
     47        * fast/dom/getElementsByClassName/array/004-expected.txt: Added.
     48        * fast/dom/getElementsByClassName/array/004.html: Added.
     49        * fast/dom/getElementsByClassName/dumpNodeList-expected.txt: Added.
     50        * fast/dom/getElementsByClassName/dumpNodeList.html: Added.
     51        * fast/dom/getElementsByClassName/resources: Added.
     52        * fast/dom/getElementsByClassName/resources/common.js: Added.
     53
    1542007-12-14  Darin Adler  <darin@apple.com>
    255
  • trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt

    r28568 r28722  
    318318window.Document.prototype.execCommand [function]
    319319window.Document.prototype.getElementById [function]
     320window.Document.prototype.getElementsByClassName [function]
    320321window.Document.prototype.getElementsByName [function]
    321322window.Document.prototype.getElementsByTagName [function]
     
    425426window.Element.prototype.getAttributeNode [function]
    426427window.Element.prototype.getAttributeNodeNS [function]
     428window.Element.prototype.getElementsByClassName [function]
    427429window.Element.prototype.getElementsByTagName [function]
    428430window.Element.prototype.getElementsByTagNameNS [function]
  • trunk/WebCore/ChangeLog

    r28721 r28722  
     12007-12-14  David Smith  <catfish.man@gmail.com>
     2
     3        Reviewed by Mitz.
     4
     5        - fix http://bugs.webkit.org/show_bug.cgi?id=14955
     6          Implement getElementsByClassName.
     7
     8        This patch also renames AtomicStringList to ClassNames to better reflect its actual use,
     9        and takes advantage of admitting that it's class-specific to encapsulate class attribute
     10        parsing so it can be shared.  It also changes the class to use a Vector, rather than a linked
     11        list to store the class names.
     12
     13        Tests: fast/dom/getElementsByClassName/001.html
     14               fast/dom/getElementsByClassName/002.html
     15               fast/dom/getElementsByClassName/003.html
     16               fast/dom/getElementsByClassName/004.html
     17               fast/dom/getElementsByClassName/005.html
     18               fast/dom/getElementsByClassName/006.html
     19               fast/dom/getElementsByClassName/007.html
     20               fast/dom/getElementsByClassName/008.html
     21               fast/dom/getElementsByClassName/009.html
     22               fast/dom/getElementsByClassName/010.xml
     23               fast/dom/getElementsByClassName/011.xml
     24               fast/dom/getElementsByClassName/012.html
     25               fast/dom/getElementsByClassName/013.html
     26               fast/dom/getElementsByClassName/014.html
     27               fast/dom/getElementsByClassName/array/001.html
     28               fast/dom/getElementsByClassName/array/002.html
     29               fast/dom/getElementsByClassName/array/003.html
     30               fast/dom/getElementsByClassName/array/004.html
     31               fast/dom/getElementsByClassName/dumpNodeList.html
     32
     33        * WebCore.xcodeproj/project.pbxproj:
     34        * css/CSSStyleSelector.cpp:
     35        (WebCore::CSSStyleSelector::matchRules):
     36        (WebCore::CSSStyleSelector::checkOneSelector):
     37        * dom/AtomicStringList.h: Removed.
     38        * dom/ClassNames.cpp: Added.
     39        (WebCore::ClassNames::contains):
     40        (WebCore::ClassNames::parseClassAttribute):
     41        * dom/ClassNames.h: Copied from WebCore/dom/AtomicStringList.h.
     42        (WebCore::ClassNames::ClassNames):
     43        (WebCore::ClassNames::size):
     44        (WebCore::ClassNames::clear):
     45        (WebCore::ClassNames::operator[]):
     46        (WebCore::isClassWhitespace):
     47        * dom/ClassNodeList.cpp: Added.
     48        (WebCore::ClassNodeList::ClassNodeList):
     49        (WebCore::ClassNodeList::length):
     50        (WebCore::ClassNodeList::item):
     51        (WebCore::ClassNodeList::nodeMatches):
     52        * dom/ClassNodeList.h: Added.
     53        * dom/Document.cpp:
     54        (WebCore::Document::getElementsByName):
     55        (WebCore::Document::getElementsByClassName):
     56        * dom/Document.h:
     57        * dom/Document.idl:
     58        * dom/Element.cpp:
     59        (WebCore::Element::getClassNames):
     60        (WebCore::Element::getElementsByClassName):
     61        * dom/Element.h:
     62        * dom/Element.idl:
     63        * dom/NameNodeList.cpp:
     64        (WebCore::NameNodeList::NameNodeList):
     65        (WebCore::NameNodeList::item):
     66        (WebCore::NameNodeList::nodeMatches):
     67        * dom/NameNodeList.h:
     68        * dom/NamedMappedAttrMap.cpp:
     69        (WebCore::NamedMappedAttrMap::clearAttributes):
     70        (WebCore::NamedMappedAttrMap::parseClassAttribute):
     71        * dom/NamedMappedAttrMap.h:
     72        (WebCore::NamedMappedAttrMap::getClassNames):
     73        * dom/StyledElement.cpp:
     74        (WebCore::StyledElement::getClassNames):
     75        * dom/StyledElement.h:
     76
    1772007-12-14  Darin Adler  <darin@apple.com>
    278
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r28672 r28722  
    16411641                93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65A640F00533BB1F0085E777 /* BlockExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16421642                93F199C208245E59001E9ABC /* WebCoreKeyGenerator.h in Headers */ = {isa = PBXBuildFile; fileRef = 84B2B1F7056BEF3A00D2B771 /* WebCoreKeyGenerator.h */; settings = {ATTRIBUTES = (Private, ); }; };
    1643                 93F199CF08245E59001E9ABC /* AtomicStringList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC3B364705C9D5E200E42902 /* AtomicStringList.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16441643                93F199DE08245E59001E9ABC /* Position.h in Headers */ = {isa = PBXBuildFile; fileRef = BE91FC8B06133666005E3790 /* Position.h */; settings = {ATTRIBUTES = (Private, ); }; };
    16451644                93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */; };
     
    35643563                BC491B780C023EFD009D6316 /* JSHTMLMarqueeElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC491B760C023EFD009D6316 /* JSHTMLMarqueeElement.cpp */; };
    35653564                BC491B790C023EFD009D6316 /* JSHTMLMarqueeElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC491B770C023EFD009D6316 /* JSHTMLMarqueeElement.h */; };
     3565                BC4BF9E40D11E133007D247F /* ClassNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4BF9E20D11E133007D247F /* ClassNames.cpp */; };
     3566                BC4BF9E50D11E133007D247F /* ClassNames.h in Headers */ = {isa = PBXBuildFile; fileRef = BC4BF9E30D11E133007D247F /* ClassNames.h */; settings = {ATTRIBUTES = (Private, ); }; };
    35663567                BC4EDEF40C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */; };
    35673568                BC5156E80C03B741008BB0EE /* DOMHTMLMarqueeElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */; };
     
    36213622                BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */; };
    36223623                BC8243E90D0CFD7500460C8F /* WindowFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = BC8243E70D0CFD7500460C8F /* WindowFeatures.h */; settings = {ATTRIBUTES = (Private, ); }; };
     3624                BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC904B720D10998F00680D32 /* ClassNodeList.cpp */; };
     3625                BC904B770D10998F00680D32 /* ClassNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BC904B730D10998F00680D32 /* ClassNodeList.h */; };
    36233626                BC926F800C0552470082776B /* JSHTMLFrameSetElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC926F7E0C0552470082776B /* JSHTMLFrameSetElement.cpp */; };
    36243627                BC926F810C0552470082776B /* JSHTMLFrameSetElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC926F7F0C0552470082776B /* JSHTMLFrameSetElement.h */; };
     
    75417544                BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLObjectElement.h; sourceTree = "<group>"; };
    75427545                BC305CA30C0781BB00CD20F0 /* JSHTMLObjectElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLObjectElementCustom.cpp; sourceTree = "<group>"; };
    7543                 BC3B364705C9D5E200E42902 /* AtomicStringList.h */ = {isa = PBXFileReference; fileEncoding = 30; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AtomicStringList.h; sourceTree = "<group>"; tabWidth = 8; usesTabs = 0; };
    75447546                BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; };
    75457547                BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; };
     
    75667568                BC491B760C023EFD009D6316 /* JSHTMLMarqueeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLMarqueeElement.cpp; sourceTree = "<group>"; };
    75677569                BC491B770C023EFD009D6316 /* JSHTMLMarqueeElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLMarqueeElement.h; sourceTree = "<group>"; };
     7570                BC4BF9E20D11E133007D247F /* ClassNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassNames.cpp; sourceTree = "<group>"; };
     7571                BC4BF9E30D11E133007D247F /* ClassNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassNames.h; sourceTree = "<group>"; };
    75687572                BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAppletElementCustom.cpp; sourceTree = "<group>"; };
    75697573                BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLMarqueeElement.h; sourceTree = "<group>"; };
     
    76247628                BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowFeatures.cpp; sourceTree = "<group>"; };
    76257629                BC8243E70D0CFD7500460C8F /* WindowFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowFeatures.h; sourceTree = "<group>"; };
     7630                BC904B720D10998F00680D32 /* ClassNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassNodeList.cpp; sourceTree = "<group>"; };
     7631                BC904B730D10998F00680D32 /* ClassNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassNodeList.h; sourceTree = "<group>"; };
    76267632                BC926F7E0C0552470082776B /* JSHTMLFrameSetElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFrameSetElement.cpp; sourceTree = "<group>"; };
    76277633                BC926F7F0C0552470082776B /* JSHTMLFrameSetElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLFrameSetElement.h; sourceTree = "<group>"; };
     
    1209312099                        isa = PBXGroup;
    1209412100                        children = (
    12095                                 BC3B364705C9D5E200E42902 /* AtomicStringList.h */,
    1209612101                                A8C4A7FC09D563270003AC8D /* Attr.cpp */,
    1209712102                                A8C4A7FB09D563270003AC8D /* Attr.h */,
     
    1211112116                                A818721A0977D3C0005826D9 /* ChildNodeList.cpp */,
    1211212117                                A81872150977D3C0005826D9 /* ChildNodeList.h */,
     12118                                BC4BF9E20D11E133007D247F /* ClassNames.cpp */,
     12119                                BC4BF9E30D11E133007D247F /* ClassNames.h */,
     12120                                BC904B720D10998F00680D32 /* ClassNodeList.cpp */,
     12121                                BC904B730D10998F00680D32 /* ClassNodeList.h */,
    1211312122                                A784941A0B5FE507001E237A /* Clipboard.cpp */,
    1211412123                                85031B280A44EFC700F992E0 /* Clipboard.h */,
     
    1227112280                                B2C3DA1F0D006C1D00EF6F26 /* AtomicString.h in Headers */,
    1227212281                                B2C3DA200D006C1D00EF6F26 /* AtomicStringImpl.h in Headers */,
    12273                                 93F199CF08245E59001E9ABC /* AtomicStringList.h in Headers */,
    1227412282                                A8C4A80D09D563270003AC8D /* Attr.h in Headers */,
    1227512283                                A8C4A80B09D563270003AC8D /* Attribute.h in Headers */,
     
    1408414092                                93309E1E099E64920056E581 /* visible_units.h in Headers */,
    1408514093                                51CBFC990D10E483002DBF51 /* CachedPagePlatformData.h in Headers */,
     14094                                BC904B770D10998F00680D32 /* ClassNodeList.h in Headers */,
     14095                                BC4BF9E50D11E133007D247F /* ClassNames.h in Headers */,
    1408614096                        );
    1408714097                        runOnlyForDeploymentPostprocessing = 0;
     
    1579315803                                93309E1D099E64920056E581 /* visible_units.cpp in Sources */,
    1579415804                                93A38B4B0D0E5808006872C2 /* EditorCommand.cpp in Sources */,
     15805                                BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */,
     15806                                BC4BF9E40D11E133007D247F /* ClassNames.cpp in Sources */,
    1579515807                        );
    1579615808                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/css/CSSStyleSelector.cpp

    r28707 r28722  
    391391        matchRulesForList(rules->getIDRules(element->getIDAttribute().impl()), firstRuleIndex, lastRuleIndex);
    392392    if (element->hasClass()) {
    393         for (const AtomicStringList* singleClass = element->getClassList(); singleClass; singleClass = singleClass->next())
    394             matchRulesForList(rules->getClassRules(singleClass->string().impl()), firstRuleIndex, lastRuleIndex);
     393        const ClassNames& classNames = *element->getClassNames();
     394        for (size_t i = 0; i < classNames.size(); ++i)
     395            matchRulesForList(rules->getClassRules(classNames[i].impl()), firstRuleIndex, lastRuleIndex);
    395396    }
    396397    matchRulesForList(rules->getTagRules(element->localName().impl()), firstRuleIndex, lastRuleIndex);
     
    14321433            if (!e->hasClass())
    14331434                return false;
    1434             for (const AtomicStringList* c = e->getClassList(); c; c = c->next())
    1435                 if (c->string() == sel->m_value)
     1435            const ClassNames& classNames = *e->getClassNames();
     1436            for (size_t i = 0; i < classNames.size(); ++i) {
     1437                if (classNames[i] == sel->m_value)
    14361438                    return true;
     1439            }
    14371440            return false;
    1438         }
    1439         else if (sel->m_match == CSSSelector::Id)
     1441        } else if (sel->m_match == CSSSelector::Id)
    14401442            return e->hasID() && e->getIDAttribute() == sel->m_value;
    14411443        else if (style && (e != element || !styledElement || (!styledElement->isMappedAttribute(sel->m_attr) && sel->m_attr != typeAttr && sel->m_attr != readonlyAttr))) {
  • trunk/WebCore/dom/ClassNames.h

    r28676 r28722  
    11/*
    2  * This file is part of the DOM implementation for KDE.
    3  *
    4  * Copyright (C) 2004 Apple Computer, Inc.
     2 * Copyright (C) 2007 Apple Computer, Inc.
    53 *
    64 * This library is free software; you can redistribute it and/or
     
    1614 * You should have received a copy of the GNU Library General Public License
    1715 * along with this library; see the file COPYING.LIB.  If not, write to
    18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
    19  * Boston, MA 02110-1301, USA.
     16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     17 * Boston, MA 02111-1307, USA.
    2018 *
    2119 */
    2220
    23 #ifndef AtomicStringList_h
    24 #define AtomicStringList_h
     21#ifndef ClassNames_h
     22#define ClassNames_h
    2523
    2624#include "AtomicString.h"
     25#include <wtf/Vector.h>
     26#include <wtf/OwnPtr.h>
    2727
    2828namespace WebCore {
    2929
    30 class AtomicStringList {
    31 public:
    32     AtomicStringList() : m_next(0) {}
    33     AtomicStringList(const AtomicString& str, AtomicStringList* n = 0) : m_string(str), m_next(n) {}
    34     ~AtomicStringList() { delete m_next; }
    35    
    36     AtomicStringList* next() const { return m_next; }
    37     void setNext(AtomicStringList* n) { m_next = n; }
    38     const AtomicString& string() const { return m_string; }
    39     void setString(const AtomicString& str) { m_string = str; }
     30    class ClassNames {
     31    public:
     32        ClassNames()
     33        {
     34        }
    4035
    41     AtomicStringList* clone() { return new AtomicStringList(m_string, m_next ? m_next->clone() : 0); }
    42     void clear() { m_string = nullAtom; delete m_next; m_next = 0; }
    43    
    44 private:
    45     AtomicString m_string;
    46     AtomicStringList* m_next;
    47 };
     36        bool contains(const AtomicString&) const;
     37        void parseClassAttribute(const String&, const bool inCompatMode);
    4838
    49 }
     39        size_t size() const { return m_nameVector ? m_nameVector->size() : 0; }
     40        void clear() { if (m_nameVector) m_nameVector->clear(); }
     41        const AtomicString& operator[](size_t i) const { return m_nameVector ? (*m_nameVector)[i] : nullAtom; }
    5042
    51 #endif
     43    private:
     44        OwnPtr<Vector<AtomicString> > m_nameVector;
     45    };
     46
     47    inline static bool isClassWhitespace(UChar c)
     48    {
     49        return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == '\f';
     50    }
     51
     52} // namespace WebCore
     53
     54#endif // ClassNames_h
  • trunk/WebCore/dom/Document.cpp

    r28639 r28722  
    3131#include "CSSStyleSheet.h"
    3232#include "CSSValueKeywords.h"
     33#include "ClassNodeList.h"
    3334#include "Comment.h"
    3435#include "CookieJar.h"
     36#include "DOMImplementation.h"
    3537#include "DatabaseThread.h"
    36 #include "DOMImplementation.h"
    3738#include "DocLoader.h"
    3839#include "DocumentFragment.h"
     
    34953496}
    34963497
    3497 PassRefPtr<NameNodeList> Document::getElementsByName(const String &elementName)
     3498PassRefPtr<NameNodeList> Document::getElementsByName(const String& elementName)
    34983499{
    34993500    return new NameNodeList(this, elementName);
     3501}
     3502
     3503PassRefPtr<NodeList> Document::getElementsByClassName(const String& className)
     3504{
     3505    return new ClassNodeList(this, className);
    35003506}
    35013507
  • trunk/WebCore/dom/Document.h

    r28639 r28722  
    214214   
    215215    PassRefPtr<NameNodeList> getElementsByName(const String& elementName);
     216    PassRefPtr<NodeList> getElementsByClassName(const String& className);
    216217
    217218    PassRefPtr<HTMLCollection> images();
  • trunk/WebCore/dom/Document.idl

    r27276 r28722  
    221221#endif
    222222
     223        // HTML 5
     224        NodeList            getElementsByClassName(in DOMString tagname);
    223225    };
    224226
  • trunk/WebCore/dom/Element.cpp

    r28639 r28722  
    44 *           (C) 2001 Peter Kelly (pmk@post.com)
    55 *           (C) 2001 Dirk Mueller (mueller@kde.org)
     6 *           (C) 2007 David Smith (catfish.man@gmail.com)
    67 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    78 *           (C) 2007 Eric Seidel (eric@webkit.org)
     
    2728
    2829#include "CSSStyleSelector.h"
     30#include "ClassNames.h"
     31#include "ClassNodeList.h"
    2932#include "Document.h"
    3033#include "Editor.h"
     
    3740#include "KURL.h"
    3841#include "NamedAttrMap.h"
     42#include "NodeList.h"
    3943#include "Page.h"
    4044#include "RenderBlock.h"
     
    197201}
    198202
    199 const AtomicStringList* Element::getClassList() const
     203const ClassNames* Element::getClassNames() const
    200204{
    201205    return 0;
     
    11201124}
    11211125
     1126PassRefPtr<NodeList> Element::getElementsByClassName(const String& className)
     1127{
     1128    return new ClassNodeList(this, className);
     1129}
     1130
    11221131void Element::cancelFocusAppearanceUpdate()
    11231132{
  • trunk/WebCore/dom/Element.h

    r27465 r28722  
    3232namespace WebCore {
    3333
    34 class AtomicStringList;
    3534class Attr;
    3635class Attribute;
    3736class CSSStyleDeclaration;
     37class ClassNames;
    3838class ElementRareData;
    3939class IntSize;
     
    4545
    4646    // Used to quickly determine whether or not an element has a given CSS class.
    47     virtual const AtomicStringList* getClassList() const;
     47    virtual const ClassNames* getClassNames() const;
    4848    const AtomicString& getIDAttribute() const;
    4949    bool hasAttribute(const QualifiedName&) const;
     
    163163    virtual void updateFocusAppearance(bool restorePreviousSelection);
    164164    void blur();
     165   
     166    PassRefPtr<NodeList> getElementsByClassName(const String&);
    165167
    166168#ifndef NDEBUG
  • trunk/WebCore/dom/Element.idl

    r27276 r28722  
    103103        void scrollByPages(in long pages);
    104104
     105        // HTML 5
     106        NodeList getElementsByClassName(in DOMString name);
     107
    105108#if defined(LANGUAGE_OBJECTIVE_C)
    106109        // Objective-C extensions
  • trunk/WebCore/dom/NameNodeList.cpp

    r25754 r28722  
    11/**
    2  * This file is part of the DOM implementation for KDE.
    3  *
    42 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    53 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    64 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    7  * Copyright (C) 2004 Apple Computer, Inc.
     5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.
    86 *
    97 * This library is free software; you can redistribute it and/or
     
    2927#include "HTMLNames.h"
    3028
    31 using namespace WebCore;
    32 
    3329namespace WebCore {
    3430
    3531using namespace HTMLNames;
    3632
    37 NameNodeList::NameNodeList(Node *n, const String &t)
    38   : NodeList(n), nodeName(t)
     33NameNodeList::NameNodeList(Node* root, const String& name)
     34    : NodeList(root)
     35    , m_nodeName(name)
    3936{
    4037}
     
    4542}
    4643
    47 Node *NameNodeList::item (unsigned index) const
     44Node* NameNodeList::item (unsigned index) const
    4845{
    4946    return recursiveItem(index);
    5047}
    5148
    52 bool NameNodeList::nodeMatches(Node *testNode) const
     49bool NameNodeList::nodeMatches(Node* testNode) const
    5350{
    54     return static_cast<Element*>(testNode)->getAttribute(nameAttr) == nodeName;
     51    return static_cast<Element*>(testNode)->getAttribute(nameAttr) == m_nodeName;
    5552}
    5653
    57 }
     54} // namespace WebCore
  • trunk/WebCore/dom/NameNodeList.h

    r26585 r28722  
    11/*
    2  * This file is part of the DOM implementation for KDE.
    3  *
    42 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    53 *           (C) 1999 Antti Koivisto (koivisto@kde.org)
    64 *           (C) 2001 Dirk Mueller (mueller@kde.org)
    7  * Copyright (C) 2004 Apple Computer, Inc.
     5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.
    86 *
    97 * This library is free software; you can redistribute it and/or
     
    3634class NameNodeList : public NodeList {
    3735public:
    38     NameNodeList(Node* doc, const String& name);
     36    NameNodeList(Node* root, const String& name);
    3937
    4038    // DOM methods overridden from  parent classes
     
    4947    virtual bool nodeMatches(Node* testNode) const;
    5048
    51     String nodeName;
     49private:
     50    String m_nodeName;
    5251};
    5352
  • trunk/WebCore/dom/NamedMappedAttrMap.cpp

    r25754 r28722  
    44 *           (C) 2001 Peter Kelly (pmk@post.com)
    55 *           (C) 2001 Dirk Mueller (mueller@kde.org)
     6 *           (C) 2007 David Smith (catfish.man@gmail.com)
    67 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
    78 *
     
    3839void NamedMappedAttrMap::clearAttributes()
    3940{
    40     m_classList.clear();
     41    m_classNames.clear();
    4142    m_mappedAttributeCount = 0;
    4243    NamedAttrMap::clearAttributes();
     
    7778}
    7879
    79 inline static bool isClassWhitespace(UChar c)
    80 {
    81     return c == ' ' || c == '\r' || c == '\n' || c == '\t';
     80void NamedMappedAttrMap::parseClassAttribute(const String& classStr)
     81{
     82    if (!element->hasClass()) {
     83        m_classNames.clear();
     84        return;
     85    }
     86
     87    m_classNames.parseClassAttribute(classStr, element->document()->inCompatMode());
    8288}
    8389
    84 void NamedMappedAttrMap::parseClassAttribute(const String& classStr)
    85 {
    86     m_classList.clear();
    87     if (!element->hasClass())
    88         return;
    89    
    90     String classAttr = element->document()->inCompatMode() ?
    91         (classStr.impl()->isLower() ? classStr : String(classStr.impl()->lower())) :
    92         classStr;
    93    
    94     AtomicStringList* curr = 0;
    95    
    96     const UChar* str = classAttr.characters();
    97     int length = classAttr.length();
    98     int sPos = 0;
    99 
    100     while (true) {
    101         while (sPos < length && isClassWhitespace(str[sPos]))
    102             ++sPos;
    103         if (sPos >= length)
    104             break;
    105         int ePos = sPos + 1;
    106         while (ePos < length && !isClassWhitespace(str[ePos]))
    107             ++ePos;
    108         if (curr) {
    109             curr->setNext(new AtomicStringList(AtomicString(str + sPos, ePos - sPos)));
    110             curr = curr->next();
    111         } else {
    112             if (sPos == 0 && ePos == length) {
    113                 m_classList.setString(AtomicString(classAttr));
    114                 break;
    115             }
    116             m_classList.setString(AtomicString(str + sPos, ePos - sPos));
    117             curr = &m_classList;
    118         }
    119         sPos = ePos + 1;
    120     }
    121 }
    12290
    12391}
  • trunk/WebCore/dom/NamedMappedAttrMap.h

    r25754 r28722  
    66 *           (C) 2001 Peter Kelly (pmk@post.com)
    77 *           (C) 2001 Dirk Mueller (mueller@kde.org)
     8 *           (C) 2007 David Smith (catfish.man@gmail.com)
    89 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc.
    910 *
     
    2829#define NamedMappedAttrMap_h
    2930
     31#include "ClassNames.h"
     32#include "MappedAttribute.h"
    3033#include "NamedAttrMap.h"
    31 #include "AtomicStringList.h"
    32 #include "MappedAttribute.h"
    3334
    3435namespace WebCore {
     
    4344    virtual bool isMappedAttributeMap() const;
    4445   
    45     virtual void parseClassAttribute(const String& classAttr);
    46     const AtomicStringList* getClassList() const { return &m_classList; }
     46    void parseClassAttribute(const String&);
     47
     48    const ClassNames* getClassNames() const { return &m_classNames; }
    4749   
    4850    virtual bool hasMappedAttributes() const { return m_mappedAttributeCount > 0; }
     
    6163   
    6264private:
    63     AtomicStringList m_classList;
     65    ClassNames m_classNames;
    6466    int m_mappedAttributeCount;
    6567};
  • trunk/WebCore/dom/StyledElement.cpp

    r28639 r28722  
    3030#include "CSSStyleSheet.h"
    3131#include "CSSValueKeywords.h"
     32#include "ClassNames.h"
    3233#include "Document.h"
    3334#include "HTMLNames.h"
     
    102103        m_synchronizingStyleAttribute = false;
    103104    }
    104 }
    105 
    106 inline static bool isClassWhitespace(UChar c)
    107 {
    108     return c == ' ' || c == '\r' || c == '\n' || c == '\t';
    109105}
    110106
     
    264260}
    265261
    266 const AtomicStringList* StyledElement::getClassList() const
    267 {
    268     return namedAttrMap ? mappedAttributes()->getClassList() : 0;
     262const ClassNames* StyledElement::getClassNames() const
     263{
     264    return namedAttrMap ? mappedAttributes()->getClassNames() : 0;
    269265}
    270266
  • trunk/WebCore/dom/StyledElement.h

    r28639 r28722  
    6767    virtual void updateStyleAttributeIfNeeded() const;
    6868   
    69     virtual const AtomicStringList* getClassList() const;
     69    virtual const ClassNames* getClassNames() const;
    7070    virtual void attributeChanged(Attribute* attr, bool preserveDecls = false);
    7171    virtual void parseMappedAttribute(MappedAttribute* attr);
Note: See TracChangeset for help on using the changeset viewer.