Changeset 77229 in webkit
- Timestamp:
- Feb 1, 2011 1:11:02 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/Android.mk
r77153 r77229 122 122 dom/DocumentMarkerController.cpp \ 123 123 dom/DocumentParser.cpp \ 124 dom/DocumentOrderedMap.cpp \ 124 125 dom/DocumentType.cpp \ 125 126 dom/DynamicNodeList.cpp \ -
trunk/Source/WebCore/CMakeLists.txt
r77153 r77229 839 839 dom/DocumentFragment.cpp 840 840 dom/DocumentParser.cpp 841 dom/DocumentOrderedMap.cpp 841 842 dom/DocumentType.cpp 842 843 dom/DOMImplementation.cpp -
trunk/Source/WebCore/ChangeLog
r77228 r77229 1 2011-02-01 Roland Steiner <rolandsteiner@chromium.org> 2 3 Reviewed by Dimitri Glazkov. 4 5 Bug 53289 - DOM: Move DocumentOrderedMap from Document into separate files 6 https://bugs.webkit.org/show_bug.cgi?id=53289 7 8 Moving the nested class DocumentOrderedMap from Document into separate files, 9 updating code where necessary. 10 11 No new tests. (refactoring) 12 13 * Android.mk: 14 * CMakeLists.txt: 15 * GNUMakefile.am: 16 * WebCore.gypi: 17 * WebCore.pro: 18 * WebCore.vcproj/WebCore.vcproj: 19 * WebCore.xcodeproj/project.pbxproj: 20 * dom/Document.cpp: 21 (WebCore::Document::getElementById): 22 (WebCore::Document::getImageMap): 23 * dom/Document.h: 24 * dom/DocumentOrderedMap.cpp: Added. 25 (WebCore::keyMatchesId): 26 (WebCore::keyMatchesMapName): 27 (WebCore::keyMatchesLowercasedMapName): 28 (WebCore::DocumentOrderedMap::clear): 29 (WebCore::DocumentOrderedMap::add): 30 (WebCore::DocumentOrderedMap::remove): 31 (WebCore::DocumentOrderedMap::get): 32 (WebCore::DocumentOrderedMap::getElementById): 33 (WebCore::DocumentOrderedMap::getElementByMapName): 34 (WebCore::DocumentOrderedMap::getElementByLowercasedMapName): 35 * dom/DocumentOrderedMap.h: Added. 36 (WebCore::DocumentOrderedMap::contains): 37 (WebCore::DocumentOrderedMap::containsMultiple): 38 * dom/DOMAllInOne.cpp: 39 1 40 2011-02-01 Naoki Takano <takano.naoki@gmail.com> 2 41 -
trunk/Source/WebCore/GNUmakefile.am
r77153 r77229 1168 1168 Source/WebCore/dom/DocumentMarkerController.h \ 1169 1169 Source/WebCore/dom/DocumentMarker.h \ 1170 Source/WebCore/dom/DocumentOrderedMap.cpp \ 1171 Source/WebCore/dom/DocumentOrderedMap.h \ 1170 1172 Source/WebCore/dom/DocumentParser.cpp \ 1171 1173 Source/WebCore/dom/DocumentParser.h \ -
trunk/Source/WebCore/WebCore.gypi
r77153 r77229 1221 1221 'dom/DocumentMarkerController.cpp', 1222 1222 'dom/DocumentMarkerController.h', 1223 'dom/DocumentOrderedMap.cpp', 1224 'dom/DocumentOrderedMap.h', 1223 1225 'dom/DocumentParser.cpp', 1224 1226 'dom/DocumentParser.h', -
trunk/Source/WebCore/WebCore.pro
r77153 r77229 731 731 dom/DocumentFragment.cpp \ 732 732 dom/DocumentMarkerController.cpp \ 733 dom/DocumentOrderedMap.cpp \ 733 734 dom/DocumentParser.cpp \ 734 735 dom/DocumentType.cpp \ … … 1665 1666 dom/DocumentMarker.h \ 1666 1667 dom/DocumentMarkerController.h \ 1668 dom/DocumentOrderedMap.h \ 1667 1669 dom/DocumentType.h \ 1668 1670 dom/DOMImplementation.h \ -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r77153 r77229 43079 43079 </File> 43080 43080 <File 43081 RelativePath="..\dom\DocumentOrderedMap.cpp" 43082 > 43083 <FileConfiguration 43084 Name="Debug|Win32" 43085 ExcludedFromBuild="true" 43086 > 43087 <Tool 43088 Name="VCCLCompilerTool" 43089 /> 43090 </FileConfiguration> 43091 <FileConfiguration 43092 Name="Release|Win32" 43093 ExcludedFromBuild="true" 43094 > 43095 <Tool 43096 Name="VCCLCompilerTool" 43097 /> 43098 </FileConfiguration> 43099 <FileConfiguration 43100 Name="Debug_Cairo_CFLite|Win32" 43101 ExcludedFromBuild="true" 43102 > 43103 <Tool 43104 Name="VCCLCompilerTool" 43105 /> 43106 </FileConfiguration> 43107 <FileConfiguration 43108 Name="Release_Cairo_CFLite|Win32" 43109 ExcludedFromBuild="true" 43110 > 43111 <Tool 43112 Name="VCCLCompilerTool" 43113 /> 43114 </FileConfiguration> 43115 <FileConfiguration 43116 Name="Debug_All|Win32" 43117 ExcludedFromBuild="true" 43118 > 43119 <Tool 43120 Name="VCCLCompilerTool" 43121 /> 43122 </FileConfiguration> 43123 <FileConfiguration 43124 Name="Release_LTCG|Win32" 43125 ExcludedFromBuild="true" 43126 > 43127 <Tool 43128 Name="VCCLCompilerTool" 43129 /> 43130 </FileConfiguration> 43131 </File> 43132 <File 43133 RelativePath="..\dom\DocumentOrderedMap.h" 43134 > 43135 </File> 43136 <File 43081 43137 RelativePath="..\dom\DocumentParser.cpp" 43082 43138 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r77153 r77229 303 303 1432E8470C51493800B1500F /* GCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1432E8460C51493800B1500F /* GCController.h */; settings = {ATTRIBUTES = (Private, ); }; }; 304 304 1432E8490C51493F00B1500F /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1432E8480C51493F00B1500F /* GCController.cpp */; }; 305 143C890812F7C15E0052FFD0 /* DocumentOrderedMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */; }; 306 143C890912F7C15E0052FFD0 /* DocumentOrderedMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */; settings = {ATTRIBUTES = (Private, ); }; }; 305 307 1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1449E24A107D4A8400B5793F /* JSCallbackData.h */; }; 306 308 1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1449E286107D4DB400B5793F /* JSCallbackData.cpp */; }; … … 5207 5209 BCE3BEC20D222B1D007E06E4 /* TagNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */; }; 5208 5210 BCE3BEC30D222B1D007E06E4 /* TagNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */; }; 5209 BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */; };5210 BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413212F748E2009B84B8 /* RenderCombineText.h */; };5211 BCE4413612F7490B009B84B8 /* FontWidthVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413512F7490B009B84B8 /* FontWidthVariant.h */; settings = {ATTRIBUTES = (Private, ); }; };5212 5211 BCE658FF0EA9248A007E4533 /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE658FE0EA9248A007E4533 /* Theme.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5213 5212 BCE659A90EA927B9007E4533 /* ThemeTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE659A80EA927B9007E4533 /* ThemeTypes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 6628 6627 1432E8460C51493800B1500F /* GCController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GCController.h; sourceTree = "<group>"; }; 6629 6628 1432E8480C51493F00B1500F /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; }; 6629 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentOrderedMap.cpp; sourceTree = "<group>"; }; 6630 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentOrderedMap.h; sourceTree = "<group>"; }; 6630 6631 1449E24A107D4A8400B5793F /* JSCallbackData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackData.h; sourceTree = "<group>"; }; 6631 6632 1449E286107D4DB400B5793F /* JSCallbackData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackData.cpp; sourceTree = "<group>"; }; … … 11541 11542 BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagNodeList.cpp; sourceTree = "<group>"; }; 11542 11543 BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagNodeList.h; sourceTree = "<group>"; }; 11543 BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCombineText.cpp; sourceTree = "<group>"; };11544 BCE4413212F748E2009B84B8 /* RenderCombineText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCombineText.h; sourceTree = "<group>"; };11545 BCE4413512F7490B009B84B8 /* FontWidthVariant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontWidthVariant.h; sourceTree = "<group>"; };11546 11544 BCE658FE0EA9248A007E4533 /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = "<group>"; }; 11547 11545 BCE659A80EA927B9007E4533 /* ThemeTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeTypes.h; sourceTree = "<group>"; }; … … 17504 17502 37202198106213C600F25C4B /* FontSmoothingMode.h */, 17505 17503 3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */, 17506 BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,17507 17504 BCE04C930DAFF902007A0F41 /* GeneratedImage.cpp */, 17508 17505 BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */, … … 18760 18757 BCEA4826097D93020094C9E4 /* RenderButton.cpp */, 18761 18758 BCEA4827097D93020094C9E4 /* RenderButton.h */, 18762 BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */,18763 BCE4413212F748E2009B84B8 /* RenderCombineText.h */,18764 18759 9392F1430AD185FE00691BD4 /* RenderCounter.cpp */, 18765 18760 9392F1410AD185F400691BD4 /* RenderCounter.h */, … … 19000 18995 A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */, 19001 18996 BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */, 18997 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */, 18998 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */, 19002 18999 86D982F6125C154000AD9E3D /* DocumentTiming.h */, 19003 19000 A8185F3209765765005826D9 /* DocumentType.cpp */, … … 22468 22465 977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */, 22469 22466 0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */, 22470 BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */, 22471 BCE4413612F7490B009B84B8 /* FontWidthVariant.h in Headers */, 22467 143C890912F7C15E0052FFD0 /* DocumentOrderedMap.h in Headers */, 22472 22468 ); 22473 22469 runOnlyForDeploymentPostprocessing = 0; … … 25168 25164 977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */, 25169 25165 0F3DD44F12F5EA1B000D9190 /* ShadowBlur.cpp in Sources */, 25170 BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */,25166 143C890812F7C15E0052FFD0 /* DocumentOrderedMap.cpp in Sources */, 25171 25167 ); 25172 25168 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r74851 r77229 61 61 #include "DocumentFragment.cpp" 62 62 #include "DocumentMarkerController.cpp" 63 #include "DocumentOrderedMap.cpp" 63 64 #include "DocumentParser.cpp" 64 65 #include "DocumentType.cpp" -
trunk/Source/WebCore/dom/Document.cpp
r76872 r77229 227 227 static const int cLayoutScheduleThreshold = 250; 228 228 229 // These functions can't have internal linkage because they are used as template arguments.230 bool keyMatchesId(AtomicStringImpl*, Element*);231 bool keyMatchesMapName(AtomicStringImpl*, Element*);232 bool keyMatchesLowercasedMapName(AtomicStringImpl*, Element*);233 234 229 // DOM Level 2 says (letters added): 235 230 // … … 508 503 } 509 504 510 inline void Document::DocumentOrderedMap::clear()511 {512 m_map.clear();513 m_duplicateCounts.clear();514 }515 516 505 void Document::removedLastRef() 517 506 { … … 996 985 } 997 986 998 inline void Document::DocumentOrderedMap::add(AtomicStringImpl* key, Element* element)999 {1000 ASSERT(key);1001 ASSERT(element);1002 1003 if (!m_duplicateCounts.contains(key)) {1004 // Fast path. The key is not already in m_duplicateCounts, so we assume that it's1005 // also not already in m_map and try to add it. If that add succeeds, we're done.1006 pair<Map::iterator, bool> addResult = m_map.add(key, element);1007 if (addResult.second)1008 return;1009 1010 // The add failed, so this key was already cached in m_map.1011 // There are multiple elements with this key. Remove the m_map1012 // cache for this key so get searches for it next time it is called.1013 m_map.remove(addResult.first);1014 m_duplicateCounts.add(key);1015 } else {1016 // There are multiple elements with this key. Remove the m_map1017 // cache for this key so get will search for it next time it is called.1018 Map::iterator cachedItem = m_map.find(key);1019 if (cachedItem != m_map.end()) {1020 m_map.remove(cachedItem);1021 m_duplicateCounts.add(key);1022 }1023 }1024 1025 m_duplicateCounts.add(key);1026 }1027 1028 inline void Document::DocumentOrderedMap::remove(AtomicStringImpl* key, Element* element)1029 {1030 ASSERT(key);1031 ASSERT(element);1032 1033 m_map.checkConsistency();1034 Map::iterator cachedItem = m_map.find(key);1035 if (cachedItem != m_map.end() && cachedItem->second == element)1036 m_map.remove(cachedItem);1037 else1038 m_duplicateCounts.remove(key);1039 }1040 1041 template<bool keyMatches(AtomicStringImpl*, Element*)> inline Element* Document::DocumentOrderedMap::get(AtomicStringImpl* key, const Document* document) const1042 {1043 ASSERT(key);1044 1045 m_map.checkConsistency();1046 1047 Element* element = m_map.get(key);1048 if (element)1049 return element;1050 1051 if (m_duplicateCounts.contains(key)) {1052 // We know there's at least one node that matches; iterate to find the first one.1053 for (Node* node = document->firstChild(); node; node = node->traverseNextNode()) {1054 if (!node->isElementNode())1055 continue;1056 element = static_cast<Element*>(node);1057 if (!keyMatches(key, element))1058 continue;1059 m_duplicateCounts.remove(key);1060 m_map.set(key, element);1061 return element;1062 }1063 ASSERT_NOT_REACHED();1064 }1065 1066 return 0;1067 }1068 1069 inline bool keyMatchesId(AtomicStringImpl* key, Element* element)1070 {1071 return element->hasID() && element->getIdAttribute().impl() == key;1072 }1073 1074 987 Element* Document::getElementById(const AtomicString& elementId) const 1075 988 { 1076 989 if (elementId.isEmpty()) 1077 990 return 0; 1078 return m_elementsById.get <keyMatchesId>(elementId.impl(), this);991 return m_elementsById.getElementById(elementId.impl(), this); 1079 992 } 1080 993 … … 3901 3814 } 3902 3815 3903 inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)3904 {3905 return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().impl() == key;3906 }3907 3908 inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)3909 {3910 return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key;3911 }3912 3913 3816 HTMLMapElement* Document::getImageMap(const String& url) const 3914 3817 { … … 3918 3821 String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl(); 3919 3822 if (isHTMLDocument()) 3920 return static_cast<HTMLMapElement*>(m_imageMapsByName.get <keyMatchesLowercasedMapName>(AtomicString(name.lower()).impl(), this));3921 return static_cast<HTMLMapElement*>(m_imageMapsByName.get <keyMatchesMapName>(AtomicString(name).impl(), this));3823 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this)); 3824 return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this)); 3922 3825 } 3923 3826 -
trunk/Source/WebCore/dom/Document.h
r77216 r77229 34 34 #include "ContainerNode.h" 35 35 #include "DOMTimeStamp.h" 36 #include "DocumentOrderedMap.h" 36 37 #include "DocumentTiming.h" 37 38 #include "QualifiedName.h" … … 40 41 #include "ViewportArguments.h" 41 42 #include <wtf/FixedArray.h> 42 #include <wtf/HashCountedSet.h>43 43 #include <wtf/OwnPtr.h> 44 44 #include <wtf/PassOwnPtr.h> 45 #include <wtf/PassRefPtr.h> 45 46 46 47 #if USE(JSC) … … 1095 1096 1096 1097 private: 1097 class DocumentOrderedMap {1098 public:1099 void add(AtomicStringImpl*, Element*);1100 void remove(AtomicStringImpl*, Element*);1101 void clear();1102 1103 bool contains(AtomicStringImpl*) const;1104 bool containsMultiple(AtomicStringImpl*) const;1105 template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const Document*) const;1106 1107 void checkConsistency() const;1108 1109 private:1110 typedef HashMap<AtomicStringImpl*, Element*> Map;1111 1112 // We maintain the invariant that m_duplicateCounts is the count of all elements with a given key1113 // excluding the one referenced in m_map, if any. This means it one less than the total count1114 // when the first node with a given key is cached, otherwise the same as the total count.1115 mutable Map m_map;1116 mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts;1117 };1118 1119 1098 friend class IgnoreDestructiveWriteCountIncrementer; 1120 1099 … … 1412 1391 }; 1413 1392 1414 inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const1415 {1416 return m_map.contains(id) || m_duplicateCounts.contains(id);1417 }1418 1419 inline bool Document::DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const1420 {1421 return m_duplicateCounts.contains(id);1422 }1423 1424 1393 inline bool Document::hasElementWithId(AtomicStringImpl* id) const 1425 1394 {
Note: See TracChangeset
for help on using the changeset viewer.