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

Side by Side Diff: Source/core/dom/Node.cpp

Issue 178543006: Move Document code out of Node.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 807
808 unsigned Node::nodeIndex() const 808 unsigned Node::nodeIndex() const
809 { 809 {
810 Node *_tempNode = previousSibling(); 810 Node *_tempNode = previousSibling();
811 unsigned count=0; 811 unsigned count=0;
812 for ( count=0; _tempNode; count++ ) 812 for ( count=0; _tempNode; count++ )
813 _tempNode = _tempNode->previousSibling(); 813 _tempNode = _tempNode->previousSibling();
814 return count; 814 return count;
815 } 815 }
816 816
817 template<unsigned type>
818 bool shouldInvalidateNodeListCachesForAttr(const unsigned nodeListCounts[], cons t QualifiedName& attrName)
819 {
820 if (nodeListCounts[type] && LiveNodeListBase::shouldInvalidateTypeOnAttribut eChange(static_cast<NodeListInvalidationType>(type), attrName))
821 return true;
822 return shouldInvalidateNodeListCachesForAttr<type + 1>(nodeListCounts, attrN ame);
823 }
824
825 template<>
826 bool shouldInvalidateNodeListCachesForAttr<numNodeListInvalidationTypes>(const u nsigned[], const QualifiedName&)
827 {
828 return false;
829 }
830
831 bool Document::shouldInvalidateNodeListCaches(const QualifiedName* attrName) con st
832 {
833 if (attrName)
834 return shouldInvalidateNodeListCachesForAttr<DoNotInvalidateOnAttributeC hanges + 1>(m_nodeListCounts, *attrName);
835
836 for (int type = 0; type < numNodeListInvalidationTypes; type++) {
837 if (m_nodeListCounts[type])
838 return true;
839 }
840
841 return false;
842 }
843
844 void Document::invalidateNodeListCaches(const QualifiedName* attrName)
845 {
846 HashSet<LiveNodeListBase*>::iterator end = m_listsInvalidatedAtDocument.end( );
847 for (HashSet<LiveNodeListBase*>::iterator it = m_listsInvalidatedAtDocument. begin(); it != end; ++it)
848 (*it)->invalidateCache(attrName);
849 }
850
851 void Node::invalidateNodeListCachesInAncestors(const QualifiedName* attrName, El ement* attributeOwnerElement) 817 void Node::invalidateNodeListCachesInAncestors(const QualifiedName* attrName, El ement* attributeOwnerElement)
852 { 818 {
853 if (hasRareData() && (!attrName || isAttributeNode())) { 819 if (hasRareData() && (!attrName || isAttributeNode())) {
854 if (NodeListsNodeData* lists = rareData()->nodeLists()) 820 if (NodeListsNodeData* lists = rareData()->nodeLists())
855 lists->clearChildNodeListCache(); 821 lists->clearChildNodeListCache();
856 } 822 }
857 823
858 // Modifications to attributes that are not associated with an Element can't invalidate NodeList caches. 824 // Modifications to attributes that are not associated with an Element can't invalidate NodeList caches.
859 if (attrName && !attributeOwnerElement) 825 if (attrName && !attributeOwnerElement)
860 return; 826 return;
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
2557 node->showTreeForThis(); 2523 node->showTreeForThis();
2558 } 2524 }
2559 2525
2560 void showNodePath(const WebCore::Node* node) 2526 void showNodePath(const WebCore::Node* node)
2561 { 2527 {
2562 if (node) 2528 if (node)
2563 node->showNodePathForThis(); 2529 node->showNodePathForThis();
2564 } 2530 }
2565 2531
2566 #endif 2532 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698