[SCM] WebKit Debian packaging branch, webkit-1.3, updated. upstream/1.3.7-4207-g178b198
rolandsteiner at chromium.org
rolandsteiner at chromium.org
Mon Feb 21 00:30:06 UTC 2011
The following commit has been merged in the webkit-1.3 branch:
commit a45aa939c807758702f2d5d470a246c659072bb2
Author: rolandsteiner at chromium.org <rolandsteiner at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Feb 1 09:11:02 2011 +0000
2011-01-28 Roland Steiner <rolandsteiner at chromium.org>
Reviewed by NOBODY (OOPS!).
Bug 53289 - DOM: Move DocumentOrderedMap from Document into separate files
https://bugs.webkit.org/show_bug.cgi?id=53289
Moving the nested class DocumentOrderedMap from Document into separate files,
updating code where necessary.
No new tests. (refactoring)
* Android.mk:
* CMakeLists.txt:
* GNUMakefile.am
* WebCore.gypi:
* WebCore.pro:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/Document.cpp:
(WebCore::Document::getElementById):
(WebCore::Document::getImageMap):
* dom/Document.h:
* dom/DocumentOrderedMap.cpp: Added.
(WebCore::keyMatchesId):
(WebCore::keyMatchesMapName):
(WebCore::keyMatchesLowercasedMapName):
(WebCore::DocumentOrderedMap::clear):
(WebCore::DocumentOrderedMap::add):
(WebCore::DocumentOrderedMap::remove):
(WebCore::DocumentOrderedMap::get):
(WebCore::DocumentOrderedMap::getElementById):
(WebCore::DocumentOrderedMap::getElementByMapName):
(WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
* dom/DocumentOrderedMap.h: Added.
(WebCore::DocumentOrderedMap::contains):
(WebCore::DocumentOrderedMap::containsMultiple):
* dom/DOMAllInOne.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@77229 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index 25d7166..1af3d1e 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -121,6 +121,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
dom/DocumentFragment.cpp \
dom/DocumentMarkerController.cpp \
dom/DocumentParser.cpp \
+ dom/DocumentOrderedMap.cpp \
dom/DocumentType.cpp \
dom/DynamicNodeList.cpp \
dom/EditingText.cpp \
diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt
index 6be3c9d..9ac7fe7 100644
--- a/Source/WebCore/CMakeLists.txt
+++ b/Source/WebCore/CMakeLists.txt
@@ -838,6 +838,7 @@ SET(WebCore_SOURCES
dom/DocumentMarkerController.cpp
dom/DocumentFragment.cpp
dom/DocumentParser.cpp
+ dom/DocumentOrderedMap.cpp
dom/DocumentType.cpp
dom/DOMImplementation.cpp
dom/DOMStringList.cpp
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 8d1750f..073ea1c 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,42 @@
+2011-02-01 Roland Steiner <rolandsteiner at chromium.org>
+
+ Reviewed by Dimitri Glazkov.
+
+ Bug 53289 - DOM: Move DocumentOrderedMap from Document into separate files
+ https://bugs.webkit.org/show_bug.cgi?id=53289
+
+ Moving the nested class DocumentOrderedMap from Document into separate files,
+ updating code where necessary.
+
+ No new tests. (refactoring)
+
+ * Android.mk:
+ * CMakeLists.txt:
+ * GNUMakefile.am:
+ * WebCore.gypi:
+ * WebCore.pro:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * dom/Document.cpp:
+ (WebCore::Document::getElementById):
+ (WebCore::Document::getImageMap):
+ * dom/Document.h:
+ * dom/DocumentOrderedMap.cpp: Added.
+ (WebCore::keyMatchesId):
+ (WebCore::keyMatchesMapName):
+ (WebCore::keyMatchesLowercasedMapName):
+ (WebCore::DocumentOrderedMap::clear):
+ (WebCore::DocumentOrderedMap::add):
+ (WebCore::DocumentOrderedMap::remove):
+ (WebCore::DocumentOrderedMap::get):
+ (WebCore::DocumentOrderedMap::getElementById):
+ (WebCore::DocumentOrderedMap::getElementByMapName):
+ (WebCore::DocumentOrderedMap::getElementByLowercasedMapName):
+ * dom/DocumentOrderedMap.h: Added.
+ (WebCore::DocumentOrderedMap::contains):
+ (WebCore::DocumentOrderedMap::containsMultiple):
+ * dom/DOMAllInOne.cpp:
+
2011-02-01 Naoki Takano <takano.naoki at gmail.com>
Reviewed by Darin Fisher.
diff --git a/Source/WebCore/GNUmakefile.am b/Source/WebCore/GNUmakefile.am
index 5206581..7f6cc54 100644
--- a/Source/WebCore/GNUmakefile.am
+++ b/Source/WebCore/GNUmakefile.am
@@ -1167,6 +1167,8 @@ webcore_sources += \
Source/WebCore/dom/DocumentMarkerController.cpp \
Source/WebCore/dom/DocumentMarkerController.h \
Source/WebCore/dom/DocumentMarker.h \
+ Source/WebCore/dom/DocumentOrderedMap.cpp \
+ Source/WebCore/dom/DocumentOrderedMap.h \
Source/WebCore/dom/DocumentParser.cpp \
Source/WebCore/dom/DocumentParser.h \
Source/WebCore/dom/DocumentTiming.h \
diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi
index 1f8efd8..48c9ffa 100644
--- a/Source/WebCore/WebCore.gypi
+++ b/Source/WebCore/WebCore.gypi
@@ -1220,6 +1220,8 @@
'dom/DocumentMarker.h',
'dom/DocumentMarkerController.cpp',
'dom/DocumentMarkerController.h',
+ 'dom/DocumentOrderedMap.cpp',
+ 'dom/DocumentOrderedMap.h',
'dom/DocumentParser.cpp',
'dom/DocumentParser.h',
'dom/DocumentTiming.h',
diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro
index 9e458f0..2004242 100644
--- a/Source/WebCore/WebCore.pro
+++ b/Source/WebCore/WebCore.pro
@@ -730,6 +730,7 @@ SOURCES += \
dom/Document.cpp \
dom/DocumentFragment.cpp \
dom/DocumentMarkerController.cpp \
+ dom/DocumentOrderedMap.cpp \
dom/DocumentParser.cpp \
dom/DocumentType.cpp \
dom/DOMImplementation.cpp \
@@ -1664,6 +1665,7 @@ HEADERS += \
dom/DocumentFragment.h \
dom/DocumentMarker.h \
dom/DocumentMarkerController.h \
+ dom/DocumentOrderedMap.h \
dom/DocumentType.h \
dom/DOMImplementation.h \
dom/DOMStringList.h \
diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
index bf8f539..8353a72 100755
--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -43078,6 +43078,62 @@
>
</File>
<File
+ RelativePath="..\dom\DocumentOrderedMap.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_Cairo_CFLite|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug_All|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release_LTCG|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\dom\DocumentOrderedMap.h"
+ >
+ </File>
+ <File
RelativePath="..\dom\DocumentParser.cpp"
>
<FileConfiguration
diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
index 415602e..af505ec 100644
--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -302,6 +302,8 @@
142011B70A003133008303F9 /* JSCSSStyleDeclaration.h in Headers */ = {isa = PBXBuildFile; fileRef = 142011B50A003133008303F9 /* JSCSSStyleDeclaration.h */; settings = {ATTRIBUTES = (Private, ); }; };
1432E8470C51493800B1500F /* GCController.h in Headers */ = {isa = PBXBuildFile; fileRef = 1432E8460C51493800B1500F /* GCController.h */; settings = {ATTRIBUTES = (Private, ); }; };
1432E8490C51493F00B1500F /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1432E8480C51493F00B1500F /* GCController.cpp */; };
+ 143C890812F7C15E0052FFD0 /* DocumentOrderedMap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */; };
+ 143C890912F7C15E0052FFD0 /* DocumentOrderedMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
1449E24C107D4A8400B5793F /* JSCallbackData.h in Headers */ = {isa = PBXBuildFile; fileRef = 1449E24A107D4A8400B5793F /* JSCallbackData.h */; };
1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1449E286107D4DB400B5793F /* JSCallbackData.cpp */; };
1477E7760BF4134A00152872 /* PageCache.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1477E7740BF4134A00152872 /* PageCache.cpp */; };
@@ -5206,9 +5208,6 @@
BCE1C4400D9830F4003B02F2 /* JSLocationCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */; };
BCE3BEC20D222B1D007E06E4 /* TagNodeList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */; };
BCE3BEC30D222B1D007E06E4 /* TagNodeList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */; };
- BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */; };
- BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413212F748E2009B84B8 /* RenderCombineText.h */; };
- BCE4413612F7490B009B84B8 /* FontWidthVariant.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE4413512F7490B009B84B8 /* FontWidthVariant.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCE658FF0EA9248A007E4533 /* Theme.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE658FE0EA9248A007E4533 /* Theme.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCE659A90EA927B9007E4533 /* ThemeTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE659A80EA927B9007E4533 /* ThemeTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
BCE659E60EA92FB2007E4533 /* ThemeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCE659E50EA92FB2007E4533 /* ThemeMac.h */; };
@@ -6627,6 +6626,8 @@
142011B50A003133008303F9 /* JSCSSStyleDeclaration.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = JSCSSStyleDeclaration.h; sourceTree = "<group>"; };
1432E8460C51493800B1500F /* GCController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = GCController.h; sourceTree = "<group>"; };
1432E8480C51493F00B1500F /* GCController.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = GCController.cpp; sourceTree = "<group>"; };
+ 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentOrderedMap.cpp; sourceTree = "<group>"; };
+ 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentOrderedMap.h; sourceTree = "<group>"; };
1449E24A107D4A8400B5793F /* JSCallbackData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCallbackData.h; sourceTree = "<group>"; };
1449E286107D4DB400B5793F /* JSCallbackData.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCallbackData.cpp; sourceTree = "<group>"; };
1477E7740BF4134A00152872 /* PageCache.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PageCache.cpp; sourceTree = "<group>"; };
@@ -11540,9 +11541,6 @@
BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSLocationCustom.cpp; sourceTree = "<group>"; };
BCE3BEC00D222B1D007E06E4 /* TagNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TagNodeList.cpp; sourceTree = "<group>"; };
BCE3BEC10D222B1D007E06E4 /* TagNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TagNodeList.h; sourceTree = "<group>"; };
- BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderCombineText.cpp; sourceTree = "<group>"; };
- BCE4413212F748E2009B84B8 /* RenderCombineText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderCombineText.h; sourceTree = "<group>"; };
- BCE4413512F7490B009B84B8 /* FontWidthVariant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontWidthVariant.h; sourceTree = "<group>"; };
BCE658FE0EA9248A007E4533 /* Theme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Theme.h; sourceTree = "<group>"; };
BCE659A80EA927B9007E4533 /* ThemeTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeTypes.h; sourceTree = "<group>"; };
BCE659E50EA92FB2007E4533 /* ThemeMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThemeMac.h; sourceTree = "<group>"; };
@@ -17503,7 +17501,6 @@
B2C3DA5A0D006CD600EF6F26 /* FontSelector.h */,
37202198106213C600F25C4B /* FontSmoothingMode.h */,
3784C34A0E11AA34007D8D48 /* FontTraitsMask.h */,
- BCE4413512F7490B009B84B8 /* FontWidthVariant.h */,
BCE04C930DAFF902007A0F41 /* GeneratedImage.cpp */,
BC23F0DA0DAFF4A4009FDC91 /* GeneratedImage.h */,
BCE04C890DAFF7A0007A0F41 /* Generator.h */,
@@ -18759,8 +18756,6 @@
BCEA4825097D93020094C9E4 /* RenderBR.h */,
BCEA4826097D93020094C9E4 /* RenderButton.cpp */,
BCEA4827097D93020094C9E4 /* RenderButton.h */,
- BCE4413112F748E2009B84B8 /* RenderCombineText.cpp */,
- BCE4413212F748E2009B84B8 /* RenderCombineText.h */,
9392F1430AD185FE00691BD4 /* RenderCounter.cpp */,
9392F1410AD185F400691BD4 /* RenderCounter.h */,
BC77CEC70FF01CBE0070887B /* RenderDataGrid.cpp */,
@@ -18999,6 +18994,8 @@
CE057FA41220731100A476D5 /* DocumentMarkerController.h */,
A8C2280D11D4A59700D5A7D3 /* DocumentParser.cpp */,
BCCFBAE70B5152ED0001F1D7 /* DocumentParser.h */,
+ 143C890612F7C15E0052FFD0 /* DocumentOrderedMap.cpp */,
+ 143C890712F7C15E0052FFD0 /* DocumentOrderedMap.h */,
86D982F6125C154000AD9E3D /* DocumentTiming.h */,
A8185F3209765765005826D9 /* DocumentType.cpp */,
A8185F3109765765005826D9 /* DocumentType.h */,
@@ -22467,8 +22464,7 @@
977E2DCE12F0E28300C13379 /* HTMLSourceTracker.h in Headers */,
977E2E0F12F0FC9C00C13379 /* XSSFilter.h in Headers */,
0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */,
- BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */,
- BCE4413612F7490B009B84B8 /* FontWidthVariant.h in Headers */,
+ 143C890912F7C15E0052FFD0 /* DocumentOrderedMap.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -25167,7 +25163,7 @@
977E2DCD12F0E28300C13379 /* HTMLSourceTracker.cpp in Sources */,
977E2E0E12F0FC9C00C13379 /* XSSFilter.cpp in Sources */,
0F3DD44F12F5EA1B000D9190 /* ShadowBlur.cpp in Sources */,
- BCE4413312F748E2009B84B8 /* RenderCombineText.cpp in Sources */,
+ 143C890812F7C15E0052FFD0 /* DocumentOrderedMap.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Source/WebCore/dom/DOMAllInOne.cpp b/Source/WebCore/dom/DOMAllInOne.cpp
index aa85bfb..c88aecf 100644
--- a/Source/WebCore/dom/DOMAllInOne.cpp
+++ b/Source/WebCore/dom/DOMAllInOne.cpp
@@ -60,6 +60,7 @@
#include "Document.cpp"
#include "DocumentFragment.cpp"
#include "DocumentMarkerController.cpp"
+#include "DocumentOrderedMap.cpp"
#include "DocumentParser.cpp"
#include "DocumentType.cpp"
#include "DynamicNodeList.cpp"
diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp
index 6adef26..cb9a2ab 100644
--- a/Source/WebCore/dom/Document.cpp
+++ b/Source/WebCore/dom/Document.cpp
@@ -226,11 +226,6 @@ using namespace HTMLNames;
// for dual G5s. :)
static const int cLayoutScheduleThreshold = 250;
-// These functions can't have internal linkage because they are used as template arguments.
-bool keyMatchesId(AtomicStringImpl*, Element*);
-bool keyMatchesMapName(AtomicStringImpl*, Element*);
-bool keyMatchesLowercasedMapName(AtomicStringImpl*, Element*);
-
// DOM Level 2 says (letters added):
//
// a) Name start characters must have one of the categories Ll, Lu, Lo, Lt, Nl.
@@ -507,12 +502,6 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML, con
#endif
}
-inline void Document::DocumentOrderedMap::clear()
-{
- m_map.clear();
- m_duplicateCounts.clear();
-}
-
void Document::removedLastRef()
{
ASSERT(!m_deletionHasBegun);
@@ -995,87 +984,11 @@ PassRefPtr<Element> Document::createElementNS(const String& namespaceURI, const
return createElement(qName, false);
}
-inline void Document::DocumentOrderedMap::add(AtomicStringImpl* key, Element* element)
-{
- ASSERT(key);
- ASSERT(element);
-
- if (!m_duplicateCounts.contains(key)) {
- // Fast path. The key is not already in m_duplicateCounts, so we assume that it's
- // also not already in m_map and try to add it. If that add succeeds, we're done.
- pair<Map::iterator, bool> addResult = m_map.add(key, element);
- if (addResult.second)
- return;
-
- // The add failed, so this key was already cached in m_map.
- // There are multiple elements with this key. Remove the m_map
- // cache for this key so get searches for it next time it is called.
- m_map.remove(addResult.first);
- m_duplicateCounts.add(key);
- } else {
- // There are multiple elements with this key. Remove the m_map
- // cache for this key so get will search for it next time it is called.
- Map::iterator cachedItem = m_map.find(key);
- if (cachedItem != m_map.end()) {
- m_map.remove(cachedItem);
- m_duplicateCounts.add(key);
- }
- }
-
- m_duplicateCounts.add(key);
-}
-
-inline void Document::DocumentOrderedMap::remove(AtomicStringImpl* key, Element* element)
-{
- ASSERT(key);
- ASSERT(element);
-
- m_map.checkConsistency();
- Map::iterator cachedItem = m_map.find(key);
- if (cachedItem != m_map.end() && cachedItem->second == element)
- m_map.remove(cachedItem);
- else
- m_duplicateCounts.remove(key);
-}
-
-template<bool keyMatches(AtomicStringImpl*, Element*)> inline Element* Document::DocumentOrderedMap::get(AtomicStringImpl* key, const Document* document) const
-{
- ASSERT(key);
-
- m_map.checkConsistency();
-
- Element* element = m_map.get(key);
- if (element)
- return element;
-
- if (m_duplicateCounts.contains(key)) {
- // We know there's at least one node that matches; iterate to find the first one.
- for (Node* node = document->firstChild(); node; node = node->traverseNextNode()) {
- if (!node->isElementNode())
- continue;
- element = static_cast<Element*>(node);
- if (!keyMatches(key, element))
- continue;
- m_duplicateCounts.remove(key);
- m_map.set(key, element);
- return element;
- }
- ASSERT_NOT_REACHED();
- }
-
- return 0;
-}
-
-inline bool keyMatchesId(AtomicStringImpl* key, Element* element)
-{
- return element->hasID() && element->getIdAttribute().impl() == key;
-}
-
Element* Document::getElementById(const AtomicString& elementId) const
{
if (elementId.isEmpty())
return 0;
- return m_elementsById.get<keyMatchesId>(elementId.impl(), this);
+ return m_elementsById.getElementById(elementId.impl(), this);
}
String Document::readyState() const
@@ -3900,16 +3813,6 @@ void Document::removeImageMap(HTMLMapElement* imageMap)
m_imageMapsByName.remove(name, imageMap);
}
-inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)
-{
- return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().impl() == key;
-}
-
-inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)
-{
- return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key;
-}
-
HTMLMapElement* Document::getImageMap(const String& url) const
{
if (url.isNull())
@@ -3917,8 +3820,8 @@ HTMLMapElement* Document::getImageMap(const String& url) const
size_t hashPos = url.find('#');
String name = (hashPos == notFound ? url : url.substring(hashPos + 1)).impl();
if (isHTMLDocument())
- return static_cast<HTMLMapElement*>(m_imageMapsByName.get<keyMatchesLowercasedMapName>(AtomicString(name.lower()).impl(), this));
- return static_cast<HTMLMapElement*>(m_imageMapsByName.get<keyMatchesMapName>(AtomicString(name).impl(), this));
+ return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByLowercasedMapName(AtomicString(name.lower()).impl(), this));
+ return static_cast<HTMLMapElement*>(m_imageMapsByName.getElementByMapName(AtomicString(name).impl(), this));
}
void Document::setDecoder(PassRefPtr<TextResourceDecoder> decoder)
diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h
index 04901e1..170822b 100644
--- a/Source/WebCore/dom/Document.h
+++ b/Source/WebCore/dom/Document.h
@@ -33,15 +33,16 @@
#include "Color.h"
#include "ContainerNode.h"
#include "DOMTimeStamp.h"
+#include "DocumentOrderedMap.h"
#include "DocumentTiming.h"
#include "QualifiedName.h"
#include "ScriptExecutionContext.h"
#include "Timer.h"
#include "ViewportArguments.h"
#include <wtf/FixedArray.h>
-#include <wtf/HashCountedSet.h>
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/PassRefPtr.h>
#if USE(JSC)
#include <runtime/WeakGCMap.h>
@@ -1094,28 +1095,6 @@ protected:
void clearXMLVersion() { m_xmlVersion = String(); }
private:
- class DocumentOrderedMap {
- public:
- void add(AtomicStringImpl*, Element*);
- void remove(AtomicStringImpl*, Element*);
- void clear();
-
- bool contains(AtomicStringImpl*) const;
- bool containsMultiple(AtomicStringImpl*) const;
- template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const Document*) const;
-
- void checkConsistency() const;
-
- private:
- typedef HashMap<AtomicStringImpl*, Element*> Map;
-
- // We maintain the invariant that m_duplicateCounts is the count of all elements with a given key
- // excluding the one referenced in m_map, if any. This means it one less than the total count
- // when the first node with a given key is cached, otherwise the same as the total count.
- mutable Map m_map;
- mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts;
- };
-
friend class IgnoreDestructiveWriteCountIncrementer;
void detachParser();
@@ -1411,16 +1390,6 @@ private:
#endif
};
-inline bool Document::DocumentOrderedMap::contains(AtomicStringImpl* id) const
-{
- return m_map.contains(id) || m_duplicateCounts.contains(id);
-}
-
-inline bool Document::DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const
-{
- return m_duplicateCounts.contains(id);
-}
-
inline bool Document::hasElementWithId(AtomicStringImpl* id) const
{
ASSERT(id);
diff --git a/Source/WebCore/dom/DocumentOrderedMap.cpp b/Source/WebCore/dom/DocumentOrderedMap.cpp
new file mode 100644
index 0000000..787fcf4
--- /dev/null
+++ b/Source/WebCore/dom/DocumentOrderedMap.cpp
@@ -0,0 +1,151 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "DocumentOrderedMap.h"
+
+#include "Element.h"
+#include "HTMLMapElement.h"
+#include "HTMLNames.h"
+
+namespace WebCore {
+
+using namespace HTMLNames;
+
+inline bool keyMatchesId(AtomicStringImpl* key, Element* element)
+{
+ return element->hasID() && element->getIdAttribute().impl() == key;
+}
+
+inline bool keyMatchesMapName(AtomicStringImpl* key, Element* element)
+{
+ return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().impl() == key;
+}
+
+inline bool keyMatchesLowercasedMapName(AtomicStringImpl* key, Element* element)
+{
+ return element->hasTagName(mapTag) && static_cast<HTMLMapElement*>(element)->getName().lower().impl() == key;
+}
+
+void DocumentOrderedMap::clear()
+{
+ m_map.clear();
+ m_duplicateCounts.clear();
+}
+
+void DocumentOrderedMap::add(AtomicStringImpl* key, Element* element)
+{
+ ASSERT(key);
+ ASSERT(element);
+
+ if (!m_duplicateCounts.contains(key)) {
+ // Fast path. The key is not already in m_duplicateCounts, so we assume that it's
+ // also not already in m_map and try to add it. If that add succeeds, we're done.
+ pair<Map::iterator, bool> addResult = m_map.add(key, element);
+ if (addResult.second)
+ return;
+
+ // The add failed, so this key was already cached in m_map.
+ // There are multiple elements with this key. Remove the m_map
+ // cache for this key so get searches for it next time it is called.
+ m_map.remove(addResult.first);
+ m_duplicateCounts.add(key);
+ } else {
+ // There are multiple elements with this key. Remove the m_map
+ // cache for this key so get will search for it next time it is called.
+ Map::iterator cachedItem = m_map.find(key);
+ if (cachedItem != m_map.end()) {
+ m_map.remove(cachedItem);
+ m_duplicateCounts.add(key);
+ }
+ }
+
+ m_duplicateCounts.add(key);
+}
+
+void DocumentOrderedMap::remove(AtomicStringImpl* key, Element* element)
+{
+ ASSERT(key);
+ ASSERT(element);
+
+ m_map.checkConsistency();
+ Map::iterator cachedItem = m_map.find(key);
+ if (cachedItem != m_map.end() && cachedItem->second == element)
+ m_map.remove(cachedItem);
+ else
+ m_duplicateCounts.remove(key);
+}
+
+template<bool keyMatches(AtomicStringImpl*, Element*)>
+inline Element* DocumentOrderedMap::get(AtomicStringImpl* key, const Document* document) const
+{
+ ASSERT(key);
+
+ m_map.checkConsistency();
+
+ Element* element = m_map.get(key);
+ if (element)
+ return element;
+
+ if (m_duplicateCounts.contains(key)) {
+ // We know there's at least one node that matches; iterate to find the first one.
+ for (Node* node = document->firstChild(); node; node = node->traverseNextNode()) {
+ if (!node->isElementNode())
+ continue;
+ element = static_cast<Element*>(node);
+ if (!keyMatches(key, element))
+ continue;
+ m_duplicateCounts.remove(key);
+ m_map.set(key, element);
+ return element;
+ }
+ ASSERT_NOT_REACHED();
+ }
+
+ return 0;
+}
+
+Element* DocumentOrderedMap::getElementById(AtomicStringImpl* key, const Document* document) const
+{
+ return get<keyMatchesId>(key, document);
+}
+
+Element* DocumentOrderedMap::getElementByMapName(AtomicStringImpl* key, const Document* document) const
+{
+ return get<keyMatchesMapName>(key, document);
+}
+
+Element* DocumentOrderedMap::getElementByLowercasedMapName(AtomicStringImpl* key, const Document* document) const
+{
+ return get<keyMatchesLowercasedMapName>(key, document);
+}
+
+} // namespace WebCore
+
diff --git a/Source/WebCore/dom/DocumentOrderedMap.h b/Source/WebCore/dom/DocumentOrderedMap.h
new file mode 100644
index 0000000..58767c6
--- /dev/null
+++ b/Source/WebCore/dom/DocumentOrderedMap.h
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef DocumentOrderedMap_h
+#define DocumentOrderedMap_h
+
+#include <wtf/HashCountedSet.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/AtomicStringImpl.h>
+
+namespace WebCore {
+
+class Document;
+class Element;
+
+class DocumentOrderedMap {
+public:
+ void add(AtomicStringImpl*, Element*);
+ void remove(AtomicStringImpl*, Element*);
+ void clear();
+
+ bool contains(AtomicStringImpl*) const;
+ bool containsMultiple(AtomicStringImpl*) const;
+ // concrete instantiations of the get<>() method template
+ Element* getElementById(AtomicStringImpl*, const Document*) const;
+ Element* getElementByMapName(AtomicStringImpl*, const Document*) const;
+ Element* getElementByLowercasedMapName(AtomicStringImpl*, const Document*) const;
+
+ void checkConsistency() const;
+
+private:
+ template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicStringImpl*, const Document*) const;
+
+ typedef HashMap<AtomicStringImpl*, Element*> Map;
+
+ // We maintain the invariant that m_duplicateCounts is the count of all elements with a given key
+ // excluding the one referenced in m_map, if any. This means it one less than the total count
+ // when the first node with a given key is cached, otherwise the same as the total count.
+ mutable Map m_map;
+ mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts;
+};
+
+inline bool DocumentOrderedMap::contains(AtomicStringImpl* id) const
+{
+ return m_map.contains(id) || m_duplicateCounts.contains(id);
+}
+
+inline bool DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const
+{
+ return m_duplicateCounts.contains(id);
+}
+
+} // namespace WebCore
+
+#endif // DocumentOrderedMap_h
+
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list