Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(833)

Unified Diff: Source/core/dom/LiveNodeList.h

Issue 132923003: Make sure the rootNode of a LiveNodeListBase is always a ContainerNode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Slightly clearer cast Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/LiveNodeList.h
diff --git a/Source/core/dom/LiveNodeList.h b/Source/core/dom/LiveNodeList.h
index cd1f9d1065d0f041dd93d97b9a98d483e19cb5c8..bb1f91f77e575d978207fc7347cfcddf95280f9b 100644
--- a/Source/core/dom/LiveNodeList.h
+++ b/Source/core/dom/LiveNodeList.h
@@ -48,7 +48,7 @@ public:
DoesNotOverrideItemAfter,
};
- LiveNodeListBase(Node* ownerNode, NodeListRootType rootType, NodeListInvalidationType invalidationType,
+ LiveNodeListBase(ContainerNode* ownerNode, NodeListRootType rootType, NodeListInvalidationType invalidationType,
bool shouldOnlyIncludeDirectChildren, CollectionType collectionType, ItemAfterOverrideType itemAfterOverrideType)
: m_ownerNode(ownerNode)
, m_cachedItem(0)
@@ -60,6 +60,7 @@ public:
, m_collectionType(collectionType)
, m_overridesItemAfter(itemAfterOverrideType == OverridesItemAfter)
{
+ ASSERT(m_ownerNode);
ASSERT(m_rootType == static_cast<unsigned>(rootType));
ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType));
ASSERT(m_collectionType == static_cast<unsigned>(collectionType));
@@ -82,7 +83,7 @@ public:
ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument || m_rootType == NodeListIsRootedAtDocumentIfOwnerHasItemrefAttr; }
ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); }
ALWAYS_INLINE CollectionType type() const { return static_cast<CollectionType>(m_collectionType); }
- Node* ownerNode() const { return m_ownerNode.get(); }
+ ContainerNode* ownerNode() const { return m_ownerNode.get(); }
ALWAYS_INLINE void invalidateCache(const QualifiedName* attrName) const
{
if (!attrName || shouldInvalidateTypeOnAttributeChange(invalidationType(), *attrName))
@@ -96,8 +97,7 @@ public:
protected:
Document& document() const { return m_ownerNode->document(); }
- Node& rootNode() const;
- ContainerNode* rootContainerNode() const;
+ ContainerNode& rootNode() const;
bool overridesItemAfter() const { return m_overridesItemAfter; }
ALWAYS_INLINE bool isItemCacheValid() const { return m_isItemCacheValid; }
@@ -123,14 +123,14 @@ protected:
bool shouldOnlyIncludeDirectChildren() const { return m_shouldOnlyIncludeDirectChildren; }
private:
- Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode* root) const;
+ Node* itemBeforeOrAfterCachedItem(unsigned offset, ContainerNode& root) const;
bool isLastItemCloserThanLastOrCachedItem(unsigned offset) const;
bool isFirstItemCloserThanCachedItem(unsigned offset) const;
Node* iterateForPreviousNode(Node* current) const;
Node* itemBefore(Node* previousItem) const;
void invalidateIdNameCacheMaps() const;
- RefPtr<Node> m_ownerNode;
+ RefPtr<ContainerNode> m_ownerNode; // Cannot be null.
mutable Node* m_cachedItem;
mutable unsigned m_cachedLength;
mutable unsigned m_cachedItemOffset;
@@ -172,7 +172,7 @@ ALWAYS_INLINE bool LiveNodeListBase::shouldInvalidateTypeOnAttributeChange(NodeL
class LiveNodeList : public NodeList, public LiveNodeListBase {
public:
- LiveNodeList(PassRefPtr<Node> ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
+ LiveNodeList(PassRefPtr<ContainerNode> ownerNode, CollectionType collectionType, NodeListInvalidationType invalidationType, NodeListRootType rootType = NodeListIsRootedAtNode)
: LiveNodeListBase(ownerNode.get(), rootType, invalidationType, collectionType == ChildNodeListType,
collectionType, DoesNotOverrideItemAfter)
{ }
@@ -185,7 +185,7 @@ public:
using LiveNodeListBase::ownerNode;
Node* traverseToFirstElement(ContainerNode& root) const;
- Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode* root) const;
+ Node* traverseForwardToOffset(unsigned offset, Node& currentNode, unsigned& currentOffset, ContainerNode& root) const;
private:
virtual bool isLiveNodeList() const OVERRIDE FINAL { return true; }

Powered by Google App Engine
This is Rietveld 408576698