Chromium Code Reviews| Index: Source/core/dom/Document.cpp |
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
| index 51c6c94cf5ac198dc65116cc60efd6ef91f9b689..f01b1e78c8d4a4432ace4226a0e78b0b4722c292 100644 |
| --- a/Source/core/dom/Document.cpp |
| +++ b/Source/core/dom/Document.cpp |
| @@ -509,8 +509,10 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
| initSecurityContext(initializer); |
| initDNSPrefetch(); |
| +#if !ENABLE(OILPAN) |
| for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) |
| m_nodeListCounts[i] = 0; |
| +#endif |
| InspectorCounters::incrementCounter(InspectorCounters::DocumentCounter); |
| @@ -589,17 +591,17 @@ Document::~Document() |
| m_fetcher.clear(); |
| #endif |
| +#if !ENABLE(OILPAN) |
| // We must call clearRareData() here since a Document class inherits TreeScope |
| // as well as Node. See a comment on TreeScope.h for the reason. |
| -#if !ENABLE(OILPAN) |
| if (hasRareData()) |
| clearRareData(); |
| -#endif |
| - ASSERT(!m_listsInvalidatedAtDocument.size()); |
| + ASSERT(m_listsInvalidatedAtDocument.isEmpty()); |
| for (unsigned i = 0; i < WTF_ARRAY_LENGTH(m_nodeListCounts); i++) |
| ASSERT(!m_nodeListCounts[i]); |
| +#endif |
| setClient(0); |
| @@ -3699,20 +3701,42 @@ void Document::setCSSTarget(Element* n) |
| void Document::registerNodeList(LiveNodeListBase* list) |
| { |
| +#if ENABLE(OILPAN) |
| + m_nodeLists[list->invalidationType()].add(list); |
| +#else |
| m_nodeListCounts[list->invalidationType()]++; |
| +#endif |
| if (list->isRootedAtDocument()) |
| m_listsInvalidatedAtDocument.add(list); |
| } |
| void Document::unregisterNodeList(LiveNodeListBase* list) |
| { |
| +#if ENABLE(OILPAN) |
| + ASSERT(m_nodeLists[list->invalidationType()].contains(WeakMember<LiveNodeListBase>(list))); |
| + m_nodeLists[list->invalidationType()].remove(WeakMember<LiveNodeListBase>(list)); |
|
haraken
2014/05/12 12:04:13
Isn't this weak processing automatically done by o
sof
2014/05/12 12:24:36
It is done automatically most times but for the ca
|
| +#else |
| m_nodeListCounts[list->invalidationType()]--; |
| +#endif |
| if (list->isRootedAtDocument()) { |
|
haraken
2014/05/12 12:04:13
I'm just curious but why is this check necessary i
sof
2014/05/15 22:15:57
It is used to handle fast invalidation of certain
|
| ASSERT(m_listsInvalidatedAtDocument.contains(list)); |
| m_listsInvalidatedAtDocument.remove(list); |
|
haraken
2014/05/12 12:04:13
I think you can remove this line from oilpan-build
sof
2014/05/12 12:24:36
I think it needs to stay; see above.
|
| } |
| } |
| +#if ENABLE(OILPAN) |
| +void Document::incrementNodeListWithIdNameCacheCount(const LiveNodeListBase* list) |
| +{ |
| + m_nodeLists[InvalidateOnIdNameAttrChange].add(WeakMember<LiveNodeListBase>(const_cast<LiveNodeListBase*>(list))); |
| +} |
| + |
| +void Document::decrementNodeListWithIdNameCacheCount(const LiveNodeListBase* list) |
|
haraken
2014/05/12 12:04:13
I'd rename these methods to {register,unregister}N
sof
2014/05/15 22:15:57
Done.
|
| +{ |
| + ASSERT(m_nodeLists[InvalidateOnIdNameAttrChange].contains(WeakMember<LiveNodeListBase>(const_cast<LiveNodeListBase*>(list)))); |
| + m_nodeLists[InvalidateOnIdNameAttrChange].remove(WeakMember<LiveNodeListBase>(const_cast<LiveNodeListBase*>(list))); |
| +} |
| +#endif |
| + |
| void Document::attachNodeIterator(NodeIterator* ni) |
| { |
| m_nodeIterators.add(ni); |
| @@ -4516,63 +4540,63 @@ bool Document::hasSVGRootNode() const |
| return isSVGSVGElement(documentElement()); |
| } |
| -PassRefPtr<HTMLCollection> Document::ensureCachedCollection(CollectionType type) |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::ensureCachedCollection(CollectionType type) |
| { |
| return ensureRareData().ensureNodeLists().addCache<HTMLCollection>(*this, type); |
| } |
| -PassRefPtr<HTMLCollection> Document::images() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::images() |
| { |
| return ensureCachedCollection(DocImages); |
| } |
| -PassRefPtr<HTMLCollection> Document::applets() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::applets() |
| { |
| return ensureCachedCollection(DocApplets); |
| } |
| -PassRefPtr<HTMLCollection> Document::embeds() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::embeds() |
| { |
| return ensureCachedCollection(DocEmbeds); |
| } |
| -PassRefPtr<HTMLCollection> Document::scripts() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::scripts() |
| { |
| return ensureCachedCollection(DocScripts); |
| } |
| -PassRefPtr<HTMLCollection> Document::links() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::links() |
| { |
| return ensureCachedCollection(DocLinks); |
| } |
| -PassRefPtr<HTMLCollection> Document::forms() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::forms() |
| { |
| return ensureCachedCollection(DocForms); |
| } |
| -PassRefPtr<HTMLCollection> Document::anchors() |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::anchors() |
| { |
| return ensureCachedCollection(DocAnchors); |
| } |
| -PassRefPtr<HTMLAllCollection> Document::allForBinding() |
| +PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::allForBinding() |
| { |
| UseCounter::count(*this, UseCounter::DocumentAll); |
| return all(); |
| } |
| -PassRefPtr<HTMLAllCollection> Document::all() |
| +PassRefPtrWillBeRawPtr<HTMLAllCollection> Document::all() |
| { |
| return ensureRareData().ensureNodeLists().addCache<HTMLAllCollection>(*this, DocAll); |
| } |
| -PassRefPtr<HTMLCollection> Document::windowNamedItems(const AtomicString& name) |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::windowNamedItems(const AtomicString& name) |
| { |
| return ensureRareData().ensureNodeLists().addCache<HTMLNameCollection>(*this, WindowNamedItems, name); |
| } |
| -PassRefPtr<HTMLCollection> Document::documentNamedItems(const AtomicString& name) |
| +PassRefPtrWillBeRawPtr<HTMLCollection> Document::documentNamedItems(const AtomicString& name) |
| { |
| return ensureRareData().ensureNodeLists().addCache<HTMLNameCollection>(*this, DocumentNamedItems, name); |
| } |
| @@ -5650,6 +5674,21 @@ bool Document::hasFocus() const |
| return false; |
| } |
| +#if ENABLE(OILPAN) |
| +template<unsigned type> |
| +bool shouldInvalidateNodeListCachesForAttr(const HeapHashSet<WeakMember<LiveNodeListBase> > nodeLists[], const QualifiedName& attrName) |
| +{ |
| + if (!nodeLists[type].isEmpty() && LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(static_cast<NodeListInvalidationType>(type), attrName)) |
| + return true; |
| + return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeLists, attrName); |
| +} |
| + |
| +template<> |
| +bool shouldInvalidateNodeListCachesForAttr<numNodeListInvalidationTypes>(const HeapHashSet<WeakMember<LiveNodeListBase> >[], const QualifiedName&) |
| +{ |
| + return false; |
| +} |
| +#else |
| template<unsigned type> |
| bool shouldInvalidateNodeListCachesForAttr(const unsigned nodeListCounts[], const QualifiedName& attrName) |
| { |
| @@ -5663,14 +5702,24 @@ bool shouldInvalidateNodeListCachesForAttr<numNodeListInvalidationTypes>(const u |
| { |
| return false; |
| } |
| +#endif |
| bool Document::shouldInvalidateNodeListCaches(const QualifiedName* attrName) const |
| { |
| - if (attrName) |
| + if (attrName) { |
| +#if ENABLE(OILPAN) |
| + return shouldInvalidateNodeListCachesForAttr<DoNotInvalidateOnAttributeChanges + 1>(m_nodeLists, *attrName); |
| +#else |
| return shouldInvalidateNodeListCachesForAttr<DoNotInvalidateOnAttributeChanges + 1>(m_nodeListCounts, *attrName); |
| +#endif |
| + } |
| for (int type = 0; type < numNodeListInvalidationTypes; type++) { |
| +#if ENABLE(OILPAN) |
| + if (!m_nodeLists[type].isEmpty()) |
| +#else |
| if (m_nodeListCounts[type]) |
| +#endif |
| return true; |
| } |
| @@ -5679,8 +5728,8 @@ bool Document::shouldInvalidateNodeListCaches(const QualifiedName* attrName) con |
| void Document::invalidateNodeListCaches(const QualifiedName* attrName) |
| { |
| - HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end(); |
| - for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) |
| + WillBeHeapHashSet<RawPtrWillBeWeakMember<LiveNodeListBase> >::iterator end = m_listsInvalidatedAtDocument.end(); |
| + for (WillBeHeapHashSet<RawPtrWillBeWeakMember<LiveNodeListBase> >::iterator it = m_listsInvalidatedAtDocument.begin(); it != end; ++it) |
| (*it)->invalidateCacheForAttribute(attrName); |
| } |
| @@ -5716,6 +5765,11 @@ void Document::trace(Visitor* visitor) |
| visitor->trace(m_titleElement); |
| visitor->trace(m_currentScriptStack); |
| visitor->trace(m_transformSourceDocument); |
| + visitor->trace(m_listsInvalidatedAtDocument); |
| +#if ENABLE(OILPAN) |
| + for (int i = 0; i < numNodeListInvalidationTypes; i++) |
| + visitor->trace(m_nodeLists[i]); |
| +#endif |
| visitor->trace(m_cssCanvasElements); |
| visitor->trace(m_topLayerElements); |
| visitor->trace(m_elemSheet); |