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

Side by Side Diff: Source/core/dom/Document.h

Issue 159503003: Do not cause unnecessary node lists invalidation on id/name attribute change (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Code clean up Created 6 years, 10 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 | « no previous file | Source/core/dom/Document.cpp » ('j') | Source/core/dom/NodeRareData.h » ('J')
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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 8 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
9 * Copyright (C) 2011 Google Inc. All rights reserved. 9 * Copyright (C) 2011 Google Inc. All rights reserved.
10 * 10 *
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 // Updates for :target (CSS3 selector). 644 // Updates for :target (CSS3 selector).
645 void setCSSTarget(Element*); 645 void setCSSTarget(Element*);
646 Element* cssTarget() const { return m_cssTarget; } 646 Element* cssTarget() const { return m_cssTarget; }
647 647
648 void scheduleStyleRecalc(); 648 void scheduleStyleRecalc();
649 bool hasPendingForcedStyleRecalc() const; 649 bool hasPendingForcedStyleRecalc() const;
650 650
651 void registerNodeList(LiveNodeListBase*); 651 void registerNodeList(LiveNodeListBase*);
652 void unregisterNodeList(LiveNodeListBase*); 652 void unregisterNodeList(LiveNodeListBase*);
653 void incrementNodeListWithIdNameCacheCount();
654 void decrementNodeListWithIdNameCacheCount();
653 bool shouldInvalidateNodeListCaches(const QualifiedName* attrName = 0) const ; 655 bool shouldInvalidateNodeListCaches(const QualifiedName* attrName = 0) const ;
654 void invalidateNodeListCaches(const QualifiedName* attrName); 656 void invalidateNodeListCaches(const QualifiedName* attrName);
655 657
656 void attachNodeIterator(NodeIterator*); 658 void attachNodeIterator(NodeIterator*);
657 void detachNodeIterator(NodeIterator*); 659 void detachNodeIterator(NodeIterator*);
658 void moveNodeIteratorsToNewDocument(Node&, Document&); 660 void moveNodeIteratorsToNewDocument(Node&, Document&);
659 661
660 void attachRange(Range*); 662 void attachRange(Range*);
661 void detachRange(Range*); 663 void detachRange(Range*);
662 664
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1370 } 1372 }
1371 1373
1372 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin) 1374 inline bool Document::shouldOverrideLegacyDescription(ViewportDescription::Type origin)
1373 { 1375 {
1374 // The different (legacy) meta tags have different priorities based on the t ype 1376 // The different (legacy) meta tags have different priorities based on the t ype
1375 // regardless of which order they appear in the DOM. The priority is given b y the 1377 // regardless of which order they appear in the DOM. The priority is given b y the
1376 // ViewportDescription::Type enum. 1378 // ViewportDescription::Type enum.
1377 return origin >= m_legacyViewportDescription.type; 1379 return origin >= m_legacyViewportDescription.type;
1378 } 1380 }
1379 1381
1382 inline void Document::incrementNodeListWithIdNameCacheCount()
1383 {
1384 m_nodeListCounts[InvalidateOnIdNameAttrChange]++;
eseidel 2014/02/12 01:55:24 This seems about the same size as just keeping a l
Inactive 2014/02/12 02:21:41 You mean an array of linked lists (whose items wou
1385 }
1386
1387 inline void Document::decrementNodeListWithIdNameCacheCount()
1388 {
1389 ASSERT(m_nodeListCounts[InvalidateOnIdNameAttrChange] > 0);
Inactive 2014/02/12 02:21:41 You mentioned having good assertions an IRC. There
1390 m_nodeListCounts[InvalidateOnIdNameAttrChange]--;
1391 }
1392
1380 DEFINE_TYPE_CASTS(Document, ExecutionContextClient, client, client->isDocument() , client.isDocument()); 1393 DEFINE_TYPE_CASTS(Document, ExecutionContextClient, client, client->isDocument() , client.isDocument());
1381 DEFINE_TYPE_CASTS(Document, ExecutionContext, context, context->isDocument(), co ntext.isDocument()); 1394 DEFINE_TYPE_CASTS(Document, ExecutionContext, context, context->isDocument(), co ntext.isDocument());
1382 DEFINE_NODE_TYPE_CASTS(Document, isDocumentNode()); 1395 DEFINE_NODE_TYPE_CASTS(Document, isDocumentNode());
1383 1396
1384 #define DEFINE_DOCUMENT_TYPE_CASTS(thisType) \ 1397 #define DEFINE_DOCUMENT_TYPE_CASTS(thisType) \
1385 DEFINE_TYPE_CASTS(thisType, Document, document, document->is##thisType(), do cument.is##thisType()) 1398 DEFINE_TYPE_CASTS(thisType, Document, document, document->is##thisType(), do cument.is##thisType())
1386 1399
1387 // All these varations are needed to avoid ambiguous overloads with the Node and TreeScope versions. 1400 // All these varations are needed to avoid ambiguous overloads with the Node and TreeScope versions.
1388 inline bool operator==(const Document& a, const Document& b) { return &a == &b; } 1401 inline bool operator==(const Document& a, const Document& b) { return &a == &b; }
1389 inline bool operator==(const Document& a, const Document* b) { return &a == b; } 1402 inline bool operator==(const Document& a, const Document* b) { return &a == b; }
1390 inline bool operator==(const Document* a, const Document& b) { return a == &b; } 1403 inline bool operator==(const Document* a, const Document& b) { return a == &b; }
1391 inline bool operator!=(const Document& a, const Document& b) { return !(a == b); } 1404 inline bool operator!=(const Document& a, const Document& b) { return !(a == b); }
1392 inline bool operator!=(const Document& a, const Document* b) { return !(a == b); } 1405 inline bool operator!=(const Document& a, const Document* b) { return !(a == b); }
1393 inline bool operator!=(const Document* a, const Document& b) { return !(a == b); } 1406 inline bool operator!=(const Document* a, const Document& b) { return !(a == b); }
1394 1407
1395 // Put these methods here, because they require the Document definition, but we really want to inline them. 1408 // Put these methods here, because they require the Document definition, but we really want to inline them.
1396 1409
1397 inline bool Node::isDocumentNode() const 1410 inline bool Node::isDocumentNode() const
1398 { 1411 {
1399 return this == document(); 1412 return this == document();
1400 } 1413 }
1401 1414
1402 Node* eventTargetNodeForDocument(Document*); 1415 Node* eventTargetNodeForDocument(Document*);
1403 1416
1404 } // namespace WebCore 1417 } // namespace WebCore
1405 1418
1406 #endif // Document_h 1419 #endif // Document_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/dom/Document.cpp » ('j') | Source/core/dom/NodeRareData.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698