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

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

Issue 54273007: Use more references in ContainerNode code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix crashes Created 7 years, 1 month 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
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/Node.cpp » ('j') | 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, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 6 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 493
494 bool isDocumentTypeNode() const { return nodeType() == DOCUMENT_TYPE_NODE; } 494 bool isDocumentTypeNode() const { return nodeType() == DOCUMENT_TYPE_NODE; }
495 virtual bool childTypeAllowed(NodeType) const { return false; } 495 virtual bool childTypeAllowed(NodeType) const { return false; }
496 unsigned childNodeCount() const; 496 unsigned childNodeCount() const;
497 Node* childNode(unsigned index) const; 497 Node* childNode(unsigned index) const;
498 498
499 void checkSetPrefix(const AtomicString& prefix, ExceptionState&); 499 void checkSetPrefix(const AtomicString& prefix, ExceptionState&);
500 bool isDescendantOf(const Node*) const; 500 bool isDescendantOf(const Node*) const;
501 bool contains(const Node*) const; 501 bool contains(const Node*) const;
502 bool containsIncludingShadowDOM(const Node*) const; 502 bool containsIncludingShadowDOM(const Node*) const;
503 bool containsIncludingHostElements(const Node*) const; 503 bool containsIncludingHostElements(const Node&) const;
504 504
505 // FIXME: Remove this when crbug.com/265716 cleans up contains semantics. 505 // FIXME: Remove this when crbug.com/265716 cleans up contains semantics.
506 bool bindingsContains(const Node* node) const { return containsIncludingShad owDOM(node); } 506 bool bindingsContains(const Node* node) const { return containsIncludingShad owDOM(node); }
507 507
508 // Used to determine whether range offsets use characters or node indices. 508 // Used to determine whether range offsets use characters or node indices.
509 virtual bool offsetInCharacters() const; 509 virtual bool offsetInCharacters() const;
510 // Number of DOM 16-bit units contained in node. Note that rendered text len gth can be different - e.g. because of 510 // Number of DOM 16-bit units contained in node. Note that rendered text len gth can be different - e.g. because of
511 // css-transform:capitalize breaking up precomposed characters and ligatures . 511 // css-transform:capitalize breaking up precomposed characters and ligatures .
512 virtual int maxCharacterOffset() const; 512 virtual int maxCharacterOffset() const;
513 513
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 return change >= Inherit || node->childNeedsStyleRecalc() || node->needsStyl eRecalc(); 914 return change >= Inherit || node->childNeedsStyleRecalc() || node->needsStyl eRecalc();
915 } 915 }
916 916
917 // Allow equality comparisons of Nodes by reference or pointer, interchangeably. 917 // Allow equality comparisons of Nodes by reference or pointer, interchangeably.
918 inline bool operator==(const Node& a, const Node& b) { return &a == &b; } 918 inline bool operator==(const Node& a, const Node& b) { return &a == &b; }
919 inline bool operator==(const Node& a, const Node* b) { return &a == b; } 919 inline bool operator==(const Node& a, const Node* b) { return &a == b; }
920 inline bool operator==(const Node* a, const Node& b) { return a == &b; } 920 inline bool operator==(const Node* a, const Node& b) { return a == &b; }
921 inline bool operator!=(const Node& a, const Node& b) { return !(a == b); } 921 inline bool operator!=(const Node& a, const Node& b) { return !(a == b); }
922 inline bool operator!=(const Node& a, const Node* b) { return !(a == b); } 922 inline bool operator!=(const Node& a, const Node* b) { return !(a == b); }
923 inline bool operator!=(const Node* a, const Node& b) { return !(a == b); } 923 inline bool operator!=(const Node* a, const Node& b) { return !(a == b); }
924 inline bool operator==(const RefPtr<Node>& a, const Node& b) { return a.get() == &b; } 924 inline bool operator==(const PassRefPtr<Node>& a, const Node& b) { return a.get( ) == &b; }
925 inline bool operator==(const Node& a, const RefPtr<Node>& b) { return &a == b.ge t(); } 925 inline bool operator==(const Node& a, const PassRefPtr<Node>& b) { return &a == b.get(); }
926 inline bool operator!=(const RefPtr<Node>& a, const Node& b) { return !(a == b); } 926 inline bool operator!=(const PassRefPtr<Node>& a, const Node& b) { return !(a == b); }
927 inline bool operator!=(const Node& a, const RefPtr<Node>& b) { return !(a == b); } 927 inline bool operator!=(const Node& a, const PassRefPtr<Node>& b) { return !(a == b); }
Inactive 2013/11/01 18:43:18 This one cost me some time debugging. I was doing
adamk 2013/11/01 18:56:50 Yikes! This is why the WebKit style guide always r
Inactive 2013/11/01 19:03:57 Oh, I think we can provide both if you are worried
adamk 2013/11/01 19:07:09 I admit it seems unlikely for the cost to be notic
Inactive 2013/11/01 19:39:01 Sadly it does not build. It is ambiguous according
adamk 2013/11/01 20:10:54 I think I'd actually prefer dropping the PassRefPt
928 928
929 929
930 #define DEFINE_NODE_TYPE_CASTS(thisType, predicate) \ 930 #define DEFINE_NODE_TYPE_CASTS(thisType, predicate) \
931 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) { return to##thisType(node.get()); } \ 931 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) { return to##thisType(node.get()); } \
932 DEFINE_TYPE_CASTS(thisType, Node, node, node->predicate, node.predicate) 932 DEFINE_TYPE_CASTS(thisType, Node, node, node->predicate, node.predicate)
933 933
934 // This requires isClassName(const Node&). 934 // This requires isClassName(const Node&).
935 #define DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) \ 935 #define DEFINE_NODE_TYPE_CASTS_WITH_FUNCTION(thisType) \
936 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) { return to##thisType(node.get()); } \ 936 template<typename T> inline thisType* to##thisType(const RefPtr<T>& node) { return to##thisType(node.get()); } \
937 DEFINE_TYPE_CASTS(thisType, Node, node, is##thisType(*node), is##thisType(no de)) 937 DEFINE_TYPE_CASTS(thisType, Node, node, is##thisType(*node), is##thisType(no de))
938 938
939 } // namespace WebCore 939 } // namespace WebCore
940 940
941 #ifndef NDEBUG 941 #ifndef NDEBUG
942 // Outside the WebCore namespace for ease of invocation from gdb. 942 // Outside the WebCore namespace for ease of invocation from gdb.
943 void showTree(const WebCore::Node*); 943 void showTree(const WebCore::Node*);
944 void showNodePath(const WebCore::Node*); 944 void showNodePath(const WebCore::Node*);
945 #endif 945 #endif
946 946
947 #endif 947 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Document.cpp ('k') | Source/core/dom/Node.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698