Reviewed by Darin.
<rdar://problem/5322268>
Safari Crash at http://www.exlibrisgroup.com/sfx_openurl.htm
Add a real copy constructor and assignment operator for CollectionInfo
so that the vectors in the cache maps will be copied correctly.
* html/HTMLCollection.cpp:
(WebCore::HTMLCollection::CollectionInfo::CollectionInfo):
(WebCore::HTMLCollection::CollectionInfo::swap):
* html/HTMLCollection.h:
(WebCore::HTMLCollection::CollectionInfo::operator=):
(WebCore::HTMLCollection::CollectionInfo::copyCacheMap):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@24451 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/html/HTMLCollection.cpp b/WebCore/html/HTMLCollection.cpp
index 0e5359d..8182f8b 100644
--- a/WebCore/html/HTMLCollection.cpp
+++ b/WebCore/html/HTMLCollection.cpp
@@ -31,6 +31,8 @@
#include "HTMLObjectElement.h"
#include "NodeList.h"
+#include <utility>
+
namespace WebCore {
using namespace HTMLNames;
@@ -58,6 +60,36 @@
reset();
}
+HTMLCollection::CollectionInfo::CollectionInfo(const CollectionInfo& other)
+{
+ version = other.version;
+ current = other.current;
+ position = other.position;
+ length = other.length;
+ elementsArrayPosition = other.elementsArrayPosition;
+
+ copyCacheMap(idCache, other.idCache);
+ copyCacheMap(nameCache, other.nameCache);
+
+ haslength = other.haslength;
+ hasNameCache = other.hasNameCache;
+}
+
+void HTMLCollection::CollectionInfo::swap(CollectionInfo& other)
+{
+ std::swap(version, other.version);
+ std::swap(current, other.current);
+ std::swap(position, other.position);
+ std::swap(length, other.length);
+ std::swap(elementsArrayPosition, other.elementsArrayPosition);
+
+ idCache.swap(other.idCache);
+ nameCache.swap(other.nameCache);
+
+ std::swap(haslength, other.haslength);
+ std::swap(hasNameCache, other.hasNameCache);
+}
+
HTMLCollection::CollectionInfo::~CollectionInfo()
{
deleteAllValues(idCache);