Changeset 166407 in webkit
- Timestamp:
- Mar 28, 2014 8:36:40 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166406 r166407 1 2014-03-28 Antti Koivisto <antti@apple.com> 2 3 Remove NodeListRootType flag 4 https://bugs.webkit.org/show_bug.cgi?id=130896 5 6 Reviewed by Anders Carlsson. 7 8 This can be handled statically (except for the RadioNodeList case) removing 9 a branch from NodeList traversal. 10 11 * dom/ClassNodeList.h: 12 * dom/Document.cpp: 13 (WebCore::Document::registerNodeListForInvalidation): 14 (WebCore::Document::unregisterNodeListForInvalidation): 15 (WebCore::Document::registerNodeList): Deleted. 16 (WebCore::Document::unregisterNodeList): Deleted. 17 18 Mark document invalidation registered lists with a bit. 19 Renamed for clarity. 20 21 * dom/Document.h: 22 * dom/LiveNodeList.cpp: 23 (WebCore::LiveNodeList::LiveNodeList): 24 (WebCore::LiveNodeList::rootNode): 25 26 Base class version that invokes virtual isRootedAtDocument. It is needed to support 27 LiveNodeList::namedItem. 28 29 * dom/LiveNodeList.h: 30 (WebCore::LiveNodeList::isRegisteredForInvalidationAtDocument): 31 (WebCore::LiveNodeList::setRegisteredForInvalidationAtDocument): 32 (WebCore::LiveNodeList::document): 33 (WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList): 34 (WebCore::CachedLiveNodeList<NodeListType>::~CachedLiveNodeList): 35 (WebCore::CachedLiveNodeList<NodeListType>::rootNode): 36 37 Call isRootedAtDocument on the final leaf type. Except for RadioNodeList this 38 resolves statically. 39 40 (WebCore::CachedLiveNodeList<NodeListType>::willValidateIndexCache): 41 (WebCore::CachedLiveNodeList<NodeListType>::invalidateCache): 42 (WebCore::LiveNodeList::isRootedAtDocument): Deleted. 43 (WebCore::LiveNodeList::rootType): Deleted. 44 (WebCore::LiveNodeList::rootNode): Deleted. 45 * dom/NameNodeList.h: 46 * dom/NodeRareData.h: 47 (WebCore::NodeListsNodeData::adoptDocument): 48 * dom/TagNodeList.h: 49 * html/HTMLCollection.cpp: 50 (WebCore::rootTypeFromCollectionType): 51 * html/HTMLCollection.h: 52 (WebCore::HTMLCollection::isRootedAtDocument): 53 (WebCore::HTMLCollection::rootType): 54 55 HTMLCollections still needs the flag. 56 57 * html/LabelsNodeList.cpp: 58 (WebCore::LabelsNodeList::LabelsNodeList): 59 * html/LabelsNodeList.h: 60 * html/RadioNodeList.cpp: 61 (WebCore::RadioNodeList::RadioNodeList): 62 * html/RadioNodeList.h: 63 1 64 2014-03-28 Mario Sanchez Prada <mario.prada@samsung.com> 2 65 -
trunk/Source/WebCore/dom/ClassNodeList.cpp
r166377 r166407 1 1 /* 2 * Copyright (C) 2007 , 2008Apple Inc. All rights reserved.2 * Copyright (C) 2007-2008, 2014 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 David Smith (catfish.man@gmail.com) 4 4 * -
trunk/Source/WebCore/dom/ClassNodeList.h
r166369 r166407 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2014 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2007 David Smith (catfish.man@gmail.com) 4 4 * … … 48 48 49 49 virtual bool nodeMatches(Element*) const override; 50 virtual bool isRootedAtDocument() const override { return false; } 50 51 51 52 private: -
trunk/Source/WebCore/dom/Document.cpp
r166277 r166407 3453 3453 } 3454 3454 3455 void Document::registerNodeList (LiveNodeList& list)3455 void Document::registerNodeListForInvalidation(LiveNodeList& list) 3456 3456 { 3457 3457 m_nodeListAndCollectionCounts[list.invalidationType()]++; 3458 if (list.isRootedAtDocument()) 3459 m_listsInvalidatedAtDocument.add(&list); 3460 } 3461 3462 void Document::unregisterNodeList(LiveNodeList& list) 3458 if (!list.isRootedAtDocument()) 3459 return; 3460 ASSERT(!list.isRegisteredForInvalidationAtDocument()); 3461 list.setRegisteredForInvalidationAtDocument(true); 3462 m_listsInvalidatedAtDocument.add(&list); 3463 } 3464 3465 void Document::unregisterNodeListForInvalidation(LiveNodeList& list) 3463 3466 { 3464 3467 m_nodeListAndCollectionCounts[list.invalidationType()]--; 3465 if (list.isRootedAtDocument()) { 3466 if (!m_listsInvalidatedAtDocument.size()) { 3467 ASSERT(m_inInvalidateNodeListAndCollectionCaches); 3468 return; 3469 } 3470 ASSERT(m_listsInvalidatedAtDocument.contains(&list)); 3471 m_listsInvalidatedAtDocument.remove(&list); 3472 } 3468 if (!list.isRegisteredForInvalidationAtDocument()) 3469 return; 3470 if (!m_listsInvalidatedAtDocument.size()) { 3471 ASSERT(m_inInvalidateNodeListAndCollectionCaches); 3472 return; 3473 } 3474 ASSERT(m_listsInvalidatedAtDocument.contains(&list)); 3475 m_listsInvalidatedAtDocument.remove(&list); 3476 list.setRegisteredForInvalidationAtDocument(false); 3473 3477 } 3474 3478 -
trunk/Source/WebCore/dom/Document.h
r165423 r166407 762 762 void optimizedStyleSheetUpdateTimerFired(Timer<Document>&); 763 763 764 void registerNodeList (LiveNodeList&);765 void unregisterNodeList (LiveNodeList&);764 void registerNodeListForInvalidation(LiveNodeList&); 765 void unregisterNodeListForInvalidation(LiveNodeList&); 766 766 void registerCollection(HTMLCollection&); 767 767 void unregisterCollection(HTMLCollection&); -
trunk/Source/WebCore/dom/LiveNodeList.cpp
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2006 , 2007, 2008, 2010, 2013Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2006-2008, 2010, 2013-2014 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 32 32 namespace WebCore { 33 33 34 LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType , NodeListRootType rootType)34 LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType) 35 35 : m_ownerNode(ownerNode) 36 , m_rootType(rootType)37 36 , m_invalidationType(invalidationType) 37 , m_isRegisteredForInvalidationAtDocument(false) 38 38 { 39 ASSERT(m_rootType == static_cast<unsigned>(rootType));40 39 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); 41 40 } … … 45 44 } 46 45 46 ContainerNode& LiveNodeList::rootNode() const 47 { 48 if (isRootedAtDocument() && ownerNode().inDocument()) 49 return ownerNode().document(); 50 51 return ownerNode(); 52 } 47 53 48 54 Node* LiveNodeList::namedItem(const AtomicString& elementId) const -
trunk/Source/WebCore/dom/LiveNodeList.h
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2006 , 2007, 2013Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2006-2007, 2013-2014 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 38 38 class Element; 39 39 40 enum NodeListRootType {41 NodeListIsRootedAtNode,42 NodeListIsRootedAtDocument43 };44 45 40 static bool shouldInvalidateTypeOnAttributeChange(NodeListInvalidationType, const QualifiedName&); 46 41 47 42 class LiveNodeList : public NodeList { 48 43 public: 49 LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType, NodeListRootType); 44 LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType); 45 virtual ~LiveNodeList(); 46 50 47 virtual Node* namedItem(const AtomicString&) const override final; 48 51 49 virtual bool nodeMatches(Element*) const = 0; 52 53 virtual ~LiveNodeList(); 54 55 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; } 50 virtual bool isRootedAtDocument() const = 0; 51 56 52 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); } 57 53 ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); } … … 63 59 virtual void invalidateCache(Document&) const = 0; 64 60 61 bool isRegisteredForInvalidationAtDocument() const { return m_isRegisteredForInvalidationAtDocument; } 62 void setRegisteredForInvalidationAtDocument(bool f) { m_isRegisteredForInvalidationAtDocument = f; } 63 65 64 protected: 66 65 Document& document() const { return m_ownerNode->document(); } 66 67 private: 68 virtual bool isLiveNodeList() const override final { return true; } 69 67 70 ContainerNode& rootNode() const; 68 71 69 ALWAYS_INLINE NodeListRootType rootType() const { return static_cast<NodeListRootType>(m_rootType); }70 71 private:72 virtual bool isLiveNodeList() const override { return true; }73 74 72 Element* iterateForPreviousElement(Element* current) const; 75 73 76 74 Ref<ContainerNode> m_ownerNode; 77 75 78 const unsigned m_ rootType : 1;79 const unsigned m_invalidationType : 4;76 const unsigned m_invalidationType; 77 bool m_isRegisteredForInvalidationAtDocument; 80 78 }; 81 79 … … 100 98 101 99 protected: 102 CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType , NodeListRootType = NodeListIsRootedAtNode);100 CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType); 103 101 104 102 private: 103 ContainerNode& rootNode() const; 104 105 105 mutable CollectionIndexCache<NodeListType, Element> m_indexCache; 106 106 }; … … 130 130 } 131 131 132 inline ContainerNode& LiveNodeList::rootNode() const 133 { 134 if (isRootedAtDocument() && ownerNode().inDocument()) 132 template <class NodeListType> 133 CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType) 134 : LiveNodeList(ownerNode, invalidationType) 135 { 136 } 137 138 template <class NodeListType> 139 CachedLiveNodeList<NodeListType>::~CachedLiveNodeList() 140 { 141 if (m_indexCache.hasValidCache()) 142 document().unregisterNodeListForInvalidation(*this); 143 } 144 145 template <class NodeListType> 146 inline ContainerNode& CachedLiveNodeList<NodeListType>::rootNode() const 147 { 148 if (static_cast<const NodeListType&>(*this).isRootedAtDocument() && ownerNode().inDocument()) 135 149 return ownerNode().document(); 136 150 137 151 return ownerNode(); 138 }139 140 template <class NodeListType>141 CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType)142 : LiveNodeList(ownerNode, invalidationType, rootType)143 {144 }145 146 template <class NodeListType>147 CachedLiveNodeList<NodeListType>::~CachedLiveNodeList()148 {149 if (m_indexCache.hasValidCache())150 document().unregisterNodeList(*this);151 152 } 152 153 … … 217 218 void CachedLiveNodeList<NodeListType>::willValidateIndexCache() const 218 219 { 219 document().registerNodeList (const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));220 document().registerNodeListForInvalidation(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this))); 220 221 } 221 222 … … 225 226 if (!m_indexCache.hasValidCache()) 226 227 return; 227 document.unregisterNodeList (const_cast<NodeListType&>(static_cast<const NodeListType&>(*this)));228 document.unregisterNodeListForInvalidation(const_cast<NodeListType&>(static_cast<const NodeListType&>(*this))); 228 229 m_indexCache.invalidate(); 229 230 } -
trunk/Source/WebCore/dom/NameNodeList.cpp
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2007, 2014 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or -
trunk/Source/WebCore/dom/NameNodeList.h
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2007 m 2008Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2007-2008, 2014 Apple Inc. All rights reserved. 6 6 * 7 7 * This library is free software; you can redistribute it and/or … … 42 42 43 43 virtual bool nodeMatches(Element*) const override; 44 virtual bool isRootedAtDocument() const override { return false; } 44 45 45 46 private: -
trunk/Source/WebCore/dom/TagNodeList.cpp
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004 , 2005, 2006, 2007Apple Inc. All rights reserved.5 * Copyright (C) 2004-2007, 2014 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 7 * -
trunk/Source/WebCore/dom/TagNodeList.h
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004 , 2005, 2006, 2007, 2008Apple Inc. All rights reserved.5 * Copyright (C) 2004-2008, 2014 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 7 7 * … … 48 48 49 49 virtual bool nodeMatches(Element*) const override; 50 virtual bool isRootedAtDocument() const override { return false; } 50 51 51 52 protected: … … 75 76 76 77 virtual bool nodeMatches(Element*) const override; 78 virtual bool isRootedAtDocument() const override { return false; } 77 79 78 80 private: -
trunk/Source/WebCore/html/HTMLCollection.cpp
r165699 r166407 66 66 } 67 67 68 static NodeListRootType rootTypeFromCollectionType(CollectionType type)68 static HTMLCollection::RootType rootTypeFromCollectionType(CollectionType type) 69 69 { 70 70 switch (type) { … … 80 80 case DocumentNamedItems: 81 81 case FormControls: 82 return NodeListIsRootedAtDocument;82 return HTMLCollection::IsRootedAtDocument; 83 83 case NodeChildren: 84 84 case TableTBodies: … … 90 90 case DataListOptions: 91 91 case MapAreas: 92 return NodeListIsRootedAtNode;92 return HTMLCollection::IsRootedAtNode; 93 93 } 94 94 ASSERT_NOT_REACHED(); 95 return NodeListIsRootedAtNode;95 return HTMLCollection::IsRootedAtNode; 96 96 } 97 97 -
trunk/Source/WebCore/html/HTMLCollection.h
r165103 r166407 101 101 size_t memoryCost() const { return m_indexCache.memoryCost() + (m_namedElementCache ? m_namedElementCache->memoryCost() : 0); } 102 102 103 bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; } 103 enum RootType { 104 IsRootedAtNode, 105 IsRootedAtDocument 106 }; 107 bool isRootedAtDocument() const { return m_rootType == IsRootedAtDocument; } 104 108 NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); } 105 109 CollectionType type() const { return static_cast<CollectionType>(m_collectionType); } … … 134 138 bool usesCustomForwardOnlyTraversal() const { return m_usesCustomForwardOnlyTraversal; } 135 139 136 NodeListRootType rootType() const { return static_cast<NodeListRootType>(m_rootType); }140 RootType rootType() const { return static_cast<RootType>(m_rootType); } 137 141 138 142 CollectionNamedElementCache& createNameItemCache() const -
trunk/Source/WebCore/html/LabelsNodeList.cpp
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2007, 2008 Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2007, 2008, 2014 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2010 Nokia Inc. All rights reserved. 7 7 * … … 35 35 36 36 LabelsNodeList::LabelsNodeList(LabelableElement& forNode) 37 : CachedLiveNodeList(forNode, InvalidateOnForAttrChange , NodeListIsRootedAtDocument)37 : CachedLiveNodeList(forNode, InvalidateOnForAttrChange) 38 38 { 39 39 } -
trunk/Source/WebCore/html/LabelsNodeList.h
r166377 r166407 3 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 4 4 * (C) 2001 Dirk Mueller (mueller@kde.org) 5 * Copyright (C) 2004, 2007 Apple Inc. All rights reserved.5 * Copyright (C) 2004, 2007, 2014 Apple Inc. All rights reserved. 6 6 * Copyright (C) 2010 Nokia Inc. All rights reserved. 7 7 * … … 40 40 41 41 virtual bool nodeMatches(Element*) const override; 42 virtual bool isRootedAtDocument() const override { return true; } 42 43 43 44 private: -
trunk/Source/WebCore/html/RadioNodeList.cpp
r166377 r166407 1 1 /* 2 2 * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. 3 * Copyright (C) 2014 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 39 40 40 41 RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name) 41 : CachedLiveNodeList(rootNode, InvalidateForFormControls , isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)42 : CachedLiveNodeList(rootNode, InvalidateForFormControls) 42 43 , m_name(name) 44 , m_isRootedAtDocument(isHTMLFormElement(ownerNode())) 43 45 { 44 46 } -
trunk/Source/WebCore/html/RadioNodeList.h
r166377 r166407 1 1 /* 2 2 * Copyright (c) 2012 Motorola Mobility, Inc. All rights reserved. 3 * Copyright (C) 2014 Apple Inc. All rights reserved. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 46 47 47 48 virtual bool nodeMatches(Element*) const override; 49 virtual bool isRootedAtDocument() const override { return m_isRootedAtDocument; } 48 50 49 51 private: … … 52 54 53 55 AtomicString m_name; 56 bool m_isRootedAtDocument; 54 57 }; 55 58
Note: See TracChangeset
for help on using the changeset viewer.