Title: [135321] trunk/Source/WebCore
- Revision
- 135321
- Author
- [email protected]
- Date
- 2012-11-20 15:40:49 -0800 (Tue, 20 Nov 2012)
Log Message
HTMLCollection's cache should not be invalidated when id or name attributes are changed
https://bugs.webkit.org/show_bug.cgi?id=102843
Reviewed by Eric Seidel.
When an id or name attribute changes, only invaliate id and name cache maps when the collection
doesn't depend on id and name attributes (e.g. document.images).
Unfortunately, I could not create a reliable test for this performance problem.
* dom/DynamicNodeList.cpp:
(WebCore::DynamicNodeListCacheBase::invalidateIdNameCacheMaps):
* dom/DynamicNodeList.h:
(WebCore::DynamicNodeListCacheBase::invalidateCache):
(DynamicNodeListCacheBase):
* dom/ElementRareData.h:
(WebCore::ElementRareData::clearHTMLCollectionCaches):
* html/HTMLCollection.cpp:
(WebCore::invalidationTypeExcludingIdAndNameAttributes):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (135320 => 135321)
--- trunk/Source/WebCore/ChangeLog 2012-11-20 23:38:44 UTC (rev 135320)
+++ trunk/Source/WebCore/ChangeLog 2012-11-20 23:40:49 UTC (rev 135321)
@@ -1,3 +1,25 @@
+2012-11-20 Ryosuke Niwa <[email protected]>
+
+ HTMLCollection's cache should not be invalidated when id or name attributes are changed
+ https://bugs.webkit.org/show_bug.cgi?id=102843
+
+ Reviewed by Eric Seidel.
+
+ When an id or name attribute changes, only invaliate id and name cache maps when the collection
+ doesn't depend on id and name attributes (e.g. document.images).
+
+ Unfortunately, I could not create a reliable test for this performance problem.
+
+ * dom/DynamicNodeList.cpp:
+ (WebCore::DynamicNodeListCacheBase::invalidateIdNameCacheMaps):
+ * dom/DynamicNodeList.h:
+ (WebCore::DynamicNodeListCacheBase::invalidateCache):
+ (DynamicNodeListCacheBase):
+ * dom/ElementRareData.h:
+ (WebCore::ElementRareData::clearHTMLCollectionCaches):
+ * html/HTMLCollection.cpp:
+ (WebCore::invalidationTypeExcludingIdAndNameAttributes):
+
2012-11-20 Adam Klein <[email protected]>
[v8] Avoid unnecessary call to ToObject() in Callback constructors
Modified: trunk/Source/WebCore/dom/DynamicNodeList.cpp (135320 => 135321)
--- trunk/Source/WebCore/dom/DynamicNodeList.cpp 2012-11-20 23:38:44 UTC (rev 135320)
+++ trunk/Source/WebCore/dom/DynamicNodeList.cpp 2012-11-20 23:40:49 UTC (rev 135321)
@@ -71,6 +71,14 @@
#endif
}
+void DynamicNodeListCacheBase::invalididateIdNameCacheMaps() const
+{
+ ASSERT(isNodeCollectionType(type()));
+ const HTMLCollectionCacheBase* cacheBase = static_cast<const HTMLCollectionCacheBase*>(this);
+ cacheBase->m_idCache.clear();
+ cacheBase->m_nameCache.clear();
+}
+
unsigned DynamicNodeList::length() const
{
return lengthCommon();
Modified: trunk/Source/WebCore/dom/DynamicNodeList.h (135320 => 135321)
--- trunk/Source/WebCore/dom/DynamicNodeList.h 2012-11-20 23:38:44 UTC (rev 135320)
+++ trunk/Source/WebCore/dom/DynamicNodeList.h 2012-11-20 23:40:49 UTC (rev 135321)
@@ -76,8 +76,11 @@
{
if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attrName))
invalidateCache();
+ else if (isNodeCollectionType(type()) && (*attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr))
+ invalididateIdNameCacheMaps();
}
void invalidateCache() const;
+ void invalididateIdNameCacheMaps() const;
static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&);
Modified: trunk/Source/WebCore/dom/ElementRareData.h (135320 => 135321)
--- trunk/Source/WebCore/dom/ElementRareData.h 2012-11-20 23:38:44 UTC (rev 135320)
+++ trunk/Source/WebCore/dom/ElementRareData.h 2012-11-20 23:40:49 UTC (rev 135321)
@@ -84,13 +84,9 @@
if (!m_cachedCollections)
return;
- bool shouldIgnoreType = !attrName || *attrName == HTMLNames::idAttr || *attrName == HTMLNames::nameAttr;
-
for (unsigned i = 0; i < (*m_cachedCollections).size(); i++) {
- if (HTMLCollection* collection = (*m_cachedCollections)[i]) {
- if (shouldIgnoreType || DynamicNodeListCacheBase::shouldInvalidateTypeOnAttributeChange(collection->invalidationType(), *attrName))
- collection->invalidateCache();
- }
+ if (HTMLCollection* collection = (*m_cachedCollections)[i])
+ collection->invalidateCache(attrName);
}
}
Modified: trunk/Source/WebCore/html/HTMLCollection.cpp (135320 => 135321)
--- trunk/Source/WebCore/html/HTMLCollection.cpp 2012-11-20 23:38:44 UTC (rev 135320)
+++ trunk/Source/WebCore/html/HTMLCollection.cpp 2012-11-20 23:40:49 UTC (rev 135321)
@@ -116,11 +116,8 @@
case DocImages:
case DocEmbeds:
case DocForms:
- case DocAnchors: // Depends on name attribute.
case DocScripts:
case DocAll:
- case WindowNamedItems: // Depends on id and name attributes.
- case DocumentNamedItems: // Ditto.
case NodeChildren:
case TableTBodies:
case TSectionRows:
@@ -134,8 +131,14 @@
case DataListOptions:
// FIXME: We can do better some day.
return InvalidateOnAnyAttrChange;
+ case DocAnchors:
+ return InvalidateOnNameAttrChange;
case DocLinks:
return InvalidateOnHRefAttrChange;
+ case WindowNamedItems:
+ return InvalidateOnIdNameAttrChange;
+ case DocumentNamedItems:
+ return InvalidateOnIdNameAttrChange;
#if ENABLE(MICRODATA)
case ItemProperties:
return InvalidateOnItemAttrChange;
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes