Changeset 28722 in webkit
- Timestamp:
- Dec 14, 2007 1:48:20 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 45 added
- 17 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r28717 r28722 1 2007-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 1 54 2007-12-14 Darin Adler <darin@apple.com> 2 55 -
trunk/LayoutTests/fast/dom/Window/window-properties-expected.txt
r28568 r28722 318 318 window.Document.prototype.execCommand [function] 319 319 window.Document.prototype.getElementById [function] 320 window.Document.prototype.getElementsByClassName [function] 320 321 window.Document.prototype.getElementsByName [function] 321 322 window.Document.prototype.getElementsByTagName [function] … … 425 426 window.Element.prototype.getAttributeNode [function] 426 427 window.Element.prototype.getAttributeNodeNS [function] 428 window.Element.prototype.getElementsByClassName [function] 427 429 window.Element.prototype.getElementsByTagName [function] 428 430 window.Element.prototype.getElementsByTagNameNS [function] -
trunk/WebCore/ChangeLog
r28721 r28722 1 2007-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 1 77 2007-12-14 Darin Adler <darin@apple.com> 2 78 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r28672 r28722 1641 1641 93F199BE08245E59001E9ABC /* BlockExceptions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65A640F00533BB1F0085E777 /* BlockExceptions.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1642 1642 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, ); }; };1644 1643 93F199DE08245E59001E9ABC /* Position.h in Headers */ = {isa = PBXBuildFile; fileRef = BE91FC8B06133666005E3790 /* Position.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1645 1644 93F199E508245E59001E9ABC /* HTMLCanvasElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 51F6A3D60663BF04004D2919 /* HTMLCanvasElement.h */; }; … … 3564 3563 BC491B780C023EFD009D6316 /* JSHTMLMarqueeElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC491B760C023EFD009D6316 /* JSHTMLMarqueeElement.cpp */; }; 3565 3564 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, ); }; }; 3566 3567 BC4EDEF40C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */; }; 3567 3568 BC5156E80C03B741008BB0EE /* DOMHTMLMarqueeElement.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */; }; … … 3621 3622 BC8243E80D0CFD7500460C8F /* WindowFeatures.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */; }; 3622 3623 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 */; }; 3623 3626 BC926F800C0552470082776B /* JSHTMLFrameSetElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC926F7E0C0552470082776B /* JSHTMLFrameSetElement.cpp */; }; 3624 3627 BC926F810C0552470082776B /* JSHTMLFrameSetElement.h in Headers */ = {isa = PBXBuildFile; fileRef = BC926F7F0C0552470082776B /* JSHTMLFrameSetElement.h */; }; … … 7541 7544 BC305C780C076BB300CD20F0 /* JSHTMLObjectElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLObjectElement.h; sourceTree = "<group>"; }; 7542 7545 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; };7544 7546 BC3C39B40C0D3D8D005F4D7A /* JSMediaList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaList.cpp; sourceTree = "<group>"; }; 7545 7547 BC3C39B50C0D3D8D005F4D7A /* JSMediaList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSMediaList.h; sourceTree = "<group>"; }; … … 7566 7568 BC491B760C023EFD009D6316 /* JSHTMLMarqueeElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLMarqueeElement.cpp; sourceTree = "<group>"; }; 7567 7569 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>"; }; 7568 7572 BC4EDEF30C08F3FB007EDD49 /* JSHTMLAppletElementCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLAppletElementCustom.cpp; sourceTree = "<group>"; }; 7569 7573 BC5156E50C03B741008BB0EE /* DOMHTMLMarqueeElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMHTMLMarqueeElement.h; sourceTree = "<group>"; }; … … 7624 7628 BC8243E60D0CFD7500460C8F /* WindowFeatures.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowFeatures.cpp; sourceTree = "<group>"; }; 7625 7629 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>"; }; 7626 7632 BC926F7E0C0552470082776B /* JSHTMLFrameSetElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLFrameSetElement.cpp; sourceTree = "<group>"; }; 7627 7633 BC926F7F0C0552470082776B /* JSHTMLFrameSetElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSHTMLFrameSetElement.h; sourceTree = "<group>"; }; … … 12093 12099 isa = PBXGroup; 12094 12100 children = ( 12095 BC3B364705C9D5E200E42902 /* AtomicStringList.h */,12096 12101 A8C4A7FC09D563270003AC8D /* Attr.cpp */, 12097 12102 A8C4A7FB09D563270003AC8D /* Attr.h */, … … 12111 12116 A818721A0977D3C0005826D9 /* ChildNodeList.cpp */, 12112 12117 A81872150977D3C0005826D9 /* ChildNodeList.h */, 12118 BC4BF9E20D11E133007D247F /* ClassNames.cpp */, 12119 BC4BF9E30D11E133007D247F /* ClassNames.h */, 12120 BC904B720D10998F00680D32 /* ClassNodeList.cpp */, 12121 BC904B730D10998F00680D32 /* ClassNodeList.h */, 12113 12122 A784941A0B5FE507001E237A /* Clipboard.cpp */, 12114 12123 85031B280A44EFC700F992E0 /* Clipboard.h */, … … 12271 12280 B2C3DA1F0D006C1D00EF6F26 /* AtomicString.h in Headers */, 12272 12281 B2C3DA200D006C1D00EF6F26 /* AtomicStringImpl.h in Headers */, 12273 93F199CF08245E59001E9ABC /* AtomicStringList.h in Headers */,12274 12282 A8C4A80D09D563270003AC8D /* Attr.h in Headers */, 12275 12283 A8C4A80B09D563270003AC8D /* Attribute.h in Headers */, … … 14084 14092 93309E1E099E64920056E581 /* visible_units.h in Headers */, 14085 14093 51CBFC990D10E483002DBF51 /* CachedPagePlatformData.h in Headers */, 14094 BC904B770D10998F00680D32 /* ClassNodeList.h in Headers */, 14095 BC4BF9E50D11E133007D247F /* ClassNames.h in Headers */, 14086 14096 ); 14087 14097 runOnlyForDeploymentPostprocessing = 0; … … 15793 15803 93309E1D099E64920056E581 /* visible_units.cpp in Sources */, 15794 15804 93A38B4B0D0E5808006872C2 /* EditorCommand.cpp in Sources */, 15805 BC904B760D10998F00680D32 /* ClassNodeList.cpp in Sources */, 15806 BC4BF9E40D11E133007D247F /* ClassNames.cpp in Sources */, 15795 15807 ); 15796 15808 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/css/CSSStyleSelector.cpp
r28707 r28722 391 391 matchRulesForList(rules->getIDRules(element->getIDAttribute().impl()), firstRuleIndex, lastRuleIndex); 392 392 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); 395 396 } 396 397 matchRulesForList(rules->getTagRules(element->localName().impl()), firstRuleIndex, lastRuleIndex); … … 1432 1433 if (!e->hasClass()) 1433 1434 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) 1436 1438 return true; 1439 } 1437 1440 return false; 1438 } 1439 else if (sel->m_match == CSSSelector::Id) 1441 } else if (sel->m_match == CSSSelector::Id) 1440 1442 return e->hasID() && e->getIDAttribute() == sel->m_value; 1441 1443 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 1 1 /* 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. 5 3 * 6 4 * This library is free software; you can redistribute it and/or … … 16 14 * You should have received a copy of the GNU Library General Public License 17 15 * along with this library; see the file COPYING.LIB. If not, write to 18 * the Free Software Foundation, Inc., 5 1 Franklin Street, Fifth Floor,19 * Boston, MA 0211 0-1301, USA.16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * Boston, MA 02111-1307, USA. 20 18 * 21 19 */ 22 20 23 #ifndef AtomicStringList_h24 #define AtomicStringList_h21 #ifndef ClassNames_h 22 #define ClassNames_h 25 23 26 24 #include "AtomicString.h" 25 #include <wtf/Vector.h> 26 #include <wtf/OwnPtr.h> 27 27 28 28 namespace WebCore { 29 29 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 } 40 35 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); 48 38 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; } 50 42 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 31 31 #include "CSSStyleSheet.h" 32 32 #include "CSSValueKeywords.h" 33 #include "ClassNodeList.h" 33 34 #include "Comment.h" 34 35 #include "CookieJar.h" 36 #include "DOMImplementation.h" 35 37 #include "DatabaseThread.h" 36 #include "DOMImplementation.h"37 38 #include "DocLoader.h" 38 39 #include "DocumentFragment.h" … … 3495 3496 } 3496 3497 3497 PassRefPtr<NameNodeList> Document::getElementsByName(const String &elementName)3498 PassRefPtr<NameNodeList> Document::getElementsByName(const String& elementName) 3498 3499 { 3499 3500 return new NameNodeList(this, elementName); 3501 } 3502 3503 PassRefPtr<NodeList> Document::getElementsByClassName(const String& className) 3504 { 3505 return new ClassNodeList(this, className); 3500 3506 } 3501 3507 -
trunk/WebCore/dom/Document.h
r28639 r28722 214 214 215 215 PassRefPtr<NameNodeList> getElementsByName(const String& elementName); 216 PassRefPtr<NodeList> getElementsByClassName(const String& className); 216 217 217 218 PassRefPtr<HTMLCollection> images(); -
trunk/WebCore/dom/Document.idl
r27276 r28722 221 221 #endif 222 222 223 // HTML 5 224 NodeList getElementsByClassName(in DOMString tagname); 223 225 }; 224 226 -
trunk/WebCore/dom/Element.cpp
r28639 r28722 4 4 * (C) 2001 Peter Kelly (pmk@post.com) 5 5 * (C) 2001 Dirk Mueller (mueller@kde.org) 6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 7 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 7 8 * (C) 2007 Eric Seidel (eric@webkit.org) … … 27 28 28 29 #include "CSSStyleSelector.h" 30 #include "ClassNames.h" 31 #include "ClassNodeList.h" 29 32 #include "Document.h" 30 33 #include "Editor.h" … … 37 40 #include "KURL.h" 38 41 #include "NamedAttrMap.h" 42 #include "NodeList.h" 39 43 #include "Page.h" 40 44 #include "RenderBlock.h" … … 197 201 } 198 202 199 const AtomicStringList* Element::getClassList() const203 const ClassNames* Element::getClassNames() const 200 204 { 201 205 return 0; … … 1120 1124 } 1121 1125 1126 PassRefPtr<NodeList> Element::getElementsByClassName(const String& className) 1127 { 1128 return new ClassNodeList(this, className); 1129 } 1130 1122 1131 void Element::cancelFocusAppearanceUpdate() 1123 1132 { -
trunk/WebCore/dom/Element.h
r27465 r28722 32 32 namespace WebCore { 33 33 34 class AtomicStringList;35 34 class Attr; 36 35 class Attribute; 37 36 class CSSStyleDeclaration; 37 class ClassNames; 38 38 class ElementRareData; 39 39 class IntSize; … … 45 45 46 46 // 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; 48 48 const AtomicString& getIDAttribute() const; 49 49 bool hasAttribute(const QualifiedName&) const; … … 163 163 virtual void updateFocusAppearance(bool restorePreviousSelection); 164 164 void blur(); 165 166 PassRefPtr<NodeList> getElementsByClassName(const String&); 165 167 166 168 #ifndef NDEBUG -
trunk/WebCore/dom/Element.idl
r27276 r28722 103 103 void scrollByPages(in long pages); 104 104 105 // HTML 5 106 NodeList getElementsByClassName(in DOMString name); 107 105 108 #if defined(LANGUAGE_OBJECTIVE_C) 106 109 // Objective-C extensions -
trunk/WebCore/dom/NameNodeList.cpp
r25754 r28722 1 1 /** 2 * This file is part of the DOM implementation for KDE.3 *4 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 5 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 7 * Copyright (C) 2004 Apple Computer, Inc.5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved. 8 6 * 9 7 * This library is free software; you can redistribute it and/or … … 29 27 #include "HTMLNames.h" 30 28 31 using namespace WebCore;32 33 29 namespace WebCore { 34 30 35 31 using namespace HTMLNames; 36 32 37 NameNodeList::NameNodeList(Node *n, const String &t) 38 : NodeList(n), nodeName(t) 33 NameNodeList::NameNodeList(Node* root, const String& name) 34 : NodeList(root) 35 , m_nodeName(name) 39 36 { 40 37 } … … 45 42 } 46 43 47 Node *NameNodeList::item (unsigned index) const44 Node* NameNodeList::item (unsigned index) const 48 45 { 49 46 return recursiveItem(index); 50 47 } 51 48 52 bool NameNodeList::nodeMatches(Node *testNode) const49 bool NameNodeList::nodeMatches(Node* testNode) const 53 50 { 54 return static_cast<Element*>(testNode)->getAttribute(nameAttr) == nodeName;51 return static_cast<Element*>(testNode)->getAttribute(nameAttr) == m_nodeName; 55 52 } 56 53 57 } 54 } // namespace WebCore -
trunk/WebCore/dom/NameNodeList.h
r26585 r28722 1 1 /* 2 * This file is part of the DOM implementation for KDE.3 *4 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 5 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 6 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 7 * Copyright (C) 2004 Apple Computer, Inc.5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved. 8 6 * 9 7 * This library is free software; you can redistribute it and/or … … 36 34 class NameNodeList : public NodeList { 37 35 public: 38 NameNodeList(Node* doc, const String& name);36 NameNodeList(Node* root, const String& name); 39 37 40 38 // DOM methods overridden from parent classes … … 49 47 virtual bool nodeMatches(Node* testNode) const; 50 48 51 String nodeName; 49 private: 50 String m_nodeName; 52 51 }; 53 52 -
trunk/WebCore/dom/NamedMappedAttrMap.cpp
r25754 r28722 4 4 * (C) 2001 Peter Kelly (pmk@post.com) 5 5 * (C) 2001 Dirk Mueller (mueller@kde.org) 6 * (C) 2007 David Smith (catfish.man@gmail.com) 6 7 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. 7 8 * … … 38 39 void NamedMappedAttrMap::clearAttributes() 39 40 { 40 m_class List.clear();41 m_classNames.clear(); 41 42 m_mappedAttributeCount = 0; 42 43 NamedAttrMap::clearAttributes(); … … 77 78 } 78 79 79 inline static bool isClassWhitespace(UChar c) 80 { 81 return c == ' ' || c == '\r' || c == '\n' || c == '\t'; 80 void 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()); 82 88 } 83 89 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 }122 90 123 91 } -
trunk/WebCore/dom/NamedMappedAttrMap.h
r25754 r28722 6 6 * (C) 2001 Peter Kelly (pmk@post.com) 7 7 * (C) 2001 Dirk Mueller (mueller@kde.org) 8 * (C) 2007 David Smith (catfish.man@gmail.com) 8 9 * Copyright (C) 2003, 2004, 2005, 2006 Apple Computer, Inc. 9 10 * … … 28 29 #define NamedMappedAttrMap_h 29 30 31 #include "ClassNames.h" 32 #include "MappedAttribute.h" 30 33 #include "NamedAttrMap.h" 31 #include "AtomicStringList.h"32 #include "MappedAttribute.h"33 34 34 35 namespace WebCore { … … 43 44 virtual bool isMappedAttributeMap() const; 44 45 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; } 47 49 48 50 virtual bool hasMappedAttributes() const { return m_mappedAttributeCount > 0; } … … 61 63 62 64 private: 63 AtomicStringList m_classList;65 ClassNames m_classNames; 64 66 int m_mappedAttributeCount; 65 67 }; -
trunk/WebCore/dom/StyledElement.cpp
r28639 r28722 30 30 #include "CSSStyleSheet.h" 31 31 #include "CSSValueKeywords.h" 32 #include "ClassNames.h" 32 33 #include "Document.h" 33 34 #include "HTMLNames.h" … … 102 103 m_synchronizingStyleAttribute = false; 103 104 } 104 }105 106 inline static bool isClassWhitespace(UChar c)107 {108 return c == ' ' || c == '\r' || c == '\n' || c == '\t';109 105 } 110 106 … … 264 260 } 265 261 266 const AtomicStringList* StyledElement::getClassList() const267 { 268 return namedAttrMap ? mappedAttributes()->getClass List() : 0;262 const ClassNames* StyledElement::getClassNames() const 263 { 264 return namedAttrMap ? mappedAttributes()->getClassNames() : 0; 269 265 } 270 266 -
trunk/WebCore/dom/StyledElement.h
r28639 r28722 67 67 virtual void updateStyleAttributeIfNeeded() const; 68 68 69 virtual const AtomicStringList* getClassList() const;69 virtual const ClassNames* getClassNames() const; 70 70 virtual void attributeChanged(Attribute* attr, bool preserveDecls = false); 71 71 virtual void parseMappedAttribute(MappedAttribute* attr);
Note: See TracChangeset
for help on using the changeset viewer.